viz: oneline inst list (#15269)

* viz: oneline inst list

* save 5 chars

* gradual padding
This commit is contained in:
qazal
2026-03-14 08:37:18 +02:00
committed by GitHub
parent 86f17468ed
commit 43ffd66fda
2 changed files with 4 additions and 7 deletions

View File

@@ -157,10 +157,6 @@
#insts .left.highlight {
background-color: rgba(0, 199, 47, 0.2);
}
#insts .n {
color: #787fa1;
min-width: 5ch;
}
#insts .wave {
color: #7aa2f7;
min-width: 2ch;

View File

@@ -323,10 +323,11 @@ function setFocus(key) {
let instList = document.getElementById("insts");
if (data.pcToShape.size == 0) return d3.select(instList?.parentElement).html("");
if (instList == null) {
let contents = "", i = 0;
let contents = "";
for (const [k, v] of data.pcToShape) {
contents += `<div class="line" data-k="${k}"><span class="left" id="inst-${k}"><span class="n">${i++}</span><span class="wave">${v.wave}</span>
<span class="pc">${"0x"+v.pc.toString(16).padStart(12, "0")}</span></span><span class="label">${data.pcMap[v.pc]}</span></div>`;
const pcHex = v.pc.toString(16);
contents += `<div class="line" data-k="${k}"><span class="left" id="inst-${k}"><span class="wave">${v.wave}</span>
<span class="pc">${"0x"+pcHex.padStart(Math.max(4, Math.ceil(pcHex.length/4)*4), 0)}</span><span class="label">${data.pcMap[v.pc]}</span></div>`;
}
instList = d3.create("pre").append("code").classed("hljs", true).style("margin-top", "20px").attr("id", "insts").html(contents)
.on("click", e => { const line = e.target.closest(".line"); line && setFocus(line.dataset.k); }).node();