mirror of
https://github.com/neovim/neovim.git
synced 2025-10-17 15:21:47 +00:00
Merge pull request #9575 from bfredl/redrawdebug
ui: implement better redrawdebug for the compositor
This commit is contained in:
@@ -49,6 +49,8 @@ static bool valid_screen = true;
|
||||
static bool msg_scroll_mode = false;
|
||||
static int msg_first_invalid = 0;
|
||||
|
||||
static int dbghl_normal, dbghl_clear, dbghl_composed, dbghl_recompose;
|
||||
|
||||
void ui_comp_init(void)
|
||||
{
|
||||
if (compositor != NULL) {
|
||||
@@ -81,6 +83,13 @@ void ui_comp_init(void)
|
||||
ui_attach_impl(compositor);
|
||||
}
|
||||
|
||||
void ui_comp_syn_init(void)
|
||||
{
|
||||
dbghl_normal = syn_check_group((char_u *)S_LEN("RedrawDebugNormal"));
|
||||
dbghl_clear = syn_check_group((char_u *)S_LEN("RedrawDebugClear"));
|
||||
dbghl_composed = syn_check_group((char_u *)S_LEN("RedrawDebugComposed"));
|
||||
dbghl_recompose = syn_check_group((char_u *)S_LEN("RedrawDebugRecompose"));
|
||||
}
|
||||
|
||||
void ui_comp_attach(UI *ui)
|
||||
{
|
||||
@@ -385,9 +394,42 @@ static void compose_line(Integer row, Integer startcol, Integer endcol,
|
||||
(const sattr_T *)attrbuf+skipstart);
|
||||
}
|
||||
|
||||
static void compose_debug(Integer startrow, Integer endrow, Integer startcol,
|
||||
Integer endcol, int syn_id, bool delay)
|
||||
{
|
||||
if (!(rdb_flags & RDB_COMPOSITOR)) {
|
||||
return;
|
||||
}
|
||||
|
||||
endrow = MIN(endrow, default_grid.Rows);
|
||||
endcol = MIN(endcol, default_grid.Columns);
|
||||
int attr = syn_id2attr(syn_id);
|
||||
|
||||
for (int row = (int)startrow; row < endrow; row++) {
|
||||
ui_composed_call_raw_line(1, row, startcol, startcol, endcol, attr, false,
|
||||
(const schar_T *)linebuf,
|
||||
(const sattr_T *)attrbuf);
|
||||
}
|
||||
|
||||
|
||||
if (delay) {
|
||||
debug_delay(endrow-startrow);
|
||||
}
|
||||
}
|
||||
|
||||
static void debug_delay(Integer lines)
|
||||
{
|
||||
ui_call_flush();
|
||||
uint64_t wd = (uint64_t)labs(p_wd);
|
||||
uint64_t factor = (uint64_t)MAX(MIN(lines, 5), 1);
|
||||
os_microdelay(factor * wd * 1000u, true);
|
||||
}
|
||||
|
||||
|
||||
static void compose_area(Integer startrow, Integer endrow,
|
||||
Integer startcol, Integer endcol)
|
||||
{
|
||||
compose_debug(startrow, endrow, startcol, endcol, dbghl_recompose, true);
|
||||
endrow = MIN(endrow, default_grid.Rows);
|
||||
endcol = MIN(endcol, default_grid.Columns);
|
||||
if (endcol <= startcol) {
|
||||
@@ -432,8 +474,11 @@ static void ui_comp_raw_line(UI *ui, Integer grid, Integer row,
|
||||
if (flags & kLineFlagInvalid
|
||||
|| kv_size(layers) > curgrid->comp_index+1
|
||||
|| curgrid->blending) {
|
||||
compose_debug(row, row+1, startcol, clearcol, dbghl_composed, true);
|
||||
compose_line(row, startcol, clearcol, flags);
|
||||
} else {
|
||||
compose_debug(row, row+1, startcol, endcol, dbghl_normal, false);
|
||||
compose_debug(row, row+1, endcol, clearcol, dbghl_clear, true);
|
||||
ui_composed_call_raw_line(1, row, startcol, endcol, clearcol, clearattr,
|
||||
flags, chunk, attrs);
|
||||
}
|
||||
@@ -493,6 +538,9 @@ static void ui_comp_grid_scroll(UI *ui, Integer grid, Integer top,
|
||||
} else {
|
||||
msg_first_invalid = MIN(msg_first_invalid, (int)top);
|
||||
ui_composed_call_grid_scroll(1, top, bot, left, right, rows, cols);
|
||||
if (rdb_flags & RDB_COMPOSITOR) {
|
||||
debug_delay(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user