forked from HEL/rivet-typst
		
	added all-bit-i config option
This commit is contained in:
		| @@ -24,6 +24,7 @@ | |||||||
| /// - width (float): TODO -> remove | /// - width (float): TODO -> remove | ||||||
| /// - height (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 | /// - 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 | /// -> dictionary | ||||||
| #let config( | #let config( | ||||||
|   default-font-family: "Ubuntu Mono", |   default-font-family: "Ubuntu Mono", | ||||||
| @@ -49,7 +50,8 @@ | |||||||
|   left-labels: false, |   left-labels: false, | ||||||
|   width: 1200, |   width: 1200, | ||||||
|   height: 800, |   height: 800, | ||||||
|   full-page: false |   full-page: false, | ||||||
|  |   all-bit-i: true | ||||||
| ) = {} | ) = {} | ||||||
|  |  | ||||||
| /// Dark theme config | /// Dark theme config | ||||||
|   | |||||||
							
								
								
									
										
											BIN
										
									
								
								docs/schema.pdf
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								docs/schema.pdf
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								manual.pdf
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								manual.pdf
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -22,7 +22,8 @@ | |||||||
|   left-labels: false, |   left-labels: false, | ||||||
|   width: 1200, |   width: 1200, | ||||||
|   height: 800, |   height: 800, | ||||||
|   full-page: false |   full-page: false, | ||||||
|  |   all-bit-i: true | ||||||
| ) = { | ) = { | ||||||
|   return ( |   return ( | ||||||
|     default-font-family: default-font-family, |     default-font-family: default-font-family, | ||||||
| @@ -48,7 +49,8 @@ | |||||||
|     left-labels: left-labels, |     left-labels: left-labels, | ||||||
|     width: width, |     width: width, | ||||||
|     height: height, |     height: height, | ||||||
|     full-page: full-page |     full-page: full-page, | ||||||
|  |     all-bit-i: all-bit-i | ||||||
|   ) |   ) | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -356,14 +356,27 @@ | |||||||
|   // Draw rectangle around structure |   // Draw rectangle around structure | ||||||
|   shapes += draw-rect(border-col, bits-x, bits-y, bits-width, bit-h, thickness: 2) |   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) { |   for i in range(struct.bits) { | ||||||
|     let bit-x = ox + i * bit-w |     let bit-x = ox + i * bit-w | ||||||
|  |     let real-i = struct.bits - i - 1 + start-bit | ||||||
|  |  | ||||||
|  |     if real-i in indices { | ||||||
|       shapes += draw-text( |       shapes += draw-text( | ||||||
|       str(struct.bits - i - 1 + start-bit), |         str(real-i), | ||||||
|         txt-col, |         txt-col, | ||||||
|         bit-x + bit-w / 2, |         bit-x + bit-w / 2, | ||||||
|         oy + bit-h / 2  |         oy + bit-h / 2  | ||||||
|       ) |       ) | ||||||
|  |     } | ||||||
|  |  | ||||||
|     // Draw separator |     // Draw separator | ||||||
|     if i != 0 { |     if i != 0 { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user