diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-05-04 13:23:44 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-05-04 13:47:45 +0200 |
| commit | 8f92b98848f9366e78c7aa824615bade83971513 (patch) | |
| tree | 8c3253181320ae22abf76a370da339840a96a464 /vis.c | |
| parent | 583045c2d85f30cfebc7a7689c27c797db2d30f4 (diff) | |
| download | vis-8f92b98848f9366e78c7aa824615bade83971513.tar.gz vis-8f92b98848f9366e78c7aa824615bade83971513.tar.xz | |
vis: clean up interaction between vis and ui
A concrete user interface implementation should not have to depend
on libtermkey. Therefore the vis core now uses an independent instance
to parse keys.
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))) |
