encoding: simplify handling of encoding in TUI

This commit is contained in:
Björn Linse 2015-06-23 21:10:35 +02:00
parent 6769438cd1
commit fa5827b144
6 changed files with 3 additions and 38 deletions

View File

@ -2312,10 +2312,6 @@ did_set_string_option (
* (with another encoding). */
if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
(void)keymap_init();
if (varp == &p_enc) {
ui_update_encoding();
}
}
} else if (varp == &p_penc) {
/* Canonize printencoding if VIM standard one */

View File

@ -25,7 +25,9 @@ void term_input_init(TermInput *input, Loop *loop)
if (!term) {
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);
termkey_set_canonflags(input->tk, curflags | TERMKEY_CANON_DELBS);
// setup input handle
@ -57,13 +59,6 @@ void term_input_stop(TermInput *input)
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)
{
char *buf = argv[0];

View File

@ -99,7 +99,6 @@ UI *tui_start(void)
ui->suspend = tui_suspend;
ui->set_title = tui_set_title;
ui->set_icon = tui_set_icon;
ui->set_encoding = tui_set_encoding;
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)
{
TUIData *data = ui->data;

View File

@ -113,11 +113,6 @@ void ui_set_icon(char *icon)
UI_CALL(flush);
}
void ui_update_encoding(void)
{
UI_CALL(set_encoding, (char*)p_enc);
}
// May update the shape of the cursor.
void ui_cursor_shape(void)
{
@ -188,7 +183,6 @@ void ui_attach(UI *ui)
}
uis[ui_count++] = ui;
ui_update_encoding();
ui_refresh();
}

View File

@ -38,7 +38,6 @@ struct ui_t {
void (*suspend)(UI *ui);
void (*set_title)(UI *ui, char *title);
void (*set_icon)(UI *ui, char *icon);
void (*set_encoding)(UI *ui, char *enc);
void (*stop)(UI *ui);
};

View File

@ -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.set_title = ui_bridge_set_title;
rv->bridge.set_icon = ui_bridge_set_icon;
rv->bridge.set_encoding = ui_bridge_set_encoding;
rv->scheduler = scheduler;
rv->ui_main = ui_main;
@ -334,14 +333,3 @@ static void ui_bridge_set_icon_event(void **argv)
ui->set_icon(ui, 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]);
}