mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
encoding: simplify handling of encoding in TUI
This commit is contained in:
parent
6769438cd1
commit
fa5827b144
@ -2312,10 +2312,6 @@ did_set_string_option (
|
|||||||
* (with another encoding). */
|
* (with another encoding). */
|
||||||
if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
|
if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
|
||||||
(void)keymap_init();
|
(void)keymap_init();
|
||||||
|
|
||||||
if (varp == &p_enc) {
|
|
||||||
ui_update_encoding();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (varp == &p_penc) {
|
} else if (varp == &p_penc) {
|
||||||
/* Canonize printencoding if VIM standard one */
|
/* Canonize printencoding if VIM standard one */
|
||||||
|
@ -25,7 +25,9 @@ void term_input_init(TermInput *input, Loop *loop)
|
|||||||
if (!term) {
|
if (!term) {
|
||||||
term = ""; // termkey_new_abstract assumes non-null (#2745)
|
term = ""; // termkey_new_abstract assumes non-null (#2745)
|
||||||
}
|
}
|
||||||
input->tk = termkey_new_abstract(term, 0);
|
int enc_flag = enc_utf8 ? TERMKEY_FLAG_UTF8 : TERMKEY_FLAG_RAW;
|
||||||
|
input->tk = termkey_new_abstract(term, enc_flag);
|
||||||
|
|
||||||
int curflags = termkey_get_canonflags(input->tk);
|
int curflags = termkey_get_canonflags(input->tk);
|
||||||
termkey_set_canonflags(input->tk, curflags | TERMKEY_CANON_DELBS);
|
termkey_set_canonflags(input->tk, curflags | TERMKEY_CANON_DELBS);
|
||||||
// setup input handle
|
// setup input handle
|
||||||
@ -57,13 +59,6 @@ void term_input_stop(TermInput *input)
|
|||||||
time_watcher_stop(&input->timer_handle);
|
time_watcher_stop(&input->timer_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void term_input_set_encoding(TermInput *input, char* enc)
|
|
||||||
{
|
|
||||||
int enc_flag = strcmp(enc, "utf-8") == 0 ? TERMKEY_FLAG_UTF8
|
|
||||||
: TERMKEY_FLAG_RAW;
|
|
||||||
termkey_set_flags(input->tk, enc_flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void input_enqueue_event(void **argv)
|
static void input_enqueue_event(void **argv)
|
||||||
{
|
{
|
||||||
char *buf = argv[0];
|
char *buf = argv[0];
|
||||||
|
@ -99,7 +99,6 @@ UI *tui_start(void)
|
|||||||
ui->suspend = tui_suspend;
|
ui->suspend = tui_suspend;
|
||||||
ui->set_title = tui_set_title;
|
ui->set_title = tui_set_title;
|
||||||
ui->set_icon = tui_set_icon;
|
ui->set_icon = tui_set_icon;
|
||||||
ui->set_encoding = tui_set_encoding;
|
|
||||||
return ui_bridge_attach(ui, tui_main, tui_scheduler);
|
return ui_bridge_attach(ui, tui_main, tui_scheduler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -625,12 +624,6 @@ static void tui_set_icon(UI *ui, char *icon)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tui_set_encoding(UI *ui, char* enc)
|
|
||||||
{
|
|
||||||
TUIData *data = ui->data;
|
|
||||||
term_input_set_encoding(&data->input, enc);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void invalidate(UI *ui, int top, int bot, int left, int right)
|
static void invalidate(UI *ui, int top, int bot, int left, int right)
|
||||||
{
|
{
|
||||||
TUIData *data = ui->data;
|
TUIData *data = ui->data;
|
||||||
|
@ -113,11 +113,6 @@ void ui_set_icon(char *icon)
|
|||||||
UI_CALL(flush);
|
UI_CALL(flush);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_update_encoding(void)
|
|
||||||
{
|
|
||||||
UI_CALL(set_encoding, (char*)p_enc);
|
|
||||||
}
|
|
||||||
|
|
||||||
// May update the shape of the cursor.
|
// May update the shape of the cursor.
|
||||||
void ui_cursor_shape(void)
|
void ui_cursor_shape(void)
|
||||||
{
|
{
|
||||||
@ -188,7 +183,6 @@ void ui_attach(UI *ui)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uis[ui_count++] = ui;
|
uis[ui_count++] = ui;
|
||||||
ui_update_encoding();
|
|
||||||
ui_refresh();
|
ui_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@ struct ui_t {
|
|||||||
void (*suspend)(UI *ui);
|
void (*suspend)(UI *ui);
|
||||||
void (*set_title)(UI *ui, char *title);
|
void (*set_title)(UI *ui, char *title);
|
||||||
void (*set_icon)(UI *ui, char *icon);
|
void (*set_icon)(UI *ui, char *icon);
|
||||||
void (*set_encoding)(UI *ui, char *enc);
|
|
||||||
void (*stop)(UI *ui);
|
void (*stop)(UI *ui);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,7 +52,6 @@ UI *ui_bridge_attach(UI *ui, ui_main_fn ui_main, event_scheduler scheduler)
|
|||||||
rv->bridge.suspend = ui_bridge_suspend;
|
rv->bridge.suspend = ui_bridge_suspend;
|
||||||
rv->bridge.set_title = ui_bridge_set_title;
|
rv->bridge.set_title = ui_bridge_set_title;
|
||||||
rv->bridge.set_icon = ui_bridge_set_icon;
|
rv->bridge.set_icon = ui_bridge_set_icon;
|
||||||
rv->bridge.set_encoding = ui_bridge_set_encoding;
|
|
||||||
rv->scheduler = scheduler;
|
rv->scheduler = scheduler;
|
||||||
|
|
||||||
rv->ui_main = ui_main;
|
rv->ui_main = ui_main;
|
||||||
@ -334,14 +333,3 @@ static void ui_bridge_set_icon_event(void **argv)
|
|||||||
ui->set_icon(ui, argv[1]);
|
ui->set_icon(ui, argv[1]);
|
||||||
xfree(argv[1]);
|
xfree(argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ui_bridge_set_encoding(UI *b, char* enc)
|
|
||||||
{
|
|
||||||
UI_CALL(b, set_encoding, 2, b, xstrdup(enc));
|
|
||||||
}
|
|
||||||
static void ui_bridge_set_encoding_event(void **argv)
|
|
||||||
{
|
|
||||||
UI *ui = UI(argv[0]);
|
|
||||||
ui->set_encoding(ui, argv[1]);
|
|
||||||
xfree(argv[1]);
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user