aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/decoration.c
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-08-19 12:26:08 -0600
committerJosh Rahm <rahm@google.com>2022-08-19 13:06:41 -0600
commita7237662f96933efe29eed8212464571e3778cd0 (patch)
tree27930202726b4251437c8cfa53069f65b4db90dc /src/nvim/decoration.c
parent02292344929069ea63c0bb872cc22d552d86b67f (diff)
parentb2f979b30beac67906b2dd717fcb6a34f46f5e54 (diff)
downloadrneovim-tmp.tar.gz
rneovim-tmp.tar.bz2
rneovim-tmp.zip
Merge branch 'master' of https://github.com/neovim/neovim into rahmtmp
Diffstat (limited to 'src/nvim/decoration.c')
-rw-r--r--src/nvim/decoration.c54
1 files changed, 31 insertions, 23 deletions
diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c
index e7c76fe38e..a93fb599c4 100644
--- a/src/nvim/decoration.c
+++ b/src/nvim/decoration.c
@@ -4,12 +4,12 @@
#include "nvim/api/ui.h"
#include "nvim/buffer.h"
#include "nvim/decoration.h"
+#include "nvim/drawscreen.h"
#include "nvim/extmark.h"
#include "nvim/highlight.h"
#include "nvim/highlight_group.h"
#include "nvim/lua/executor.h"
#include "nvim/move.h"
-#include "nvim/screen.h"
#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
@@ -358,7 +358,8 @@ next_mark:
return attr;
}
-void decor_redraw_signs(buf_T *buf, int row, int *num_signs, sign_attrs_T sattrs[])
+void decor_redraw_signs(buf_T *buf, int row, int *num_signs, SignTextAttrs sattrs[],
+ HlPriAttr *num_attrs, HlPriAttr *line_attrs, HlPriAttr *cul_attrs)
{
if (!buf->b_signs) {
return;
@@ -383,30 +384,37 @@ void decor_redraw_signs(buf_T *buf, int row, int *num_signs, sign_attrs_T sattrs
goto next_mark;
}
- int j;
- for (j = (*num_signs); j > 0; j--) {
- if (sattrs[j].sat_prio <= decor->priority) {
- break;
- }
- sattrs[j] = sattrs[j - 1];
- }
- if (j < SIGN_SHOW_MAX) {
- memset(&sattrs[j], 0, sizeof(sign_attrs_T));
- sattrs[j].sat_text = decor->sign_text;
- if (decor->sign_hl_id != 0) {
- sattrs[j].sat_texthl = syn_id2attr(decor->sign_hl_id);
- }
- if (decor->number_hl_id != 0) {
- sattrs[j].sat_numhl = syn_id2attr(decor->number_hl_id);
+ if (decor->sign_text) {
+ int j;
+ for (j = (*num_signs); j > 0; j--) {
+ if (sattrs[j - 1].priority >= decor->priority) {
+ break;
+ }
+ sattrs[j] = sattrs[j - 1];
}
- if (decor->line_hl_id != 0) {
- sattrs[j].sat_linehl = syn_id2attr(decor->line_hl_id);
+ if (j < SIGN_SHOW_MAX) {
+ sattrs[j] = (SignTextAttrs) {
+ .text = decor->sign_text,
+ .hl_attr_id = decor->sign_hl_id == 0 ? 0 : syn_id2attr(decor->sign_hl_id),
+ .priority = decor->priority
+ };
+ (*num_signs)++;
}
- if (decor->cursorline_hl_id != 0) {
- sattrs[j].sat_culhl = syn_id2attr(decor->cursorline_hl_id);
+ }
+
+ struct { HlPriAttr *dest; int hl; } cattrs[] = {
+ { line_attrs, decor->line_hl_id },
+ { num_attrs, decor->number_hl_id },
+ { cul_attrs, decor->cursorline_hl_id },
+ { NULL, -1 },
+ };
+ for (int i = 0; cattrs[i].dest; i++) {
+ if (cattrs[i].hl != 0 && decor->priority >= cattrs[i].dest->priority) {
+ *cattrs[i].dest = (HlPriAttr) {
+ .attr_id = syn_id2attr(cattrs[i].hl),
+ .priority = decor->priority
+ };
}
- sattrs[j].sat_prio = decor->priority;
- (*num_signs)++;
}
next_mark: