static void remote_ui_flush(UI *ui) { UIData *data = ui->data; if (data->buffer.size > 0) { if (!ui->ui_ext[kUINewgrid]) { remote_ui_cursor_goto(ui, data->cursor_row, data->cursor_col); } rpc_send_event(data->channel_id, "redraw", data->buffer); data->buffer = (Array)ARRAY_DICT_INIT; } }
/// "true" cursor used only for input focus static void remote_ui_grid_cursor_goto(UI *ui, Integer grid, Integer row, Integer col) { if (ui->ui_ext[kUILinegrid]) { Array args = ARRAY_DICT_INIT; ADD(args, INTEGER_OBJ(grid)); ADD(args, INTEGER_OBJ(row)); ADD(args, INTEGER_OBJ(col)); push_call(ui, "grid_cursor_goto", args); } else { UIData *data = ui->data; data->cursor_row = row; data->cursor_col = col; remote_ui_cursor_goto(ui, row, col); } }
static void remote_ui_raw_line(UI *ui, Integer grid, Integer row, Integer startcol, Integer endcol, Integer clearcol, Integer clearattr, Boolean wrap, const schar_T *chunk, const sattr_T *attrs) { UIData *data = ui->data; if (ui->ui_ext[kUILinegrid]) { Array args = ARRAY_DICT_INIT; ADD(args, INTEGER_OBJ(grid)); ADD(args, INTEGER_OBJ(row)); ADD(args, INTEGER_OBJ(startcol)); Array cells = ARRAY_DICT_INIT; int repeat = 0; size_t ncells = (size_t)(endcol-startcol); int last_hl = -1; for (size_t i = 0; i < ncells; i++) { repeat++; if (i == ncells-1 || attrs[i] != attrs[i+1] || STRCMP(chunk[i], chunk[i+1])) { Array cell = ARRAY_DICT_INIT; ADD(cell, STRING_OBJ(cstr_to_string((const char *)chunk[i]))); if (attrs[i] != last_hl || repeat > 1) { ADD(cell, INTEGER_OBJ(attrs[i])); last_hl = attrs[i]; } if (repeat > 1) { ADD(cell, INTEGER_OBJ(repeat)); } ADD(cells, ARRAY_OBJ(cell)); repeat = 0; } } if (endcol < clearcol) { Array cell = ARRAY_DICT_INIT; ADD(cell, STRING_OBJ(cstr_to_string(" "))); ADD(cell, INTEGER_OBJ(clearattr)); ADD(cell, INTEGER_OBJ(clearcol-endcol)); ADD(cells, ARRAY_OBJ(cell)); } ADD(args, ARRAY_OBJ(cells)); push_call(ui, "grid_line", args); } else { for (int i = 0; i < endcol-startcol; i++) { remote_ui_cursor_goto(ui, row, startcol+i); remote_ui_highlight_set(ui, attrs[i]); remote_ui_put(ui, (const char *)chunk[i]); if (utf_ambiguous_width(utf_ptr2char(chunk[i]))) { data->client_col = -1; // force cursor update } } if (endcol < clearcol) { remote_ui_cursor_goto(ui, row, endcol); remote_ui_highlight_set(ui, (int)clearattr); // legacy eol_clear was only ever used with cleared attributes // so be on the safe side if (clearattr == 0 && clearcol == Columns) { Array args = ARRAY_DICT_INIT; push_call(ui, "eol_clear", args); } else { for (Integer c = endcol; c < clearcol; c++) { remote_ui_put(ui, " "); } } } } }