mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Preserved Linux console mode. When console was in one char mode, restore it.
When console was in UTF-8 mode, restore it, too.
This commit is contained in:
parent
8850d85998
commit
c1c494bd4b
@ -206,7 +206,7 @@ resize_terminal(void)
|
|||||||
itrm_queue_event(ditrm, (char *) &ev, sizeof(ev));
|
itrm_queue_event(ditrm, (char *) &ev, sizeof(ev));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
get_terminal_name(unsigned char name[MAX_TERM_LEN])
|
get_terminal_name(unsigned char name[MAX_TERM_LEN])
|
||||||
{
|
{
|
||||||
unsigned char *term = getenv("TERM");
|
unsigned char *term = getenv("TERM");
|
||||||
|
@ -125,6 +125,7 @@ void resize_terminal(void);
|
|||||||
void dispatch_special(unsigned char *);
|
void dispatch_special(unsigned char *);
|
||||||
void kbd_ctrl_c(void);
|
void kbd_ctrl_c(void);
|
||||||
int is_blocked(void);
|
int is_blocked(void);
|
||||||
|
void get_terminal_name(unsigned char *);
|
||||||
|
|
||||||
#define kbd_get_key(kbd_) ((kbd_)->key)
|
#define kbd_get_key(kbd_) ((kbd_)->key)
|
||||||
#define kbd_key_is(kbd_, key) (kbd_get_key(kbd_) == (key))
|
#define kbd_key_is(kbd_, key) (kbd_get_key(kbd_) == (key))
|
||||||
|
@ -38,9 +38,24 @@
|
|||||||
|
|
||||||
INIT_LIST_HEAD(terminals);
|
INIT_LIST_HEAD(terminals);
|
||||||
|
|
||||||
|
|
||||||
static void check_if_no_terminal(void);
|
static void check_if_no_terminal(void);
|
||||||
|
|
||||||
|
static int
|
||||||
|
was_utf8(int in, int out)
|
||||||
|
{
|
||||||
|
/* taken from setedit */
|
||||||
|
static unsigned char *str = "\033[1;1H\357\200\240\033[6n";
|
||||||
|
unsigned char buf[20];
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
hard_write(out, str, strlen(str));
|
||||||
|
buf[0] = '\0';
|
||||||
|
read(in, buf, 6);
|
||||||
|
if (sscanf(buf,"\033[%d;%dR",&y,&x)==2) {
|
||||||
|
if (x > 2) return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
redraw_terminal(struct terminal *term)
|
redraw_terminal(struct terminal *term)
|
||||||
@ -72,6 +87,7 @@ cls_redraw_all_terminals(void)
|
|||||||
struct terminal *
|
struct terminal *
|
||||||
init_term(int fdin, int fdout)
|
init_term(int fdin, int fdout)
|
||||||
{
|
{
|
||||||
|
unsigned char name[MAX_TERM_LEN + 9] = "terminal.";
|
||||||
struct terminal *term = mem_calloc(1, sizeof(*term));
|
struct terminal *term = mem_calloc(1, sizeof(*term));
|
||||||
|
|
||||||
if (!term) {
|
if (!term) {
|
||||||
@ -91,9 +107,16 @@ init_term(int fdin, int fdout)
|
|||||||
term->fdout = fdout;
|
term->fdout = fdout;
|
||||||
term->master = (term->fdout == get_output_handle());
|
term->master = (term->fdout == get_output_handle());
|
||||||
term->blocked = -1;
|
term->blocked = -1;
|
||||||
term->spec = get_opt_rec(config_options, "terminal._template_");
|
|
||||||
|
get_terminal_name(name + 9);
|
||||||
|
term->spec = get_opt_rec(config_options, name);
|
||||||
object_lock(term->spec);
|
object_lock(term->spec);
|
||||||
|
|
||||||
|
/* The hack to restore console in the right mode */
|
||||||
|
if (get_opt_int_tree(term->spec, "type") == TERM_LINUX) {
|
||||||
|
term->linux_was_utf8 = was_utf8(get_input_handle(), term->fdout);
|
||||||
|
}
|
||||||
|
|
||||||
add_to_list(terminals, term);
|
add_to_list(terminals, term);
|
||||||
|
|
||||||
set_handlers(fdin, (select_handler_T) in_term, NULL,
|
set_handlers(fdin, (select_handler_T) in_term, NULL,
|
||||||
@ -141,6 +164,14 @@ destroy_terminal(struct terminal *term)
|
|||||||
del_from_list(term);
|
del_from_list(term);
|
||||||
close(term->fdin);
|
close(term->fdin);
|
||||||
|
|
||||||
|
if (get_opt_int_tree(term->spec, "type") == TERM_LINUX) {
|
||||||
|
if (term->linux_was_utf8) {
|
||||||
|
hard_write(term->fdout, "\033%G", 3);
|
||||||
|
} else {
|
||||||
|
hard_write(term->fdout, "\033%@", 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (term->fdout != 1) {
|
if (term->fdout != 1) {
|
||||||
if (term->fdout != term->fdin) close(term->fdout);
|
if (term->fdout != term->fdin) close(term->fdout);
|
||||||
} else {
|
} else {
|
||||||
|
@ -131,6 +131,9 @@ struct terminal {
|
|||||||
unsigned int utf8:1;
|
unsigned int utf8:1;
|
||||||
#endif /* CONFIG_UTF_8 */
|
#endif /* CONFIG_UTF_8 */
|
||||||
|
|
||||||
|
/* Indicates whether Linux console was in UTF-8 mode on startup */
|
||||||
|
unsigned int linux_was_utf8:1;
|
||||||
|
|
||||||
/* The current tab number. */
|
/* The current tab number. */
|
||||||
int current_tab;
|
int current_tab;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user