1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
From 141436933a8d30edfd33aa5fcfb0c93cfa3ae9d5 Mon Sep 17 00:00:00 2001
From: Timothy Stack <timothyshanestack@gmail.com>
Date: Wed, 9 Dec 2020 15:35:06 -0800
Subject: [PATCH] [view_curses] use VC_ROLE instead of VC_STYLE where possible
and fix segv in mvwattrline
Fixes #806
Signed-off-by: Randy Barlow <randy@electronsweatshop.com>
--- a/src/highlighter.cc
+++ b/src/highlighter.cc
@@ -115,7 +115,9 @@ void highlighter::annotate(attr_line_t &al, int start) const
vc.match_color(this->h_bg));
}
if (this->h_role != view_colors::VCR_NONE) {
- attrs |= vc.attrs_for_role(this->h_role);
+ sa.emplace_back(lr,
+ &view_curses::VC_ROLE,
+ this->h_role);
}
sa.emplace_back(lr, &view_curses::VC_STYLE, attrs);
--- a/src/logfile_sub_source.cc
+++ b/src/logfile_sub_source.cc
@@ -468,25 +468,28 @@ void logfile_sub_source::text_attrs_for_line(textview_curses &lv,
shift_string_attrs(value_out, 0, time_offset_end);
- attrs = vc.attrs_for_role(view_colors::VCR_OFFSET_TIME);
- value_out.emplace_back(lr, &view_curses::VC_STYLE, attrs);
+ value_out.emplace_back(lr,
+ &view_curses::VC_ROLE,
+ view_colors::VCR_OFFSET_TIME);
value_out.emplace_back(line_range(12, 13),
&view_curses::VC_GRAPHIC, ACS_VLINE);
- int bar_attrs = 0;
+ view_colors::role_t bar_role = view_colors::VCR_NONE;
switch (this->get_line_accel_direction(vis_line_t(row))) {
case log_accel::A_STEADY:
break;
case log_accel::A_DECEL:
- bar_attrs = vc.attrs_for_role(view_colors::VCR_DIFF_DELETE);
+ bar_role = view_colors::VCR_DIFF_DELETE;
break;
case log_accel::A_ACCEL:
- bar_attrs = vc.attrs_for_role(view_colors::VCR_DIFF_ADD);
+ bar_role = view_colors::VCR_DIFF_ADD;
break;
}
- value_out.push_back(
- string_attr(line_range(12, 13), &view_curses::VC_STYLE, bar_attrs));
+ if (bar_role != view_colors::VCR_NONE) {
+ value_out.emplace_back(
+ line_range(12, 13), &view_curses::VC_ROLE, bar_role);
+ }
}
lr.lr_start = 0;
--- a/src/view_curses.cc
+++ b/src/view_curses.cc
@@ -402,13 +402,16 @@ void view_curses::mvwattrline(WINDOW *window,
}
}
+ if (attr_range.lr_end == -1) {
+ attr_range.lr_end = line_width_chars;
+ }
+ if (attr_range.lr_end < lr_chars.lr_start) {
+ continue;
+ }
attr_range.lr_start = max(0, attr_range.lr_start - lr_chars.lr_start);
if (attr_range.lr_start > line_width_chars) {
continue;
}
- if (attr_range.lr_end == -1) {
- attr_range.lr_end = lr_chars.lr_start + line_width_chars;
- }
attr_range.lr_end = min(line_width_chars, attr_range.lr_end - lr_chars.lr_start);
|