mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Disable DEC Special Graphics at exit if vt100
If a vt100 terminal receives the Shift In character '\016' it will enable the 7 bit DEC Special Graphics character set used for line drawing. For most users this can happen due to line noise from the tty device and will likely mess up your terminal even after tio exits. To better handle this we want to make sure that tio disables this mode by sending the Shift Out character '\017' at exit. This mechanism will only activate if environment variable TERM assumes value "vt100".
This commit is contained in:
parent
cd160250a6
commit
f5f62ee02d
3 changed files with 17 additions and 0 deletions
|
|
@ -118,6 +118,7 @@ struct option_t option =
|
||||||
.exclude_drivers = NULL,
|
.exclude_drivers = NULL,
|
||||||
.exclude_tids = NULL,
|
.exclude_tids = NULL,
|
||||||
.hex_n_value = 0,
|
.hex_n_value = 0,
|
||||||
|
.vt100 = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
void print_help(char *argv[])
|
void print_help(char *argv[])
|
||||||
|
|
@ -487,6 +488,13 @@ void options_parse(int argc, char *argv[])
|
||||||
option.color = -1;
|
option.color = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for vt100 terminal
|
||||||
|
char *term = getenv("TERM");
|
||||||
|
if ((term != NULL) && (!strcmp(term, "vt100")))
|
||||||
|
{
|
||||||
|
option.vt100 = true;
|
||||||
|
}
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
static struct option long_options[] =
|
static struct option long_options[] =
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,7 @@ struct option_t
|
||||||
const char *exclude_drivers;
|
const char *exclude_drivers;
|
||||||
const char *exclude_tids;
|
const char *exclude_tids;
|
||||||
int hex_n_value;
|
int hex_n_value;
|
||||||
|
bool vt100;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct option_t option;
|
extern struct option_t option;
|
||||||
|
|
|
||||||
|
|
@ -1067,6 +1067,14 @@ void stdin_configure(void)
|
||||||
void stdout_restore(void)
|
void stdout_restore(void)
|
||||||
{
|
{
|
||||||
tcsetattr(STDOUT_FILENO, TCSANOW, &stdout_old);
|
tcsetattr(STDOUT_FILENO, TCSANOW, &stdout_old);
|
||||||
|
|
||||||
|
// If terminal is vt100
|
||||||
|
if (option.vt100)
|
||||||
|
{
|
||||||
|
// Disable DEC Special Graphics character set just in case it was randomly
|
||||||
|
// enabled by noise from serial device.
|
||||||
|
putchar('\017');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void stdout_configure(void)
|
void stdout_configure(void)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue