From 7ef7f653b7952349efabf5ccf84704528e9a2cde Mon Sep 17 00:00:00 2001 From: rajayonin Date: Mon, 20 Oct 2025 18:01:28 +0200 Subject: [PATCH 1/2] support for non-consecutive ranges Paints the start/end line of a range if there was no previous range. --- src/renderer.typ | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/renderer.typ b/src/renderer.typ index 39ecb2e..5afda4f 100644 --- a/src/renderer.typ +++ b/src/renderer.typ @@ -453,8 +453,9 @@ let desc-y = bits-y + bit-h * 2 // 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 end-i = to-real-i(if config.ltr-bits {range_.end} else {range_.start}) let start-x = bits-x + start-i * bit-w let width = rng.bits(range_) * bit-w @@ -464,6 +465,28 @@ let line-x = if config.ltr-bits {start-x + width} else {start-x} 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) + + // 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 != "" { let shapes_ @@ -568,4 +591,4 @@ config: config, render: render.with(config) ) -} \ No newline at end of file +} -- 2.49.1 From c7c777f5fa24c1e102a89d3b9ff3df46bf3f90d0 Mon Sep 17 00:00:00 2001 From: rajayonin Date: Mon, 20 Oct 2025 19:04:54 +0200 Subject: [PATCH 2/2] ensure first and last bits are included when `all-bit-i` is set --- src/renderer.typ | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/renderer.typ b/src/renderer.typ index 5afda4f..6f0e793 100644 --- a/src/renderer.typ +++ b/src/renderer.typ @@ -407,6 +407,11 @@ indices.push(r.start) indices.push(r.end) } + // ensure first and last bits are included + if not indices.contains(0) { indices.insert(0, struct.start) } + if not indices.contains(struct.bits + struct.start - 1) { + indices.push(struct.bits + struct.start - 1) + } } for i in range(struct.bits) { -- 2.49.1