aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/tui
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2015-05-09 22:23:54 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2015-06-13 19:49:25 +0200
commit80d61fb87be5ef96b1a28dc88699ade4aa7c83df (patch)
tree0d77636e55efb295f58a4c4152a1160e10394e15 /src/nvim/tui
parentde589e72e6d64173f4536724b6f44af83494375c (diff)
downloadrneovim-80d61fb87be5ef96b1a28dc88699ade4aa7c83df.tar.gz
rneovim-80d61fb87be5ef96b1a28dc88699ade4aa7c83df.tar.bz2
rneovim-80d61fb87be5ef96b1a28dc88699ade4aa7c83df.zip
tui: make termkey use utf-8 mode when &encoding=utf-8 #2469
Diffstat (limited to 'src/nvim/tui')
-rw-r--r--src/nvim/tui/term_input.inl21
-rw-r--r--src/nvim/tui/tui.c7
2 files changed, 15 insertions, 13 deletions
diff --git a/src/nvim/tui/term_input.inl b/src/nvim/tui/term_input.inl
index 544fe8b12c..d25cbb7ba1 100644
--- a/src/nvim/tui/term_input.inl
+++ b/src/nvim/tui/term_input.inl
@@ -257,23 +257,11 @@ static TermInput *term_input_new(void)
rv->paste_enabled = false;
rv->in_fd = 0;
- // Set terminal encoding based on environment(taken from libtermkey source
- // code)
- const char *e;
- int flags = 0;
- if (((e = os_getenv("LANG")) || (e = os_getenv("LC_MESSAGES"))
- || (e = os_getenv("LC_ALL"))) && (e = strchr(e, '.')) && e++ &&
- (strcasecmp(e, "UTF-8") == 0 || strcasecmp(e, "UTF8") == 0)) {
- flags |= TERMKEY_FLAG_UTF8;
- } else {
- flags |= TERMKEY_FLAG_RAW;
- }
-
const char *term = os_getenv("TERM");
if (!term) {
term = ""; // termkey_new_abstract assumes non-null (#2745)
}
- rv->tk = termkey_new_abstract(term, flags);
+ rv->tk = termkey_new_abstract(term, 0);
int curflags = termkey_get_canonflags(rv->tk);
termkey_set_canonflags(rv->tk, curflags | TERMKEY_CANON_DELBS);
// setup input handle
@@ -302,3 +290,10 @@ static void term_input_destroy(TermInput *input)
event_poll(0); // Run once to remove references to input/timer handles
xfree(input);
}
+
+static 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);
+}
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 7df1c4f381..fe29dbd961 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -161,6 +161,7 @@ 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;
// Attach
ui_attach(ui);
return ui;
@@ -592,6 +593,12 @@ 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;