multigrid: Change screen_* functions to grid_* functions

This commit is contained in:
Utkarsh Maheshwari
2018-05-19 21:03:17 +05:30
committed by Björn Linse
parent c9b559a030
commit f102f50ebe
14 changed files with 553 additions and 454 deletions

View File

@@ -81,6 +81,8 @@ void grid_line(Integer grid, Integer row, Integer col_start, Array data)
void grid_scroll(Integer grid, Integer top, Integer bot, void grid_scroll(Integer grid, Integer top, Integer bot,
Integer left, Integer right, Integer rows, Integer cols) Integer left, Integer right, Integer rows, Integer cols)
FUNC_API_SINCE(5) FUNC_API_REMOTE_IMPL; FUNC_API_SINCE(5) FUNC_API_REMOTE_IMPL;
void grid_destroy(Integer grid)
FUNC_API_SINCE(5) FUNC_API_REMOTE_ONLY;
void popupmenu_show(Array items, Integer selected, Integer row, Integer col) void popupmenu_show(Array items, Integer selected, Integer row, Integer col)
FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;

View File

@@ -1183,6 +1183,8 @@ struct window_S {
int w_tagstackidx; /* idx just below active entry */ int w_tagstackidx; /* idx just below active entry */
int w_tagstacklen; /* number of tags on stack */ int w_tagstacklen; /* number of tags on stack */
ScreenGrid w_grid; // the grid specific to the window
/* /*
* w_fraction is the fractional row of the cursor within the window, from * w_fraction is the fractional row of the cursor within the window, from
* 0 at the top row to FRACTION_MULT at the last row. * 0 at the top row to FRACTION_MULT at the last row.

View File

@@ -560,7 +560,7 @@ static int insert_check(VimState *state)
if (curwin->w_wcol < s->mincol - curbuf->b_p_ts if (curwin->w_wcol < s->mincol - curbuf->b_p_ts
&& curwin->w_wrow == curwin->w_winrow && curwin->w_wrow == curwin->w_winrow
+ curwin->w_height - 1 - p_so + curwin->w_grid.Rows - 1 - p_so
&& (curwin->w_cursor.lnum != curwin->w_topline && (curwin->w_cursor.lnum != curwin->w_topline
|| curwin->w_topfill > 0)) { || curwin->w_topfill > 0)) {
if (curwin->w_topfill > 0) { if (curwin->w_topfill > 0) {
@@ -1502,17 +1502,17 @@ void edit_putchar(int c, int highlight)
} else { } else {
attr = 0; attr = 0;
} }
pc_row = curwin->w_winrow + curwin->w_wrow; pc_row = curwin->w_wrow;
pc_col = curwin->w_wincol; pc_col = 0;
pc_status = PC_STATUS_UNSET; pc_status = PC_STATUS_UNSET;
if (curwin->w_p_rl) { if (curwin->w_p_rl) {
pc_col += curwin->w_width - 1 - curwin->w_wcol; pc_col += curwin->w_grid.Columns - 1 - curwin->w_wcol;
if (has_mbyte) { if (has_mbyte) {
int fix_col = mb_fix_col(pc_col, pc_row); int fix_col = mb_fix_col(pc_col, pc_row);
if (fix_col != pc_col) { if (fix_col != pc_col) {
screen_putchar(' ', pc_row, fix_col, attr); grid_putchar(&curwin->w_grid, ' ', pc_row, fix_col, attr);
--curwin->w_wcol; curwin->w_wcol--;
pc_status = PC_STATUS_RIGHT; pc_status = PC_STATUS_RIGHT;
} }
} }
@@ -1524,10 +1524,10 @@ void edit_putchar(int c, int highlight)
/* save the character to be able to put it back */ /* save the character to be able to put it back */
if (pc_status == PC_STATUS_UNSET) { if (pc_status == PC_STATUS_UNSET) {
screen_getbytes(pc_row, pc_col, pc_bytes, &pc_attr); grid_getbytes(&curwin->w_grid, pc_row, pc_col, pc_bytes, &pc_attr);
pc_status = PC_STATUS_SET; pc_status = PC_STATUS_SET;
} }
screen_putchar(c, pc_row, pc_col, attr); grid_putchar(&curwin->w_grid, c, pc_row, pc_col, attr);
} }
} }
@@ -1543,7 +1543,8 @@ void edit_unputchar(void)
if (pc_status == PC_STATUS_RIGHT || pc_status == PC_STATUS_LEFT) { if (pc_status == PC_STATUS_RIGHT || pc_status == PC_STATUS_LEFT) {
redrawWinline(curwin, curwin->w_cursor.lnum, false); redrawWinline(curwin, curwin->w_cursor.lnum, false);
} else { } else {
screen_puts(pc_bytes, pc_row - msg_scrolled, pc_col, pc_attr); grid_puts(&curwin->w_grid, pc_bytes, pc_row - msg_scrolled, pc_col,
pc_attr);
} }
} }
} }
@@ -1566,7 +1567,7 @@ void display_dollar(colnr_T col)
char_u *p = get_cursor_line_ptr(); char_u *p = get_cursor_line_ptr();
curwin->w_cursor.col -= utf_head_off(p, p + col); curwin->w_cursor.col -= utf_head_off(p, p + col);
curs_columns(false); // Recompute w_wrow and w_wcol curs_columns(false); // Recompute w_wrow and w_wcol
if (curwin->w_wcol < curwin->w_width) { if (curwin->w_wcol < curwin->w_grid.Columns) {
edit_putchar('$', FALSE); edit_putchar('$', FALSE);
dollar_vcol = curwin->w_virtcol; dollar_vcol = curwin->w_virtcol;
} }
@@ -5825,7 +5826,7 @@ static void check_auto_format(
/* /*
* Find out textwidth to be used for formatting: * Find out textwidth to be used for formatting:
* if 'textwidth' option is set, use it * if 'textwidth' option is set, use it
* else if 'wrapmargin' option is set, use curwin->w_width - 'wrapmargin' * else if 'wrapmargin' option is set, use curwin->w_grid.Columns-'wrapmargin'
* if invalid value, use 0. * if invalid value, use 0.
* Set default to window width (maximum 79) for "gq" operator. * Set default to window width (maximum 79) for "gq" operator.
*/ */
@@ -5840,7 +5841,7 @@ comp_textwidth (
if (textwidth == 0 && curbuf->b_p_wm) { if (textwidth == 0 && curbuf->b_p_wm) {
/* The width is the window width minus 'wrapmargin' minus all the /* The width is the window width minus 'wrapmargin' minus all the
* things that add to the margin. */ * things that add to the margin. */
textwidth = curwin->w_width - curbuf->b_p_wm; textwidth = curwin->w_grid.Columns - curbuf->b_p_wm;
if (cmdwin_type != 0) if (cmdwin_type != 0)
textwidth -= 1; textwidth -= 1;
textwidth -= curwin->w_p_fdc; textwidth -= curwin->w_p_fdc;
@@ -5855,7 +5856,7 @@ comp_textwidth (
if (textwidth < 0) if (textwidth < 0)
textwidth = 0; textwidth = 0;
if (ff && textwidth == 0) { if (ff && textwidth == 0) {
textwidth = curwin->w_width - 1; textwidth = curwin->w_grid.Columns - 1;
if (textwidth > 79) if (textwidth > 79)
textwidth = 79; textwidth = 79;
} }

View File

@@ -161,7 +161,8 @@ EXTERN char_u *LineWraps INIT(= NULL); /* line wraps to next line */
EXTERN int screen_Rows INIT(= 0); /* actual size of ScreenLines[] */ EXTERN int screen_Rows INIT(= 0); /* actual size of ScreenLines[] */
EXTERN int screen_Columns INIT(= 0); /* actual size of ScreenLines[] */ EXTERN int screen_Columns INIT(= 0); /* actual size of ScreenLines[] */
EXTERN ScreenGrid default_grid INIT(= { 0 }); EXTERN ScreenGrid default_grid INIT(= { 0, NULL, NULL, NULL, NULL, 0, 0, 0, 0,
0, 0, 0 });
/* /*
* When vgetc() is called, it sets mod_mask to the set of modifiers that are * When vgetc() is called, it sets mod_mask to the set of modifiers that are

View File

@@ -582,8 +582,8 @@ static void prt_header(prt_settings_T *const psettings, const int pagenum,
*/ */
static void prt_message(char_u *s) static void prt_message(char_u *s)
{ {
screen_fill((int)Rows - 1, (int)Rows, 0, (int)Columns, ' ', ' ', 0); grid_fill(&default_grid, (int)Rows - 1, (int)Rows, 0, (int)Columns, ' ', ' ', 0);
screen_puts(s, (int)Rows - 1, 0, HL_ATTR(HLF_R)); grid_puts(&default_grid, s, (int)Rows - 1, 0, HL_ATTR(HLF_R));
ui_flush(); ui_flush();
} }

View File

@@ -1547,7 +1547,7 @@ void msg_prt_line(char_u *s, int list)
} }
/* /*
* Use screen_puts() to output one multi-byte character. * Use grid_puts() to output one multi-byte character.
* Return the pointer "s" advanced to the next character. * Return the pointer "s" advanced to the next character.
*/ */
static char_u *screen_puts_mbyte(char_u *s, int l, int attr) static char_u *screen_puts_mbyte(char_u *s, int l, int attr)
@@ -1563,7 +1563,7 @@ static char_u *screen_puts_mbyte(char_u *s, int l, int attr)
return s; return s;
} }
screen_puts_len(s, l, msg_row, msg_col, attr); grid_puts_len(&default_grid, s, l, msg_row, msg_col, attr);
if (cmdmsg_rl) { if (cmdmsg_rl) {
msg_col -= cw; msg_col -= cw;
if (msg_col == 0) { if (msg_col == 0) {
@@ -1888,17 +1888,17 @@ static void msg_scroll_up(void)
{ {
if (dy_flags & DY_MSGSEP) { if (dy_flags & DY_MSGSEP) {
if (msg_scrolled == 0) { if (msg_scrolled == 0) {
screen_fill(Rows-p_ch-1, Rows-p_ch, 0, (int)Columns, grid_fill(&default_grid, Rows-p_ch-1, Rows-p_ch, 0, (int)Columns,
fill_msgsep, fill_msgsep, HL_ATTR(HLF_MSGSEP)); fill_msgsep, fill_msgsep, HL_ATTR(HLF_MSGSEP));
} }
int nscroll = MIN(msg_scrollsize()+1, Rows); int nscroll = MIN(msg_scrollsize()+1, Rows);
screen_del_lines(Rows-nscroll, 1, Rows, 0, Columns); grid_del_lines(&default_grid, Rows-nscroll, 1, Rows, 0, Columns);
} else { } else {
screen_del_lines(0, 1, (int)Rows, 0, Columns); grid_del_lines(&default_grid, 0, 1, (int)Rows, 0, Columns);
} }
// TODO(bfredl): when msgsep display is properly batched, this fill should be // TODO(bfredl): when msgsep display is properly batched, this fill should be
// eliminated. // eliminated.
screen_fill(Rows-1, Rows, 0, (int)Columns, ' ', ' ', 0); grid_fill(&default_grid, Rows-1, Rows, 0, (int)Columns, ' ', ' ', 0);
} }
/* /*
@@ -2097,7 +2097,7 @@ static void t_puts(int *t_col, const char_u *t_s, const char_u *s, int attr)
{ {
// Output postponed text. // Output postponed text.
msg_didout = true; // Remember that line is not empty. msg_didout = true; // Remember that line is not empty.
screen_puts_len((char_u *)t_s, (int)(s - t_s), msg_row, msg_col, attr); grid_puts_len(&default_grid, (char_u *)t_s, (int)(s - t_s), msg_row, msg_col, attr);
msg_col += *t_col; msg_col += *t_col;
*t_col = 0; *t_col = 0;
/* If the string starts with a composing character don't increment the /* If the string starts with a composing character don't increment the
@@ -2313,8 +2313,9 @@ static int do_more_prompt(int typed_char)
} }
if (toscroll == -1 if (toscroll == -1
&& screen_ins_lines(0, 1, (int)Rows, 0, (int)Columns) == OK) { && grid_ins_lines(&default_grid, 0, 1, (int)Rows,
screen_fill(0, 1, 0, (int)Columns, ' ', ' ', 0); 0, (int)Columns) == OK) {
grid_fill(&default_grid, 0, 1, 0, (int)Columns, ' ', ' ', 0);
// display line at top // display line at top
(void)disp_sb_line(0, mp); (void)disp_sb_line(0, mp);
} else { } else {
@@ -2333,7 +2334,7 @@ static int do_more_prompt(int typed_char)
/* scroll up, display line at bottom */ /* scroll up, display line at bottom */
msg_scroll_up(); msg_scroll_up();
inc_msg_scrolled(); inc_msg_scrolled();
screen_fill((int)Rows - 2, (int)Rows - 1, 0, grid_fill(&default_grid, (int)Rows - 2, (int)Rows - 1, 0,
(int)Columns, ' ', ' ', 0); (int)Columns, ' ', ' ', 0);
mp_last = disp_sb_line((int)Rows - 2, mp_last); mp_last = disp_sb_line((int)Rows - 2, mp_last);
--toscroll; --toscroll;
@@ -2342,7 +2343,7 @@ static int do_more_prompt(int typed_char)
if (toscroll <= 0) { if (toscroll <= 0) {
/* displayed the requested text, more prompt again */ /* displayed the requested text, more prompt again */
screen_fill((int)Rows - 1, (int)Rows, 0, grid_fill(&default_grid, (int)Rows - 1, (int)Rows, 0,
(int)Columns, ' ', ' ', 0); (int)Columns, ' ', ' ', 0);
msg_moremsg(FALSE); msg_moremsg(FALSE);
continue; continue;
@@ -2356,7 +2357,7 @@ static int do_more_prompt(int typed_char)
} }
/* clear the --more-- message */ /* clear the --more-- message */
screen_fill((int)Rows - 1, (int)Rows, 0, (int)Columns, ' ', ' ', 0); grid_fill(&default_grid, (int)Rows - 1, (int)Rows, 0, (int)Columns, ' ', ' ', 0);
State = oldState; State = oldState;
setmouse(); setmouse();
if (quit_more) { if (quit_more) {
@@ -2452,8 +2453,8 @@ void mch_msg(char *str)
*/ */
static void msg_screen_putchar(int c, int attr) static void msg_screen_putchar(int c, int attr)
{ {
msg_didout = TRUE; /* remember that line is not empty */ msg_didout = true; // remember that line is not empty
screen_putchar(c, msg_row, msg_col, attr); grid_putchar(&default_grid, c, msg_row, msg_col, attr);
if (cmdmsg_rl) { if (cmdmsg_rl) {
if (--msg_col == 0) { if (--msg_col == 0) {
msg_col = Columns; msg_col = Columns;
@@ -2473,11 +2474,12 @@ void msg_moremsg(int full)
char_u *s = (char_u *)_("-- More --"); char_u *s = (char_u *)_("-- More --");
attr = HL_ATTR(HLF_M); attr = HL_ATTR(HLF_M);
screen_puts(s, (int)Rows - 1, 0, attr); grid_puts(&default_grid, s, (int)Rows - 1, 0, attr);
if (full) if (full) {
screen_puts((char_u *) grid_puts(&default_grid, (char_u *)
_(" SPACE/d/j: screen/page/line down, b/u/k: up, q: quit "), _(" SPACE/d/j: screen/page/line down, b/u/k: up, q: quit "),
(int)Rows - 1, vim_strsize(s), attr); (int)Rows - 1, vim_strsize(s), attr);
}
} }
/* /*
@@ -2526,11 +2528,11 @@ void msg_clr_eos(void)
void msg_clr_eos_force(void) void msg_clr_eos_force(void)
{ {
if (cmdmsg_rl) { if (cmdmsg_rl) {
screen_fill(msg_row, msg_row + 1, 0, msg_col + 1, ' ', ' ', 0); grid_fill(&default_grid, msg_row, msg_row + 1, 0, msg_col + 1, ' ', ' ', 0);
screen_fill(msg_row + 1, (int)Rows, 0, (int)Columns, ' ', ' ', 0); grid_fill(&default_grid, msg_row + 1, (int)Rows, 0, (int)Columns, ' ', ' ', 0);
} else { } else {
screen_fill(msg_row, msg_row + 1, msg_col, (int)Columns, ' ', ' ', 0); grid_fill(&default_grid, msg_row, msg_row + 1, msg_col, (int)Columns, ' ', ' ', 0);
screen_fill(msg_row + 1, (int)Rows, 0, (int)Columns, ' ', ' ', 0); grid_fill(&default_grid, msg_row + 1, (int)Rows, 0, (int)Columns, ' ', ' ', 0);
} }
} }

View File

@@ -3466,10 +3466,10 @@ static void display_showcmd(void)
int len; int len;
len = (int)STRLEN(showcmd_buf); len = (int)STRLEN(showcmd_buf);
if (len == 0) if (len == 0) {
showcmd_is_clear = true; showcmd_is_clear = true;
else { } else {
screen_puts(showcmd_buf, (int)Rows - 1, sc_col, 0); grid_puts(&default_grid, showcmd_buf, (int)Rows - 1, sc_col, 0);
showcmd_is_clear = false; showcmd_is_clear = false;
} }
@@ -3477,7 +3477,8 @@ static void display_showcmd(void)
* clear the rest of an old message by outputting up to SHOWCMD_COLS * clear the rest of an old message by outputting up to SHOWCMD_COLS
* spaces * spaces
*/ */
screen_puts((char_u *)" " + len, (int)Rows - 1, sc_col + len, 0); grid_puts(&default_grid, (char_u *)" " + len, (int)Rows - 1,
sc_col + len, 0);
setcursor(); /* put cursor back where it belongs */ setcursor(); /* put cursor back where it belongs */
} }

View File

@@ -351,10 +351,10 @@ void pum_redraw(void)
// prepend a space if there is room // prepend a space if there is room
if (curwin->w_p_rl) { if (curwin->w_p_rl) {
if (pum_col < curwin->w_wincol + curwin->w_width - 1) { if (pum_col < curwin->w_wincol + curwin->w_width - 1) {
screen_putchar(' ', row, pum_col + 1, attr); grid_putchar(&default_grid, ' ', row, pum_col + 1, attr);
} }
} else if (pum_col > 0) { } else if (pum_col > 0) {
screen_putchar(' ', row, pum_col - 1, attr); grid_putchar(&default_grid, ' ', row, pum_col - 1, attr);
} }
// Display each entry, use two spaces for a Tab. // Display each entry, use two spaces for a Tab.
@@ -416,12 +416,13 @@ void pum_redraw(void)
size++; size++;
} }
} }
screen_puts_len(rt, (int)STRLEN(rt), row, col - size + 1, attr); grid_puts_len(&default_grid, rt, (int)STRLEN(rt), row, col - size + 1,
attr);
xfree(rt_start); xfree(rt_start);
xfree(st); xfree(st);
col -= width; col -= width;
} else { } else {
screen_puts_len(st, (int)STRLEN(st), row, col, attr); grid_puts_len(&default_grid, st, (int)STRLEN(st), row, col, attr);
xfree(st); xfree(st);
col += width; col += width;
} }
@@ -432,10 +433,10 @@ void pum_redraw(void)
// Display two spaces for a Tab. // Display two spaces for a Tab.
if (curwin->w_p_rl) { if (curwin->w_p_rl) {
screen_puts_len((char_u *)" ", 2, row, col - 1, attr); grid_puts_len(&default_grid, (char_u *)" ", 2, row, col - 1, attr);
col -= 2; col -= 2;
} else { } else {
screen_puts_len((char_u *)" ", 2, row, col, attr); grid_puts_len(&default_grid, (char_u *)" ", 2, row, col, attr);
col += 2; col += 2;
} }
totwidth += 2; totwidth += 2;
@@ -466,11 +467,11 @@ void pum_redraw(void)
} }
if (curwin->w_p_rl) { if (curwin->w_p_rl) {
screen_fill(row, row + 1, pum_col - pum_base_width - n + 1, grid_fill(&default_grid, row, row + 1, pum_col - pum_base_width - n + 1,
col + 1, ' ', ' ', attr); col + 1, ' ', ' ', attr);
col = pum_col - pum_base_width - n + 1; col = pum_col - pum_base_width - n + 1;
} else { } else {
screen_fill(row, row + 1, col, pum_col + pum_base_width + n, grid_fill(&default_grid, row, row + 1, col, pum_col + pum_base_width + n,
' ', ' ', attr); ' ', ' ', attr);
col = pum_col + pum_base_width + n; col = pum_col + pum_base_width + n;
} }
@@ -478,24 +479,24 @@ void pum_redraw(void)
} }
if (curwin->w_p_rl) { if (curwin->w_p_rl) {
screen_fill(row, row + 1, pum_col - pum_width + 1, col + 1, ' ', ' ', grid_fill(&default_grid, row, row + 1, pum_col - pum_width + 1, col + 1, ' ', ' ',
attr); attr);
} else { } else {
screen_fill(row, row + 1, col, pum_col + pum_width, ' ', ' ', attr); grid_fill(&default_grid, row, row + 1, col, pum_col + pum_width, ' ', ' ', attr);
} }
if (pum_scrollbar > 0) { if (pum_scrollbar > 0) {
if (curwin->w_p_rl) { if (curwin->w_p_rl) {
screen_putchar(' ', row, pum_col - pum_width, grid_putchar(&default_grid, ' ', row, pum_col - pum_width,
i >= thumb_pos && i < thumb_pos + thumb_heigth i >= thumb_pos && i < thumb_pos + thumb_heigth
? attr_thumb : attr_scroll); ? attr_thumb : attr_scroll);
} else { } else {
screen_putchar(' ', row, pum_col + pum_width, grid_putchar(&default_grid, ' ', row, pum_col + pum_width,
i >= thumb_pos && i < thumb_pos + thumb_heigth i >= thumb_pos && i < thumb_pos + thumb_heigth
? attr_thumb : attr_scroll); ? attr_thumb : attr_scroll);
} }
} }
screen_puts_line_flush(false); grid_puts_line_flush(&default_grid, false);
row++; row++;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -23,14 +23,24 @@ typedef char_u schar_T[(MAX_MCO+1) * 4 + 1];
typedef int16_t sattr_T; typedef int16_t sattr_T;
// TODO(bfredl): find me a good home // TODO(bfredl): find me a good home
typedef int GridHandle;
typedef struct { typedef struct {
GridHandle handle;
schar_T *ScreenLines; schar_T *ScreenLines;
sattr_T *ScreenAttrs; sattr_T *ScreenAttrs;
unsigned *LineOffset; unsigned *LineOffset;
char_u *LineWraps; char_u *LineWraps;
// the size of the allocated grid
int Rows; int Rows;
int Columns; int Columns;
// offsets for the grid relative to the screen
int OffsetRow;
int OffsetColumn;
int was_resized;
} ScreenGrid; } ScreenGrid;
#endif // NVIM_TYPES_H #endif // NVIM_TYPES_H

View File

@@ -57,6 +57,7 @@ static int busy = 0;
static int mode_idx = SHAPE_IDX_N; static int mode_idx = SHAPE_IDX_N;
static bool pending_mode_info_update = false; static bool pending_mode_info_update = false;
static bool pending_mode_update = false; static bool pending_mode_update = false;
static GridHandle cursor_grid_handle = 1;
#if MIN_LOG_LEVEL > DEBUG_LOG_LEVEL #if MIN_LOG_LEVEL > DEBUG_LOG_LEVEL
# define UI_LOG(funname, ...) # define UI_LOG(funname, ...)
@@ -315,12 +316,18 @@ void ui_set_ext_option(UI *ui, UIExtension ext, bool active)
} }
} }
void ui_line(int row, int startcol, int endcol, int clearcol, int clearattr, void ui_line(ScreenGrid *grid, int row, int startcol, int endcol, int clearcol,
bool wrap) int clearattr, bool wrap)
{ {
size_t off = LineOffset[row]+(size_t)startcol; size_t off = grid->LineOffset[row] + (size_t)startcol;
UI_CALL(raw_line, 1, row, startcol, endcol, clearcol, clearattr, wrap, int row_off = ui_is_external(kUIMultigrid) ? 0 : grid->OffsetRow;
(const schar_T *)ScreenLines+off, (const sattr_T *)ScreenAttrs+off); int col_off = ui_is_external(kUIMultigrid) ? 0 : grid->OffsetColumn;
UI_CALL(raw_line, grid->handle, row_off + row, col_off + startcol,
col_off + endcol, col_off + clearcol, clearattr, wrap,
(const schar_T *)grid->ScreenLines + off,
(const sattr_T *)grid->ScreenAttrs + off);
if (p_wd) { // 'writedelay': flush & delay each time. if (p_wd) { // 'writedelay': flush & delay each time.
int old_row = row, old_col = col; int old_row = row, old_col = col;
// If'writedelay is active, we set the cursor to highlight what was drawn // If'writedelay is active, we set the cursor to highlight what was drawn
@@ -334,11 +341,20 @@ void ui_line(int row, int startcol, int endcol, int clearcol, int clearattr,
void ui_cursor_goto(int new_row, int new_col) void ui_cursor_goto(int new_row, int new_col)
{ {
if (new_row == row && new_col == col) { ui_grid_cursor_goto(&default_grid, new_row, new_col);
}
void ui_grid_cursor_goto(ScreenGrid *grid, int new_row, int new_col)
{
int off_row = (ui_is_external(kUIMultigrid) ? 0 : grid->OffsetRow);
int off_col = (ui_is_external(kUIMultigrid) ? 0 : grid->OffsetColumn);
if (new_row + off_row == row && new_col + off_col == col) {
return; return;
} }
row = new_row; row = new_row + off_row;
col = new_col; col = new_col + off_col;
cursor_grid_handle = grid->handle;
pending_cursor_update = true; pending_cursor_update = true;
} }
@@ -361,7 +377,7 @@ void ui_flush(void)
{ {
cmdline_ui_flush(); cmdline_ui_flush();
if (pending_cursor_update) { if (pending_cursor_update) {
ui_call_grid_cursor_goto(1, row, col); ui_call_grid_cursor_goto(cursor_grid_handle, row, col);
pending_cursor_update = false; pending_cursor_update = false;
} }
if (pending_mode_info_update) { if (pending_mode_info_update) {

View File

@@ -16,6 +16,7 @@ typedef enum {
kUIWildmenu, kUIWildmenu,
#define kUIGlobalCount (kUIWildmenu+1) #define kUIGlobalCount (kUIWildmenu+1)
kUILinegrid, kUILinegrid,
kUIMultigrid,
kUIHlState, kUIHlState,
kUIExtCount, kUIExtCount,
} UIExtension; } UIExtension;
@@ -26,6 +27,7 @@ EXTERN const char *ui_ext_names[] INIT(= {
"ext_tabline", "ext_tabline",
"ext_wildmenu", "ext_wildmenu",
"ext_linegrid", "ext_linegrid",
"ext_multigrid",
"ext_hlstate", "ext_hlstate",
}); });

View File

@@ -2271,8 +2271,8 @@ static void do_intro_line(long row, char_u *mesg, int attr)
} }
} }
assert(row <= INT_MAX && col <= INT_MAX); assert(row <= INT_MAX && col <= INT_MAX);
screen_puts_len(p, l, (int)row, (int)col, grid_puts_len(&default_grid, p, l, (int)row, (int)col,
*p == '<' ? HL_ATTR(HLF_8) : attr); *p == '<' ? HL_ATTR(HLF_8) : attr);
col += clen; col += clen;
} }
} }

View File

@@ -3958,6 +3958,8 @@ win_free (
xfree(wp->w_p_cc_cols); xfree(wp->w_p_cc_cols);
win_free_grid(wp, false);
if (wp != aucmd_win) if (wp != aucmd_win)
win_remove(wp, tp); win_remove(wp, tp);
if (autocmd_busy) { if (autocmd_busy) {
@@ -3970,6 +3972,20 @@ win_free (
unblock_autocmds(); unblock_autocmds();
} }
void win_free_grid(win_T *wp, bool reinit)
{
if (wp->w_grid.handle != 0 && ui_is_external(kUIMultigrid)) {
ui_call_grid_destroy(wp->w_grid.handle);
wp->w_grid.handle = 0;
}
free_screengrid(&wp->w_grid);
if (reinit) {
// if a float is turned into a split and back into a float, the grid
// data structure will be reused
memset(&wp->w_grid, 0, sizeof(wp->w_grid));
}
}
/* /*
* Append window "wp" in the window list after window "after". * Append window "wp" in the window list after window "after".
*/ */
@@ -4247,6 +4263,7 @@ void win_setheight_win(int height, win_T *win)
} }
frame_setheight(win->w_frame, height + win->w_status_height); frame_setheight(win->w_frame, height + win->w_status_height);
win_grid_alloc(win, false);
/* recompute the window positions */ /* recompute the window positions */
row = win_comp_pos(); row = win_comp_pos();
@@ -4256,7 +4273,7 @@ void win_setheight_win(int height, win_T *win)
* line, clear it. * line, clear it.
*/ */
if (full_screen && msg_scrolled == 0 && row < cmdline_row) if (full_screen && msg_scrolled == 0 && row < cmdline_row)
screen_fill(row, cmdline_row, 0, (int)Columns, ' ', ' ', 0); grid_fill(&default_grid, row, cmdline_row, 0, (int)Columns, ' ', ' ', 0);
cmdline_row = row; cmdline_row = row;
msg_row = row; msg_row = row;
msg_col = 0; msg_col = 0;
@@ -4443,6 +4460,7 @@ void win_setwidth_win(int width, win_T *wp)
} }
frame_setwidth(wp->w_frame, width + wp->w_vsep_width); frame_setwidth(wp->w_frame, width + wp->w_vsep_width);
win_grid_alloc(wp, false);
/* recompute the window positions */ /* recompute the window positions */
(void)win_comp_pos(); (void)win_comp_pos();
@@ -4706,7 +4724,7 @@ void win_drag_status_line(win_T *dragwin, int offset)
fr = fr->fr_next; fr = fr->fr_next;
} }
row = win_comp_pos(); row = win_comp_pos();
screen_fill(row, cmdline_row, 0, (int)Columns, ' ', ' ', 0); grid_fill(&default_grid, row, cmdline_row, 0, (int)Columns, ' ', ' ', 0);
cmdline_row = row; cmdline_row = row;
p_ch = Rows - cmdline_row; p_ch = Rows - cmdline_row;
if (p_ch < 1) if (p_ch < 1)
@@ -5054,7 +5072,7 @@ void command_height(void)
/* clear the lines added to cmdline */ /* clear the lines added to cmdline */
if (full_screen) if (full_screen)
screen_fill(cmdline_row, (int)Rows, 0, grid_fill(&default_grid, cmdline_row, (int)Rows, 0,
(int)Columns, ' ', ' ', 0); (int)Columns, ' ', ' ', 0);
msg_row = cmdline_row; msg_row = cmdline_row;
redraw_cmdline = TRUE; redraw_cmdline = TRUE;