code / tomo-btui

Lines1.1K C700 Tomo305 Markdown95
(46 lines)

BTUI - Bruce's Terminal User Interface

This is an extremely lightweight, but powerful Tomo library for making terminal user interfaces based on the C library BTUI.

Usage

Add this to your modules.ini:

[btui]
version=v1.1
git=https://github.com/bruce-hill/tomo-btui

Example program

use btui

func main()
    set_mode(TUI)
    size := get_size()
    style(bold=yes)
    write("Welcome to BTUI", size/2, Center)
    style(bold=no, faint=yes)
    write("Press 'q' or 'Ctrl-c' to quit", size/2 + ScreenVec2(0,1), Center)
    style(bold=no)
    repeat
        key := get_key()
        pos := size/2 + ScreenVec2(0,2)
        clear(Line, pos=pos)
        style(Magenta)
        write("Your input: $key", pos, Center)
        if key == "q" or key == "Ctrl-c"
            stop

    disable()

A more complex example program can be found at examples/picker.tm

License

This code is licensed under the MIT license with the Commons Clause. See LICENSE.md for full details.

1 # BTUI - Bruce's Terminal User Interface
3 This is an extremely lightweight, but powerful Tomo library for making terminal
4 user interfaces based on the C library [BTUI](https://github.com/bruce-hill/btui).
6 ## Usage
8 Add this to your `modules.ini`:
10 ```
11 [btui]
12 version=v1.1
13 git=https://github.com/bruce-hill/tomo-btui
14 ```
16 ## Example program
18 ```
19 use btui
21 func main()
22 set_mode(TUI)
23 size := get_size()
24 style(bold=yes)
25 write("Welcome to BTUI", size/2, Center)
26 style(bold=no, faint=yes)
27 write("Press 'q' or 'Ctrl-c' to quit", size/2 + ScreenVec2(0,1), Center)
28 style(bold=no)
29 repeat
30 key := get_key()
31 pos := size/2 + ScreenVec2(0,2)
32 clear(Line, pos=pos)
33 style(Magenta)
34 write("Your input: $key", pos, Center)
35 if key == "q" or key == "Ctrl-c"
36 stop
38 disable()
39 ```
41 A more complex example program can be found at [examples/picker.tm](examples/picker.tm)
43 ## License
45 This code is licensed under the MIT license with the Commons Clause.
46 See [LICENSE.md](LICENSE.md) for full details.