+96
-2
lines changedFilter options
+96
-2
lines changed Original file line number Diff line number Diff line change
@@ -115,7 +115,12 @@ static Array extmark_to_array(ExtmarkInfo extmark, bool id, bool add_dict)
115
115
if (decor->hl_id) {
116
116
String name = cstr_to_string((const char *)syn_id2name(decor->hl_id));
117
117
PUT(dict, "hl_group", STRING_OBJ(name));
118
+
PUT(dict, "hl_eol", BOOLEAN_OBJ(decor->hl_eol));
118
119
}
120
+
if (decor->hl_mode) {
121
+
PUT(dict, "hl_mode", STRING_OBJ(cstr_to_string(hl_mode_str[decor->hl_mode])));
122
+
}
123
+
119
124
if (kv_size(decor->virt_text)) {
120
125
Array chunks = ARRAY_DICT_INIT;
121
126
for (size_t i = 0; i < decor->virt_text.size; i++) {
@@ -129,6 +134,36 @@ static Array extmark_to_array(ExtmarkInfo extmark, bool id, bool add_dict)
129
134
ADD(chunks, ARRAY_OBJ(chunk));
130
135
}
131
136
PUT(dict, "virt_text", ARRAY_OBJ(chunks));
137
+
PUT(dict, "virt_text_hide", BOOLEAN_OBJ(decor->virt_text_hide));
138
+
if (decor->virt_text_pos == kVTWinCol) {
139
+
PUT(dict, "virt_text_win_col", INTEGER_OBJ(decor->col));
140
+
}
141
+
PUT(dict, "virt_text_pos",
142
+
STRING_OBJ(cstr_to_string(virt_text_pos_str[decor->virt_text_pos])));
143
+
}
144
+
145
+
if (kv_size(decor->virt_lines)) {
146
+
Array all_chunks = ARRAY_DICT_INIT;
147
+
bool virt_lines_leftcol = false;
148
+
for (size_t i = 0; i < decor->virt_lines.size; i++) {
149
+
Array chunks = ARRAY_DICT_INIT;
150
+
VirtText *vt = &decor->virt_lines.items[i].line;
151
+
virt_lines_leftcol = decor->virt_lines.items[i].left_col;
152
+
for (size_t j = 0; j < vt->size; j++) {
153
+
Array chunk = ARRAY_DICT_INIT;
154
+
VirtTextChunk *vtc = &vt->items[j];
155
+
ADD(chunk, STRING_OBJ(cstr_to_string(vtc->text)));
156
+
if (vtc->hl_id > 0) {
157
+
ADD(chunk,
158
+
STRING_OBJ(cstr_to_string((const char *)syn_id2name(vtc->hl_id))));
159
+
}
160
+
ADD(chunks, ARRAY_OBJ(chunk));
161
+
}
162
+
ADD(all_chunks, ARRAY_OBJ(chunks));
163
+
}
164
+
PUT(dict, "virt_lines", ARRAY_OBJ(all_chunks));
165
+
PUT(dict, "virt_lines_above", BOOLEAN_OBJ(decor->virt_lines_above));
166
+
PUT(dict, "virt_lines_leftcol", BOOLEAN_OBJ(virt_lines_leftcol));
132
167
}
133
168
134
169
if (decor->hl_id || kv_size(decor->virt_text)) {
Original file line number Diff line number Diff line change
@@ -17,13 +17,17 @@ typedef enum {
17
17
kVTRightAlign,
18
18
} VirtTextPos;
19
19
20
+
EXTERN const char *const virt_text_pos_str[] INIT(= { "eol", "overlay", "win_col", "right_align" });
21
+
20
22
typedef enum {
21
23
kHlModeUnknown,
22
24
kHlModeReplace,
23
25
kHlModeCombine,
24
26
kHlModeBlend,
25
27
} HlMode;
26
28
29
+
EXTERN const char *const hl_mode_str[] INIT(= { "", "replace", "combine", "blend" });
30
+
27
31
typedef kvec_t(VirtTextChunk) VirtText;
28
32
#define VIRTTEXT_EMPTY ((VirtText)KV_INITIAL_VALUE)
29
33
Original file line number Diff line number Diff line change
@@ -1448,6 +1448,49 @@ describe('API/extmarks', function()
1448
1448
})
1449
1449
eq({ {1, 0, 0, { end_col = 0, end_row = 1 }} }, get_extmarks(ns, 0, -1, {details=true}))
1450
1450
end)
1451
+
1452
+
it('can get details', function()
1453
+
set_extmark(ns, marks[1], 0, 0, {
1454
+
end_col = 0,
1455
+
end_row = 1,
1456
+
priority = 0,
1457
+
hl_eol = true,
1458
+
hl_mode = "blend",
1459
+
hl_group = "String",
1460
+
virt_text = { { "text", "Statement" } },
1461
+
virt_text_pos = "right_align",
1462
+
virt_text_hide = true,
1463
+
virt_lines = { { { "lines", "Statement" } }},
1464
+
virt_lines_above = true,
1465
+
virt_lines_leftcol = true,
1466
+
})
1467
+
set_extmark(ns, marks[2], 0, 0, {
1468
+
priority = 0,
1469
+
virt_text = { { "text", "Statement" } },
1470
+
virt_text_win_col = 1,
1471
+
})
1472
+
eq({0, 0, {
1473
+
end_col = 0,
1474
+
end_row = 1,
1475
+
priority = 0,
1476
+
hl_eol = true,
1477
+
hl_mode = "blend",
1478
+
hl_group = "String",
1479
+
virt_text = { { "text", "Statement" } },
1480
+
virt_text_pos = "right_align",
1481
+
virt_text_hide = true,
1482
+
virt_lines = { { { "lines", "Statement" } }},
1483
+
virt_lines_above = true,
1484
+
virt_lines_leftcol = true,
1485
+
} }, get_extmark_by_id(ns, marks[1], { details = true }))
1486
+
eq({0, 0, {
1487
+
priority = 0,
1488
+
virt_text = { { "text", "Statement" } },
1489
+
virt_text_hide = false,
1490
+
virt_text_pos = "win_col",
1491
+
virt_text_win_col = 1,
1492
+
} }, get_extmark_by_id(ns, marks[2], { details = true }))
1493
+
end)
1451
1494
end)
1452
1495
1453
1496
describe('Extmarks buffer api with many marks', function()
Original file line number Diff line number Diff line change
@@ -755,12 +755,24 @@ describe('Buffer highlighting', function()
755
755
-- TODO: only a virtual text from the same ns curretly overrides
756
756
-- an existing virtual text. We might add a prioritation system.
757
757
set_virtual_text(id1, 0, s1, {})
758
-
eq({{1, 0, 0, { priority = 0, virt_text = s1}}}, get_extmarks(id1, {0,0}, {0, -1}, {details=true}))
758
+
eq({{1, 0, 0, {
759
+
priority = 0,
760
+
virt_text = s1,
761
+
-- other details
762
+
virt_text_pos = 'eol',
763
+
virt_text_hide = false,
764
+
}}}, get_extmarks(id1, {0,0}, {0, -1}, {details=true}))
759
765
760
766
-- TODO: is this really valid? shouldn't the max be line_count()-1?
761
767
local lastline = line_count()
762
768
set_virtual_text(id1, line_count(), s2, {})
763
-
eq({{3, lastline, 0, { priority = 0, virt_text = s2}}}, get_extmarks(id1, {lastline,0}, {lastline, -1}, {details=true}))
769
+
eq({{3, lastline, 0, {
770
+
priority = 0,
771
+
virt_text = s2,
772
+
-- other details
773
+
virt_text_pos = 'eol',
774
+
virt_text_hide = false,
775
+
}}}, get_extmarks(id1, {lastline,0}, {lastline, -1}, {details=true}))
764
776
765
777
eq({}, get_extmarks(id1, {lastline+9000,0}, {lastline+9000, -1}, {}))
766
778
end)
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4