diff options
Diffstat (limited to 'vis.c')
| -rw-r--r-- | vis.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -19,7 +19,6 @@ #include <sys/ioctl.h> #include <sys/mman.h> #include <pwd.h> -#include <termkey.h> #include "vis.h" #include "text-util.h" @@ -350,6 +349,12 @@ 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; @@ -408,6 +413,8 @@ 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); } @@ -671,7 +678,7 @@ const char *vis_keys_next(Vis *vis, const char *keys) { if (!keys || !*keys) return NULL; TermKeyKey key; - TermKey *termkey = vis->ui->termkey_get(vis->ui); + TermKey *termkey = vis->termkey; const char *next = NULL; /* first try to parse a special key of the form <Key> */ if (*keys == '<' && (next = termkey_strpkey(termkey, keys+1, &key, TERMKEY_FORMAT_VIM)) && *next == '>') @@ -927,8 +934,7 @@ int vis_run(Vis *vis, int argc, char *argv[]) { continue; } - TermKey *termkey = vis->ui->termkey_get(vis->ui); - termkey_advisereadable(termkey); + vis->ui->needkey(vis->ui); const char *key; while ((key = getkey(vis))) |
