diff options
Diffstat (limited to 'src/nvim/ui_compositor.c')
-rw-r--r-- | src/nvim/ui_compositor.c | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/src/nvim/ui_compositor.c b/src/nvim/ui_compositor.c index e28e8d4da7..38d882462d 100644 --- a/src/nvim/ui_compositor.c +++ b/src/nvim/ui_compositor.c @@ -101,6 +101,35 @@ bool ui_comp_should_draw(void) return composed_uis != 0 && valid_screen; } +/// Raises or lowers the layer, syncing comp_index with zindex. +/// +/// This function adjusts the position of a layer in the layers array +/// based on its zindex, either raising or lowering it. +/// +/// @param[in] layer_idx Index of the layer to be raised or lowered. +/// @param[in] raise Raise the layer if true, else lower it. +void ui_comp_layers_adjust(size_t layer_idx, bool raise) +{ + size_t size = layers.size; + ScreenGrid *layer = layers.items[layer_idx]; + + if (raise) { + while (layer_idx < size - 1 && layer->zindex > layers.items[layer_idx + 1]->zindex) { + layers.items[layer_idx] = layers.items[layer_idx + 1]; + layers.items[layer_idx]->comp_index = layer_idx; + layer_idx++; + } + } else { + while (layer_idx > 0 && layer->zindex < layers.items[layer_idx - 1]->zindex) { + layers.items[layer_idx] = layers.items[layer_idx - 1]; + layers.items[layer_idx]->comp_index = layer_idx; + layer_idx--; + } + } + layers.items[layer_idx] = layer; + layer->comp_index = layer_idx; +} + /// Places `grid` at (col,row) position with (width * height) size. /// Adds `grid` as the top layer if it is a new layer. /// @@ -425,7 +454,7 @@ static void compose_line(Integer row, Integer startcol, Integer endcol, LineFlag for (int i = skipstart; i < (endcol - skipend) - startcol; i++) { if (attrbuf[i] < 0) { - if (rdb_flags & RDB_INVALID) { + if (rdb_flags & kOptRdbFlagInvalid) { abort(); } else { attrbuf[i] = 0; @@ -441,7 +470,7 @@ static void compose_line(Integer row, Integer startcol, Integer endcol, LineFlag static void compose_debug(Integer startrow, Integer endrow, Integer startcol, Integer endcol, int syn_id, bool delay) { - if (!(rdb_flags & RDB_COMPOSITOR) || startcol >= endcol) { + if (!(rdb_flags & kOptRdbFlagCompositor) || startcol >= endcol) { return; } @@ -637,7 +666,7 @@ void ui_comp_grid_scroll(Integer grid, Integer top, Integer bot, Integer left, I } } else { ui_composed_call_grid_scroll(1, top, bot, left, right, rows, cols); - if (rdb_flags & RDB_COMPOSITOR) { + if (rdb_flags & kOptRdbFlagCompositor) { debug_delay(2); } } |