From e2e0162b5bfd2a5ef31f1d09fca4da8962d5d098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Tue, 10 May 2016 22:22:52 +0200 Subject: Revert "vis: clean up interaction between vis and ui" This caused issues on OpenBSD where it crashed the terminal. Also on Mac OS X suspend via ^Z (Ctrl-Z) was missing a \r i.e. the shell prompt was not properly redrawn. While in principle user interfaces should not have to depend on libtermkey, in practice this won't be an issue unless we are adding a non-terminal based UI (which won't happen anytime soon). This reverts commit 8f92b98848f9366e78c7aa824615bade83971513. Close #311 --- vis.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'vis.c') diff --git a/vis.c b/vis.c index e29371c..3f04c87 100644 --- a/vis.c +++ b/vis.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "vis.h" #include "text-util.h" @@ -339,12 +340,6 @@ Vis *vis_new(Ui *ui, VisEvent *event) { Vis *vis = calloc(1, sizeof(Vis)); if (!vis) return NULL; - const char *term = getenv("TERM"); - if (!term) - term = "xterm"; - vis->termkey = termkey_new_abstract(term, TERMKEY_FLAG_UTF8); - if (!vis->termkey) - goto err; vis->ui = ui; vis->ui->init(vis->ui, vis); vis->tabwidth = 8; @@ -403,8 +398,6 @@ void vis_free(Vis *vis) { map_free(vis_modes[i].bindings); array_release_full(&vis->motions); array_release_full(&vis->textobjects); - if (vis->termkey) - termkey_destroy(vis->termkey); free(vis); } @@ -668,7 +661,7 @@ const char *vis_keys_next(Vis *vis, const char *keys) { if (!keys || !*keys) return NULL; TermKeyKey key; - TermKey *termkey = vis->termkey; + TermKey *termkey = vis->ui->termkey_get(vis->ui); const char *next = NULL; /* first try to parse a special key of the form */ if (*keys == '<' && (next = termkey_strpkey(termkey, keys+1, &key, TERMKEY_FORMAT_VIM)) && *next == '>') @@ -924,7 +917,8 @@ int vis_run(Vis *vis, int argc, char *argv[]) { continue; } - vis->ui->needkey(vis->ui); + TermKey *termkey = vis->ui->termkey_get(vis->ui); + termkey_advisereadable(termkey); const char *key; while ((key = getkey(vis))) -- cgit v1.2.3