From 4f5f246a958e66e04a5d62b3bf0d8986afb51c09 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Fri, 12 Dec 2014 16:25:11 -0300 Subject: ui: Add update_fg/update_bg methods It is necessary to notify the UI when the default background/foreground colors change in order to render correctly. --- src/nvim/msgpack_rpc/remote_ui.c | 16 ++++++++++++++++ src/nvim/syntax.c | 3 +++ src/nvim/ui.c | 14 ++++++++++++++ src/nvim/ui.h | 2 ++ 4 files changed, 35 insertions(+) (limited to 'src') diff --git a/src/nvim/msgpack_rpc/remote_ui.c b/src/nvim/msgpack_rpc/remote_ui.c index f980a77b4c..af7b82dfd4 100644 --- a/src/nvim/msgpack_rpc/remote_ui.c +++ b/src/nvim/msgpack_rpc/remote_ui.c @@ -67,6 +67,8 @@ Object remote_ui_attach(uint64_t channel_id, uint64_t request_id, Array args, ui->put = remote_ui_put; ui->bell = remote_ui_bell; ui->visual_bell = remote_ui_visual_bell; + ui->update_fg = remote_ui_update_fg; + ui->update_bg = remote_ui_update_bg; ui->flush = remote_ui_flush; ui->suspend = remote_ui_suspend; pmap_put(uint64_t)(connected_uis, channel_id, ui); @@ -266,6 +268,20 @@ static void remote_ui_visual_bell(UI *ui) push_call(ui, "visual_bell", args); } +static void remote_ui_update_fg(UI *ui, int fg) +{ + Array args = ARRAY_DICT_INIT; + ADD(args, INTEGER_OBJ(fg)); + push_call(ui, "update_fg", args); +} + +static void remote_ui_update_bg(UI *ui, int bg) +{ + Array args = ARRAY_DICT_INIT; + ADD(args, INTEGER_OBJ(bg)); + push_call(ui, "update_bg", args); +} + static void remote_ui_flush(UI *ui) { UIData *data = ui->data; diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index f35da39bb3..8f686ca59f 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -45,6 +45,7 @@ #include "nvim/strings.h" #include "nvim/syntax_defs.h" #include "nvim/term.h" +#include "nvim/ui.h" #include "nvim/os/os.h" #include "nvim/os/time.h" @@ -6528,6 +6529,7 @@ do_highlight ( if (is_normal_group) { normal_fg = HL_TABLE()[idx].sg_rgb_fg; + ui_fg_updated(); } } else if (STRCMP(key, "GUIBG") == 0) { if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) { @@ -6546,6 +6548,7 @@ do_highlight ( if (is_normal_group) { normal_bg = HL_TABLE()[idx].sg_rgb_bg; + ui_bg_updated(); } } else if (STRCMP(key, "GUISP") == 0) { // Ignored diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 9c58193e8c..b37bc92b1a 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -113,6 +113,18 @@ void ui_write(uint8_t *s, int len) free(tofree); } +void ui_fg_updated(void) +{ + UI_CALL(update_fg, normal_fg); + UI_CALL(flush); +} + +void ui_bg_updated(void) +{ + UI_CALL(update_bg, normal_bg); + UI_CALL(flush); +} + /* * If the machine has job control, use it to suspend the program, * otherwise fake it by starting a new shell. @@ -167,6 +179,8 @@ void ui_cursor_shape(void) void ui_resize(int width, int height) { + ui_fg_updated(); + ui_bg_updated(); sr.top = 0; sr.bot = height - 1; sr.left = 0; diff --git a/src/nvim/ui.h b/src/nvim/ui.h index d0933055cc..7c4a233d79 100644 --- a/src/nvim/ui.h +++ b/src/nvim/ui.h @@ -32,6 +32,8 @@ struct ui_t { void (*bell)(UI *ui); void (*visual_bell)(UI *ui); void (*flush)(UI *ui); + void (*update_fg)(UI *ui, int fg); + void (*update_bg)(UI *ui, int bg); void (*suspend)(UI *ui); }; -- cgit From b17005edd98dd7b46b5ff689d83d7bcebac756e5 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Fri, 12 Dec 2014 16:26:27 -0300 Subject: ui: Increase cursor row when text being rendered would cross its limit --- src/nvim/ui.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index b37bc92b1a..cd8c3b73e6 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -458,6 +458,9 @@ static void parse_abstract_ui_codes(uint8_t *ptr, int len) UI_CALL(put, NULL, 0); col++; } + if (col >= width) { + ui_cursor_goto(row + 1, 0); + } p += clen; } ptr = p; -- cgit From 68151636065f9f23ea40dca826964ffafa29c283 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Fri, 12 Dec 2014 16:27:54 -0300 Subject: ui: Add mising T_CSV code to abstract_ui termcap This code is required for screen.c to set a vertical scroll region, which is a great optimization when scrolling vertically split windows. --- src/nvim/term.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/term.c b/src/nvim/term.c index dfc42632c6..f5ca10e6d9 100644 --- a/src/nvim/term.c +++ b/src/nvim/term.c @@ -170,6 +170,7 @@ static struct builtin_term builtin_termcaps[] = {(int)KS_DL, "\033|d"}, {(int)KS_CDL, "\033|%p1%dD"}, {(int)KS_CS, "\033|%p1%d;%p2%dR"}, + {(int)KS_CSV, "\033|%p1%d;%p2%dV"}, {(int)KS_CL, "\033|C"}, // attributes switched on with 'h', off with * 'H' {(int)KS_ME, "\033|31H"}, // HL_ALL -- cgit From 748920d505e2997c79e08d87d09c564eaea23a2f Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Fri, 12 Dec 2014 16:29:25 -0300 Subject: ui: Test for abstract_ui whenever a minimal t_colors value is required t_colors should not be checked when abstract_ui is active, because nvim UI is not limited to a terminal. --- src/nvim/edit.c | 3 +-- src/nvim/eval.c | 2 +- src/nvim/main.c | 4 +--- src/nvim/screen.c | 10 ++++------ src/nvim/syntax.c | 12 ++++++------ 5 files changed, 13 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/nvim/edit.c b/src/nvim/edit.c index e1a1fb18fa..89696410c9 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -2294,8 +2294,7 @@ static int pum_wanted(void) return FALSE; /* The display looks bad on a B&W display. */ - if (t_colors < 8 - ) + if (!abstract_ui && t_colors < 8) return FALSE; return TRUE; } diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 9974315d3f..913d6bf8c6 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -14440,7 +14440,7 @@ static void f_synIDattr(typval_T *argvars, typval_T *rettv) if (modec != 't' && modec != 'c' && modec != 'g') modec = 0; /* replace invalid with current */ } else { - if (t_colors > 1) + if (abstract_ui || t_colors > 1) modec = 'c'; else modec = 't'; diff --git a/src/nvim/main.c b/src/nvim/main.c index 1f6c8ddc81..5e9fde67f5 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -281,9 +281,7 @@ int main(int argc, char **argv) event_init(); - if (abstract_ui) { - t_colors = 256; - } else { + if (!abstract_ui) { // Print a warning if stdout is not a terminal TODO(tarruda): Remove this // check once the new terminal UI is implemented check_tty(¶ms); diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 855c09619e..614f138e31 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -5971,7 +5971,7 @@ void screen_stop_highlight(void) */ void reset_cterm_colors(void) { - if (t_colors > 1) { + if (abstract_ui || t_colors > 1) { /* set Normal cterm colors */ if (cterm_normal_fg_color > 0 || cterm_normal_bg_color > 0) { out_str(T_OP); @@ -6150,8 +6150,7 @@ void screen_fill(int start_row, int end_row, int start_col, int end_col, int c1, return; /* it's a "normal" terminal when not in a GUI or cterm */ - norm_term = ( - t_colors <= 1); + norm_term = (!abstract_ui && t_colors <= 1); for (row = start_row; row < end_row; ++row) { if (has_mbyte ) { @@ -6675,7 +6674,7 @@ static void linecopy(int to, int from, win_T *wp) */ int can_clear(char_u *p) { - return *p != NUL && (t_colors <= 1 + return *p != NUL && ((!abstract_ui && t_colors <= 1) || cterm_normal_bg_color == 0 || *T_UT != NUL); } @@ -7702,8 +7701,7 @@ static void draw_tabline(void) int attr_fill = hl_attr(HLF_TPF); char_u *p; int room; - int use_sep_chars = (t_colors < 8 - ); + int use_sep_chars = !abstract_ui && t_colors < 8; redraw_tabline = FALSE; diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 8f686ca59f..68589522c4 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -5984,7 +5984,7 @@ init_highlight ( * With 8 colors brown is equal to yellow, need to use black for Search fg * to avoid Statement highlighted text disappears. * Clear the attributes, needed when changing the t_Co value. */ - if (t_colors > 8) + if (abstract_ui || t_colors > 8) do_highlight( (char_u *)(*p_bg == 'l' ? "Visual cterm=NONE ctermbg=LightGrey" @@ -6449,7 +6449,7 @@ do_highlight ( HL_TABLE()[idx].sg_cterm &= ~HL_BOLD; } color &= 7; /* truncate to 8 colors */ - } else if (t_colors == 16 || t_colors == 88 + } else if (abstract_ui || t_colors == 16 || t_colors == 88 || t_colors == 256) { /* * Guess: if the termcap entry ends in 'm', it is @@ -6497,7 +6497,7 @@ do_highlight ( if (color >= 0) { if (termcap_active) term_bg_color(color); - if (t_colors < 16) + if (!abstract_ui && t_colors < 16) i = (color == 0 || color == 4); else i = (color < 7 || color == 8); @@ -6873,7 +6873,7 @@ int hl_combine_attr(int char_attr, int prim_attr) if (char_attr <= HL_ALL && prim_attr <= HL_ALL) return char_attr | prim_attr; - if (t_colors > 1) { + if (abstract_ui || t_colors > 1) { if (char_attr > HL_ALL) char_aep = syn_cterm_attr2entry(char_attr); if (char_aep != NULL) @@ -6937,7 +6937,7 @@ int syn_attr2attr(int attr) { attrentry_T *aep; - if (t_colors > 1) + if (abstract_ui || t_colors > 1) aep = syn_cterm_attr2entry(attr); else aep = syn_term_attr2entry(attr); @@ -7364,7 +7364,7 @@ int syn_id2attr(int hl_id) hl_id = syn_get_final_id(hl_id); sgp = &HL_TABLE()[hl_id - 1]; /* index is ID minus one */ - if (t_colors > 1) + if (abstract_ui || t_colors > 1) attr = sgp->sg_cterm_attr; else attr = sgp->sg_term_attr; -- cgit From 9b30abcecbc2492910f0281f596679714d95a88c Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Sat, 13 Dec 2014 09:20:00 -0300 Subject: remote_ui: Move handler registration to remote_ui.c Also don't defer attach_ui handling --- src/nvim/msgpack_rpc/channel.c | 7 ------- src/nvim/msgpack_rpc/remote_ui.c | 45 +++++++++++++++++++++++----------------- 2 files changed, 26 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 4c35cce09a..f3c5a7a1e2 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -103,14 +103,7 @@ void channel_init(void) } if (abstract_ui) { - // Add handler for "attach_ui" remote_ui_init(); - String method = cstr_as_string("attach_ui"); - MsgpackRpcRequestHandler handler = {.fn = remote_ui_attach, .defer = true}; - msgpack_rpc_add_method_handler(method, handler); - method = cstr_as_string("detach_ui"); - handler.fn = remote_ui_detach; - msgpack_rpc_add_method_handler(method, handler); } } diff --git a/src/nvim/msgpack_rpc/remote_ui.c b/src/nvim/msgpack_rpc/remote_ui.c index af7b82dfd4..e27d4383c0 100644 --- a/src/nvim/msgpack_rpc/remote_ui.c +++ b/src/nvim/msgpack_rpc/remote_ui.c @@ -26,10 +26,32 @@ static PMap(uint64_t) *connected_uis = NULL; void remote_ui_init(void) { connected_uis = pmap_new(uint64_t)(); + // Add handler for "attach_ui" + String method = cstr_as_string("attach_ui"); + MsgpackRpcRequestHandler handler = {.fn = remote_ui_attach, .defer = false}; + msgpack_rpc_add_method_handler(method, handler); + method = cstr_as_string("detach_ui"); + handler.fn = remote_ui_detach; + msgpack_rpc_add_method_handler(method, handler); } -Object remote_ui_attach(uint64_t channel_id, uint64_t request_id, Array args, - Error *error) +void remote_ui_disconnect(uint64_t channel_id) +{ + UI *ui = pmap_get(uint64_t)(connected_uis, channel_id); + if (!ui) { + return; + } + UIData *data = ui->data; + // destroy pending screen updates + api_free_array(data->buffer); + pmap_del(uint64_t)(connected_uis, channel_id); + free(ui->data); + ui_detach(ui); + free(ui); +} + +static Object remote_ui_attach(uint64_t channel_id, uint64_t request_id, + Array args, Error *error) { if (pmap_has(uint64_t)(connected_uis, channel_id)) { api_set_error(error, Exception, _("UI already attached for channel")); @@ -77,8 +99,8 @@ Object remote_ui_attach(uint64_t channel_id, uint64_t request_id, Array args, return NIL; } -Object remote_ui_detach(uint64_t channel_id, uint64_t request_id, Array args, - Error *error) +static Object remote_ui_detach(uint64_t channel_id, uint64_t request_id, + Array args, Error *error) { if (!pmap_has(uint64_t)(connected_uis, channel_id)) { api_set_error(error, Exception, _("UI is not attached for channel")); @@ -88,21 +110,6 @@ Object remote_ui_detach(uint64_t channel_id, uint64_t request_id, Array args, return NIL; } -void remote_ui_disconnect(uint64_t channel_id) -{ - UI *ui = pmap_get(uint64_t)(connected_uis, channel_id); - if (!ui) { - return; - } - UIData *data = ui->data; - // destroy pending screen updates - api_free_array(data->buffer); - pmap_del(uint64_t)(connected_uis, channel_id); - free(ui->data); - ui_detach(ui); - free(ui); -} - static void push_call(UI *ui, char *name, Array args) { Array call = ARRAY_DICT_INIT; -- cgit From 213c3c3e53459a77c77166cda85ba619e7eb2eb1 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Sat, 13 Dec 2014 12:58:06 -0300 Subject: ui: Fix ui resizing and change some method names --- src/nvim/msgpack_rpc/remote_ui.c | 32 +++++++++++++++-- src/nvim/syntax.c | 6 ++-- src/nvim/ui.c | 74 +++++++++++++++------------------------- 3 files changed, 61 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/nvim/msgpack_rpc/remote_ui.c b/src/nvim/msgpack_rpc/remote_ui.c index e27d4383c0..a0bc573698 100644 --- a/src/nvim/msgpack_rpc/remote_ui.c +++ b/src/nvim/msgpack_rpc/remote_ui.c @@ -27,12 +27,15 @@ void remote_ui_init(void) { connected_uis = pmap_new(uint64_t)(); // Add handler for "attach_ui" - String method = cstr_as_string("attach_ui"); + String method = cstr_as_string("ui_attach"); MsgpackRpcRequestHandler handler = {.fn = remote_ui_attach, .defer = false}; msgpack_rpc_add_method_handler(method, handler); - method = cstr_as_string("detach_ui"); + method = cstr_as_string("ui_detach"); handler.fn = remote_ui_detach; msgpack_rpc_add_method_handler(method, handler); + method = cstr_as_string("ui_try_resize"); + handler.fn = remote_ui_try_resize; + msgpack_rpc_add_method_handler(method, handler); } void remote_ui_disconnect(uint64_t channel_id) @@ -95,7 +98,6 @@ static Object remote_ui_attach(uint64_t channel_id, uint64_t request_id, ui->suspend = remote_ui_suspend; pmap_put(uint64_t)(connected_uis, channel_id, ui); ui_attach(ui); - return NIL; } @@ -110,6 +112,30 @@ static Object remote_ui_detach(uint64_t channel_id, uint64_t request_id, return NIL; } +static Object remote_ui_try_resize(uint64_t channel_id, uint64_t request_id, + Array args, Error *error) +{ + if (!pmap_has(uint64_t)(connected_uis, channel_id)) { + api_set_error(error, Exception, _("UI is not attached for channel")); + } + + if (args.size != 2 || args.items[0].type != kObjectTypeInteger + || args.items[1].type != kObjectTypeInteger + || args.items[0].data.integer <= 0 || args.items[1].data.integer <= 0) { + api_set_error(error, Validation, + _("Arguments must be a pair of positive integers " + "representing the remote screen width/height")); + return NIL; + } + + UI *ui = pmap_get(uint64_t)(connected_uis, channel_id); + ui->width = (int)args.items[0].data.integer; + ui->height = (int)args.items[1].data.integer; + ui_refresh(); + return NIL; +} + + static void push_call(UI *ui, char *name, Array args) { Array call = ARRAY_DICT_INIT; diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 68589522c4..c2fb34cde0 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -6529,7 +6529,6 @@ do_highlight ( if (is_normal_group) { normal_fg = HL_TABLE()[idx].sg_rgb_fg; - ui_fg_updated(); } } else if (STRCMP(key, "GUIBG") == 0) { if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) { @@ -6548,7 +6547,6 @@ do_highlight ( if (is_normal_group) { normal_bg = HL_TABLE()[idx].sg_rgb_bg; - ui_bg_updated(); } } else if (STRCMP(key, "GUISP") == 0) { // Ignored @@ -6645,6 +6643,10 @@ do_highlight ( if (is_normal_group) { HL_TABLE()[idx].sg_term_attr = 0; HL_TABLE()[idx].sg_cterm_attr = 0; + if (abstract_ui) { + // If the normal group has changed, it is simpler to refresh every UI + ui_refresh(); + } } else set_hl_attr(idx); HL_TABLE()[idx].sg_scriptID = current_SID; diff --git a/src/nvim/ui.c b/src/nvim/ui.c index cd8c3b73e6..de92079ada 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -64,7 +64,7 @@ static HlAttrs current_attrs = { false, false, false, false, false, false, -1, -1 }; static bool cursor_enabled = true; -static int height = INT_MAX, width = INT_MAX; +static int height, width; // This set of macros allow us to use UI_CALL to invoke any function on // registered UI instances. The functions can have 0-5 arguments(configurable @@ -113,18 +113,6 @@ void ui_write(uint8_t *s, int len) free(tofree); } -void ui_fg_updated(void) -{ - UI_CALL(update_fg, normal_fg); - UI_CALL(flush); -} - -void ui_bg_updated(void) -{ - UI_CALL(update_bg, normal_bg); - UI_CALL(flush); -} - /* * If the machine has job control, use it to suspend the program, * otherwise fake it by starting a new shell. @@ -177,10 +165,32 @@ void ui_cursor_shape(void) } } -void ui_resize(int width, int height) +void ui_refresh(void) { - ui_fg_updated(); - ui_bg_updated(); + width = height = INT_MAX; + + for (size_t i = 0; i < ui_count; i++) { + UI *ui = uis[i]; + width = ui->width < width ? ui->width : width; + height = ui->height < height ? ui->height : height; + } + + screen_resize(width, height, true); +} + +void ui_resize(int new_width, int new_height) +{ + width = new_width; + height = new_height; + + if (normal_fg != -1) { + UI_CALL(update_fg, normal_fg); + } + + if (normal_bg != -1) { + UI_CALL(update_bg, normal_bg); + } + sr.top = 0; sr.bot = height - 1; sr.left = 0; @@ -254,7 +264,7 @@ void ui_attach(UI *ui) } uis[ui_count++] = ui; - resized(ui); + ui_refresh(); } void ui_detach(UI *ui) @@ -281,17 +291,8 @@ void ui_detach(UI *ui) ui_count--; - if (ui->width == width || ui->height == height) { - // It is possible that the UI being detached had the smallest screen, - // so check for the new minimum dimensions - width = height = INT_MAX; - for (size_t i = 0; i < ui_count; i++) { - check_dimensions(uis[i]); - } - } - if (ui_count) { - screen_resize(width, height, true); + ui_refresh(); } } @@ -474,25 +475,6 @@ static void parse_abstract_ui_codes(uint8_t *ptr, int len) UI_CALL(flush); } -static void resized(UI *ui) -{ - check_dimensions(ui); - screen_resize(width, height, true); -} - -static void check_dimensions(UI *ui) -{ - // The internal screen dimensions are always the minimum required to fit on - // all connected screens - if (ui->width < width) { - width = ui->width; - } - - if (ui->height < height) { - height = ui->height; - } -} - static void ui_linefeed(void) { int new_col = 0; -- cgit From 0219c87534ff0770b95925529f8e89a2b6c34b14 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Sun, 14 Dec 2014 09:20:07 -0300 Subject: input: Ignore invalid "<" key sequences Ignoring invalid key sequences simplifies input handling in UIs. The only downside is having to use "" everytime a "<" is needed on functional tests. --- src/nvim/os/input.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index c0d588f4ef..130e239a34 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -187,14 +187,20 @@ size_t input_enqueue(String keys) unsigned int new_size = trans_special((uint8_t **)&ptr, buf, false); if (!new_size) { + if (*ptr == '<') { + // Invalid key sequence, skip until the next '>' or until *end + do { + ptr++; + } while (ptr < end && *ptr != '>'); + ptr++; + continue; + } // copy the character unmodified *buf = (uint8_t)*ptr++; new_size = 1; } new_size = handle_mouse_event(&ptr, buf, new_size); - // TODO(tarruda): Don't produce past unclosed '<' characters, except if - // there's a lot of characters after the '<' rbuffer_write(input_buffer, (char *)buf, new_size); } -- cgit From 0887c5446ee8ec6ea53ef69e5d02bd319e1bca1c Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Tue, 30 Dec 2014 08:24:22 -0300 Subject: ui: Merge standout and reverse into one attribute --- src/nvim/msgpack_rpc/remote_ui.c | 4 ---- src/nvim/ui.c | 5 ++--- src/nvim/ui.h | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nvim/msgpack_rpc/remote_ui.c b/src/nvim/msgpack_rpc/remote_ui.c index a0bc573698..e1cb474530 100644 --- a/src/nvim/msgpack_rpc/remote_ui.c +++ b/src/nvim/msgpack_rpc/remote_ui.c @@ -249,10 +249,6 @@ static void remote_ui_highlight_set(UI *ui, HlAttrs attrs) PUT(hl, "bold", BOOLEAN_OBJ(true)); } - if (attrs.standout) { - PUT(hl, "standout", BOOLEAN_OBJ(true)); - } - if (attrs.underline) { PUT(hl, "underline", BOOLEAN_OBJ(true)); } diff --git a/src/nvim/ui.c b/src/nvim/ui.c index de92079ada..b95fdd1104 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -61,7 +61,7 @@ static struct { } sr; static int current_highlight_mask = 0; static HlAttrs current_attrs = { - false, false, false, false, false, false, -1, -1 + false, false, false, false, false, -1, -1 }; static bool cursor_enabled = true; static int height, width; @@ -338,11 +338,10 @@ static void set_highlight_args(int mask, HlAttrs *attrs) } attrs->bold = mask & HL_BOLD; - attrs->standout = mask & HL_STANDOUT; attrs->underline = mask & HL_UNDERLINE; attrs->undercurl = mask & HL_UNDERCURL; attrs->italic = mask & HL_ITALIC; - attrs->reverse = mask & HL_INVERSE; + attrs->reverse = mask & (HL_INVERSE | HL_STANDOUT); attrs->foreground = aep && aep->fg_color >= 0 ? aep->fg_color : normal_fg; attrs->background = aep && aep->bg_color >= 0 ? aep->bg_color : normal_bg; } diff --git a/src/nvim/ui.h b/src/nvim/ui.h index 7c4a233d79..0fcd686e7b 100644 --- a/src/nvim/ui.h +++ b/src/nvim/ui.h @@ -6,7 +6,7 @@ #include typedef struct { - bool bold, standout, underline, undercurl, italic, reverse; + bool bold, underline, undercurl, italic, reverse; int foreground, background; } HlAttrs; -- cgit From c1252a5615d9e69cac50570e8de70e5036a67908 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Fri, 2 Jan 2015 21:03:25 -0300 Subject: syntax: Take rgb fg/bg when allocating cterm attr number --- src/nvim/syntax.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index c2fb34cde0..884a563fea 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -7209,9 +7209,10 @@ set_hl_attr ( * For the color term mode: If there are other than "normal" * highlighting attributes, need to allocate an attr number. */ - if (sgp->sg_cterm_fg == 0 && sgp->sg_cterm_bg == 0) + if (sgp->sg_cterm_fg == 0 && sgp->sg_cterm_bg == 0 + && sgp->sg_rgb_fg == -1 && sgp->sg_rgb_bg == -1) { sgp->sg_cterm_attr = sgp->sg_cterm; - else { + } else { at_en.ae_attr = abstract_ui ? sgp->sg_gui : sgp->sg_cterm; at_en.ae_u.cterm.fg_color = sgp->sg_cterm_fg; at_en.ae_u.cterm.bg_color = sgp->sg_cterm_bg; -- cgit From a4525bc5231bc175a4abd5f60624ed40e85c700b Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Mon, 5 Jan 2015 07:39:38 -0300 Subject: screen: Remove abstract_ui test in reset_cterm_colors --- src/nvim/screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 614f138e31..0ff74176d4 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -5971,7 +5971,7 @@ void screen_stop_highlight(void) */ void reset_cterm_colors(void) { - if (abstract_ui || t_colors > 1) { + if (t_colors > 1) { /* set Normal cterm colors */ if (cterm_normal_fg_color > 0 || cterm_normal_bg_color > 0) { out_str(T_OP); -- cgit From 869c734890e493279b1880a773de24fa5f57adfb Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Mon, 5 Jan 2015 14:55:36 -0300 Subject: screen: Fix bug that causes separator to always be redraw for utf8 --- src/nvim/screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 0ff74176d4..a3b1b4d433 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -4548,7 +4548,7 @@ static void screen_line(int row, int coloff, int endcol, int clear_width, int rl int c; c = fillchar_vsep(&hl); - if (ScreenLines[off_to] != c + if (ScreenLines[off_to] != ((schar_T)c) || (enc_utf8 && (int)ScreenLinesUC[off_to] != (c >= 0x80 ? c : 0)) || ScreenAttrs[off_to] != hl) { -- cgit From a8fe32040b039c134087c4c0d8c9e14bf50fef1a Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Thu, 8 Jan 2015 10:42:12 -0300 Subject: ui: Dont resize screen if no UIs are attached This prevents a race condition when a UI attaches early in the program and can receive redraw commands for a invalid screen --- src/nvim/ui.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index b95fdd1104..80f8b9221a 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -167,6 +167,10 @@ void ui_cursor_shape(void) void ui_refresh(void) { + if (!ui_count) { + return; + } + width = height = INT_MAX; for (size_t i = 0; i < ui_count; i++) { -- cgit From 74c247f75baec5778296adf164831c5ffea0fb88 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Thu, 8 Jan 2015 11:23:45 -0300 Subject: ui: Add 'rgb' parameter to ui_attach When set to false, nvim will send cterm color numbers with `highlight_set`. --- src/nvim/msgpack_rpc/remote_ui.c | 4 ++- src/nvim/syntax.c | 7 +++--- src/nvim/ui.c | 54 ++++++++++++++++++++++++---------------- src/nvim/ui.h | 1 + 4 files changed, 40 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/nvim/msgpack_rpc/remote_ui.c b/src/nvim/msgpack_rpc/remote_ui.c index e1cb474530..6a638df61c 100644 --- a/src/nvim/msgpack_rpc/remote_ui.c +++ b/src/nvim/msgpack_rpc/remote_ui.c @@ -61,8 +61,9 @@ static Object remote_ui_attach(uint64_t channel_id, uint64_t request_id, return NIL; } - if (args.size != 2 || args.items[0].type != kObjectTypeInteger + if (args.size != 3 || args.items[0].type != kObjectTypeInteger || args.items[1].type != kObjectTypeInteger + || args.items[2].type != kObjectTypeBoolean || args.items[0].data.integer <= 0 || args.items[1].data.integer <= 0) { api_set_error(error, Validation, _("Arguments must be a pair of positive integers " @@ -75,6 +76,7 @@ static Object remote_ui_attach(uint64_t channel_id, uint64_t request_id, UI *ui = xcalloc(1, sizeof(UI)); ui->width = (int)args.items[0].data.integer; ui->height = (int)args.items[1].data.integer; + ui->rgb = args.items[2].data.boolean; ui->data = data; ui->resize = remote_ui_resize; ui->clear = remote_ui_clear; diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 884a563fea..805f808449 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -6432,7 +6432,9 @@ do_highlight ( /* Use the _16 table to check if its a valid color name. */ color = color_numbers_16[i]; if (color >= 0) { - if (t_colors == 8) { + if (abstract_ui) { + color = color_numbers_256[i]; + } else if (t_colors == 8) { /* t_Co is 8: use the 8 colors table */ #if defined(__QNXNTO__) color = color_numbers_8_qansi[i]; @@ -6449,8 +6451,7 @@ do_highlight ( HL_TABLE()[idx].sg_cterm &= ~HL_BOLD; } color &= 7; /* truncate to 8 colors */ - } else if (abstract_ui || t_colors == 16 || t_colors == 88 - || t_colors == 256) { + } else if (t_colors == 16 || t_colors == 88 || t_colors == 256) { /* * Guess: if the termcap entry ends in 'm', it is * probably an xterm-like terminal. Use the changed diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 80f8b9221a..8012bb4ee7 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -60,9 +60,6 @@ static struct { int top, bot, left, right; } sr; static int current_highlight_mask = 0; -static HlAttrs current_attrs = { - false, false, false, false, false, -1, -1 -}; static bool cursor_enabled = true; static int height, width; @@ -187,13 +184,8 @@ void ui_resize(int new_width, int new_height) width = new_width; height = new_height; - if (normal_fg != -1) { - UI_CALL(update_fg, normal_fg); - } - - if (normal_bg != -1) { - UI_CALL(update_bg, normal_bg); - } + UI_CALL(update_fg, (ui->rgb ? normal_fg : cterm_normal_fg_color - 1)); + UI_CALL(update_bg, (ui->rgb ? normal_bg : cterm_normal_bg_color - 1)); sr.top = 0; sr.bot = height - 1; @@ -314,8 +306,7 @@ static void highlight_start(int mask) return; } - set_highlight_args(current_highlight_mask, ¤t_attrs); - UI_CALL(highlight_set, current_attrs); + set_highlight_args(current_highlight_mask); } static void highlight_stop(int mask) @@ -328,12 +319,12 @@ static void highlight_stop(int mask) current_highlight_mask &= ~mask; } - set_highlight_args(current_highlight_mask, ¤t_attrs); - UI_CALL(highlight_set, current_attrs); + set_highlight_args(current_highlight_mask); } -static void set_highlight_args(int mask, HlAttrs *attrs) +static void set_highlight_args(int mask) { + HlAttrs rgb_attrs = { false, false, false, false, false, -1, -1 }; attrentry_T *aep = NULL; if (mask > HL_ALL) { @@ -341,13 +332,32 @@ static void set_highlight_args(int mask, HlAttrs *attrs) mask = aep ? aep->ae_attr : 0; } - attrs->bold = mask & HL_BOLD; - attrs->underline = mask & HL_UNDERLINE; - attrs->undercurl = mask & HL_UNDERCURL; - attrs->italic = mask & HL_ITALIC; - attrs->reverse = mask & (HL_INVERSE | HL_STANDOUT); - attrs->foreground = aep && aep->fg_color >= 0 ? aep->fg_color : normal_fg; - attrs->background = aep && aep->bg_color >= 0 ? aep->bg_color : normal_bg; + rgb_attrs.bold = mask & HL_BOLD; + rgb_attrs.underline = mask & HL_UNDERLINE; + rgb_attrs.undercurl = mask & HL_UNDERCURL; + rgb_attrs.italic = mask & HL_ITALIC; + rgb_attrs.reverse = mask & (HL_INVERSE | HL_STANDOUT); + HlAttrs cterm_attrs = rgb_attrs; + + if (aep) { + if (aep->fg_color != normal_fg) { + rgb_attrs.foreground = aep->fg_color; + } + + if (aep->bg_color != normal_bg) { + rgb_attrs.background = aep->bg_color; + } + + if (cterm_normal_fg_color != aep->ae_u.cterm.fg_color) { + cterm_attrs.foreground = aep->ae_u.cterm.fg_color - 1; + } + + if (cterm_normal_bg_color != aep->ae_u.cterm.bg_color) { + cterm_attrs.background = aep->ae_u.cterm.bg_color - 1; + } + } + + UI_CALL(highlight_set, (ui->rgb ? rgb_attrs : cterm_attrs)); } static void parse_abstract_ui_codes(uint8_t *ptr, int len) diff --git a/src/nvim/ui.h b/src/nvim/ui.h index 0fcd686e7b..9ec10db75e 100644 --- a/src/nvim/ui.h +++ b/src/nvim/ui.h @@ -13,6 +13,7 @@ typedef struct { typedef struct ui_t UI; struct ui_t { + bool rgb; int width, height; void *data; void (*resize)(UI *ui, int rows, int columns); -- cgit From cba91622155f1dbecf364f36f6ee31120b9121ad Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Fri, 9 Jan 2015 09:07:58 -0300 Subject: channel: Free channels created from libuv streams --- src/nvim/msgpack_rpc/channel.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index f3c5a7a1e2..af7e7fa409 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -637,6 +637,7 @@ static void close_channel(Channel *channel) uv_handle_t *handle = (uv_handle_t *)channel->data.streams.uv; if (handle) { uv_close(handle, close_cb); + free_channel(channel); } else { event_push((Event) { .handler = on_stdio_close }, false); } -- cgit From abc147a9775ef7de221443ff68ddfbc8ff6e0177 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Fri, 9 Jan 2015 09:18:23 -0300 Subject: ui: Don't parse abstract_ui codes if there are no attached UIs --- src/nvim/ui.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 8012bb4ee7..da47080045 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -362,6 +362,10 @@ static void set_highlight_args(int mask) static void parse_abstract_ui_codes(uint8_t *ptr, int len) { + if (!ui_count) { + return; + } + int arg1 = 0, arg2 = 0; uint8_t *end = ptr + len, *p, c; bool update_cursor = false; -- cgit From d992213678ecd14902ae74ff765e682fb76d5ad9 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Fri, 9 Jan 2015 09:51:11 -0300 Subject: ui: Reimplement `:suspend` command for remote UIs. - Remove suspend method from the UI protocol - Handle `:suspend` by disconnecting the last channel that sent a request to nvim. --- src/nvim/ex_docmd.c | 13 ++++++++++--- src/nvim/globals.h | 3 +++ src/nvim/msgpack_rpc/channel.c | 1 + src/nvim/msgpack_rpc/remote_ui.c | 7 ------- src/nvim/ui.c | 4 +--- src/nvim/ui.h | 1 - 6 files changed, 15 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index ca79270fcc..5dae96d774 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -71,6 +71,7 @@ #include "nvim/os/time.h" #include "nvim/ex_cmds_defs.h" #include "nvim/mouse.h" +#include "nvim/msgpack_rpc/channel.h" static int quitmore = 0; static int ex_pressedreturn = FALSE; @@ -5398,10 +5399,16 @@ static void ex_stop(exarg_T *eap) /* * Disallow suspending for "rvim". */ - if (!check_restricted() - ) { - if (!eap->forceit) + if (!check_restricted()) { + if (!eap->forceit) { autowrite_all(); + } + + if (abstract_ui) { + channel_close(last_message_source); + return; + } + windgoto((int)Rows - 1, 0); out_char('\n'); out_flush(); diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 11a7e9ecac..854dd33552 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -1245,6 +1245,9 @@ EXTERN int curr_tmode INIT(= TMODE_COOK); /* contains current terminal mode */ EXTERN bool embedded_mode INIT(= false); // Using the "abstract_ui" termcap EXTERN bool abstract_ui INIT(= false); +// Id of the last channel sent a message to nvim. Used to determine the target +// of channel-specific actions such as suspending +EXTERN uint64_t last_message_source INIT(= 0); /// Used to track the status of external functions. /// Currently only used for iconv(). diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index af7e7fa409..85511fb587 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -485,6 +485,7 @@ static void on_request_event(Event event) { RequestEvent *e = event.data; Channel *channel = e->channel; + last_message_source = channel->id; MsgpackRpcRequestHandler handler = e->handler; Array args = e->args; uint64_t request_id = e->request_id; diff --git a/src/nvim/msgpack_rpc/remote_ui.c b/src/nvim/msgpack_rpc/remote_ui.c index 6a638df61c..4db9c71ebb 100644 --- a/src/nvim/msgpack_rpc/remote_ui.c +++ b/src/nvim/msgpack_rpc/remote_ui.c @@ -97,7 +97,6 @@ static Object remote_ui_attach(uint64_t channel_id, uint64_t request_id, ui->update_fg = remote_ui_update_fg; ui->update_bg = remote_ui_update_bg; ui->flush = remote_ui_flush; - ui->suspend = remote_ui_suspend; pmap_put(uint64_t)(connected_uis, channel_id, ui); ui_attach(ui); return NIL; @@ -319,9 +318,3 @@ static void remote_ui_flush(UI *ui) channel_send_event(data->channel_id, "redraw", data->buffer); data->buffer = (Array)ARRAY_DICT_INIT; } - -static void remote_ui_suspend(UI *ui) -{ - UIData *data = ui->data; - remote_ui_disconnect(data->channel_id); -} diff --git a/src/nvim/ui.c b/src/nvim/ui.c index da47080045..5bd4382483 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -117,9 +117,7 @@ void ui_write(uint8_t *s, int len) */ void ui_suspend(void) { - if (abstract_ui) { - UI_CALL(suspend); - } else { + if (!abstract_ui) { mch_suspend(); } } diff --git a/src/nvim/ui.h b/src/nvim/ui.h index 9ec10db75e..3d3e2f4ffc 100644 --- a/src/nvim/ui.h +++ b/src/nvim/ui.h @@ -35,7 +35,6 @@ struct ui_t { void (*flush)(UI *ui); void (*update_fg)(UI *ui, int fg); void (*update_bg)(UI *ui, int bg); - void (*suspend)(UI *ui); }; #ifdef INCLUDE_GENERATED_DECLARATIONS -- cgit From e3b2907f2f4dceece300e1f9b61cfd8060ff4dce Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Sat, 10 Jan 2015 01:30:31 -0300 Subject: channel: Make pending_requests a field of the Channel type This is required to send redraw notifications while a msgpack-rpc call is being performed by another channel. --- src/nvim/msgpack_rpc/channel.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 85511fb587..f2db65c605 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -45,6 +45,7 @@ typedef struct { typedef struct { uint64_t id; + size_t pending_requests; PMap(cstr_t) *subscribed_events; bool is_job, closed; msgpack_unpacker *unpacker; @@ -83,7 +84,6 @@ static uint64_t next_id = 1; static PMap(uint64_t) *channels = NULL; static PMap(cstr_t) *event_strings = NULL; static msgpack_sbuffer out_buffer; -static size_t pending_requests = 0; #ifdef INCLUDE_GENERATED_DECLARATIONS # include "msgpack_rpc/channel.c.generated.h" @@ -193,20 +193,21 @@ bool channel_send_event(uint64_t id, char *name, Array args) return false; } - if (pending_requests) { - DelayedNotification p = { - .channel = channel, - .method = cstr_to_string(name), - .args = args - }; - // Pending request, queue the notification for sending later - *kl_pushp(DelayedNotification, delayed_notifications) = p; - } else { - if (channel) { - send_event(channel, name, args); + if (channel) { + if (channel->pending_requests) { + DelayedNotification p = { + .channel = channel, + .method = cstr_to_string(name), + .args = args + }; + // Pending request, queue the notification for sending later + *kl_pushp(DelayedNotification, delayed_notifications) = p; } else { - broadcast_event(name, args); + send_event(channel, name, args); } + } else { + // TODO(tarruda): Implement event broadcasting in vimscript + broadcast_event(name, args); } return true; @@ -239,10 +240,10 @@ Object channel_send_call(uint64_t id, // Push the frame ChannelCallFrame frame = {request_id, false, false, NIL}; kv_push(ChannelCallFrame *, channel->call_stack, &frame); - pending_requests++; + channel->pending_requests++; event_poll_until(-1, frame.returned); (void)kv_pop(channel->call_stack); - pending_requests--; + channel->pending_requests--; if (frame.errored) { api_set_error(err, Exception, "%s", frame.result.data.string.data); @@ -254,7 +255,7 @@ Object channel_send_call(uint64_t id, free_channel(channel); } - if (!pending_requests) { + if (!channel->pending_requests) { send_delayed_notifications(); } @@ -682,6 +683,7 @@ static Channel *register_channel(void) rv->closed = false; rv->unpacker = msgpack_unpacker_new(MSGPACK_UNPACKER_INIT_BUFFER_SIZE); rv->id = next_id++; + rv->pending_requests = 0; rv->subscribed_events = pmap_new(cstr_t)(); rv->next_request_id = 1; kv_init(rv->call_stack); -- cgit From e1da130ca9bb132335e4255421fded3e80ca4fad Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Sat, 10 Jan 2015 02:37:22 -0300 Subject: ui: Fix out_flush/ui_write behavior to always flush for abstract_ui --- src/nvim/term.c | 9 +++------ src/nvim/ui.c | 4 ++++ 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/term.c b/src/nvim/term.c index f5ca10e6d9..15ced48d91 100644 --- a/src/nvim/term.c +++ b/src/nvim/term.c @@ -1823,12 +1823,9 @@ static int out_pos = 0; /* number of chars in out_buf */ */ void out_flush(void) { - if (out_pos != 0) { - /* set out_pos to 0 before ui_write, to avoid recursiveness */ - int len = out_pos; - out_pos = 0; - ui_write(out_buf, len); - } + int len = out_pos; + out_pos = 0; + ui_write(out_buf, len); } /* diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 5bd4382483..5b28cf2243 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -95,6 +95,10 @@ void ui_write(uint8_t *s, int len) return; } + if (!len) { + return; + } + char_u *tofree = NULL; if (output_conv.vc_type != CONV_NONE) { -- cgit From 7703fd328c44793cc3793fe4c2bf1b58d63dec45 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Sat, 10 Jan 2015 22:44:29 -0300 Subject: ui: Use ui_linefeed to handle line breaks correctly ui_linefeed will scroll the screen when it becomes full. This can happen when executing external commands. --- src/nvim/ui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 5b28cf2243..d66be0f8df 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -479,7 +479,7 @@ static void parse_abstract_ui_codes(uint8_t *ptr, int len) col++; } if (col >= width) { - ui_cursor_goto(row + 1, 0); + ui_linefeed(); } p += clen; } -- cgit From 418a49f7f1eb5c6a5235cbf34852212899ea4a06 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Sun, 11 Jan 2015 11:17:16 -0300 Subject: shell: When executing command, use screen functions to display output By calling ui_write directly, the internal screen isn't updated and invalid bytes aren't handled, which breaks the abstract UI model. --- src/nvim/os/shell.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index d0f8442768..d481d6af56 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -24,7 +24,6 @@ #include "nvim/option_defs.h" #include "nvim/charset.h" #include "nvim/strings.h" -#include "nvim/ui.h" #define DYNAMIC_BUFFER_INIT {NULL, 0, 0} @@ -414,6 +413,7 @@ static size_t write_output(char *output, size_t remaining, bool to_buffer, char *start = output; size_t off = 0; + int lastrow = (int)Rows - 1; while (off < remaining) { if (output[off] == NL) { // Insert the line @@ -421,10 +421,8 @@ static size_t write_output(char *output, size_t remaining, bool to_buffer, if (to_buffer) { ml_append(curwin->w_cursor.lnum++, (char_u *)output, 0, false); } else { - // pending data from the output buffer has been flushed to the screen, - // safe to call ui_write directly - ui_write((char_u *)output, (int)off); - ui_write((char_u *)"\r\n", 2); + screen_del_lines(0, 0, 1, (int)Rows, true, NULL); + screen_puts_len((char_u *)output, (int)off, lastrow, 0, 0); } size_t skip = off + 1; output += skip; @@ -448,8 +446,8 @@ static size_t write_output(char *output, size_t remaining, bool to_buffer, // remember that the NL was missing curbuf->b_no_eol_lnum = curwin->w_cursor.lnum; } else { - ui_write((char_u *)output, (int)remaining); - ui_write((char_u *)"\r\n", 2); + screen_del_lines(0, 0, 1, (int)Rows, true, NULL); + screen_puts_len((char_u *)output, (int)remaining, lastrow, 0, 0); } output += remaining; } else if (to_buffer) { -- cgit From a16cd73eadf473e3f2da104e2620680c4b5dd9d6 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Mon, 12 Jan 2015 08:59:51 -0300 Subject: ui: Fix redraw bug caused by race conditions with remote clients Before sending a resize command to the UIs, flush the current output buffer to ensure no redraw commands for a screen with invalid size are processed. --- src/nvim/screen.c | 3 +++ src/nvim/term.c | 6 ++++++ src/nvim/ui.c | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index a3b1b4d433..b593d5a687 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -8186,6 +8186,9 @@ void screen_resize(int width, int height, int mustset) check_shellsize(); if (abstract_ui) { + // Clear the output buffer to ensure UIs don't receive redraw command meant + // for invalid screen sizes. + out_buf_clear(); ui_resize(width, height); } else { mch_set_shellsize(); diff --git a/src/nvim/term.c b/src/nvim/term.c index 15ced48d91..6459be9703 100644 --- a/src/nvim/term.c +++ b/src/nvim/term.c @@ -1818,6 +1818,12 @@ void term_write(char_u *s, size_t len) static char_u out_buf[OUT_SIZE + 1]; static int out_pos = 0; /* number of chars in out_buf */ +// Clear the output buffer +void out_buf_clear(void) +{ + out_pos = 0; +} + /* * out_flush(): flush the output buffer */ diff --git a/src/nvim/ui.c b/src/nvim/ui.c index d66be0f8df..80dbea31cb 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -170,7 +170,7 @@ void ui_refresh(void) return; } - width = height = INT_MAX; + int width = INT_MAX, height = INT_MAX; for (size_t i = 0; i < ui_count; i++) { UI *ui = uis[i]; -- cgit From 62c1daffe028185030d0d8e95dc2c6532457b4fa Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Mon, 12 Jan 2015 10:28:32 -0300 Subject: syntax: Refresh UI when the color scheme changes --- src/nvim/syntax.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 805f808449..e5f7662a32 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -6037,6 +6037,7 @@ int load_colors(char_u *name) apply_autocmds(EVENT_COLORSCHEME, name, curbuf->b_fname, FALSE, curbuf); recursive = FALSE; + ui_refresh(); return retval; } -- cgit