ui
ui
ui
Common UI flow widgets for Zirric.
ui is a model-update-view loop for terminal and application interfaces. A widget turns a message into a new widget plus a command, and renders itself into a tree of tagged nodes. The library ships the loop itself and two widgets built on it.
Installation
Declare ui as a dependency of your module:
mod app
import cave
@cave.Dependencies()
data App {
@cave.Git("https://code.knabel.dev/zirric-lang/ui")
@cave.Version("main")
ui
}
ui depends on colors for the ColorLike values its nodes accept.
Usage
import ui.flow { Step }
import ui.textinput
const input = textinput.new("")
const step = textinput.update(input, textinput.KeyPressMsg("a"))
const view = textinput.view(step.model, dispatch)
Every update returns a Step: the next widget and the command to run before the next message arrives.
Modules
| Module | Description |
|---|---|
ui.flow |
The Widget and Cmd attributes, Step, View and the built-in commands. |
ui.flow.node |
Text, Foreground and Background, the nodes a view renders into. |
ui.label |
A widget displaying a fixed string. |
ui.textinput |
A widget collecting typed text. |
Status
Early draft. The widgets compile against an evolving flow module and several declarations still disagree with their use — see the changelog for the current list.
License
See LICENSE.