mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[terminal] Cache ui.double_esc
This commit is contained in:
parent
2ee82fc890
commit
ac7038d9d4
@ -34,6 +34,7 @@
|
|||||||
#include "util/string.h"
|
#include "util/string.h"
|
||||||
#include "viewer/text/draw.h"
|
#include "viewer/text/draw.h"
|
||||||
|
|
||||||
|
extern int ui_double_esc;
|
||||||
|
|
||||||
/* TODO? In the past, covered by shadow and legends, remembered only by the
|
/* TODO? In the past, covered by shadow and legends, remembered only by the
|
||||||
* ELinks Elders now, options were in hashes (it was not for a long time, after
|
* ELinks Elders now, options were in hashes (it was not for a long time, after
|
||||||
@ -864,6 +865,13 @@ change_hook_ui(struct session *ses, struct option *current, struct option *chang
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
change_hook_ui_double_esc(struct session *ses, struct option *current, struct option *changed)
|
||||||
|
{
|
||||||
|
ui_double_esc = changed->value.number;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/** Make option templates visible or invisible in the option manager.
|
/** Make option templates visible or invisible in the option manager.
|
||||||
* This is called once on startup, and then each time the value of the
|
* This is called once on startup, and then each time the value of the
|
||||||
* "config.show_template" option is changed.
|
* "config.show_template" option is changed.
|
||||||
@ -936,6 +944,7 @@ static const struct change_hook_info change_hooks[] = {
|
|||||||
{ "document.html", change_hook_html },
|
{ "document.html", change_hook_html },
|
||||||
{ "document.plain", change_hook_html },
|
{ "document.plain", change_hook_html },
|
||||||
{ "terminal", change_hook_terminal },
|
{ "terminal", change_hook_terminal },
|
||||||
|
{ "ui.double_esc", change_hook_ui_double_esc },
|
||||||
{ "ui.language", change_hook_language },
|
{ "ui.language", change_hook_language },
|
||||||
{ "ui", change_hook_ui },
|
{ "ui", change_hook_ui },
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
@ -956,6 +965,8 @@ init_options(void)
|
|||||||
|
|
||||||
register_autocreated_options();
|
register_autocreated_options();
|
||||||
register_change_hooks(change_hooks);
|
register_change_hooks(change_hooks);
|
||||||
|
|
||||||
|
ui_double_esc = get_opt_bool("ui.double_esc", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! @relates option */
|
/*! @relates option */
|
||||||
|
@ -771,6 +771,14 @@ get_esc_code(unsigned char *str, int len, char *final_byte,
|
|||||||
#include <ctype.h> /* isprint() isspace() */
|
#include <ctype.h> /* isprint() isspace() */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int ui_double_esc;
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
get_ui_double_esc(void)
|
||||||
|
{
|
||||||
|
return ui_double_esc;
|
||||||
|
}
|
||||||
|
|
||||||
/** Decode a control sequence that begins with CSI (CONTROL SEQUENCE
|
/** Decode a control sequence that begins with CSI (CONTROL SEQUENCE
|
||||||
* INTRODUCER) encoded as ESC [, and set @a *ev accordingly.
|
* INTRODUCER) encoded as ESC [, and set @a *ev accordingly.
|
||||||
* (ECMA-48 also allows 0x9B as a single-byte CSI, but we don't
|
* (ECMA-48 also allows 0x9B as a single-byte CSI, but we don't
|
||||||
@ -789,7 +797,7 @@ decode_terminal_escape_sequence(struct itrm *itrm, struct interlink_event *ev)
|
|||||||
int v;
|
int v;
|
||||||
int el;
|
int el;
|
||||||
|
|
||||||
if (itrm->in.queue.len == 2 && itrm->in.queue.data[1] == ASCII_ESC && get_opt_bool("ui.double_esc", NULL)) {
|
if (itrm->in.queue.len == 2 && itrm->in.queue.data[1] == ASCII_ESC && get_ui_double_esc()) {
|
||||||
kbd.key = KBD_ESC;
|
kbd.key = KBD_ESC;
|
||||||
set_kbd_interlink_event(ev, kbd.key, kbd.modifier);
|
set_kbd_interlink_event(ev, kbd.key, kbd.modifier);
|
||||||
return 2;
|
return 2;
|
||||||
@ -1141,7 +1149,7 @@ process_queue(struct itrm *itrm)
|
|||||||
* beginning of e.g. ESC ESC 0x5B 0x41,
|
* beginning of e.g. ESC ESC 0x5B 0x41,
|
||||||
* which we should parse as Esc Up. */
|
* which we should parse as Esc Up. */
|
||||||
if (itrm->in.queue.len < 3) {
|
if (itrm->in.queue.len < 3) {
|
||||||
if (get_opt_bool("ui.double_esc", NULL)) {
|
if (get_ui_double_esc()) {
|
||||||
el = decode_terminal_escape_sequence(itrm, &ev);
|
el = decode_terminal_escape_sequence(itrm, &ev);
|
||||||
} else {
|
} else {
|
||||||
/* Need more data to figure it out. */
|
/* Need more data to figure it out. */
|
||||||
|
Loading…
Reference in New Issue
Block a user