jaar23 / tui_widget

terminal ui widget based on illwill
14 stars 1 forks source link

tui_widget

Terminal UI widget based on illwill

The widgets is currently in alpha version. API is getting stable and you're welcome to build yout own text based application.

Note Experimental feature in 0.1.1 branch.

Quick preview

preview

It feels like an old school software, let's stick with the keyboard :D, it is navigate by [tab] button between widgets.

TerminalApp supports auto-resize and dynamic grid layout of adding widgets too. Check out the docs / examples for how-tos.

Usage

git clone https://github.com/jaar23/tui_widget.git

cd tui_widget && nimble install

Dependencies

# base
nimble install illwill@0.4.0

# for paste event
nimble install nimclipboard

# for chart widget
# instead of nimble install asciigraph, use the following backup repo
nimble install https://github.com/nimbackup/asciigraph

# for multi-thread
nimble install threading
nimble install malebolgia

Simple Example

import tui_widget, illwill

var inputBox = newInputBox(1, 1, consoleWidth(), 3, "message")

var display = newDisplay(1, 4, consoleWidth(), 16, "display panel") 

let enterEv = proc(ib: InputBox, arg: varargs[string]) =
  display.add(inputBox.value & "\n")
  inputBox.value("")

inputBox.onEnter = enterEv

var app = newTerminalApp(title="tui widget")

app.addWidget(inputBox)
app.addWidget(display)

app.run()

Docs

Getting Started, learn how to create a terminal application with tui_widget by simple examples.

Widgets, widgets API

Events, explain how tui_widget's events works

TerminalApp, bootstrap widget with TerminalApp.

Examples

Refers to tests / examples folder for example.