6 releases (stable)
new 1.2.1 | Nov 22, 2024 |
---|---|
1.2.0 | Jan 28, 2021 |
0.1.1 | Jan 9, 2021 |
#295 in Visualization
299 downloads per month
21KB
316 lines
text_block_layout
Rust library for joining together blocks of text characters, in for example a TUI or text document.
The key feature of the library is that it enables you to easily specify how blocks of text should be positioned in relation to other block, by joining blocks together, either vertically or horizontally, and using paddings and fills.
Examples
See Examples directory for example uses.
The text block layout is used in the math_expressions example to generates the following output:
2
⌠ 2 ⌠ ⎛ ix -ix⎞
⎮ cos (x) dx = ⎮ ⎜e + e ⎟ dx
⌡ ⌡ ⎜──────────⎟
⎝ 2 ⎠
1 ⌠ ⎛ 2ix -2ix⎞
= ─ ⎮ ⎝e + 2 + e ⎠ dx
4 ⌡
1
= ─ (2x + sin(2x)) + C
4
Example overlapping_boxes shows that blocks can be layered over each other. Transperancy character can be configured.
Blocks can be put on top of each other, with transparency!
OOOOO
O O
O **O****
O * O *
OOOOO *
* *
* *
* *
*******
Example named invoice shows yet another usage example.
INVOICE
Acme DATE 2020/01/01
Where customers are billed INVOICE # 12345678
Address
City, State ZIP
SHIP TO Name BILL TO Name
Address Address
City, State ZIP City, State ZIP
DESCRIPTION UNIT PRICE QUANTITY AMMOUNT
──────────────────────────────────────────────────────────────────────
Toilet paper, 13-pack $ 3.95 200 $ 790.00
Coffee, medium ground, 3 lbs $ 6.95 4 $ 27.80
──────────────────────────────────────────────────────────────────────
SUBTOTAL $ 817.80
──────────────────────
TAX RATE 8 %
──────────────────────
SALES TAX $ 65.42
──────────────────────
TOTAL $ 883.22
══════════════════════
Improvements and contributions
Feel free to open a issue or open a pull request in the GitHub repository.
Dependencies
~1.5MB
~22K SLoC