mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 09:25:01 +00:00
ncurses: panic with error message if $TERM is unset
This commit is contained in:
parent
4f34e97f27
commit
dcee6da16a
@ -59,6 +59,14 @@ fn write_to_tty(bytes: &[u8]) -> io::Result<()> {
|
||||
impl Backend {
|
||||
/// Creates a new ncurses-based backend.
|
||||
pub fn init() -> Box<dyn backend::Backend> {
|
||||
// Check the $TERM variable.
|
||||
if std::env::var("TERM")
|
||||
.map(|var| var.is_empty())
|
||||
.unwrap_or(true)
|
||||
{
|
||||
panic!("$TERM is unset. Cannot initialize ncurses interface.");
|
||||
}
|
||||
|
||||
// Change the locale.
|
||||
// For some reasons it's mandatory to get some UTF-8 support.
|
||||
ncurses::setlocale(ncurses::LcCategory::all, "");
|
||||
|
Loading…
Reference in New Issue
Block a user