Skip to content

Commit 69187a0

Browse files
committed
logview: highlight the selected line
Add a background colour to help seeing which one needs to be looked at. Signed-off-by: Matthieu Baerts <matttbe@kernel.org>
1 parent 9c8f7fd commit 69187a0

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

ui/logview.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
--plan: #0550ae;
1717
--bar-bg: #f2f2f2;
1818
--hl: #fff8c5;
19+
--bg-line: #f2dd2650;
1920
}
2021
@media (prefers-color-scheme: dark) {
2122
:root {
@@ -28,6 +29,7 @@
2829
--plan: #809fff;
2930
--bar-bg: #282828;
3031
--hl: #4a3f1a;
32+
--bg-line: #f2dd2650;
3133
}
3234
}
3335
html, body {
@@ -76,6 +78,7 @@
7678
.ln-diag { color: var(--dim); }
7779
.ln-totals { color: var(--plan); }
7880
.ln-err { color: var(--fail); }
81+
.ln-bg { background-color: var(--bg-line); }
7982
.fold-toggle {
8083
cursor: pointer;
8184
color: var(--plan);
@@ -160,27 +163,33 @@
160163

161164
function renderLine(line, i) {
162165
i += this.add;
166+
var classes = []
163167
const cls = classify(line);
164168
if (cls === "ln-pass") pass++;
165169
else if (cls === "ln-fail") fail++;
166170
else if (cls === "ln-skip") skip++;
171+
if (cls) classes.push(cls);
172+
if (this.bg == i) classes.push("ln-bg")
167173
const e = esc(line);
168-
const c = cls ? `class=${cls}` : ``;
174+
const c = classes.length > 0 ? `class="${classes.join(" ")}"` : ``;
169175
return `<span id="L${i}" ${c}>${e}</span>`;
170176
}
171177

172178
// Group runs of deeply-nested "# #" diagnostic lines into a foldable
173179
// block (rendered expanded; collapse via the marker or "fold all").
174180
// Totals lines are kept out so the summary stays visible.
175181
const foldable = l => l.startsWith("# #") && !/Totals: pass/.test(l);
182+
const anchor = window.location.hash.match(/^#L(\d+)/);
183+
this.bg = anchor && anchor.length > 1 ? anchor[1] : -1;
176184
this.add = 0;
177185
const pieces = [];
178186
let i = 0;
179187
while (i < lines.length) {
180188
if (foldable(lines[i])) {
181189
let j = i;
182190
while (j < lines.length && foldable(lines[j])) j++;
183-
const body = lines.slice(i, j).map(renderLine, {add: i}).join("\n");
191+
const body = lines.slice(i, j).map(renderLine,
192+
{add: i, bg: bg}).join("\n");
184193
pieces.push(
185194
`<span class="fold open"><span class="fold-toggle">${j - i} lines` +
186195
`</span><span class="fold-body">\n${body}</span></span>`);

0 commit comments

Comments
 (0)