diff --git a/docs/config.typ b/docs/config.typ index 54c8c3d..3023224 100644 --- a/docs/config.typ +++ b/docs/config.typ @@ -24,6 +24,7 @@ /// - width (float): TODO -> remove /// - height (float): TODO -> remove /// - full-page (bool): If true, the page will be resized to fit the diagram and take the background color +/// - all-bit-i (bool): If true, all bit indices will be rendered, otherwise, only the ends of each range will be displayed /// -> dictionary #let config( default-font-family: "Ubuntu Mono", @@ -49,7 +50,8 @@ left-labels: false, width: 1200, height: 800, - full-page: false + full-page: false, + all-bit-i: true ) = {} /// Dark theme config diff --git a/docs/schema.pdf b/docs/schema.pdf deleted file mode 100644 index 3f5474a..0000000 Binary files a/docs/schema.pdf and /dev/null differ diff --git a/manual.pdf b/manual.pdf index fd03bfe..b9945ac 100644 Binary files a/manual.pdf and b/manual.pdf differ diff --git a/src/config.typ b/src/config.typ index f835eb4..f3868ad 100644 --- a/src/config.typ +++ b/src/config.typ @@ -22,7 +22,8 @@ left-labels: false, width: 1200, height: 800, - full-page: false + full-page: false, + all-bit-i: true ) = { return ( default-font-family: default-font-family, @@ -48,7 +49,8 @@ left-labels: left-labels, width: width, height: height, - full-page: full-page + full-page: full-page, + all-bit-i: all-bit-i ) } diff --git a/src/renderer.typ b/src/renderer.typ index 6b61674..83cac04 100644 --- a/src/renderer.typ +++ b/src/renderer.typ @@ -356,14 +356,27 @@ // Draw rectangle around structure shapes += draw-rect(border-col, bits-x, bits-y, bits-width, bit-h, thickness: 2) + let indices = range(struct.bits) + if not config.all-bit-i { + indices = () + for r in struct.ranges.values() { + indices.push(r.start) + indices.push(r.end) + } + } + for i in range(struct.bits) { let bit-x = ox + i * bit-w - shapes += draw-text( - str(struct.bits - i - 1 + start-bit), - txt-col, - bit-x + bit-w / 2, - oy + bit-h / 2 - ) + let real-i = struct.bits - i - 1 + start-bit + + if real-i in indices { + shapes += draw-text( + str(real-i), + txt-col, + bit-x + bit-w / 2, + oy + bit-h / 2 + ) + } // Draw separator if i != 0 {