diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-12-06 11:27:36 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-12-08 23:44:23 -0300 |
commit | 07e569a25dba4bf6d9743102a34666964efb45cb (patch) | |
tree | f0a1e6bc8546327365cae045505a6d059a87d64f /src/nvim/main.c | |
parent | 8b6cfff6a18d839d11900cd1fade5938dc9a02d5 (diff) | |
download | rneovim-07e569a25dba4bf6d9743102a34666964efb45cb.tar.gz rneovim-07e569a25dba4bf6d9743102a34666964efb45cb.tar.bz2 rneovim-07e569a25dba4bf6d9743102a34666964efb45cb.zip |
ui: Add abstract_ui termcap and split UI layer
This is how Nvim behaves when the "abstract_ui" termcap is activated:
- No data is written/read to stdout/stdin by default.
- Instead of sending data to stdout, ui_write will parse the termcap codes
and invoke dispatch functions in the ui.c module.
- The dispatch functions will forward the calls to all attached UI
instances(each UI instance is an implementation of the UI layer and is
registered with ui_attach).
- Like with the "builtin_gui" termcap, "abstract_ui" does not contain any key
sequences. Instead, vim key strings(<cr>, <esc>, etc) are parsed directly by
input_enqueue and the translated strings are pushed to the input buffer.
With this new input model, its not possible to send mouse events yet. Thats
because mouse sequence parsing happens in term.c/check_termcodes which must
return early when "abstract_ui" is activated.
Diffstat (limited to 'src/nvim/main.c')
-rw-r--r-- | src/nvim/main.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c index 8e19cf3686..c806431872 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -265,13 +265,6 @@ int main(int argc, char **argv) term_init(); TIME_MSG("shell init"); - event_init(); - - if (!embedded_mode) { - // Print a warning if stdout is not a terminal. - check_tty(¶ms); - } - /* This message comes before term inits, but after setting "silent_mode" * when the input is not a tty. */ if (GARGCOUNT > 1 && !silent_mode) @@ -283,6 +276,7 @@ int main(int argc, char **argv) // initial screen size of 80x20 full_screen = true; screen_resize(80, 20, false); + termcapinit((uint8_t *)"abstract_ui"); } else { // set terminal name and get terminal capabilities (will set full_screen) // Do some initialization of the screen @@ -292,6 +286,16 @@ int main(int argc, char **argv) TIME_MSG("Termcap init"); } + event_init(); + + if (abstract_ui) { + t_colors = 256; + } else { + // Print a warning if stdout is not a terminal TODO(tarruda): Remove this + // check once the new terminal UI is implemented + check_tty(¶ms); + } + /* * Set the default values for the options that use Rows and Columns. */ @@ -424,19 +428,17 @@ int main(int argc, char **argv) TIME_MSG("waiting for return"); } - if (!embedded_mode) { - starttermcap(); // start termcap if not done by wait_return() - TIME_MSG("start termcap"); - may_req_ambiguous_char_width(); - setmouse(); // may start using the mouse + starttermcap(); // start termcap if not done by wait_return() + TIME_MSG("start termcap"); + may_req_ambiguous_char_width(); + setmouse(); // may start using the mouse - if (scroll_region) { - scroll_region_reset(); // In case Rows changed - } - - scroll_start(); // may scroll the screen to the right position + if (scroll_region) { + scroll_region_reset(); // In case Rows changed } + scroll_start(); // may scroll the screen to the right position + /* * Don't clear the screen when starting in Ex mode, unless using the GUI. */ |