Skip to content

Commit 4047a12

Browse files
committed
column filters
1 parent 990e705 commit 4047a12

File tree

3 files changed

+96
-4
lines changed

3 files changed

+96
-4
lines changed

gcovr-templates/html/gcovr.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
initTreeControls();
1818
initViewToggle();
1919
initTlaNavigation();
20+
initColumnToggles();
2021
initPopupResize();
2122

2223
// Reveal page now that all init is done
@@ -1387,6 +1388,58 @@
13871388
}
13881389
}
13891390

1391+
// ===========================================
1392+
// Column Visibility Toggles
1393+
// ===========================================
1394+
1395+
function initColumnToggles() {
1396+
var buttons = document.querySelectorAll('.col-toggle');
1397+
if (buttons.length === 0) return;
1398+
1399+
var table = document.querySelector('.source-table');
1400+
if (!table) return;
1401+
1402+
// Restore saved state
1403+
var hidden = [];
1404+
try {
1405+
var saved = localStorage.getItem('gcovr-hidden-columns');
1406+
if (saved) hidden = JSON.parse(saved);
1407+
} catch (e) {}
1408+
1409+
// Apply saved hidden columns
1410+
for (var i = 0; i < hidden.length; i++) {
1411+
table.classList.add('hide-col-' + hidden[i]);
1412+
}
1413+
1414+
// Update button appearance to match state
1415+
buttons.forEach(function(btn) {
1416+
var col = btn.getAttribute('data-col');
1417+
if (hidden.indexOf(col) >= 0) {
1418+
btn.classList.remove('show-col');
1419+
}
1420+
});
1421+
1422+
// Handle clicks
1423+
buttons.forEach(function(btn) {
1424+
btn.addEventListener('click', function() {
1425+
var col = this.getAttribute('data-col');
1426+
var hideClass = 'hide-col-' + col;
1427+
var isHidden = table.classList.toggle(hideClass);
1428+
this.classList.toggle('show-col', !isHidden);
1429+
1430+
// Save state
1431+
var current = [];
1432+
var allBtns = document.querySelectorAll('.col-toggle');
1433+
allBtns.forEach(function(b) {
1434+
if (!b.classList.contains('show-col')) {
1435+
current.push(b.getAttribute('data-col'));
1436+
}
1437+
});
1438+
localStorage.setItem('gcovr-hidden-columns', JSON.stringify(current));
1439+
});
1440+
});
1441+
}
1442+
13901443
// ===========================================
13911444
// Prefetch pages on hover for instant nav
13921445
// ===========================================

gcovr-templates/html/source_page.content.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
</button>
2525
{% endif %}
2626
</div>
27+
<div class="source-column-filters">
28+
{% if has_branches %}
29+
<button type="button" class="btn btn-sm col-toggle show-col" data-col="branch" title="Toggle Branch column">Branch</button>
30+
{% endif %}
31+
<button type="button" class="btn btn-sm col-toggle show-col" data-col="tla" title="Toggle TLA column">TLA</button>
32+
<button type="button" class="btn btn-sm col-toggle show-col" data-col="count" title="Toggle Hits column">Hits</button>
33+
</div>
2734
{% if info.navigation is defined and fname in info.navigation %}
2835
<div class="source-nav-links">
2936
<a class="nav-link nav-prev" href="{% if info.single_page %}#{% endif %}{{info.navigation[fname][0] or ROOT_FNAME}}" title="Previous file">

gcovr-templates/html/style.css

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,11 +1345,11 @@ body.sidebar-resizing .main-content {
13451345
.source-header {
13461346
display: flex;
13471347
align-items: center;
1348-
padding: 12px 16px;
1348+
padding: 8px 12px;
13491349
background: var(--bg-tertiary);
13501350
border-bottom: 1px solid var(--border-color);
13511351
flex-wrap: wrap;
1352-
gap: 12px;
1352+
gap: 8px;
13531353
}
13541354

13551355
.source-title {
@@ -1361,16 +1361,43 @@ body.sidebar-resizing .main-content {
13611361

13621362
.source-line-filters {
13631363
display: flex;
1364-
gap: 8px;
1364+
gap: 6px;
13651365
flex-wrap: wrap;
13661366
}
13671367

1368+
.source-column-filters {
1369+
display: flex;
1370+
gap: 6px;
1371+
flex-wrap: wrap;
1372+
}
1373+
1374+
.col-toggle {
1375+
text-decoration: line-through;
1376+
opacity: 0.6;
1377+
}
1378+
1379+
.col-toggle.show-col {
1380+
text-decoration: none;
1381+
opacity: 1;
1382+
}
1383+
13681384
.source-nav-links {
13691385
display: flex;
1370-
gap: 8px;
1386+
gap: 6px;
13711387
margin-left: auto;
13721388
}
13731389

1390+
.source-header .btn.btn-sm {
1391+
padding: 2px 6px;
1392+
gap: 4px;
1393+
}
1394+
1395+
.source-header .nav-link {
1396+
padding: 2px 8px;
1397+
font-size: var(--font-size-xs);
1398+
gap: 2px;
1399+
}
1400+
13741401
.source-table-container {
13751402
overflow-x: auto;
13761403
}
@@ -1547,6 +1574,11 @@ body.sidebar-resizing .main-content {
15471574
color: var(--coverage-medium);
15481575
}
15491576

1577+
/* Column visibility toggle hide rules */
1578+
.source-table.hide-col-branch .col-branch { display: none; }
1579+
.source-table.hide-col-tla .col-tla { display: none; }
1580+
.source-table.hide-col-count .col-count { display: none; }
1581+
15501582
.hit-miss {
15511583
color: var(--coverage-low);
15521584
font-weight: bold;

0 commit comments

Comments
 (0)