Terminal UI library for MoonBit with reactive signals
{
"deps": {
"mizchi/tui": "0.1.0"
}
}fn main {
let count = @signals.signal(0)
let app = @tui.App::new(80, 24)
app.create_render_effect(
fn() {
@tui.box([
@tui.text("Count: " + count.get().to_string())
])
},
fn(output) { println(output) }
)
}moon run examples/counterpub struct App {
width : Int
height : Int
prev_buffer : CharBuffer?
last_layout : Layout?
handlers : EventHandlers
}pub(all) struct BorderChars {
top_left : Char
top_right : Char
bottom_left : Char
bottom_right : Char
horizontal : Char
vertical : Char
}fn CharBuffer::fill_rect(self : CharBuffer, x : Int, y : Int, w : Int, h : Int, cell : CharCell) -> Unitfn CharBuffer::write_text(self : CharBuffer, x : Int, y : Int, text : String, style : TextStyle, max_width : Int) -> Intfn CharBuffer::write_text_wrapped(self : CharBuffer, x : Int, y : Int, text : String, style : TextStyle, max_width : Int, max_height : Int) -> Intpub type ClickHandler () -> Unit#deprecated("Use `struct T(A)` to declare a newtype and use `.0` access the underlying type instead.")
fn ClickHandler::inner(self : ClickHandler) -> (() -> Unit)pub(all) struct Color {
r : Int
g : Int
b : Int
a : Double
}pub(all) struct HitTestResult {
id : String
x : Int
y : Int
width : Int
height : Int
}pub(all) enum InputResult {
Confirmed(String)
Cancelled
TabNext(String)
TabPrev(String)
}pub(all) enum KeyModifier {
None
Shift
Ctrl
Alt
CtrlShift
CtrlAlt
ShiftAlt
CtrlShiftAlt
}impl Show for KeyModifierpub(all) enum MouseButton {
Left
Middle
Right
ScrollUp
ScrollDown
None
}impl Show for MouseButtonpub(all) struct MouseEvent {
button : MouseButton
event_type : MouseEventType
x : Int
y : Int
modifier : KeyModifier
}impl Show for MouseEventpub(all) enum MouseEventType {
Press
Release
Move
Drag
}impl Show for MouseEventTypepub(all) struct RenderStyle {
fg : Color
bg : Color
bold : Bool
underline : Bool
border : BorderChars?
border_fg : Color
}#deprecated("Use `struct T(A)` to declare a newtype and use `.0` access the underlying type instead.")
fn RenderStyleMap::inner(self : RenderStyleMap) -> Map[String, RenderStyle]pub(all) enum SpecialKey {
Up
Down
Left
Right
Home
End
PageUp
PageDown
Insert
Delete
Tab
BackTab
Backspace
Enter
Escape
F(Int)
}impl Show for SpecialKey#deprecated("Use `struct T(A)` to declare a newtype and use `.0` access the underlying type instead.")
fn TextContentMap::inner(self : TextContentMap) -> Map[String, String]fn ansi_full_reset() -> Stringfn box(children : Array[Component], id? : String, width? : Dimension, height? : Dimension, min_width? : Dimension, min_height? : Dimension, max_width? : Dimension, max_height? : Dimension, flex_grow? : Double, flex_shrink? : Double, flex_basis? : Dimension, flex_direction? : FlexDirection, flex_wrap? : FlexWrap, justify_content? : Alignment, align_items? : Alignment, align_content? : Alignment, gap? : Double, padding? : Double, padding_x? : Double, padding_y? : Double, margin? : Double, margin_x? : Double, margin_y? : Double, border? : BorderChars?, border_color? : Color, bg? : Color, fg? : Color) -> Componentfn find_layout_by_id(layout : Layout, target_id : String, offset_x : Int, offset_y : Int) -> HitTestResult?fn hit_test(layout : Layout, mouse_x : Int, mouse_y : Int, offset_x : Int, offset_y : Int) -> HitTestResult?fn keep_alive_nonblocking(ms : Int) -> Unitfn poll_keypress() -> Boolfn render_layout(buf : CharBuffer, layout : Layout, styles : RenderStyleMap, texts : TextContentMap, offset_x : Int, offset_y : Int) -> Unitfn render_to_ansi(layout : Layout, styles : RenderStyleMap, texts : TextContentMap, width : Int, height : Int) -> Stringfn rgb_to_256(r : Int, g : Int, b : Int) -> Intfn run_app(width : Int, height : Int, render_fn : () -> Component, output_fn : (String) -> Unit) -> (() -> Unit)fn start_inline_input(label : String, initial : String, row : Int, col : Int, max_width : Int, max_height : Int, on_result : (InputResult) -> Unit) -> Unitfn start_inline_input_cooked(field_name : String, initial : String, on_result : (InputResult) -> Unit) -> Unitfn start_inplace_input(row : Int, col : Int, width : Int, height : Int, multiline : Bool, initial : String, on_result : (InputResult) -> Unit, on_lines_change? : (Int) -> Int?) -> Unitfn start_keypress_listener(callback : (String) -> Unit) -> Unitfn start_render_ticker(ms : Int, callback : () -> Unit) -> Intfn string_display_width(s : String) -> Intfn text_box(content : String, id? : String, width? : Dimension, height? : Dimension, min_width? : Dimension, min_height? : Dimension, max_width? : Dimension, max_height? : Dimension, flex_grow? : Double, flex_shrink? : Double, flex_basis? : Dimension, padding? : Double, padding_x? : Double, padding_y? : Double, margin? : Double, margin_x? : Double, margin_y? : Double, border? : BorderChars?, border_color? : Color, bg? : Color, fg? : Color, bold? : Bool, underline? : Bool) -> Component