mirror of
https://github.com/neovim/neovim.git
synced 2025-10-15 06:16:08 +00:00
feat(api/ui): win_extmarks
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
|
||||
|
||||
#include "nvim/buffer.h"
|
||||
#include "nvim/api/ui.h"
|
||||
#include "nvim/decoration.h"
|
||||
#include "nvim/extmark.h"
|
||||
#include "nvim/highlight.h"
|
||||
@@ -73,7 +74,8 @@ void decor_redraw(buf_T *buf, int row1, int row2, Decoration *decor)
|
||||
}
|
||||
}
|
||||
|
||||
if (decor && kv_size(decor->virt_text)) {
|
||||
if (decor && (kv_size(decor->virt_text)
|
||||
|| decor->ui_watched)) {
|
||||
redraw_buf_line_later(buf, row1 + 1);
|
||||
}
|
||||
|
||||
@@ -195,9 +197,11 @@ bool decor_redraw_start(buf_T *buf, int top_row, DecorState *state)
|
||||
Decoration decor = get_decor(mark);
|
||||
|
||||
// Exclude non-paired marks unless they contain virt_text or a sign
|
||||
// or they are ui-watched
|
||||
if (!mt_paired(mark)
|
||||
&& !kv_size(decor.virt_text)
|
||||
&& !decor_has_sign(&decor)) {
|
||||
&& !decor_has_sign(&decor)
|
||||
&& !decor.ui_watched) {
|
||||
goto next_mark;
|
||||
}
|
||||
|
||||
@@ -206,21 +210,22 @@ bool decor_redraw_start(buf_T *buf, int top_row, DecorState *state)
|
||||
// Exclude start marks if the end mark position is above the top row
|
||||
// Exclude end marks if we have already added the start mark
|
||||
if ((mt_start(mark) && altpos.row < top_row
|
||||
&& !kv_size(decor.virt_text))
|
||||
&& !kv_size(decor.virt_text)
|
||||
&& !decor.ui_watched)
|
||||
|| (mt_end(mark) && altpos.row >= top_row)) {
|
||||
goto next_mark;
|
||||
}
|
||||
|
||||
if (mt_end(mark)) {
|
||||
decor_add(state, altpos.row, altpos.col, mark.pos.row, mark.pos.col,
|
||||
&decor, false);
|
||||
&decor, false, mark.ns, mark.id);
|
||||
} else {
|
||||
if (altpos.row == -1) {
|
||||
altpos.row = mark.pos.row;
|
||||
altpos.col = mark.pos.col;
|
||||
}
|
||||
decor_add(state, mark.pos.row, mark.pos.col, altpos.row, altpos.col,
|
||||
&decor, false);
|
||||
&decor, false, mark.ns, mark.id);
|
||||
}
|
||||
|
||||
next_mark:
|
||||
@@ -246,13 +251,13 @@ bool decor_redraw_line(buf_T *buf, int row, DecorState *state)
|
||||
}
|
||||
|
||||
static void decor_add(DecorState *state, int start_row, int start_col, int end_row, int end_col,
|
||||
Decoration *decor, bool owned)
|
||||
Decoration *decor, bool owned, uint64_t ns_id, uint64_t mark_id)
|
||||
{
|
||||
int attr_id = decor->hl_id > 0 ? syn_id2attr(decor->hl_id) : 0;
|
||||
|
||||
DecorRange range = { start_row, start_col, end_row, end_col,
|
||||
*decor, attr_id,
|
||||
kv_size(decor->virt_text) && owned, -1 };
|
||||
kv_size(decor->virt_text) && owned, -1, ns_id, mark_id };
|
||||
|
||||
kv_pushp(state->active);
|
||||
size_t index;
|
||||
@@ -298,13 +303,13 @@ int decor_redraw_col(buf_T *buf, int col, int win_col, bool hidden, DecorState *
|
||||
|
||||
if (endpos.row < mark.pos.row
|
||||
|| (endpos.row == mark.pos.row && endpos.col <= mark.pos.col)) {
|
||||
if (!kv_size(decor.virt_text)) {
|
||||
if (!kv_size(decor.virt_text) && !decor.ui_watched) {
|
||||
goto next_mark;
|
||||
}
|
||||
}
|
||||
|
||||
decor_add(state, mark.pos.row, mark.pos.col, endpos.row, endpos.col,
|
||||
&decor, false);
|
||||
&decor, false, mark.ns, mark.id);
|
||||
|
||||
next_mark:
|
||||
marktree_itr_next(buf->b_marktree, state->itr);
|
||||
@@ -321,7 +326,8 @@ next_mark:
|
||||
bool active = false, keep = true;
|
||||
if (item.end_row < state->row
|
||||
|| (item.end_row == state->row && item.end_col <= col)) {
|
||||
if (!(item.start_row >= state->row && kv_size(item.decor.virt_text))) {
|
||||
if (!(item.start_row >= state->row
|
||||
&& (kv_size(item.decor.virt_text) || item.decor.ui_watched))) {
|
||||
keep = false;
|
||||
}
|
||||
} else {
|
||||
@@ -349,7 +355,7 @@ next_mark:
|
||||
}
|
||||
}
|
||||
if ((item.start_row == state->row && item.start_col <= col)
|
||||
&& kv_size(item.decor.virt_text)
|
||||
&& (kv_size(item.decor.virt_text) || item.decor.ui_watched)
|
||||
&& item.decor.virt_text_pos == kVTOverlay && item.win_col == -1) {
|
||||
item.win_col = (item.decor.virt_text_hide && hidden) ? -2 : win_col;
|
||||
}
|
||||
@@ -517,7 +523,8 @@ bool decor_redraw_eol(buf_T *buf, DecorState *state, int *eol_attr, int eol_col)
|
||||
bool has_virttext = false;
|
||||
for (size_t i = 0; i < kv_size(state->active); i++) {
|
||||
DecorRange item = kv_A(state->active, i);
|
||||
if (item.start_row == state->row && kv_size(item.decor.virt_text)) {
|
||||
if (item.start_row == state->row
|
||||
&& (kv_size(item.decor.virt_text) || item.decor.ui_watched)) {
|
||||
has_virttext = true;
|
||||
}
|
||||
|
||||
@@ -528,13 +535,14 @@ bool decor_redraw_eol(buf_T *buf, DecorState *state, int *eol_attr, int eol_col)
|
||||
return has_virttext;
|
||||
}
|
||||
|
||||
void decor_add_ephemeral(int start_row, int start_col, int end_row, int end_col, Decoration *decor)
|
||||
void decor_add_ephemeral(int start_row, int start_col, int end_row, int end_col,
|
||||
Decoration *decor, uint64_t ns_id, uint64_t mark_id)
|
||||
{
|
||||
if (end_row == -1) {
|
||||
end_row = start_row;
|
||||
end_col = start_col;
|
||||
}
|
||||
decor_add(&decor_state, start_row, start_col, end_row, end_col, decor, true);
|
||||
decor_add(&decor_state, start_row, start_col, end_row, end_col, decor, true, ns_id, mark_id);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user