#TUI #block #box #text #layout

text_block_layout

Library for joining together blocks of text characters, in for example a TUI or text document

4 releases (2 stable)

1.1.0 Jan 12, 2021
1.0.0 Jan 10, 2021
0.1.1 Jan 9, 2021
0.1.0 Jan 9, 2021

#24 in Visualization

MIT license

18KB
277 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 Github issue or open a pull request.

Dependencies

~36KB