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.
This commit is contained in:
Thiago de Arruda
2014-12-06 11:27:36 -03:00
parent 8b6cfff6a1
commit 07e569a25d
11 changed files with 615 additions and 81 deletions

View File

@@ -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(&params);
}
/* 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(&params);
}
/*
* 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.
*/