support for non-consecutive ranges

Paints the start/end line of a range if there was no previous range.
This commit is contained in:
2025-10-20 18:01:28 +02:00
parent dd6d38a282
commit 7ef7f653b7

View File

@@ -453,8 +453,9 @@
let desc-y = bits-y + bit-h * 2 let desc-y = bits-y + bit-h * 2
// Names + simple descriptions // Names + simple descriptions
for range_ in ranges { for (i, range_) in ranges.enumerate() {
let start-i = to-real-i(if config.ltr-bits {range_.start} else {range_.end}) let start-i = to-real-i(if config.ltr-bits {range_.start} else {range_.end})
let end-i = to-real-i(if config.ltr-bits {range_.end} else {range_.start})
let start-x = bits-x + start-i * bit-w let start-x = bits-x + start-i * bit-w
let width = rng.bits(range_) * bit-w let width = rng.bits(range_) * bit-w
@@ -465,6 +466,28 @@
shapes += draw-line(border-col, (line-x, bits-y), (line-x, bits-y + bit-h)) shapes += draw-line(border-col, (line-x, bits-y), (line-x, bits-y + bit-h))
shapes += draw-text(range_.name, txt-col, name-x, name-y, fill: bg-col) shapes += draw-text(range_.name, txt-col, name-x, name-y, fill: bg-col)
// paint end line only if needed
if (
start-i != 0
and end-i != struct.bits - 1
and ranges
.at(
i
+ {
if config.ltr-bits and i < ranges.len() - 1 { 1 } else { -1 }
},
)
.end
!= range_.start - 1
) {
line-x += if config.ltr-bits { -width } else { width }
shapes += draw-line(
border-col,
(line-x, bits-y),
(line-x, bits-y + bit-h),
)
}
if range_.description != "" { if range_.description != "" {
let shapes_ let shapes_
(shapes_, desc-x, desc-y) = draw-description( (shapes_, desc-x, desc-y) = draw-description(