mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
screen: add some documentation of internals of msg_grid implementation
This commit is contained in:
parent
e04b9e7c78
commit
14615f7f67
@ -58,18 +58,30 @@ typedef struct {
|
|||||||
// external UI.
|
// external UI.
|
||||||
bool throttled;
|
bool throttled;
|
||||||
|
|
||||||
// offsets for the grid relative to the global screen
|
// offsets for the grid relative to the global screen. Used by screen.c
|
||||||
|
// for windows that don't have w_grid->chars etc allocated
|
||||||
int row_offset;
|
int row_offset;
|
||||||
int col_offset;
|
int col_offset;
|
||||||
|
|
||||||
// whether the compositor should blend the grid with the background grid
|
// whether the compositor should blend the grid with the background grid
|
||||||
bool blending;
|
bool blending;
|
||||||
|
|
||||||
|
// whether the grid can be focused with mouse clicks.
|
||||||
bool focusable;
|
bool focusable;
|
||||||
|
|
||||||
// state owned by the compositor.
|
// Below is state owned by the compositor. Should generally not be set/read
|
||||||
|
// outside this module, except for specific compatibilty hacks
|
||||||
|
|
||||||
|
// position of the grid on the composed screen.
|
||||||
int comp_row;
|
int comp_row;
|
||||||
int comp_col;
|
int comp_col;
|
||||||
|
|
||||||
|
// z-index of the grid. Grids with higher index is draw on top.
|
||||||
|
// default_grid.comp_index is always zero.
|
||||||
size_t comp_index;
|
size_t comp_index;
|
||||||
|
|
||||||
|
// compositor should momentarily ignore the grid. Used internally when
|
||||||
|
// moving around grids etc.
|
||||||
bool comp_disabled;
|
bool comp_disabled;
|
||||||
} ScreenGrid;
|
} ScreenGrid;
|
||||||
|
|
||||||
|
@ -3522,7 +3522,6 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname,
|
|||||||
}
|
}
|
||||||
xfree(name);
|
xfree(name);
|
||||||
|
|
||||||
|
|
||||||
// pretend screen didn't scroll, need redraw anyway
|
// pretend screen didn't scroll, need redraw anyway
|
||||||
msg_reset_scroll();
|
msg_reset_scroll();
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ void msg_grid_validate(void)
|
|||||||
ui_call_grid_resize(msg_grid.handle, msg_grid.Columns, msg_grid.Rows);
|
ui_call_grid_resize(msg_grid.handle, msg_grid.Columns, msg_grid.Rows);
|
||||||
|
|
||||||
msg_grid.throttled = false; // don't throttle in 'cmdheight' area
|
msg_grid.throttled = false; // don't throttle in 'cmdheight' area
|
||||||
msg_scroll_at_flush = msg_scrolled;
|
msg_scrolled_at_flush = msg_scrolled;
|
||||||
msg_grid.focusable = false;
|
msg_grid.focusable = false;
|
||||||
if (!msg_scrolled) {
|
if (!msg_scrolled) {
|
||||||
msg_grid_set_pos(Rows - p_ch, false);
|
msg_grid_set_pos(Rows - p_ch, false);
|
||||||
@ -2197,6 +2197,21 @@ void msg_scroll_up(bool may_throttle)
|
|||||||
HL_ATTR(HLF_MSG));
|
HL_ATTR(HLF_MSG));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Send throttled message output to UI clients
|
||||||
|
///
|
||||||
|
/// The way message.c uses the grid_xx family of functions is quite inefficient
|
||||||
|
/// relative to the "gridline" UI protocol used by TUI and modern clients.
|
||||||
|
/// For instance scrolling is done one line at a time. By throttling drawing
|
||||||
|
/// on the message grid, we can coalesce scrolling to a single grid_scroll
|
||||||
|
/// per screen update.
|
||||||
|
///
|
||||||
|
/// NB: The bookkeeping is quite messy, and rests on a bunch of poorly
|
||||||
|
/// documented assumtions. For instance that the message area always grows while
|
||||||
|
/// being throttled, messages are only being output on the last line etc.
|
||||||
|
///
|
||||||
|
/// Probably message scrollback storage should reimplented as a file_buffer, and
|
||||||
|
/// message scrolling in TUI be reimplemented as a modal floating window. Then
|
||||||
|
/// we get throttling "for free" using standard redraw_win_later code paths.
|
||||||
void msg_scroll_flush(void)
|
void msg_scroll_flush(void)
|
||||||
{
|
{
|
||||||
if (!msg_grid.throttled) {
|
if (!msg_grid.throttled) {
|
||||||
@ -2205,7 +2220,7 @@ void msg_scroll_flush(void)
|
|||||||
msg_grid.throttled = false;
|
msg_grid.throttled = false;
|
||||||
int pos_delta = msg_grid_pos_at_flush - msg_grid_pos;
|
int pos_delta = msg_grid_pos_at_flush - msg_grid_pos;
|
||||||
assert(pos_delta >= 0);
|
assert(pos_delta >= 0);
|
||||||
int delta = MIN(msg_scrolled - msg_scroll_at_flush, msg_grid.Rows);
|
int delta = MIN(msg_scrolled - msg_scrolled_at_flush, msg_grid.Rows);
|
||||||
|
|
||||||
if (pos_delta > 0) {
|
if (pos_delta > 0) {
|
||||||
ui_ext_msg_set_pos(msg_grid_pos, true);
|
ui_ext_msg_set_pos(msg_grid_pos, true);
|
||||||
@ -2228,7 +2243,7 @@ void msg_scroll_flush(void)
|
|||||||
HL_ATTR(HLF_MSG), false);
|
HL_ATTR(HLF_MSG), false);
|
||||||
msg_grid.dirty_col[row] = 0;
|
msg_grid.dirty_col[row] = 0;
|
||||||
}
|
}
|
||||||
msg_scroll_at_flush = msg_scrolled;
|
msg_scrolled_at_flush = msg_scrolled;
|
||||||
msg_grid_scroll_discount = 0;
|
msg_grid_scroll_discount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2257,7 +2272,7 @@ void msg_reset_scroll(void)
|
|||||||
redraw_all_later(NOT_VALID);
|
redraw_all_later(NOT_VALID);
|
||||||
}
|
}
|
||||||
msg_scrolled = 0;
|
msg_scrolled = 0;
|
||||||
msg_scroll_at_flush = 0;
|
msg_scrolled_at_flush = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2701,7 +2716,7 @@ static int do_more_prompt(int typed_char)
|
|||||||
if (msg_dothrottle() && !msg_grid.throttled) {
|
if (msg_dothrottle() && !msg_grid.throttled) {
|
||||||
// Tricky: we redraw at one line higher than usual. Therefore
|
// Tricky: we redraw at one line higher than usual. Therefore
|
||||||
// the non-flushed area is one line larger.
|
// the non-flushed area is one line larger.
|
||||||
msg_scroll_at_flush--;
|
msg_scrolled_at_flush--;
|
||||||
msg_grid_scroll_discount++;
|
msg_grid_scroll_discount++;
|
||||||
}
|
}
|
||||||
// scroll up, display line at bottom
|
// scroll up, display line at bottom
|
||||||
@ -2908,10 +2923,10 @@ int msg_end(void)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @TODO(bfredl): calling flush here inhibits substantial performance
|
// NOTE: ui_flush() used to be called here. This had to be removed, as it
|
||||||
// improvements. Caller should call ui_flush before waiting on user input or
|
// inhibited substantial performance improvements. It is assumed that relevant
|
||||||
// CPU busywork.
|
// callers invoke ui_flush() before going into CPU busywork, or restricted
|
||||||
// ui_flush(); // calls msg_ext_ui_flush
|
// event processing after displaying a message to the user.
|
||||||
msg_ext_ui_flush();
|
msg_ext_ui_flush();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -91,12 +91,22 @@ extern MessageHistoryEntry *last_msg_hist;
|
|||||||
|
|
||||||
EXTERN bool msg_ext_need_clear INIT(= false);
|
EXTERN bool msg_ext_need_clear INIT(= false);
|
||||||
|
|
||||||
|
// allocated grid for messages. Used when display+=msgsep is set, or
|
||||||
|
// ext_multigrid is active. See also the description at msg_scroll_flush()
|
||||||
EXTERN ScreenGrid msg_grid INIT(= SCREEN_GRID_INIT);
|
EXTERN ScreenGrid msg_grid INIT(= SCREEN_GRID_INIT);
|
||||||
|
EXTERN int msg_grid_pos INIT(= 0);
|
||||||
|
|
||||||
|
// "adjusted" message grid. This grid accepts positions relative to
|
||||||
|
// default_grid. Internally it will be translated to a position on msg_grid
|
||||||
|
// relative to the start of the message area, or directly mapped to default_grid
|
||||||
|
// for legacy (display-=msgsep) message scroll behavior.
|
||||||
|
// // TODO(bfredl): refactor "internal" message logic, msg_row etc
|
||||||
|
// to use the correct positions already.
|
||||||
EXTERN ScreenGrid msg_grid_adj INIT(= SCREEN_GRID_INIT);
|
EXTERN ScreenGrid msg_grid_adj INIT(= SCREEN_GRID_INIT);
|
||||||
|
|
||||||
EXTERN int msg_scroll_at_flush INIT(= 0);
|
// value of msg_scrolled at latest msg_scroll_flush.
|
||||||
|
EXTERN int msg_scrolled_at_flush INIT(= 0);
|
||||||
|
|
||||||
EXTERN int msg_grid_pos INIT(= 0);
|
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
# include "message.h.generated.h"
|
# include "message.h.generated.h"
|
||||||
|
@ -320,7 +320,7 @@ int update_screen(int type)
|
|||||||
// separate bookkeeping for now.
|
// separate bookkeeping for now.
|
||||||
if (msg_did_scroll) {
|
if (msg_did_scroll) {
|
||||||
msg_did_scroll = false;
|
msg_did_scroll = false;
|
||||||
msg_scroll_at_flush = 0;
|
msg_scrolled_at_flush = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type >= CLEAR || !default_grid.valid) {
|
if (type >= CLEAR || !default_grid.valid) {
|
||||||
@ -379,7 +379,7 @@ int update_screen(int type)
|
|||||||
redraw_tabline = TRUE;
|
redraw_tabline = TRUE;
|
||||||
}
|
}
|
||||||
msg_scrolled = 0;
|
msg_scrolled = 0;
|
||||||
msg_scroll_at_flush = 0;
|
msg_scrolled_at_flush = 0;
|
||||||
need_wait_return = false;
|
need_wait_return = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,6 +353,8 @@ static void compose_line(Integer row, Integer startcol, Integer endcol,
|
|||||||
size_t n = (size_t)(until-col);
|
size_t n = (size_t)(until-col);
|
||||||
|
|
||||||
if (row == msg_sep_row && grid->comp_index <= msg_grid.comp_index) {
|
if (row == msg_sep_row && grid->comp_index <= msg_grid.comp_index) {
|
||||||
|
// TODO(bfredl): when we implement borders around floating windows, then
|
||||||
|
// msgsep can just be a border "around" the message grid.
|
||||||
grid = &msg_grid;
|
grid = &msg_grid;
|
||||||
sattr_T msg_sep_attr = (sattr_T)HL_ATTR(HLF_MSGSEP);
|
sattr_T msg_sep_attr = (sattr_T)HL_ATTR(HLF_MSGSEP);
|
||||||
for (int i = col; i < until; i++) {
|
for (int i = col; i < until; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user