mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Check $TERM on pancurses as well
This commit is contained in:
parent
f765e9ac07
commit
9cd4f21963
@ -35,6 +35,20 @@ fn find_closest_pair(pair: ColorPair) -> (i16, i16) {
|
||||
impl Backend {
|
||||
/// Creates a new pancurses-based backend.
|
||||
pub fn init() -> std::io::Result<Box<dyn backend::Backend>> {
|
||||
// Check the $TERM variable (at least on unix).
|
||||
// Otherwise we'll just abort.
|
||||
// TODO: On windows, is there anything to check?
|
||||
if cfg!(unix)
|
||||
&& std::env::var("TERM")
|
||||
.map(|var| var.is_empty())
|
||||
.unwrap_or(true)
|
||||
{
|
||||
return Err(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
"$TERM is unset. Cannot initialize pancurses interface.",
|
||||
));
|
||||
}
|
||||
|
||||
::std::env::set_var("ESCDELAY", "25");
|
||||
|
||||
// TODO: use pancurses::newterm()
|
||||
|
Loading…
Reference in New Issue
Block a user