Interfaces for the terminal,
down to the serial line.
moonetui is a terminal UI toolkit for MoonBit — a synchronous, portable core with a cell buffer, a differential ANSI renderer, a CSS-like design system, and widgets that run the same on wasm, on Node, in the browser — and on a plain UART.
moon run --target native src/examples/gallery.Why moonetui
Everything a terminal interface needs, on a core that fits in a microcontroller's flash.
Synchronous by design
No async, no event loop you can't see. The host drives one step(): poll, parse, dispatch, lay out, compose, diff, write.
A real design system
Selectors, specificity and cascade over name, id and class — the CSS model you already know, applied to the terminal.
Differential renderer
Two frames become only the runs of cells that changed, then only the escape sequences needed. A widget that moved its cursor redraws its own rows: the rest of the screen is left as it stands.
Unicode-honest
A generated width table measures every line: CJK double width, emoji, combining marks. Padding is never a guess.
Layout that adds up
Fixed, percentage, auto and fractional sizes along an axis, plus a grid with spans and gutters — integer division that loses no column.
Tested on four backends
The same suite runs on wasm, wasm-gc, js and native, so a regression in one world fails loudly everywhere.
Where it runs
The core is pure and portable; only four operations touch a platform — write, read, raw mode, and the size query. Bring your own terminal: a real one through the C library, a canvas in a browser, a Node pipe — or a serial line with no cursor addressing at all.
| Target | Driver | What you get |
|---|---|---|
| Native terminal | @driver/native | termios on Unix, VT mode on Windows — the full modern feature set |
| Node.js | @driver/node | raw mode over stdin/stdout with a queue-fed frame pump |
| Browser | @driver/web | a terminal drawn on a canvas, keys encoded, resize in-band |
| Serial UART | your Driver | ECMA-48 / ISO 6429 subset over a byte stream; full repaint degrades gracefully |
Getting started
One command to add the toolkit, three to see it run.
Install
moonetui is published on mooncakes under the moonbitstack account:
# in your MoonBit project
moon add moonbitstack/moonetui
Run the examples
Every widget and style live in one terminal, a complete application, and the same toolkit on Node, in a browser and on a bare serial line:
# every widget and every style, live; up and down choose, tab moves in moon run --target native src/examples/gallery # a complete little application: tabs, timers, a command line moon run --target native src/examples/monitor/main # the database client, in a real terminal, Unix or Windows moon run --target native examples/dbmux/src/main -- --demo # a Jujutsu client, reading the repository you run it in moon run --target native examples/mbtjj/src/main # under Node moon run --target js src/examples/hello # the gallery in a browser: build, serve the repository, open the page moon build --target js python -m http.server # then http://localhost:8000/src/examples/browser/index.html # whole frames of plain text, as a bare serial line receives them moon run --target native src/examples/uart
A first application
Widgets are values. They render a line at a time, report what they want through typed messages, and never call back into your code:
let button = @widget.Button::new(" Press me ") let w : &@widget.Widget = button let ctx = @widget.Ctx::new(1, @geom.Size::new(20, 3)) w.handle(ctx, @widget.Msg::Key(@event.Key::of(Enter))) // ctx.asked() == [Pressed(id=1)]
Compose them in a tree, style them with a stylesheet, and drive the frame loop from a driver — the architecture page lays out the pieces.
What the library expects of you
- A
Driverfor your terminal — or one of the three shipped. - A stylesheet if you want one — plain styles work without.
- A message handler that answers the widgets' typed messages.
Architecture
Twelve packages, one direction of flow, four points of contact with the platform.
The frame, step by step
The core is synchronous. wasm-gc has no async, and the core must run there — so the main loop is a step() the host drives: a blocking poll on native, setInterval under Node, requestAnimationFrame in a browser.
poll → parse → dispatch → lay out → compose → diff → write
- poll — the driver reports what arrived; the app measures the terminal and sends every widget the time that passed.
- parse —
@inputturns the byte stream into events: CSI and SS3 sequences, modifiers, SGR mouse, bracketed paste, UTF-8 split across reads. - dispatch — the app walks the focus ring and hands each event to a widget; widgets answer with typed messages.
- lay out —
@layoutand the design system place boxes along an axis or on the grid. - compose —
@compturns placements into composed rows of styled cells. A frame that only damaged part of the screen composes those rows, on the placements the last frame left behind. - diff — consecutive screens become only the runs of cells that changed, each reached with one cursor move.
- write —
@stylerenders the changed styles as differential SGR sequences, and the driver writes them.
The package map
| Package | Responsibility |
|---|---|
@geom | Integer rectangle algebra — Offset, Size, Region, Spacing — with intersection, union, splitting and clamping. |
@style | Colours (named, indexed, true colour), text attributes, palette quantisation, differential SGR rendering. |
@strip | One rendered line: styled segments measured in terminal columns over a generated Unicode width table. |
@event | Keys, mouse reports, paste, resize and focus as plain values. |
@input | The incremental terminal byte parser. |
@comp | The compositor: placements to rows, rows to diffs, diffs to escape sequences. |
@driver | The seam to a terminal, plus a headless terminal for tests. |
@vt | A virtual terminal: the screen an escape stream draws, read by the browser driver, by tests and by screenshots. |
@layout | Axis placement and the grid — spans, gutters, integer division that loses no column. |
@design | The style system: rules, specificity, cascade, inheritance, chrome. |
@widget | The widget contract and the widget inventory. |
@app | The widget tree, focus ring, scroll containers, docks, grids, screens, timers, and the frame loop. |
The widget contract
A widget is a value with four operations. No callbacks, no inheritance, no hidden state:
pub(open) trait Widget { fn render_line(Self, Int32, @geom.Size) -> @strip.Strip fn hint(Self, @geom.Size) -> @geom.Size fn handle(Self, Ctx, Msg) -> Bool fn focusable(Self) -> Bool }
render_line draws one row — the compositor asks only for rows it can see. hint reports the size the content wants. handle takes a message and answers through the Ctx: typed outputs like Pressed, Changed, Selected, Highlighted, Toggled — which a handler can claim before the app acts on them.
Widgets
55 widgets, each with its own keyboard contract, message shape and rendering. Every card runs its demo from src/examples/showcase right here: click one and use the keys, and the line under it shows what the widget reports. The code under that is the demo's own source.
moon run --target native src/examples/gallery
Text and display
Static
Text clipped at a character boundary, aligned left, centre or right.
pub fn static_text() -> Demo { let left = @widget.Static::new("Text sits on the left by default.") let centre = @widget.Static::new("Or in the centre,", align=Centre) let right = @widget.Static::new("or on the right.", align=Right) let tinted = @widget.label( "label() styles it in one call.", style=@style.Style::new(fg=@style.cyan, bold=true), ) Demo::new( "Static", @app.column(0, [ @app.leaf(1, left, box=line(1)), @app.leaf(2, centre, box=line(1)), @app.leaf(3, right, box=line(1)), @app.leaf(4, tinted, box=line(1)), ]), group=Text, note="Text clipped at a character boundary, aligned left, centre or right.", rows=4, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
Header
The title bar: the title in the centre, a note at the right edge.
pub fn header() -> Demo { let bar = @widget.Header::new("moonetui", note="ctrl-c to quit") Demo::new( "Header", @app.column(0, [@app.leaf(1, bar, box=line(1))]), group=Text, note="The title bar: the title in the centre, a note at the right edge.", rows=1, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
Clock
A time of day that runs off the same tick every widget sees, so a header can keep one without a clock of the host's.
pub fn clock() -> Demo { let bar = @widget.Header::new( "moonetui", note="0.3.1", clock=@widget.Clock::new(hour=9, minute=41, second=26), ) Demo::new( "Clock", @app.column(0, [ @app.leaf(1, bar, box=line(1)), @app.leaf( 2, @widget.label( "The bar's clock counts itself forward from every frame.", style=@style.Style::new(dim=true), ), box=line(1), ), ]), group=Text, note="A time of day that runs off the same tick every widget sees, so a header can keep one without a clock of the host's.", rows=2, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
Link
Words that go somewhere: underlined, taken by Enter or by a click, and dimmed once they have been.
pub fn link() -> Demo { let guide = @widget.Link::new( "The MoonBit guide", target="https://docs.moonbitlang.com", ) let mooncakes = @widget.Link::new("mooncakes.io") Demo::new( "Link", @app.column(0, [ @app.leaf(1, guide, box=line(1)), @app.leaf(2, mooncakes, box=line(1)), ]), group=Text, note="Words that go somewhere: underlined, taken by Enter or by a click, and dimmed once they have been.", rows=2, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
Rule
A horizontal or vertical rule in any of nine styles.
pub fn rule() -> Demo { let kinds : Array[(String, @widget.RuleKind)] = [ ("solid", Solid), ("heavy", Heavy), ("double", Double), ("dashed", Dashed), ("thick", Thick), ("ascii", Ascii), ] let rows = kinds.mapi((i, kind) => { @app.row( i * 10, [ @app.leaf(i * 10 + 1, @widget.Static::new(kind.0), box=line(8)), @app.leaf( i * 10 + 2, @widget.Rule::horizontal(kind=kind.1), box=@layout.Box::new(extent=Frac(1)), ), ], box=line(1), ) }) Demo::new( "Rule", @app.column(100, rows), group=Text, note="A horizontal or vertical rule in any of nine styles.", rows=6, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
Digits
Three-row glyphs for clocks and counters, plain or bold.
pub fn digits() -> Demo { let clock = @widget.Digits::new(value="12:34") let price = @widget.Digits::new( value="€9.99", style=@style.Style::new(fg=@style.yellow, bold=true), ) Demo::new( "Digits", @app.row( 0, [@app.leaf(1, clock, box=line(17)), @app.leaf(2, price)], box=line(3), ), group=Text, note="Three-row glyphs for clocks and counters, plain or bold.", rows=3, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
Sparkline
An eight-level bar chart that buckets its data to fit the width.
pub fn sparkline() -> Demo { let load = @widget.Sparkline::new(data=[ 3.0, 5.0, 2.0, 8.0, 6.0, 4.0, 7.0, 9.0, 5.0, 3.0, 6.0, 8.0, 4.0, 2.0, 5.0, 7.0, ]) let tall = @widget.Sparkline::new( data=[1.0, 2.0, 4.0, 7.0, 9.0, 7.0, 4.0, 2.0, 1.0, 2.0, 4.0, 7.0], summary=Mean, ) Demo::new( "Sparkline", @app.column(0, [ @app.leaf(1, load, box=line(1)), @app.leaf(2, tall, box=line(3)), ]), group=Text, note="An eight-level bar chart that buckets its data to fit the width.", rows=4, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
Progress
A bar against a total, filled in eighths of a column.
pub fn progress() -> Demo { let done = @widget.Progress::new(total=100) done.set(62) let fine = @widget.Progress::new(total=1000) fine.set(333) Demo::new( "Progress", @app.column(0, [ @app.leaf(1, done, box=line(1)), @app.leaf(2, fine, box=line(1)), ]), group=Text, note="A bar against a total, filled in eighths of a column.", rows=2, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
LoadingIndicator
Five dots that pulse on every frame, for work with no end in sight.
pub fn loading_indicator() -> Demo { Demo::new( "LoadingIndicator", @app.column(0, [@app.leaf(1, @widget.LoadingIndicator::new())]), group=Text, note="Five dots that pulse on every frame, for work with no end in sight.", rows=3, ) }
Placeholder
A coloured stand-in for a widget not written yet; a click cycles what it shows.
pub fn placeholder() -> Demo { Demo::new( "Placeholder", @app.row(0, [ @app.leaf( 1, @widget.Placeholder::new(label="Sidebar"), box=@layout.Box::new(extent=Frac(1)), ), @app.leaf( 2, @widget.Placeholder::new(label="Content", colour=3), box=@layout.Box::new(extent=Frac(2)), ), ]), group=Text, note="A coloured stand-in for a widget not written yet; a click cycles what it shows.", rows=4, ) }
Pretty
A value printed the way it reads: laid out with an indent, coloured by what each part is, on one line when it fits.
pub fn pretty() -> Demo { let pretty = @widget.Pretty::new( value=VObj([ ("name", VStr("moonetui")), ("version", VStr("0.3.1")), ("widgets", VInt(48)), ("colours", VArr([VStr("ansi"), VStr("256"), VStr("24-bit")])), ("unicode", VBool(true)), ]), ) Demo::new( "Pretty", @app.column(0, [@app.leaf(1, pretty, box=line(10))]), group=Text, note="A value printed the way it reads: laid out with an indent, coloured by what each part is, on one line when it fits.", rows=10, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
KeyPanel
What the keys do, in columns: a key against its description, drawn and nothing more.
pub fn key_panel() -> Demo { let keys = @widget.KeyPanel::new(bindings=[ ("ctrl+p", "command palette"), ("ctrl+s", "save"), ("tab", "next field"), ("shift+tab", "field before"), ("esc", "close"), ("?", "this panel"), ]) Demo::new( "KeyPanel", @app.column(0, [@app.leaf(1, keys)]), group=Text, note="What the keys do, in columns: a key against its description, drawn and nothing more.", rows=3, ) }
Entry and logs
Input
A single-line field with Textual's keys; a password field shows dots.
pub fn input() -> Demo { let name = @widget.Input::new(placeholder="your name") let secret = @widget.Input::new(placeholder="password", password=true) let code = @widget.Input::new(placeholder="four digits", max_length=4) Demo::new( "Input", @app.column(0, [ @app.leaf(1, name, box=line(1)), @app.leaf(2, secret, box=line(1)), @app.leaf(3, code, box=line(1)), ]), group=Entry, note="A single-line field with Textual's keys; a password field shows dots.", rows=3, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
MaskedInput
A field ruled by a template: # a digit, A a letter, ? either, * anything, and the rest written as it is.
pub fn masked_input() -> Demo { let phone = @widget.MaskedInput::new("(###) ###-####") let date = @widget.MaskedInput::new("####-##-##") let key = @widget.MaskedInput::new("????-????", placeholder="·") Demo::new( "MaskedInput", @app.column(0, [ @app.leaf(1, phone, box=line(1)), @app.leaf(2, date, box=line(1)), @app.leaf(3, key, box=line(1)), ]), group=Entry, note="A field ruled by a template: # a digit, A a letter, ? either, * anything, and the rest written as it is.", rows=3, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
TextArea
A multi-line editor with selection, undo, word moves and a line gutter.
pub fn text_area() -> Demo { let area = @widget.TextArea::new(text="fn main {\n println(\"hello\")\n}\n") Demo::new( "TextArea", @app.column(0, [@app.leaf(1, area)]), group=Entry, note="A multi-line editor with selection, undo, word moves and a line gutter.", rows=5, ) }
Log
Lines that follow the tail until the reader scrolls away from it.
pub fn log() -> Demo { let lines = @widget.Log::new() lines.write_lines([ "boot ok", "loading modules", "listening on 12000", "ready", ]) Demo::new( "Log", @app.column(0, [@app.leaf(1, lines)]), group=Entry, note="Lines that follow the tail until the reader scrolls away from it.", rows=4, ) }
RichLog
A log of styled lines that can wrap to the width.
pub fn rich_log() -> Demo { let lines = @widget.RichLog::new(wrap=true) lines.write("deploy passed", style=@style.Style::new(fg=@style.green)) lines.write("2 warnings", style=@style.Style::new(fg=@style.yellow)) lines.write("one failure", style=@style.Style::new(fg=@style.red, bold=true)) lines.write("done") Demo::new( "RichLog", @app.column(0, [@app.leaf(1, lines)]), group=Entry, note="A log of styled lines that can wrap to the width.", rows=4, ) }
Choices
Switch
An on-off thumb that slides to the side of its value.
pub fn switch() -> Demo { Demo::new( "Switch", @app.row(0, [ @app.leaf(1, @widget.Switch::new(), box=line(6)), @app.leaf(2, @widget.Switch::new(value=true), box=line(6)), ]), group=Choice, note="An on-off thumb that slides to the side of its value.", rows=1, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
Checkbox
A labelled box that Space, Enter or a click turns on and off.
pub fn checkbox() -> Demo { Demo::new( "Checkbox", @app.column(0, [ @app.leaf( 1, @widget.Checkbox::new("Enable extras", value=true), box=line(1), ), @app.leaf(2, @widget.Checkbox::new("Send reports"), box=line(1)), ]), group=Choice, note="A labelled box that Space, Enter or a click turns on and off.", rows=2, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
RadioSet
Radio buttons where pressing one releases the rest.
pub fn radio_set() -> Demo { let set = @widget.RadioSet::new([ @widget.RadioButton::new("Fast"), @widget.RadioButton::new("Balanced", value=true), @widget.RadioButton::new("Quiet"), ]) Demo::new( "RadioSet", @app.column(0, [@app.leaf(1, set)]), group=Choice, note="Radio buttons where pressing one releases the rest.", rows=3, ) }
OptionList
Prompts with separators; the highlight never rests on a disabled one.
pub fn option_list() -> Demo { let list = @widget.OptionList::new(options=[ @widget.Choice::new("Alpha"), @widget.Choice::new("Beta"), @widget.Choice::new("Retired", disabled=true), ]) list.add_separator() list.add_option(@widget.Choice::new("Omega")) Demo::new( "OptionList", @app.column(0, [@app.leaf(1, list)]), group=Choice, note="Prompts with separators; the highlight never rests on a disabled one.", rows=5, ) }
SelectionList
A list where every entry is a checkbox of its own.
pub fn selection_list() -> Demo { let list = @widget.SelectionList::new(options=[ @widget.Selection::new("Clean build", "clean", initial_state=true), @widget.Selection::new("All targets", "targets", initial_state=true), @widget.Selection::new("Sign the tag", "sign"), ]) Demo::new( "SelectionList", @app.column(0, [@app.leaf(1, list)]), group=Choice, note="A list where every entry is a checkbox of its own.", rows=3, ) }
Select
A prompt that opens in place; typing narrows it, Escape folds it away.
pub fn select() -> Demo { let pick = @widget.Select::new( options=[("Alpha", "a"), ("Beta", "b"), ("Gamma", "g"), ("Delta", "d")], prompt="Pick a letter", ) Demo::new( "Select", @app.column(0, [@app.leaf(1, pick)]), group=Choice, note="A prompt that opens in place; typing narrows it, Escape folds it away.", rows=5, ) }
Slider
A number chosen along a track: arrows and a page, Home and End, a click on the track, and the wheel.
pub fn slider() -> Demo { Demo::new( "Slider", @app.column(0, [ @app.leaf(1, @widget.Slider::new(value=64), box=line(1)), @app.leaf( 2, @widget.Slider::new(value=30, low=0, high=50, step=5), box=line(1), ), ]), group=Choice, note="A number chosen along a track: arrows and a page, Home and End, a click on the track, and the wheel.", rows=2, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
Calendar
A month as a grid with one day picked out; arrows walk days, Page Up and Page Down walk months.
pub fn calendar() -> Demo { Demo::new( "Calendar", @app.column(0, [ @app.leaf(1, @widget.Calendar::on(2026, 11, 8), box=line(21)), ]), group=Choice, note="A month as a grid with one day picked out; arrows walk days, Page Up and Page Down walk months.", rows=8, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
Navigation and structure
Button
Enter, Space or a click presses it; a disabled one takes neither focus nor input.
pub fn button() -> Demo { let save = @widget.Button::new(" Save ") let cancel = @widget.Button::new(" Cancel ") let later = @widget.Button::new(" Later ") later.disable(true) Demo::new( "Button", @app.row( 0, [ @app.leaf(1, save, box=line(10)), @app.leaf(2, cancel, box=line(12)), @app.leaf(3, later, box=line(11)), ], gap=2, ), group=Navigation, note="Enter, Space or a click presses it; a disabled one takes neither focus nor input.", rows=1, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
ListView
A vertical list with a moving highlight; wide characters keep their columns.
pub fn list_view() -> Demo { let list = @widget.ListView::new([ "alpha", "beta", "gamma", "delta", "epsilon", "中文也对齐", ]) Demo::new( "ListView", @app.column(0, [@app.leaf(1, list)]), group=Navigation, note="A vertical list with a moving highlight; wide characters keep their columns.", rows=4, ) }
StatefulList
Selection and scroll live in a ListState the caller keeps, so another widget can share them or the caller can set them between frames.
pub fn stateful_list() -> Demo { let state = @widget.ListState::new(selected=1) let list = @widget.StatefulList::new( items=["alpha", "beta", "gamma", "delta", "epsilon", "中文也对齐"], state~, ) Demo::new( "StatefulList", @app.column(0, [@app.leaf(1, list)]), group=Navigation, note="Selection and scroll live in a ListState the caller keeps, so another widget can share them or the caller can set them between frames.", rows=4, ) }
Paginator
Which page of a longer list is on show; the arrows and a click on a number change it.
pub fn paginator() -> Demo { let pager = @widget.Paginator::new(page=3, pages=12) Demo::new( "Paginator", @app.column(0, [@app.leaf(1, pager, box=line(1))]), group=Navigation, note="Which page of a longer list is on show; the arrows and a click on a number change it.", rows=1, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
Tabs
A row of tabs with an underline under the active one; the arrows move it.
pub fn tabs() -> Demo { Demo::new( "Tabs", @app.column(0, [ @app.leaf(1, @widget.Tabs::new(labels=["Inbox", "Reports", "Settings"])), ]), group=Navigation, note="A row of tabs with an underline under the active one; the arrows move it.", rows=2, ) }
TabbedContent
Tabs over panes: keys go to the pane first and switch tabs when it passes.
pub fn tabbed_content() -> Demo { let jobs = @widget.ListView::new(["build", "test", "deploy"]) let notes = @widget.Static::new("last run: 42 seconds ago\nall green") let panes : Array[&@widget.Widget] = [jobs, notes] Demo::new( "TabbedContent", @app.column(0, [ @app.leaf(1, @widget.TabbedContent::new(labels=["Jobs", "Notes"], panes~)), ]), group=Navigation, note="Tabs over panes: keys go to the pane first and switch tabs when it passes.", rows=5, ) }
Collapsible
A titled section that Enter or a click folds and unfolds.
pub fn collapsible() -> Demo { let body : &@widget.Widget = @widget.Static::new( "Four backends, all passing.\nNo warnings.", ) Demo::new( "Collapsible", @app.column(0, [ @app.leaf( 1, @widget.Collapsible::new( title="Details", contents=body, collapsed=false, ), ), ]), group=Navigation, note="A titled section that Enter or a click folds and unfolds.", rows=6, ) }
ContentSwitcher
One of several widgets in the same place: the one showing is drawn, measured and given the input.
pub fn content_switcher() -> Demo { let first = @widget.Static::new("The first thing the space holds.") let second = @widget.Button::new("Take the second") let switcher = @widget.ContentSwitcher::new(children=[first, second]) switcher.switch_to(0) Demo::new( "ContentSwitcher", @app.column(0, [ @app.leaf(1, switcher, box=line(1)), @app.leaf( 2, @widget.label( "One of several in the same place; the host calls switch_to.", style=@style.Style::new(dim=true), ), box=line(1), ), @app.leaf(3, @widget.Button::new("Switch"), box=line(1)), ]), group=Navigation, note="One of several widgets in the same place: the one showing is drawn, measured and given the input.", rows=3, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
Block
A frame, a title and padding around any other widget, which is drawn and driven at the size left for it.
pub fn block() -> Demo { let framed = @widget.Block::new( @widget.Static::new("Any widget goes inside."), title="Wrapped", border=Some(@widget.round), padding=@geom.Spacing::all(1), ) let padded = @widget.Block::new( @widget.Static::new("Padding alone.", align=Centre), border=None, padding=@geom.Spacing::all(1), style=@style.Style::new(bg=@style.blue), ) Demo::new( "Block", @app.row( 0, [ @app.leaf( 1, framed, box=@layout.Box::new(extent=Frac(1)), styles=@design.Styles::new(border=@design.Off), ), @app.leaf(2, padded, box=@layout.Box::new(extent=Frac(1))), ], gap=1, ), group=Navigation, note="A frame, a title and padding around any other widget, which is drawn and driven at the size left for it.", rows=5, ) }
Tree
Nodes with guides; Enter selects, Space folds, Shift and an arrow walk the family.
pub fn tree() -> Demo { let tree = @widget.Tree::new(root_label="Dune") let root = tree.root_id() let arrakis = tree.add(root, "Arrakis", expand=true) ignore(tree.add_leaf(arrakis, "Arrakeen")) ignore(tree.add_leaf(arrakis, "Carthag")) let caladan = tree.add(root, "Caladan") ignore(tree.add_leaf(caladan, "Castle Caladan")) tree.expand(root) Demo::new( "Tree", @app.column(0, [@app.leaf(1, tree)]), group=Navigation, note="Nodes with guides; Enter selects, Space folds, Shift and an arrow walk the family.", rows=6, ) }
DirectoryTree
A tree over a file system that reads each folder when it opens.
pub fn directory_tree() -> Demo { let disk = @widget.DirectoryTree::new(path=".", loader=path => { if path == "." { [ @widget.DirEntry::new("src", is_dir=true), @widget.DirEntry::new("docs", is_dir=true), @widget.DirEntry::new("moon.mod", is_dir=false), @widget.DirEntry::new("README.md", is_dir=false), ] } else { [ @widget.DirEntry::new("main.mbt", is_dir=false), @widget.DirEntry::new("moon.pkg", is_dir=false), ] } }) Demo::new( "DirectoryTree", @app.column(0, [@app.leaf(1, disk)]), group=Navigation, note="A tree over a file system that reads each folder when it opens.", rows=6, ) }
Data and notices
DataTable
Columns, a cell cursor, sorting by any column, and stripes if asked.
pub fn data_table() -> Demo { let table = @widget.DataTable::new(zebra=true) ignore(table.add_column("Target", width=10)) ignore(table.add_column("Tests", width=6, align=Right)) ignore(table.add_column("Status")) ignore(table.add_row(["wasm", "336", "pass"])) ignore(table.add_row(["wasm-gc", "336", "pass"])) ignore(table.add_row(["js", "336", "pass"])) ignore(table.add_row(["native", "336", "pass"])) Demo::new( "DataTable", @app.column(0, [@app.leaf(1, table)]), group=Data, note="Columns, a cell cursor, sorting by any column, and stripes if asked.", rows=5, ) }
StatefulTable
The active cell lives in a TableState the caller keeps, in the same way.
pub fn stateful_table() -> Demo { let state = @widget.TableState::new(row=1, column=1) let table = @widget.StatefulTable::new( header=["Name", "Role", "Status"], rows=[ ["alpha", "builder", "ok"], ["beta", "tester", "ok"], ["gamma", "deployer", "busy"], ], state~, ) Demo::new( "StatefulTable", @app.column(0, [@app.leaf(1, table)]), group=Data, note="The active cell lives in a TableState the caller keeps, in the same way.", rows=5, ) }
HexView
Bytes as a dump reads: the offset, the bytes in hex, and the same bytes as text.
pub fn hex_view() -> Demo { let bytes = b"GET /index.html HTTP/1.1\r\nHost: moonbitstack\r\n" Demo::new( "HexView", @app.column(0, [@app.leaf(1, @widget.HexView::new(data=bytes))]), group=Data, note="Bytes as a dump reads: the offset, the bytes in hex, and the same bytes as text.", rows=3, ) }
Diff
A unified difference as a reader of patches expects it: marks in the margin, headings picked out.
pub fn diff() -> Demo { let patch = #|--- a/moon.mod #|+++ b/moon.mod #|@@ -1,3 +1,3 @@ #| name = "moonbitstack/moonetui" #|-version = "0.3.4" #|+version = "0.3.5" #| source = "src" Demo::new( "Diff", @app.column(0, [@app.leaf(1, @widget.Diff::of_unified(patch))]), group=Data, note="A unified difference as a reader of patches expects it: marks in the margin, headings picked out.", rows=6, ) }
Markdown
Headings, emphasis, lists, quotes, code and tables, wrapped to the width.
pub fn markdown() -> Demo { let doc = @widget.Markdown::new( "# Deploy report\n\nAll **four** backends pass, with `--deny-warn`.\n\n- wasm and wasm-gc\n- js and native\n\n> Shipped on a Thursday.", ) Demo::new( "Markdown", @app.column(0, [@app.leaf(1, doc)]), group=Data, note="Headings, emphasis, lists, quotes, code and tables, wrapped to the width.", rows=9, ) }
Tooltip
A padded box of wrapped text, for a hint beside what it explains.
pub fn tooltip() -> Demo { let tip = @widget.Tooltip::new( "Builds every target and runs the whole suite on each.", max_width=34, style=@style.Style::new(bg=@style.Colour::rgb(60, 60, 80)), ) Demo::new( "Tooltip", @app.column(0, [@app.leaf(1, tip)]), group=Data, note="A padded box of wrapped text, for a hint beside what it explains.", rows=4, ) }
Toast
A notice with a coloured bar for its level; it expires on its own or on a click.
pub fn toast() -> Demo { let done = @widget.Toast::new( "All four backends pass.", title="Deployed", duration=0, ) let warn = @widget.Toast::new( "Two tests were skipped.", title="Heads up", level=Warning, duration=0, ) Demo::new( "Toast", @app.column(0, [@app.leaf(1, done), @app.leaf(2, warn)]), group=Data, note="A notice with a coloured bar for its level; it expires on its own or on a click.", rows=4, ) }
Dialogs, menus and commands
MessageBox
A question or a notice with a row of buttons: the arrows move, Enter takes, Escape closes.
pub fn message_box() -> Demo { let ask = @widget.MessageBox::new( title="Quit", message="The buffer has changes that were never saved. Discard them?", kind=Question, buttons=@widget.yes_no, ) let note = @widget.MessageBox::new( title="Saved", message="Everything is written to disk.", kind=Info, buttons=@widget.ok, ) Demo::new( "MessageBox", @app.row( 0, [ @app.leaf(1, ask, box=@layout.Box::new(extent=Frac(1))), @app.leaf(2, note, box=@layout.Box::new(extent=Frac(1))), ], gap=1, ), group=Overlay, note="A question or a notice with a row of buttons: the arrows move, Enter takes, Escape closes.", rows=7, ) }
InputBox
A prompt, a one-line field and two buttons: typing goes to the field, Enter takes the button highlighted.
pub fn input_box() -> Demo { let box = @widget.InputBox::new( title="Rename", prompt="New name", value="untitled", buttons=@widget.ok_cancel, ) Demo::new( "InputBox", @app.column(0, [@app.leaf(1, box, box=line(5))]), group=Overlay, note="A prompt, a one-line field and two buttons: typing goes to the field, Enter takes the button highlighted.", rows=5, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
FileDialog
A listing the caller hands over: this library never touches a file system, so walking the tree stays outside it.
pub fn file_dialog() -> Demo { let dialog = @widget.FileDialog::new( title="Open file", path="~/src/moonetui", mode=Open, filter="mbt", entries=[ @widget.FileEntry::new("..", dir=true), @widget.FileEntry::new("src", dir=true), @widget.FileEntry::new("docs", dir=true), @widget.FileEntry::new("widget.mbt", size=4820), @widget.FileEntry::new("app.mbt", size=3110), @widget.FileEntry::new("README.md", size=812), ], ) Demo::new( "FileDialog", @app.column(0, [@app.leaf(1, dialog, box=line(12))]), group=Overlay, note="A listing the caller hands over: this library never touches a file system, so walking the tree stays outside it.", rows=12, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
CommandPalette
Type part of a name and the list narrows: the query's letters read out of the name in order.
pub fn command_palette() -> Demo { let palette = @widget.CommandPalette::new() palette.add("Open file", hint="read one in", key="ctrl-o") palette.add("Save file", hint="write it out", key="ctrl-s") palette.add("Toggle wrap", key="ctrl-w") palette.add("Switch theme", hint="dark, light, nord") palette.add("Quit", key="ctrl-q") Demo::new( "CommandPalette", @app.column(0, [@app.leaf(1, palette, box=line(9))]), group=Overlay, note="Type part of a name and the list narrows: the query's letters read out of the name in order.", rows=9, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
Charts and meters
Chart
Series of points on two axes: one joined from point to point, one left as the points themselves.
pub fn chart() -> Demo { let load = @widget.Chart::new( datasets=[ @widget.Dataset::new( "cpu", [(0.0, 1.0), (1.0, 3.0), (2.0, 2.0), (3.0, 5.0), (4.0, 4.0), (5.0, 6.0)], style=@style.Style::new(fg=@style.cyan), ), @widget.Dataset::new( "mem", [(0.0, 2.0), (1.0, 2.0), (2.0, 4.0), (3.0, 3.0), (4.0, 5.0), (5.0, 5.0)], kind=Scatter, style=@style.Style::new(fg=@style.magenta), ), ], x=@widget.Axis::new( labels=["0s", "5s", "10s"], bounds=@widget.Bounds::new(low=0.0, high=5.0), title="time", ), y=@widget.Axis::new(bounds=@widget.Bounds::new(low=0.0, high=6.0)), ) Demo::new( "Chart", @app.column(0, [@app.leaf(1, load)]), group=Chart, note="Series of points on two axes: one joined from point to point, one left as the points themselves.", rows=10, ) }
Canvas
Braille dots, four rows and two columns per cell: a wave, its peaks and the baseline it crosses.
pub fn canvas() -> Demo { // One period of a wave, drawn as the segments between its samples, over a // baseline: the plot is in its own coordinates, so the same shapes are a // thumbnail in a narrow column and a full plot here. let shapes : Array[@widget.Shape] = [@widget.Line(0.0, 0.0, 6.283, 0.0)] for step in 0..<96 { let x0 = step.to_double() / 96.0 * 6.283 let x1 = (step + 1).to_double() / 96.0 * 6.283 shapes.push(@widget.Line(x0, @math.sin(x0), x1, @math.sin(x1))) } for peak in [1.5708, 4.7124] { shapes.push(@widget.Dot(peak, 1.0)) } let plot = @widget.Canvas::new( shapes~, x_range=(0.0, 6.283), y_range=(-1.2, 1.2), style=@style.Style::new(fg=@style.cyan), ) Demo::new( "Canvas", @app.column(0, [@app.leaf(1, plot)]), group=Chart, note="Braille dots, four rows and two columns per cell: a wave, its peaks and the baseline it crosses.", rows=10, ) }
BarChart
A column per bar, named along the bottom, the tallest filling the plot unless a scale is given.
pub fn bar_chart() -> Demo { let chart = @widget.BarChart::new( bars=[ @widget.Bar::new( "mon", value=5.0, style=@style.Style::new(fg=@style.cyan), ), @widget.Bar::new("tue", value=8.0), @widget.Bar::new("wed", value=3.0), @widget.Bar::new("thu", value=6.0), @widget.Bar::new("fri", value=9.0), ], values=true, ) Demo::new( "BarChart", @app.column(0, [@app.leaf(1, chart)]), group=Chart, note="A column per bar, named along the bottom, the tallest filling the plot unless a scale is given.", rows=8, ) }
Gauge
How far round a meter is: a word on the left, a bar, and the percentage on the right.
pub fn gauge() -> Demo { let cpu = @widget.Gauge::new(ratio=0.62, label="cpu") let memory = @widget.Gauge::new( ratio=0.35, label="memory", bar_style=@style.Style::new(fg=@style.green), ) let disk = @widget.Gauge::new( ratio=0.91, label="disk", bar_style=@style.Style::new(fg=@style.red), ) Demo::new( "Gauge", @app.column(0, [ @app.leaf(1, cpu, box=line(1)), @app.leaf(2, memory, box=line(1)), @app.leaf(3, disk, box=line(1)), ]), group=Chart, note="How far round a meter is: a word on the left, a bar, and the percentage on the right.", rows=3, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
Scrollbar
A thumb in a track, on either axis: a click goes to that part of the content, and the keys move once it has focus.
pub fn scrollbar() -> Demo { let bar = @widget.Scrollbar::new(content=100, viewport=24) let across = @widget.Scrollbar::new( content=100, viewport=24, vertical=false, thumb_style=@style.Style::new(fg=@style.cyan, reverse=true), ) let lines : Array[@app.Node] = [] for i in 0..<6 { lines.push( @app.leaf( 10 + i, @widget.Static::new("line " + i.to_string()), box=line(1), ), ) } Demo::new( "Scrollbar", @app.column(0, [ @app.row( 1, [ @app.column(2, lines), @app.leaf(3, bar, box=@layout.Box::new(extent=Cells(1))), ], box=line(6), ), @app.leaf(4, across, box=line(1)), ]), group=Chart, note="A thumb in a track, on either axis: a click goes to that part of the content, and the keys move once it has focus.", rows=7, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
Design system
The CSS model you already know — selectors, specificity, cascade, inheritance — applied to the terminal.
Rules and cascade
Give a node a name, an id and classes; write rules against them. Rules stack by specificity — ids, then classes and pseudo-classes, then names, compared in that order as CSS does — then by position, and a node inherits the text style of its container:
let sheet = @design.Stylesheet::new() sheet.add( @design.Sel::new(name="Header"), @design.Styles::new(text=@style.Style::new(bold=true, fg=@style.cyan)), ) sheet.add( @design.Sel::new(classes=["framed"], focus=true), @design.Styles::new(border=Heavy), )
- Selectors — name, id, class, and the
:focus,:hoverand:disabledpseudo-classes. - Properties — border, padding, margin, alignment, display, dock, grid spans, offsets, transitions, scroll-bar styles, and the text style itself.
- Chrome — borders, padding and margins draw behind the children, so a framed container never clips its own frame.
- States — a node the pointer rests on takes
:hover; a disabled one takes:disabledand neither focus nor input. - Transitions — an offset moves a node without telling the layout; a transition glides it to wherever the next layout puts it.
Scroll containers and docks
A pane sizes its child to the child's own content, shows a window of it, draws bars that track the window, and moves by wheel, by the arrow, page, home and end keys, and to whatever just took focus. A docked child sits against an edge of its container, over the flow that gives up the space.
Seen live
Borders
Five kinds of frame, drawn by the design system around any node.
pub fn borders() -> Demo { let kinds : Array[(String, @design.EdgeKind)] = [ ("thin", Thin), ("round", Round), ("heavy", Heavy), ("double", Double), ("ascii", Ascii), ] let boxes = kinds.mapi((i, kind) => { @app.leaf( i + 1, @widget.Static::new(kind.0, align=Centre), box=@layout.Box::new(extent=Frac(1)), styles=@design.Styles::new(border=kind.1), ) }) Demo::new( "Borders", @app.row(0, boxes, gap=1, box=line(3)), group=Style, note="Five kinds of frame, drawn by the design system around any node.", rows=3, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
Colours
The sixteen named colours, the 256-colour cube, and a true-colour sweep cut down to 256 and to 16.
pub fn colours() -> Demo { Demo::new( "Colours", @app.column(0, [@app.leaf(1, Swatches::{ })]), group=Style, note="The sixteen named colours, the 256-colour cube, and a true-colour sweep cut down to 256 and to 16.", rows=5, ) } /// A widget of its own: each row a strip of coloured cells after a label. priv struct Swatches {} impl @widget.Widget for Swatches with fn render_line(_self, row, size) { let label = ["16", "256", "24-bit", "→ 256", "→ 16"] if row < 0 || row >= label.length() { return @strip.Strip::blank(size.width, @style.default) } let lead = @strip.Strip::of(label[row], @style.Style::new(dim=true)).pad_to( 8, @style.default, ) let span = @cmp.maximum(size.width - 8, 0) let cells = Array::makei(span, x => { let colour : @style.Colour = match row { 0 => Ansi(x * 16 / @cmp.maximum(span, 1)) 1 => Ansi256(16 + x * 216 / @cmp.maximum(span, 1)) _ => { let swept = sweep(x, span) match row { 3 => swept.to_ansi256() 4 => swept.to_ansi16() _ => swept } } } @strip.Seg::new(" ", @style.Style::new(bg=colour)) }) @strip.Strip::join([lead, @strip.Strip::from_segs(cells)]) } impl @widget.Widget for Swatches with fn hint(_self, size) { @geom.Size::new(size.width, 5) } impl @widget.Widget for Swatches with fn handle(_self, _ctx, _msg) { false } impl @widget.Widget for Swatches with fn focusable(_self) { false } /// The hue at column `x` of `span`, fully saturated. fn sweep(x : Int32, span : Int32) -> @style.Colour { let h = x.to_double() * 6.0 / @cmp.maximum(span, 1).to_double() let f = h - h.floor() let up = (f * 255.0).to_int() let down = 255 - up match h.to_int() { 0 => @style.Colour::rgb(255, up, 0) 1 => @style.Colour::rgb(down, 255, 0) 2 => @style.Colour::rgb(0, 255, up) 3 => @style.Colour::rgb(0, down, 255) 4 => @style.Colour::rgb(up, 0, 255) _ => @style.Colour::rgb(255, 0, down) } }
Text styles
The SGR attributes every terminal knows, set on any style.
pub fn text_styles() -> Demo { let styles : Array[(String, @style.Style)] = [ ("bold", @style.Style::new(bold=true)), ("dim", @style.Style::new(dim=true)), ("italic", @style.Style::new(italic=true)), ("underline", @style.Style::new(underline=true)), ("strike", @style.Style::new(strike=true)), ("reverse", @style.Style::new(reverse=true)), ] let words = styles.mapi((i, pair) => { @app.leaf( i + 1, @widget.label(pair.0, style=pair.1), box=line(pair.0.length()), ) }) Demo::new( "Text styles", @app.row(0, words, gap=3, box=line(1)), group=Style, note="The SGR attributes every terminal knows, set on any style.", rows=1, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
Docks and fractions
Edge docks take their side first; the flow divides what is left in cells and shares.
pub fn docks() -> Demo { let sheet = @theme.sheet() sheet.add( @design.Sel::new(classes=["pane"]), @design.Styles::new(border=Round), ) sheet.add(@design.Sel::new(name="Header"), @design.Styles::new(dock=Top)) sheet.add(@design.Sel::new(name="Footer"), @design.Styles::new(dock=Bottom)) let pane = (id : Int32, text : String, extent : @layout.Extent) => { @app.leaf( id, @widget.Static::new(text, align=Centre), box=@layout.Box::new(extent~), classes=["pane"], ) } Demo::new( "Docks and fractions", @app.column(0, [ @app.leaf(1, @widget.Header::new("docked to the top"), name="Header"), @app.row(2, [ pane(3, "12 columns", Cells(12)), pane(4, "two shares", Frac(2)), pane(5, "one share", Frac(1)), ]), @app.leaf(6, @widget.Footer::new([("dock", "bottom")]), name="Footer"), ]), group=Style, note="Edge docks take their side first; the flow divides what is left in cells and shares.", rows=7, sheet~, ) }
Anchors
A box held to the edges it names: an axis with both edges held stretches, one with neither keeps its size and sits where its pivot says.
pub fn anchoring() -> Demo { let corners : Array[@app.Node] = [] let pinned : Array[(String, @layout.Anchor)] = [ ("top left", @layout.Anchor::new(top=true, left=true)), ("top right", @layout.Anchor::new(top=true, right=true)), ("bottom left", @layout.Anchor::new(bottom=true, left=true)), ("bottom right", @layout.Anchor::new(bottom=true, right=true)), ] for i, place in pinned { let (word, anchor) = place corners.push( @app.leaf( i + 1, @widget.Static::new(word, align=Centre), styles=@design.Styles::new( width=Cells(16), height=Cells(3), anchor~, align=@design.Align::new(v=@design.Middle), border=@design.Round, ), ), ) } corners.push( @app.leaf( 9, @widget.Static::new("held to nothing, put in the middle", align=Centre), styles=@design.Styles::new( width=Cells(36), height=Cells(3), anchor=@layout.free, pivot=Middle, align=@design.Align::new(v=@design.Middle), border=@design.Round, ), ), ) Demo::new( "Anchors", @app.column(0, corners), group=Style, note="A box held to the edges it names: an axis with both edges held stretches, one with neither keeps its size and sits where its pivot says.", rows=8, ) }
Grid
A grid of columns and rows, with spans and a gutter that loses no column.
pub fn grid() -> Demo { let sheet = @theme.sheet() sheet.add( @design.Sel::new(classes=["cell"]), @design.Styles::new(border=Thin), ) let cell = (id : Int32, text : String) => { @app.leaf(id, @widget.Static::new(text, align=Centre), classes=["cell"]) } Demo::new( "Grid", @app.grid( 0, [ @app.leaf( 1, @widget.Static::new("two columns", align=Centre), classes=["cell"], styles=@design.Styles::new(column_span=2), ), @app.leaf( 2, @widget.Static::new("two rows", align=Centre), classes=["cell"], styles=@design.Styles::new(row_span=2), ), cell(3, "one"), cell(4, "one"), ], cols=3, gutter=1, ), group=Style, note="A grid of columns and rows, with spans and a gutter that loses no column.", rows=6, sheet~, ) }
Theme
One value holding every semantic colour: set it as a whole and everything styled by role changes with it.
pub fn theme() -> Demo { let sheet = @design.dark.sheet() let roles = @design.roles() let swatches : Array[@app.Node] = [] for i, role in roles { swatches.push( @app.leaf( i + 1, @widget.Static::new(role.name(), align=Centre), box=line(1), classes=[role.name() + "-fill"], ), ) } Demo::new( "Theme", @app.column(0, swatches), group=Style, note="One value holding every semantic colour: set it as a whole and everything styled by role changes with it.", rows=11, sheet~, ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
States
Rules for :focus, :hover and :disabled stack over the plain rule by weight.
pub fn states() -> Demo { let sheet = @theme.sheet() sheet.add( @design.Sel::new(classes=["key"]), @design.Styles::new(border=Round), ) sheet.add( @design.Sel::new(classes=["key"], hover=true), @design.Styles::new(text=@style.Style::new(fg=@style.cyan)), ) sheet.add( @design.Sel::new(classes=["key"], focus=true), @design.Styles::new(border=Heavy, text=@style.Style::new(bold=true)), ) sheet.add( @design.Sel::new(classes=["key"], disabled=true), @design.Styles::new(text=@style.Style::new(dim=true)), ) let key = (id : Int32, text : String) => { @app.leaf( id, @widget.Button::new(text, focus_style=@style.default), box=line(14), classes=["key"], ) } Demo::new( "States", @app.row( 0, [key(1, "focus me"), key(2, "hover me"), key(3, "disabled")], gap=1, box=line(3), ), group=Style, note="Rules for :focus, :hover and :disabled stack over the plain rule by weight.", rows=3, sheet~, disabled=[3], ) } fn line(n : Int32) -> @layout.Box { @layout.Box::new(extent=Cells(n)) }
Drivers & terminals
Four operations touch a platform: write, read what is available, set raw mode, and ask for the terminal size. Everything else is pure.
Shipped drivers
| Driver | Environment | Notes |
|---|---|---|
@driver/native | A real terminal | termios on Unix; virtual terminal mode on Windows. |
@driver/node | Node.js | Raw mode, a queue the data handler fills, a frame pump on the clock. |
@driver/web | Browser | A terminal on a canvas — a grid of cells, its own escape handling, key encoding, resize in-band. |
@driver (headless) | Tests | A terminal that understands the sequences — the whole suite runs against it. |
The three terminal worlds
Bare serial UART
A microcontroller and a wire. No cursor addressing, no colour: pass plain=true when the app is built and the renderer sends whole frames instead of diffs — the same cell buffer, written line by line, nothing but text and newlines. Bring a Driver that writes bytes; nothing else changes.
Serial-era terminals
Anything speaking the classic control set: cursor movement, erase, and the eight-colour palette. moonetui emits only the ECMA-48 / ISO 6429 subset these terminals understand — SGR (CSI … m) for style runs, CUP (CSI H) for addressing — and quantises true colour down to the palette the far end actually has.
Modern terminals
The full feature set: true colour, box-drawing glyphs, double-width CJK and emoji, bracketed paste, SGR mouse reports, focus events. The differential renderer keeps the wire quiet between frames.
Standards
- Unicode — every line is measured in terminal columns over a generated width table: wide CJK characters, double-width emoji, combining marks. Alignment and padding are never guesses.
- ECMA-48 / ISO 6429 — the control sequences moonetui emits follow the international standard for control functions for coded character sets: SGR for character attributes, CUP and friends for cursor addressing, ED for erase. A terminal built to the standard renders moonetui output without negotiation.
- UTF-8 — the input side decodes UTF-8 incrementally, so a code point split across two reads arrives whole.
Testing
The same suite on four backends — a regression in one world fails loudly everywhere.
Run the suite
moon check --target all --deny-warn
moon build --target all
moon test --target all
moon fmt && moon info --target all # the diff must stay clean
What the suite covers
- Geometry and strips — rectangle algebra, clipping at character boundaries, Unicode width.
- The parser — CSI and SS3 sequences, modifiers, mouse, paste, split UTF-8, and sequences it should pass over whole.
- The virtual terminal — cursor movement, erasing, private modes, string sequences and scrolling, so output can be checked cell by cell.
- The compositor — rows from placements, diffs from consecutive frames, spans to escape sequences.
- Layout and design — axis and grid placement, the cascade, inheritance, chrome behind children.
- Every widget — each one's keyboard contract, message shape and rendered rows asserted against expected text.
- Every demo — each one in the gallery starts in a headless application and draws, so the examples on this site cannot rot.
CI runs the whole gate on Ubuntu, macOS and Windows on every pull request and every push to master, and a tag publishes the module to mooncakes.
API reference
Every public type, value and function, package by package, read from the interfaces moon info writes.
geommoonbitstack/moonetui/geom
Integer rectangles. Operations clamp rather than raise: off screen is empty.
typeOffset
pub(all) struct Offset { x : Int32 y : Int32 }
Add, Neg, Subpub fn Offset::add(Self, Self) -> Self
pub fn Offset::is_origin(Self) -> Bool
pub fn Offset::neg(Self) -> Self
pub fn Offset::scale(Self, Int32) -> Self
pub fn Offset::sub(Self, Self) -> Self
pub fn Offset::transpose(Self) -> Self
typeRegion
pub(all) struct Region { x : Int32 y : Int32 width : Int32 height : Int32 }
pub fn Region::area(Self) -> Int32
pub fn Region::bottom(Self) -> Int32
pub fn Region::clip(Self, Int32, Int32) -> Self
pub fn Region::contains(Self, Int32, Int32) -> Bool
pub fn Region::contains_region(Self, Self) -> Bool
pub fn Region::from_corners(Int32, Int32, Int32, Int32) -> Self
pub fn Region::intersection(Self, Self) -> Self
pub fn Region::is_empty(Self) -> Bool
pub fn Region::new(Int32, Int32, Int32, Int32) -> Self
pub fn Region::offset(Self) -> Offset
pub fn Region::overlaps(Self, Self) -> Bool
pub fn Region::right(Self) -> Int32
pub fn Region::size(Self) -> Size
pub fn Region::split_horizontal(Self, Int32) -> (Self, Self)
pub fn Region::split_vertical(Self, Int32) -> (Self, Self)
pub fn Region::translate(Self, Offset) -> Self
pub fn Region::union(Self, Self) -> Self
typeSize
pub(all) struct Size { width : Int32 height : Int32 }
pub fn Size::area(Self) -> Int32
pub fn Size::clamp_offset(Self, Offset) -> Offset
pub fn Size::contains(Self, Int32, Int32) -> Bool
pub fn Size::is_empty(Self) -> Bool
pub fn Size::new(Int32, Int32) -> Self
pub fn Size::region(Self) -> Region
typeSpacing
pub(all) struct Spacing { top : Int32 right : Int32 bottom : Int32 left : Int32 }
pub fn Spacing::add(Self, Self) -> Self
pub fn Spacing::all(Int32) -> Self
pub fn Spacing::grow_region(Self, Region) -> Region
pub fn Spacing::height(Self) -> Int32
pub fn Spacing::horizontal(Int32) -> Self
pub fn Spacing::is_zero(Self) -> Bool
pub fn Spacing::shrink_region(Self, Region) -> Region
pub fn Spacing::vertical(Int32) -> Self
pub fn Spacing::width(Self) -> Int32
letorigin
pub let origin : Offset
stylemoonbitstack/moonetui/style
Colours, attributes and differential SGR: a cell emits only what changed.
typeAttrs
pub(all) struct Attrs { bold : Bool dim : Bool italic : Bool underline : Bool blink : Bool reverse : Bool strike : Bool }
pub fn Attrs::drops_from(Self, Self) -> Bool
pub fn Attrs::is_plain(Self) -> Bool
pub fn Attrs::union(Self, Self) -> Self
typeColour
pub(all) enum Colour { Default Ansi(Int32) Ansi256(Int32) Rgb(Int32, Int32, Int32) }
pub fn Colour::blend(Self, Self, Int32) -> Self
pub fn Colour::parse(String) -> Self?
pub fn Colour::rgb(Int32, Int32, Int32) -> Self
pub fn Colour::to_ansi16(Self) -> Self
pub fn Colour::to_ansi256(Self) -> Self
pub fn Colour::to_rgb(Self) -> (Int32, Int32, Int32)?
typePalette
pub(all) struct Palette { named : Array[(Int32, Int32, Int32)] }
The sixteen named colours as whatever paints the cells resolves them, in terminal order: black, red, green, yellow, blue, magenta, cyan and white, then their bright forms. A terminal lets its user choose these; a driver that paints for itself, such as a canvas, takes them from here. An entry left out resolves as the standard table does.
pub fn Palette::rgb(Self, Colour) -> (Int32, Int32, Int32)?
colour as red, green and blue under this palette, None for the default. The first sixteen of the 256 are the named colours, as in a terminal.
typeStyle
pub(all) struct Style { fg : Colour bg : Colour attrs : Attrs }
pub fn Style::is_default(Self) -> Bool
pub fn Style::merge(Self, Self) -> Self
pub fn Style::new(fg? : Colour, bg? : Colour, bold? : Bool, dim? : Bool, italic? : Bool, underline? : Bool, blink? : Bool, reverse? : Bool, strike? : Bool) -> Self
pub fn Style::swap(Self) -> Self
pub fn Style::to_ansi16(Self) -> Self
pub fn Style::to_ansi256(Self) -> Self
letblack
pub let black : Colour
letblue
pub let blue : Colour
letbright_black
pub let bright_black : Colour
letbright_blue
pub let bright_blue : Colour
letbright_cyan
pub let bright_cyan : Colour
letbright_green
pub let bright_green : Colour
letbright_magenta
pub let bright_magenta : Colour
letbright_red
pub let bright_red : Colour
letbright_white
pub let bright_white : Colour
letbright_yellow
pub let bright_yellow : Colour
letcyan
pub let cyan : Colour
letdefault
pub let default : Style
letgreen
pub let green : Colour
letmagenta
pub let magenta : Colour
letpalette
pub let palette : Palette
The standard table that Colour::to_rgb and the quantisers use, so a driver paints what the rest of the library assumes unless it is told otherwise.
letplain
pub let plain : Attrs
letred
pub let red : Colour
letreset
pub let reset : String
letwhite
pub let white : Colour
letyellow
pub let yellow : Colour
fndelta
pub fn delta(Style, Style) -> String
fnrender
pub fn render(Style) -> String
stripmoonbitstack/moonetui/strip
One rendered line, measured in columns once, when a segment is built.
typeSeg
pub(all) struct Seg { text : String style : @style.Style cells : Int32 }
pub fn Seg::new(String, @style.Style) -> Self
typeStrip
pub(all) struct Strip { segs : Array[Seg] cells : Int32 }
pub fn Strip::apply(Self, @style.Style) -> Self
pub fn Strip::blank(Int32, @style.Style) -> Self
pub fn Strip::cell_length(Self) -> Int32
pub fn Strip::crop(Self, Int32, Int32) -> Self
pub fn Strip::divide(Self, Array[Int32]) -> Array[Self]
pub fn Strip::empty() -> Self
pub fn Strip::from_segs(Array[Seg]) -> Self
pub fn Strip::is_empty(Self) -> Bool
pub fn Strip::join(Array[Self]) -> Self
pub fn Strip::of(String, @style.Style) -> Self
pub fn Strip::pad_to(Self, Int32, @style.Style) -> Self
pub fn Strip::simplify(Self) -> Self
pub fn Strip::text(Self) -> String
fncell_width
pub fn cell_width(Int32) -> Int32
fncells_before
pub fn cells_before(String, Int32) -> Int32
fnclusters
pub fn clusters(String) -> Array[(Int32, Int32, Int32)]
The grapheme clusters of text with the cells each takes, as (start, end, cells) in UTF-16 offsets. A cluster is what a reader sees as one character and a cursor steps over (UAX #29): a letter with its combining marks, an emoji ZWJ sequence, a flag. A ZWJ sequence takes the cells of its first emoji, and a Variation Selector 16 widens a text-style character to two, as terminals draw them. A control character takes none.
fncode_at
pub fn code_at(String, Int32) -> (Int32, Int32)
fncut_at
pub fn cut_at(String, Int32) -> Int32
fnnext_cluster
pub fn next_cluster(String, Int32) -> Int32
Where the cluster after the one at index starts.
fnprev_cluster
pub fn prev_cluster(String, Int32) -> Int32
Where the cluster before index starts.
fnstr_cells
pub fn str_cells(String) -> Int32
layoutmoonbitstack/moonetui/layout
Sizes along an axis. Every split lands on whole cells and adds up to the whole, since a lost column shows as a gap.
typeAnchor
pub(all) struct Anchor { top : Bool right : Bool bottom : Bool left : Bool }
Which edges of the parent a box is held to. A held edge keeps its distance however the parent is sized; an axis with both of its edges held stretches the box to fill what lies between them. A box held to no edge keeps the size it asked for and sits where its pivot says.
pub fn Anchor::is_free(Self) -> Bool
pub fn Anchor::new(top? : Bool, right? : Bool, bottom? : Bool, left? : Bool) -> Self
pub fn Anchor::spans_x(Self) -> Bool
Whether both horizontal edges are held, which stretches the box across.
pub fn Anchor::spans_y(Self) -> Bool
Whether both vertical edges are held, which stretches the box down.
typeBox
pub(all) struct Box { extent : Extent min : Int32 max : Int32 pad : @geom.Spacing }
A max of -1 means unbounded, which no real limit can be confused with.
pub fn Box::new(extent? : Extent, min? : Int32, max? : Int32, pad? : @geom.Spacing) -> Self
typeDir
pub(all) enum Dir { Vertical Horizontal }
typeExtent
pub(all) enum Extent { Auto Cells(Int32) Frac(Int32) Pct(Int32) }
typeGridChild
pub(all) struct GridChild { col_span : Int32 row_span : Int32 height : Int32 }
pub fn GridChild::new(col_span? : Int32, row_span? : Int32, height? : Int32) -> Self
typePivot
pub(all) enum Pivot { TopLeft TopCentre TopRight MiddleLeft Middle MiddleRight BottomLeft BottomCentre BottomRight }
Where a box no edge holds sits in the space its parent left it.
pub fn Pivot::frac_x(Self) -> Double
How far across the free space the box starts, as a fraction of it.
pub fn Pivot::frac_y(Self) -> Double
How far down the free space the box starts, as a fraction of it.
letcentre
pub let centre : Pivot
letfree
pub let free : Anchor
Held to nothing: the box floats, placed by its pivot.
letstretch
pub let stretch : Anchor
Held to every edge: the box fills its parent.
fnanchor_region
pub fn anchor_region(@geom.Region, @geom.Size, anchor? : Anchor, pivot? : Pivot, margin? : @geom.Spacing) -> @geom.Region
Where want lands inside area: held to the edges anchor names, or, on an axis no edge holds, of the size it asked for and put where pivot says. margin holds the box off the parent before either is applied.
fnarrange
pub fn arrange(@geom.Region, Dir, Array[Box], Array[Int32], gap? : Int32) -> Array[@geom.Region]
fnarrange_grid
pub fn arrange_grid(@geom.Region, Array[(Int32, Int32)], Array[GridChild], cols~ : Int32, gutter? : Int32) -> Array[@geom.Region]
Regions for the slots grid_slots handed out: equal columns, rows tall enough for their content with the leftover shared out evenly, gutters between cells.
fncorners
pub fn corners() -> Array[Anchor]
The four corners and the four edge midpoints, as anchors: the anchors a bar or a status line is usually given.
fncross_of
pub fn cross_of(@geom.Size, Dir) -> Int32
fngrid_row_heights
pub fn grid_row_heights(Array[GridChild], Array[(Int32, Int32)]) -> Array[Int32]
What each row of the grid asks for: the tallest child that touches it, counting a spanning child's height once per row it covers.
fngrid_slots
pub fn grid_slots(Array[GridChild], cols~ : Int32, rows? : Int32) -> Array[(Int32, Int32)]
The cell each child lands in, row-major over the first free block that fits its spans. A rows of zero or less grows rows until every child fits, which is how a grid without a row count grows.
fnmain_of
pub fn main_of(@geom.Size, Dir) -> Int32
fnpivots
pub fn pivots() -> Array[Pivot]
The nine pivots, in the order they read: across, then down.
eventmoonbitstack/moonetui/event
Keys, mouse reports, pastes, resizes and focus, as plain values.
typeEvent
pub(all) enum Event { Key(Key) Mouse(Mouse) Paste(String) Resize(Int32, Int32) FocusIn FocusOut }
typeKey
pub(all) struct Key { code : KeyCode mods : Mods }
pub fn Key::char(Int32) -> Self
pub fn Key::of(KeyCode) -> Self
pub fn Key::with_mods(KeyCode, Mods) -> Self
typeKeyCode
pub(all) enum KeyCode { Char(Int32) Enter Tab BackTab Backspace Delete Escape Insert Up Down Left Right Home End PageUp PageDown F(Int32) }
typeMods
pub(all) struct Mods { ctrl : Bool alt : Bool shift : Bool }
pub fn Mods::is_none(Self) -> Bool
pub fn Mods::of_param(Int32) -> Self
typeMouse
pub(all) struct Mouse { kind : MouseKind button : Int32 x : Int32 y : Int32 mods : Mods }
typeMouseKind
pub(all) enum MouseKind { Down Up Move ScrollUp ScrollDown ScrollLeft ScrollRight }
letnone
pub let none : Mods
inputmoonbitstack/moonetui/input
The terminal's byte stream to events, one parser for every platform.
typeParser
pub struct Parser { mut buf : Array[Int32] mut head : Int32 mut pasting : Bool pasted : StringBuilder }
pub fn Parser::feed(Self, Bytes, Array[@event.Event]) -> Unit
pub fn Parser::idle(Self, Array[@event.Event]) -> Unit
pub fn Parser::new() -> Self
pub fn Parser::pending(Self) -> Int32
pub fn Parser::reset(Self) -> Unit
vtmoonbitstack/moonetui/vt
The screen an escape stream draws, for the browser driver, tests and screenshots.
typeCell
pub(all) struct Cell { text : String style : @style.Style }
compmoonbitstack/moonetui/comp
Placements to a screen, two screens to the escape sequence between them. Knows nothing of widgets, so it is testable without a terminal.
typeCell
pub(all) struct Cell { text : String style : @style.Style continuation : Bool }
pub fn Cell::blank(@style.Style) -> Self
typePlacement
pub(all) struct Placement { node : Int32 rect : @geom.Region clip : @geom.Region }
pub fn Placement::visible(Self) -> @geom.Region
typeScene
pub(all) struct Scene { size : @geom.Size items : Array[Placement] }
pub fn Scene::compose(Self, (Int32, Int32) -> @strip.Strip, @style.Style) -> Array[@strip.Strip]
pub fn Scene::compose_line(Self, Int32, (Int32, Int32) -> @strip.Strip, @style.Style) -> @strip.Strip
One row of the screen: the first placement covering a column wins it, so nothing is drawn twice and front items hide those behind them.
pub fn Scene::cuts(Self, Int32) -> Array[Int32]
pub fn Scene::new(@geom.Size) -> Self
pub fn Scene::place(Self, Int32, @geom.Region, @geom.Region) -> Unit
typeSpan
pub(all) struct Span { y : Int32 x : Int32 line : @strip.Strip }
letclear
pub let clear : String
fncells
pub fn cells(@strip.Strip) -> Array[Cell]
fncursor_to
pub fn cursor_to(Int32, Int32) -> String
fndiff
pub fn diff(Array[@strip.Strip], Array[@strip.Strip], base? : @style.Style) -> Array[Span]
The spans that turn one screen into the next: one per run of changed cells, so a row with two changes far apart is written as two short spans rather than as everything between them.
fndiff_rows
pub fn diff_rows(Array[@strip.Strip], Array[@strip.Strip], over? : Array[Int32], base? : @style.Style) -> Array[Span]
diff over the rows named, for a frame that only redrew part of the screen: rows outside the list are taken as unchanged.
fnencode
pub fn encode(Array[Span], @style.Style) -> String
fnencode_stream
pub fn encode_stream(Array[Span]) -> String
fnfull
pub fn full(Array[@strip.Strip]) -> Array[Span]
fnline_of
pub fn line_of(ArrayView[Cell], @style.Style) -> @strip.Strip
fnshow_cursor
pub fn show_cursor(Bool) -> String
designmoonbitstack/moonetui/design
Style properties, selectors and the cascade Textual runs, as functions: a selector that type-checks beats a file that parses.
typeAlign
pub(all) struct Align { h : HAlign v : VAlign }
pub fn Align::main_offset(Self, @layout.Dir, Int32) -> Int32
pub fn Align::new(h? : HAlign, v? : VAlign) -> Self
typeDecor
pub(all) struct Decor { border : EdgeKind style : @style.Style size : @geom.Size }
pub fn Decor::frame_line(Self, @geom.Spacing, Int32, @strip.Strip?) -> @strip.Strip
pub fn Decor::line(Self, Int32) -> @strip.Strip
typeDisplay
pub(all) enum Display { Block Hidden }
typeEdge
pub(all) enum Edge { Top Right Bottom Left }
typeEdgeKind
pub(all) enum EdgeKind { Off Ascii Thin Round Double Heavy }
pub fn EdgeKind::glyphs(Self) -> @widget.Border
typeHAlign
pub(all) enum HAlign { Left Centre Right }
typePreset
pub(all) struct Preset { base : @style.Style sheet : Stylesheet }
A starting point: a base text style and a stylesheet of sensible rules, both free to be added to or overridden.
pub fn Preset::dark() -> Self
Light letters on whatever the terminal draws behind them.
pub fn Preset::light() -> Self
Dark letters on a lit background, with scroll bars standing out from it.
typeResolved
pub(all) struct Resolved { hidden : Bool margin : @geom.Spacing padding : @geom.Spacing border : EdgeKind align : Align dock : Edge? anchor : @layout.Anchor? pivot : @layout.Pivot column_span : Int32? row_span : Int32? offset_x : Int32 offset_y : Int32 transition : Int32 scrollbar : @style.Style? width : @layout.Extent? height : @layout.Extent? min_width : Int32? max_width : Int32? min_height : Int32? max_height : Int32? text : @style.Style }
pub fn Resolved::box(Self, @layout.Dir, @layout.Box) -> @layout.Box
pub fn Resolved::content_region(Self, @geom.Region) -> @geom.Region
pub fn Resolved::has_chrome(Self) -> Bool
pub fn Resolved::of(Styles, @style.Style) -> Self
typeRole
pub(all) enum Role { Primary Secondary Accent Surface Panel Text Muted Success Warning Error Border }
What a colour in a theme is for. A widget asks for a role and the theme answers with the colour that role holds, so a whole look changes by swapping one value.
pub fn Role::name(Self) -> String
The class a rule carries for this role: the name a stylesheet is written against, so a theme can be applied without naming its colours.
pub fn Role::note(Self) -> String
What the role is for, as one line.
typeRule
pub(all) struct Rule { sel : Sel styles : Styles }
pub fn Rule::new(Sel, Styles) -> Self
typeSel
pub(all) struct Sel { name : String id : Int32 classes : Array[String] focus : Bool hover : Bool disabled : Bool }
pub fn Sel::matches(Self, String, Int32, Array[String], Bool, Bool, Bool) -> Bool
pub fn Sel::new(name? : String, id? : Int32, classes? : Array[String], focus? : Bool, hover? : Bool, disabled? : Bool) -> Self
pub fn Sel::specificity(Self) -> Int32
The CSS weight of the selector: ids, then classes and pseudo-classes, then names, packed so that one number orders the same way the triple does.
typeStyles
pub(all) struct Styles { display : Display? width : @layout.Extent? height : @layout.Extent? min_width : Int32? max_width : Int32? min_height : Int32? max_height : Int32? padding : @geom.Spacing? margin : @geom.Spacing? border : EdgeKind? align : Align? dock : Edge? anchor : @layout.Anchor? pivot : @layout.Pivot? column_span : Int32? row_span : Int32? offset_x : Int32? offset_y : Int32? transition : Int32? scrollbar : @style.Style? text : @style.Style? }
pub fn Styles::is_empty(Self) -> Bool
pub fn Styles::merge(Self, Self) -> Self
pub fn Styles::new(display? : Display, width? : @layout.Extent, height? : @layout.Extent, min_width? : Int32, max_width? : Int32, min_height? : Int32, max_height? : Int32, padding? : @geom.Spacing, margin? : @geom.Spacing, border? : EdgeKind, align? : Align, dock? : Edge, anchor? : @layout.Anchor, pivot? : @layout.Pivot, column_span? : Int32, row_span? : Int32, offset_x? : Int32, offset_y? : Int32, transition? : Int32, scrollbar? : @style.Style, text? : @style.Style) -> Self
typeStylesheet
pub(all) struct Stylesheet { rules : Array[Rule] }
pub fn Stylesheet::add(Self, Sel, Styles) -> Unit
pub fn Stylesheet::append(Self, Self) -> Unit
Every rule of other after this sheet's own, which is how a theme's rules and a caller's are combined: the ones added last win.
pub fn Stylesheet::is_empty(Self) -> Bool
pub fn Stylesheet::list(Self) -> Array[Rule]
pub fn Stylesheet::new() -> Self
pub fn Stylesheet::pick(Self, String, Int32, Array[String], Bool, hovered? : Bool, disabled? : Bool) -> Styles
typeTheme
pub(all) struct Theme { name : String primary : @style.Colour secondary : @style.Colour accent : @style.Colour surface : @style.Colour panel : @style.Colour text : @style.Colour muted : @style.Colour success : @style.Colour warning : @style.Colour error : @style.Colour border : @style.Colour }
A set of semantic colours as one value: everything a look is made of, switched as a whole.
pub fn Theme::base(Self) -> @style.Style
What the tree inherits: the text colour on the surface.
pub fn Theme::colour(Self, Role) -> @style.Colour
The colour this role holds.
pub fn Theme::fg(Self, Role) -> @style.Style
Words in this role's colour.
pub fn Theme::fill(Self, Role) -> @style.Style
A ground in this role's colour.
pub fn Theme::new(name? : String, primary? : @style.Colour, secondary? : @style.Colour, accent? : @style.Colour, surface? : @style.Colour, panel? : @style.Colour, text? : @style.Colour, muted? : @style.Colour, success? : @style.Colour, warning? : @style.Colour, error? : @style.Colour, border? : @style.Colour) -> Self
A theme of the default look, with any role left out taken from dark.
pub fn Theme::of(String) -> Self?
The theme of that name, if there is one.
pub fn Theme::set(Self, Role, @style.Colour) -> Self
This theme with one role's colour changed; every other role is kept.
pub fn Theme::sheet(Self) -> Stylesheet
The theme as rules: one class per role for words in its colour, and one class per role for a ground in it, so set_sheet with this switches everything styled by role at once.
typeVAlign
pub(all) enum VAlign { Top Middle Bottom }
letbare
pub let bare : Resolved
letdark
pub let dark : Theme
The dark look: light words on a near-black ground, the site's own colours.
letempty
pub let empty : Styles
letlight
pub let light : Theme
The light look: the same roles on a paper-white ground.
letnord
pub let nord : Theme
The Nord look: the Polar Night ground, Snow Storm words and the Frost and Aurora colours.
fnroles
pub fn roles() -> Array[Role]
fnthemes
pub fn themes() -> Array[Theme]
Every theme this library carries.
widgetmoonbitstack/moonetui/widget
Widgets render lines and say what they want as values, so they test without an application.
traitWidget
pub(open) trait Widget { fn render_line(Self, Int32, @geom.Size) -> @strip.Strip fn hint(Self, @geom.Size) -> @geom.Size fn handle(Self, Ctx, Msg) -> Bool fn focusable(Self) -> Bool }
typeAlign
pub(all) enum Align { Left Centre Right }
typeAxis
pub(all) struct Axis { title : String labels : Array[String] bounds : Bounds style : @style.Style }
One side of a plot: the words along it and the stretch they cover.
pub fn Axis::new(labels? : Array[String], bounds? : Bounds, title? : String, style? : @style.Style) -> Self
typeBar
pub(all) struct Bar { label : String value : Double style : @style.Style? }
One column of a bar chart: what it is called, how tall it stands, and the colour it is drawn in when it has one of its own.
pub fn Bar::new(String, value? : Double, style? : @style.Style) -> Self
typeBarChart
pub struct BarChart { mut bars : Array[Bar] mut max : Double? gap : Int32 values : Bool style : @style.Style bar_style : @style.Style label_style : @style.Style }
Columns of heights, named along the bottom.
The tallest bar fills the plot unless a max is given, which is how several charts are held to one scale.
Widgetpub fn BarChart::bars(Self) -> Array[Bar]
pub fn BarChart::focusable(Self) -> Bool
pub fn BarChart::handle(Self, Ctx, Msg) -> Bool
pub fn BarChart::hint(Self, @geom.Size) -> @geom.Size
pub fn BarChart::new(bars? : Array[Bar], max? : Double, gap? : Int32, values? : Bool, style? : @style.Style, bar_style? : @style.Style, label_style? : @style.Style) -> Self
pub fn BarChart::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn BarChart::scale(Self) -> Double
What the tallest column is measured against.
pub fn BarChart::set_bars(Self, Array[Bar]) -> Unit
pub fn BarChart::set_max(Self, Double?) -> Unit
Hold every bar to this scale, or let the tallest one set it.
typeBlock
pub struct Block { inner : &Widget border : Border? mut title : String title_align : Align padding : @geom.Spacing style : @style.Style border_style : @style.Style title_style : @style.Style }
A frame, a title and padding around any other widget. The widget inside is drawn and driven at the size the frame leaves it, so a Block goes round a widget without that widget knowing.
Widgetpub fn Block::focusable(Self) -> Bool
pub fn Block::handle(Self, Ctx, Msg) -> Bool
pub fn Block::hint(Self, @geom.Size) -> @geom.Size
pub fn Block::new(&Widget, title? : String, border? : Border?, padding? : @geom.Spacing, title_align? : Align, style? : @style.Style, border_style? : @style.Style, title_style? : @style.Style) -> Self
pub fn Block::padding_of(Self) -> @geom.Spacing
How many rows and columns the frame and padding take off each side.
pub fn Block::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Block::set_title(Self, String) -> Unit
pub fn Block::title(Self) -> String
typeBorder
pub(all) struct Border { top_left : String top : String top_right : String left : String right : String bottom_left : String bottom : String bottom_right : String }
typeBounds
pub(all) struct Bounds { low : Double high : Double }
The stretch of values an axis covers. A high no greater than low is taken from the data instead.
pub fn Bounds::new(low? : Double, high? : Double) -> Self
pub fn Bounds::span(Self) -> Double
typeButton
pub struct Button { mut text : String style : @style.Style focus_style : @style.Style mut disabled : Bool mut focused : Bool }
Widgetpub fn Button::disable(Self, Bool) -> Unit
pub fn Button::focusable(Self) -> Bool
pub fn Button::handle(Self, Ctx, Msg) -> Bool
pub fn Button::has_focus(Self) -> Bool
pub fn Button::hint(Self, @geom.Size) -> @geom.Size
pub fn Button::is_disabled(Self) -> Bool
pub fn Button::new(String, style? : @style.Style, focus_style? : @style.Style) -> Self
pub fn Button::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Button::set(Self, String) -> Unit
pub fn Button::text(Self) -> String
typeCalendar
pub struct Calendar { mut date : @moondate.Date style : @style.Style title_style : @style.Style weekday_style : @style.Style day_style : @style.Style selected_style : @style.Style }
A month laid out as a grid, one day picked out: the title, the weekdays and six rows of days, Monday first.
The arrows walk a day or a week, Page Up and Page Down walk a month, Home and End go to the ends of the month, and a click on a day goes to it.
Widgetpub fn Calendar::date(Self) -> @moondate.Date
The day picked out.
pub fn Calendar::focusable(Self) -> Bool
pub fn Calendar::handle(Self, Ctx, Msg) -> Bool
pub fn Calendar::height(Self) -> Int32
How many rows a whole month is drawn in, title and weekdays included.
pub fn Calendar::hint(Self, @geom.Size) -> @geom.Size
pub fn Calendar::new(date? : @moondate.Date, style? : @style.Style, title_style? : @style.Style, weekday_style? : @style.Style, day_style? : @style.Style, selected_style? : @style.Style) -> Self
pub fn Calendar::on(Int32, Int32, Int32, style? : @style.Style, title_style? : @style.Style, weekday_style? : @style.Style, day_style? : @style.Style, selected_style? : @style.Style) -> Self
A calendar on a day given as three numbers, each held to a real one: a builder for callers that know the date rather than hold a Date.
pub fn Calendar::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Calendar::set_date(Self, @moondate.Date) -> Unit
Pick a day out; the month on show follows it.
typeCanvas
pub struct Canvas { mut shapes : Array[Shape] mut x_range : (Double, Double) mut y_range : (Double, Double) style : @style.Style mut dots : Array[Bool] mut dots_width : Int32 mut dots_height : Int32 mut drawn_width : Int32 mut drawn_height : Int32 }
A plot drawn with Braille dots: each cell of the terminal is two dots wide and four tall, which is the finest grid a terminal without images offers.
The canvas draws into whatever size the layout gives it, so the same shapes are a thumbnail in a sidebar and a full plot in the main pane. x_range and y_range say what coordinates the shape values are in; y grows upwards, as a plot does, though the rows of a terminal grow down.
Widgetpub fn Canvas::draw(Self, Shape) -> Unit
Adds one shape to what is already there.
pub fn Canvas::focusable(Self) -> Bool
pub fn Canvas::handle(Self, Ctx, Msg) -> Bool
pub fn Canvas::hint(Self, @geom.Size) -> @geom.Size
pub fn Canvas::new(shapes? : Array[Shape], x_range? : (Double, Double), y_range? : (Double, Double), style? : @style.Style) -> Self
pub fn Canvas::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Canvas::set_range(Self, x_range~ : (Double, Double), y_range~ : (Double, Double)) -> Unit
The coordinates the shapes are read in. y grows upwards.
pub fn Canvas::set_shapes(Self, Array[Shape]) -> Unit
pub fn Canvas::shapes(Self) -> Array[Shape]
pub fn Canvas::x_range(Self) -> (Double, Double)
pub fn Canvas::y_range(Self) -> (Double, Double)
typeChart
pub struct Chart { mut datasets : Array[Dataset] mut x : Axis mut y : Axis legend : Bool style : @style.Style axis_style : @style.Style label_style : @style.Style }
Points on two axes, one or more series of them, and a legend: a plot that fits whatever box it is given.
A series drawn as a line is joined across the columns between its points; one drawn as scatter keeps to the points themselves.
Widgetpub fn Chart::bounds(Self) -> Bounds
The stretch the vertical axis covers: what it was given, or what the data spans with a little room above.
pub fn Chart::datasets(Self) -> Array[Dataset]
pub fn Chart::focusable(Self) -> Bool
pub fn Chart::handle(Self, Ctx, Msg) -> Bool
pub fn Chart::hint(Self, @geom.Size) -> @geom.Size
pub fn Chart::new(datasets? : Array[Dataset], x? : Axis, y? : Axis, legend? : Bool, style? : @style.Style, axis_style? : @style.Style, label_style? : @style.Style) -> Self
pub fn Chart::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Chart::set_datasets(Self, Array[Dataset]) -> Unit
pub fn Chart::set_x(Self, Axis) -> Unit
pub fn Chart::set_y(Self, Axis) -> Unit
typeCheckbox
pub struct Checkbox { mut label : String mut value : Bool button_first : Bool on_style : @style.Style off_style : @style.Style label_style : @style.Style focus_style : @style.Style mut focused : Bool }
Widgetpub fn Checkbox::focusable(Self) -> Bool
pub fn Checkbox::handle(Self, Ctx, Msg) -> Bool
pub fn Checkbox::hint(Self, @geom.Size) -> @geom.Size
pub fn Checkbox::label(Self) -> String
pub fn Checkbox::new(String, value? : Bool, button_first? : Bool, on_style? : @style.Style, off_style? : @style.Style, label_style? : @style.Style, focus_style? : @style.Style) -> Self
pub fn Checkbox::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Checkbox::set_label(Self, String) -> Unit
pub fn Checkbox::set_value(Self, Bool) -> Unit
Set the value without reporting it, for programmatic changes.
pub fn Checkbox::toggle(Self) -> Unit
pub fn Checkbox::value(Self) -> Bool
typeChoice
pub(all) struct Choice { prompt : String mut disabled : Bool divider : Bool }
pub fn Choice::new(String, disabled? : Bool) -> Self
typeClock
pub(all) struct Clock { mut hour : Int32 mut minute : Int32 mut second : Int32 mut carry : Int32 }
A time of day that counts itself forward from the frames it is given, so a clock runs off the same Tick every other widget sees and needs no clock of the host's.
pub fn Clock::advance(Self, Int32) -> Bool
Move on by ms milliseconds, answering whether the time it shows changed, which is all a caller needs to know to ask for a frame.
pub fn Clock::hour(Self) -> Int32
pub fn Clock::minute(Self) -> Int32
pub fn Clock::new(hour? : Int32, minute? : Int32, second? : Int32) -> Self
pub fn Clock::second(Self) -> Int32
pub fn Clock::seconds(Self) -> Int32
Seconds since midnight, which is what two clocks are compared by.
pub fn Clock::set(Self, hour~ : Int32, minute~ : Int32, second~ : Int32) -> Unit
pub fn Clock::text(Self) -> String
The time as it is shown: hours, minutes and seconds, two digits each.
typeCollapsible
pub struct Collapsible { mut title : String mut collapsed : Bool collapsed_symbol : String expanded_symbol : String contents : &Widget mut focused : Bool mut hover : Bool bar_style : @style.Style title_style : @style.Style hover_style : @style.Style focus_style : @style.Style style : @style.Style }
Widgetpub fn Collapsible::focusable(Self) -> Bool
pub fn Collapsible::handle(Self, Ctx, Msg) -> Bool
pub fn Collapsible::hint(Self, @geom.Size) -> @geom.Size
pub fn Collapsible::is_collapsed(Self) -> Bool
pub fn Collapsible::new(title~ : String, contents~ : &Widget, collapsed? : Bool, collapsed_symbol? : String, expanded_symbol? : String, bar_style? : @style.Style, title_style? : @style.Style, hover_style? : @style.Style, focus_style? : @style.Style, style? : @style.Style) -> Self
pub fn Collapsible::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Collapsible::set_collapsed(Self, Bool) -> Unit
pub fn Collapsible::set_title(Self, String) -> Unit
pub fn Collapsible::title(Self) -> String
typeColumn
pub(all) struct Column { label : String width : Int32 align : Align }
pub fn Column::new(String, width? : Int32, align? : Align) -> Self
typeCommand
pub(all) struct Command { name : String hint : String key : String }
One thing the application can do, as the palette lists it.
pub fn Command::new(String, hint? : String, key? : String) -> Self
typeCommandPalette
pub struct CommandPalette { commands : Array[Command] mut query : String mut highlighted : Int32 mut offset : Int32 mut seen : Int32 mut run : Int32 mut focused : Bool style : @style.Style hint_style : @style.Style key_style : @style.Style border_style : @style.Style field_style : @style.Style highlight : @style.Style blurred_highlight : @style.Style }
A field and a list: what a program puts up when the user is to find one of many commands by typing part of its name.
Typing narrows the list, the arrows move over what is left, Enter runs the one highlighted and Escape closes. A match is the query's characters appearing in the name in order, so opn finds Open file.
Widgetpub fn CommandPalette::add(Self, String, hint? : String, key? : String) -> Unit
pub fn CommandPalette::commands(Self) -> Array[Command]
pub fn CommandPalette::focusable(Self) -> Bool
pub fn CommandPalette::handle(Self, Ctx, Msg) -> Bool
pub fn CommandPalette::hint(Self, @geom.Size) -> @geom.Size
pub fn CommandPalette::matches(Self) -> Array[Int32]
What the query narrows the list to, best first, as places in the list of commands.
pub fn CommandPalette::new(commands? : Array[Command], style? : @style.Style, hint_style? : @style.Style, key_style? : @style.Style, border_style? : @style.Style, field_style? : @style.Style, highlight? : @style.Style, blurred_highlight? : @style.Style) -> Self
pub fn CommandPalette::query(Self) -> String
pub fn CommandPalette::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn CommandPalette::run(Self) -> Int32?
The command run, if one has been.
pub fn CommandPalette::set_query(Self, String) -> Unit
typeContentSwitcher
pub struct ContentSwitcher { children : Array[&Widget] mut current : Int32 mut focused : Bool }
Several widgets in one place, one showing at a time: what a screen puts where the same space holds different content.
The one showing is drawn, measured, given the input and asked whether it takes focus, so the switcher is invisible to everything around it.
Widgetpub fn ContentSwitcher::add(Self, &Widget) -> Unit
pub fn ContentSwitcher::count(Self) -> Int32
pub fn ContentSwitcher::current(Self) -> Int32
Which one is showing.
pub fn ContentSwitcher::focusable(Self) -> Bool
pub fn ContentSwitcher::handle(Self, Ctx, Msg) -> Bool
pub fn ContentSwitcher::hint(Self, @geom.Size) -> @geom.Size
pub fn ContentSwitcher::new(children? : Array[&Widget], current? : Int32) -> Self
pub fn ContentSwitcher::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn ContentSwitcher::switch_to(Self, Int32) -> Unit
Put another one in its place, held to the ones there are.
typeCtx
pub struct Ctx { id : Int32 size : @geom.Size focused : Bool out : Array[Out] }
pub fn Ctx::asked(Self) -> Array[Out]
pub fn Ctx::emit(Self, Out) -> Unit
pub fn Ctx::new(Int32, @geom.Size, focused? : Bool) -> Self
pub fn Ctx::repaint(Self) -> Unit
typeCursorType
pub(all) enum CursorType { Cell Row Column None }
typeDataTable
pub struct DataTable { mut columns : Array[Column] mut rows : Array[Row] mut cursor_row : Int32 mut cursor_col : Int32 cursor_type : CursorType show_cursor : Bool zebra : Bool show_header : Bool show_row_labels : Bool cell_padding : Int32 mut hover_row : Int32 mut hover_col : Int32 mut offset_x : Int32 mut offset_y : Int32 mut seen : Int32 mut focused : Bool header_style : @style.Style cursor_style : @style.Style hover_style : @style.Style odd_style : @style.Style even_style : @style.Style label_style : @style.Style style : @style.Style }
Widgetpub fn DataTable::add_column(Self, String, width? : Int32, align? : Align) -> Int32
pub fn DataTable::add_row(Self, Array[String], label? : String) -> Int32
pub fn DataTable::cell(Self, Int32, Int32) -> String
pub fn DataTable::clear(Self) -> Unit
pub fn DataTable::clear_rows(Self) -> Unit
pub fn DataTable::column_count(Self) -> Int32
pub fn DataTable::column_width(Self, Int32) -> Int32
pub fn DataTable::content_width(Self) -> Int32
pub fn DataTable::cursor_col(Self) -> Int32
pub fn DataTable::cursor_row(Self) -> Int32
pub fn DataTable::focusable(Self) -> Bool
pub fn DataTable::handle(Self, Ctx, Msg) -> Bool
pub fn DataTable::hint(Self, @geom.Size) -> @geom.Size
pub fn DataTable::line_count(Self) -> Int32
pub fn DataTable::move_cursor(Self, row~ : Int32, col~ : Int32) -> Unit
pub fn DataTable::new(show_header? : Bool, show_row_labels? : Bool, zebra? : Bool, cursor_type? : CursorType, cell_padding? : Int32, header_style? : @style.Style, cursor_style? : @style.Style, hover_style? : @style.Style, odd_style? : @style.Style, even_style? : @style.Style, label_style? : @style.Style, style? : @style.Style) -> Self
pub fn DataTable::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn DataTable::row_count(Self) -> Int32
pub fn DataTable::set_cell(Self, Int32, Int32, String) -> Unit
pub fn DataTable::sort(Self, Int32, reverse? : Bool) -> Unit
Sort the rows by column col, keeping rows that compare equal in the order they were in.
typeDataset
pub(all) struct Dataset { name : String kind : GraphKind points : Array[(Double, Double)] style : @style.Style }
One series of points, named and drawn in its own colour.
pub fn Dataset::new(String, Array[(Double, Double)], kind? : GraphKind, style? : @style.Style) -> Self
typeDialogKind
pub(all) enum DialogKind { Info Question Warning Error }
What a message box is telling the user, which sets the mark beside the text and the colour it is drawn in.
pub fn DialogKind::mark(Self) -> String
pub fn DialogKind::style(Self) -> @style.Style
typeDiff
pub struct Diff { mut lines : Array[DiffLine] mut offset : Int32 mut focused : Bool style : @style.Style added_style : @style.Style removed_style : @style.Style hunk_style : @style.Style header_style : @style.Style meta_style : @style.Style }
A difference as a reader of patches expects it: one line a row, added lines marked and coloured, removed lines the other way, headings picked out.
The arrows walk a line or a screen, Home and End go to the ends, and the wheel moves a line.
Widgetpub fn Diff::focusable(Self) -> Bool
pub fn Diff::handle(Self, Ctx, Msg) -> Bool
pub fn Diff::hint(Self, @geom.Size) -> @geom.Size
pub fn Diff::lines(Self) -> Array[DiffLine]
pub fn Diff::new(lines? : Array[DiffLine], offset? : Int32, style? : @style.Style, added_style? : @style.Style, removed_style? : @style.Style, hunk_style? : @style.Style, header_style? : @style.Style, meta_style? : @style.Style) -> Self
pub fn Diff::of_unified(String, style? : @style.Style, added_style? : @style.Style, removed_style? : @style.Style, hunk_style? : @style.Style, header_style? : @style.Style, meta_style? : @style.Style) -> Self
Read a unified difference: the --- and +++ pair, the @@ headings, the + and - lines, and the git notes above them.
A unified difference prefixes every line it carries, so a blank line is the one byte of padding above or below a patch and is dropped. A line that starts with none of those marks reads as context.
pub fn Diff::offset(Self) -> Int32
The line the view starts at.
pub fn Diff::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Diff::set_lines(Self, Array[DiffLine]) -> Unit
pub fn Diff::set_offset(Self, Int32) -> Unit
pub fn Diff::stats(Self) -> (Int32, Int32)
How many lines were added and how many removed.
typeDiffLine
pub(all) struct DiffLine { kind : LineKind text : String }
One line, with what it is.
pub fn DiffLine::kind(Self) -> LineKind
pub fn DiffLine::new(kind? : LineKind, text? : String) -> Self
pub fn DiffLine::text(Self) -> String
typeDigits
pub struct Digits { mut value : String style : @style.Style }
Widgetpub fn Digits::focusable(Self) -> Bool
pub fn Digits::handle(Self, Ctx, Msg) -> Bool
pub fn Digits::hint(Self, @geom.Size) -> @geom.Size
pub fn Digits::new(value? : String, style? : @style.Style) -> Self
pub fn Digits::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Digits::update(Self, String) -> Unit
pub fn Digits::value(Self) -> String
pub fn Digits::width_of(String) -> Int32
typeDirEntry
pub struct DirEntry { name : String is_dir : Bool }
pub fn DirEntry::new(String, is_dir~ : Bool) -> Self
typeDirectoryTree
pub struct DirectoryTree { tree : Tree loader : (String) -> Array[DirEntry] }
Widgetpub fn DirectoryTree::focusable(Self) -> Bool
pub fn DirectoryTree::handle(Self, Ctx, Msg) -> Bool
pub fn DirectoryTree::hint(Self, @geom.Size) -> @geom.Size
pub fn DirectoryTree::new(path~ : String, loader~ : (String) -> Array[DirEntry], style? : @style.Style, guide_style? : @style.Style, cursor_style? : @style.Style, hover_style? : @style.Style) -> Self
pub fn DirectoryTree::path(Self) -> String
pub fn DirectoryTree::reload(Self) -> Unit
pub fn DirectoryTree::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn DirectoryTree::set_path(Self, String) -> Unit
pub fn DirectoryTree::tree(Self) -> Tree
typeFileDialog
pub struct FileDialog { mut title : String mode : FileMode mut path : String mut entries : Array[FileEntry] mut filter : String mut name : String mut highlighted : Int32 mut offset : Int32 mut seen : Int32 mut follow : Bool mut answered : Int32 mut focused : Bool style : @style.Style border_style : @style.Style title_style : @style.Style dir_style : @style.Style size_style : @style.Style highlight : @style.Style blurred_highlight : @style.Style field_style : @style.Style }
A listing, a name and two buttons: the dialog that opens or saves a file.
The entries come from the caller and the caller is told when one is entered, so the walking of directories stays outside this library. The arrows move through the listing, Enter goes into a directory or takes the file named, Escape closes without answering, and a second click on an entry already highlighted goes into it.
Widgetpub fn FileDialog::buttons(Self) -> Array[String]
pub fn FileDialog::chosen(Self) -> Int32?
The button taken, if any has been.
pub fn FileDialog::filter(Self) -> String
pub fn FileDialog::focusable(Self) -> Bool
pub fn FileDialog::handle(Self, Ctx, Msg) -> Bool
pub fn FileDialog::hint(Self, @geom.Size) -> @geom.Size
pub fn FileDialog::is_answered(Self) -> Bool
pub fn FileDialog::name(Self) -> String
pub fn FileDialog::new(title? : String, path? : String, entries? : Array[FileEntry], mode? : FileMode, filter? : String, name? : String, style? : @style.Style, border_style? : @style.Style, title_style? : @style.Style, dir_style? : @style.Style, size_style? : @style.Style, highlight? : @style.Style, blurred_highlight? : @style.Style, field_style? : @style.Style) -> Self
pub fn FileDialog::path(Self) -> String
pub fn FileDialog::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn FileDialog::selected(Self) -> FileEntry?
The entry highlighted, if the listing has one.
pub fn FileDialog::set_entries(Self, Array[FileEntry]) -> Unit
The listing to show, as the caller found it.
pub fn FileDialog::set_filter(Self, String) -> Unit
Only entries whose name ends this way are listed; directories always are.
pub fn FileDialog::set_name(Self, String) -> Unit
The name to write, which the caller can fill from a listing too.
pub fn FileDialog::set_path(Self, String) -> Unit
Where the listing was found, as the caller names it.
pub fn FileDialog::set_title(Self, String) -> Unit
pub fn FileDialog::title(Self) -> String
pub fn FileDialog::value(Self) -> String
The whole answer: the path the caller gave joined to the name.
typeFileEntry
pub(all) struct FileEntry { name : String dir : Bool size : Int32 }
One row of a listing, as the caller hands it over. This library never touches a file system: whatever walks the directories is the caller's, and what it finds comes in as this.
pub fn FileEntry::is_dir(Self) -> Bool
pub fn FileEntry::new(String, dir? : Bool, size? : Int32) -> Self
typeFileMode
pub(all) enum FileMode { Open Save }
Whether to open something that is there, or to name something to write.
pub fn FileMode::confirm(Self) -> String
typeFooter
pub struct Footer { mut bindings : Array[(String, String)] style : @style.Style key_style : @style.Style }
Widgetpub fn Footer::focusable(Self) -> Bool
pub fn Footer::handle(Self, Ctx, Msg) -> Bool
pub fn Footer::hint(Self, @geom.Size) -> @geom.Size
pub fn Footer::new(Array[(String, String)], style? : @style.Style, key_style? : @style.Style) -> Self
pub fn Footer::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Footer::set(Self, Array[(String, String)]) -> Unit
typeGauge
pub struct Gauge { mut ratio : Double mut label : String style : @style.Style bar_style : @style.Style rest_style : @style.Style }
How far round a meter is: a word on the left, a bar, and the percentage on the right.
Widgetpub fn Gauge::focusable(Self) -> Bool
pub fn Gauge::handle(Self, Ctx, Msg) -> Bool
pub fn Gauge::hint(Self, @geom.Size) -> @geom.Size
pub fn Gauge::label(Self) -> String
pub fn Gauge::new(ratio? : Double, label? : String, style? : @style.Style, bar_style? : @style.Style, rest_style? : @style.Style) -> Self
pub fn Gauge::percent(Self) -> Int32
pub fn Gauge::ratio(Self) -> Double
pub fn Gauge::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Gauge::set_label(Self, String) -> Unit
pub fn Gauge::set_ratio(Self, Double) -> Unit
How full the meter is, held between nothing and all of it.
typeGraphKind
pub(all) enum GraphKind { Line Scatter }
How a series is drawn: joined from point to point, or as the points themselves.
pub fn GraphKind::marker(Self) -> String
typeHeader
pub struct Header { mut title : String mut note : String mut clock : Clock? style : @style.Style }
The title bar: the title in the centre, a note at the right edge, and a clock beside it when one is given.
Widgetpub fn Header::focusable(Self) -> Bool
pub fn Header::handle(Self, Ctx, Msg) -> Bool
pub fn Header::hint(Self, @geom.Size) -> @geom.Size
pub fn Header::new(String, note? : String, clock? : Clock, style? : @style.Style) -> Self
pub fn Header::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Header::set(Self, String) -> Unit
pub fn Header::set_clock(Self, Clock?) -> Unit
Give the bar a clock to keep, or take it away with None.
pub fn Header::set_note(Self, String) -> Unit
pub fn Header::time(Self) -> String?
What the clock reads, if the bar has one.
typeHexView
pub struct HexView { data : Bytes mut offset : Int32 mut focused : Bool per_row : Int32 style : @style.Style offset_style : @style.Style hex_style : @style.Style ascii_style : @style.Style }
Bytes as a reader of dumps expects them: the offset, the bytes in hex, and the same bytes as text on the right.
The arrows walk a line or a screen, Home and End go to the ends, and the wheel moves a line. A narrow view shows eight bytes a row, and narrower still four, so the hex column always fits.
Widgetpub fn HexView::data(Self) -> Bytes
pub fn HexView::focusable(Self) -> Bool
pub fn HexView::handle(Self, Ctx, Msg) -> Bool
pub fn HexView::hint(Self, @geom.Size) -> @geom.Size
pub fn HexView::new(data? : Bytes, offset? : Int32, per_row? : Int32, style? : @style.Style, offset_style? : @style.Style, hex_style? : @style.Style, ascii_style? : @style.Style) -> Self
pub fn HexView::offset(Self) -> Int32
The byte the view starts at.
pub fn HexView::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn HexView::set_offset(Self, Int32) -> Unit
Start at a byte, held to the ones there are.
typeInput
pub struct Input { mut text : String mut cursor : Int32 mut offset : Int32 mut focused : Bool placeholder : String password : Bool max_length : Int32 style : @style.Style placeholder_style : @style.Style cursor_style : @style.Style }
A single-line text field.
The keys are Textual's: the arrows and Home and End move, Control with an arrow moves by words, Control-A and Control-E go to either end, Backspace and Delete take a character, Control-W and Control-F a word, Control-U and Control-K everything on that side of the cursor, and Enter submits.
Widgetpub fn Input::cursor(Self) -> Int32
pub fn Input::cursor_column(Self, Int32) -> Int32
The column the cursor shows in, once the field is width wide.
pub fn Input::focusable(Self) -> Bool
pub fn Input::handle(Self, Ctx, Msg) -> Bool
pub fn Input::hint(Self, @geom.Size) -> @geom.Size
pub fn Input::insert(Self, String) -> Unit
Insert text at the cursor, as much of it as max_length leaves room for.
pub fn Input::new(placeholder? : String, password? : Bool, max_length? : Int32, style? : @style.Style, placeholder_style? : @style.Style, cursor_style? : @style.Style) -> Self
An empty field. password shows a dot for every character; max_length caps how many characters it takes, and zero means no cap.
pub fn Input::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Input::set(Self, String) -> Unit
Replace the text and put the cursor after it.
pub fn Input::text(Self) -> String
typeInputBox
pub struct InputBox { mut title : String mut prompt : String field : Input buttons : Array[String] mut highlighted : Int32 mut answered : Int32 style : @style.Style border_style : @style.Style title_style : @style.Style highlight : @style.Style }
A prompt, a one-line field and a row of buttons: the dialog that asks for a string.
Typing goes to the field, whatever button is highlighted; the arrows and Tab move between the buttons, Enter takes the one highlighted and Escape takes the last.
Widgetpub fn InputBox::chosen(Self) -> Int32?
The button taken, if any has been.
pub fn InputBox::focusable(Self) -> Bool
pub fn InputBox::handle(Self, Ctx, Msg) -> Bool
pub fn InputBox::hint(Self, @geom.Size) -> @geom.Size
pub fn InputBox::is_answered(Self) -> Bool
pub fn InputBox::label(Self) -> String?
pub fn InputBox::new(title? : String, prompt? : String, value? : String, buttons? : Array[String], style? : @style.Style, border_style? : @style.Style, title_style? : @style.Style, highlight? : @style.Style) -> Self
pub fn InputBox::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn InputBox::set(Self, String) -> Unit
pub fn InputBox::set_prompt(Self, String) -> Unit
pub fn InputBox::set_title(Self, String) -> Unit
pub fn InputBox::text(Self) -> String
What the field holds now.
typeItem
pub(all) struct Item { label : String shortcut : String checked : Bool enabled : Bool rule : Bool }
One line of a menu: a label, the keys that do the same thing, a tick for a setting that is on, or a rule between two groups of them.
pub fn Item::is_enabled(Self) -> Bool
pub fn Item::is_separator(Self) -> Bool
pub fn Item::new(String, shortcut? : String, checked? : Bool, enabled? : Bool) -> Self
pub fn Item::separator() -> Self
typeKeyPanel
pub struct KeyPanel { mut bindings : Array[(String, String)] columns : Int32 style : @style.Style key_style : @style.Style note_style : @style.Style }
What the keys do, in columns: a key, right-aligned against its description, so a reader can look one up while a screen of a program is in front of them.
The panel draws and nothing more. It takes no focus, and a host that wants a binding to act puts the action in its own key handler.
Widgetpub fn KeyPanel::bindings(Self) -> Array[(String, String)]
The bindings, each a key and what it does.
pub fn KeyPanel::focusable(Self) -> Bool
pub fn KeyPanel::handle(Self, Ctx, Msg) -> Bool
pub fn KeyPanel::hint(Self, @geom.Size) -> @geom.Size
pub fn KeyPanel::new(bindings? : Array[(String, String)], columns? : Int32, style? : @style.Style, key_style? : @style.Style, note_style? : @style.Style) -> Self
pub fn KeyPanel::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn KeyPanel::rows(Self, Int32) -> Int32
How many rows the whole panel needs at a given width.
pub fn KeyPanel::set_bindings(Self, Array[(String, String)]) -> Unit
typeLineKind
pub(all) enum LineKind { Context Added Removed Hunk Header Meta }
What a line of a difference is: unchanged, added, removed, a hunk heading, a file heading, or the note above one.
typeLink
pub struct Link { mut text : String mut target : String mut visited : Bool mut focused : Bool style : @style.Style visited_style : @style.Style focus_style : @style.Style }
Words that go somewhere: underlined, taken by Enter or by a click, and drawn differently once they have been.
Widgetpub fn Link::focusable(Self) -> Bool
pub fn Link::handle(Self, Ctx, Msg) -> Bool
pub fn Link::hint(Self, @geom.Size) -> @geom.Size
pub fn Link::is_visited(Self) -> Bool
pub fn Link::new(String, target? : String, style? : @style.Style, visited_style? : @style.Style, focus_style? : @style.Style) -> Self
A link to target, or to what it says when no target is given.
pub fn Link::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Link::set(Self, String) -> Unit
pub fn Link::set_target(Self, String) -> Unit
pub fn Link::target(Self) -> String
Where the link goes.
pub fn Link::text(Self) -> String
pub fn Link::visit(Self, visited? : Bool) -> Unit
Mark the link as gone to, or forget that it was.
typeListState
pub(all) struct ListState { mut selected : Int32 mut offset : Int32 mut seen : Int32 mut followed : Bool }
What a list knows and the caller keeps: which row is chosen and how far the view has been scrolled. A widget that takes one is drawn from it and moves it, so two widgets can share a choice and a caller can set either without asking the widget.
pub fn ListState::clear(Self) -> Unit
pub fn ListState::follow(Self, Int32, Int32) -> Unit
Bring the choice back into view, but only once for each move of it: a view the wheel put somewhere else is left where it is.
pub fn ListState::is_set(Self) -> Bool
pub fn ListState::move_by(Self, Int32, Int32) -> Bool
Move the choice by by rows, held to the ones there are.
pub fn ListState::new(selected? : Int32, offset? : Int32) -> Self
pub fn ListState::offset(Self) -> Int32
pub fn ListState::scroll_by(Self, Int32, Int32) -> Bool
Scroll the view without touching the choice, which is what a wheel does.
pub fn ListState::seen(Self) -> Int32
How many rows the view last showed.
pub fn ListState::select(Self, Int32, Int32) -> Bool
Choose a row, held to the ones there are.
pub fn ListState::selected(Self) -> Int32
The row chosen, or -1 when none is.
typeListView
pub struct ListView { mut items : Array[String] mut index : Int32 mut offset : Int32 mut follow : Bool mut focused : Bool style : @style.Style highlight : @style.Style blurred_highlight : @style.Style }
Widgetpub fn ListView::focusable(Self) -> Bool
pub fn ListView::handle(Self, Ctx, Msg) -> Bool
pub fn ListView::hint(Self, @geom.Size) -> @geom.Size
pub fn ListView::index(Self) -> Int32
pub fn ListView::items(Self) -> Array[String]
pub fn ListView::new(Array[String], style? : @style.Style, highlight? : @style.Style, blurred_highlight? : @style.Style) -> Self
pub fn ListView::offset(Self) -> Int32
pub fn ListView::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn ListView::select(Self, Int32) -> Unit
pub fn ListView::set(Self, Array[String]) -> Unit
typeLoadingIndicator
pub struct LoadingIndicator { mut frame : Int32 style : @style.Style dim_style : @style.Style }
Widgetpub fn LoadingIndicator::focusable(Self) -> Bool
pub fn LoadingIndicator::frame(Self) -> Int32
pub fn LoadingIndicator::handle(Self, Ctx, Msg) -> Bool
pub fn LoadingIndicator::hint(Self, @geom.Size) -> @geom.Size
pub fn LoadingIndicator::new(style? : @style.Style, dim_style? : @style.Style) -> Self
pub fn LoadingIndicator::render_line(Self, Int32, @geom.Size) -> @strip.Strip
typeLog
pub struct Log { mut lines : Array[String] mut width : Int32 max_lines : Int32? mut auto_scroll : Bool mut stick : Bool mut seen : Int32 mut offset_x : Int32 mut offset_y : Int32 mut focused : Bool style : @style.Style }
Widgetpub fn Log::clear(Self) -> Unit
pub fn Log::focusable(Self) -> Bool
pub fn Log::handle(Self, Ctx, Msg) -> Bool
pub fn Log::hint(Self, @geom.Size) -> @geom.Size
pub fn Log::line_count(Self) -> Int32
pub fn Log::lines(Self) -> Array[String]
pub fn Log::new(max_lines? : Int32, auto_scroll? : Bool, style? : @style.Style) -> Self
pub fn Log::offset(Self) -> (Int32, Int32)
pub fn Log::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Log::set_auto_scroll(Self, Bool) -> Unit
pub fn Log::write(Self, String, scroll_end? : Bool) -> Unit
pub fn Log::write_line(Self, String, scroll_end? : Bool) -> Unit
pub fn Log::write_lines(Self, Array[String], scroll_end? : Bool) -> Unit
typeMarkdown
pub struct Markdown { mut source : String mut laid : Array[@strip.Strip] mut laid_width : Int32 mut dirty : Bool mut offset_y : Int32 mut seen : Int32 style : @style.Style heading_style : @style.Style code_style : @style.Style quote_style : @style.Style rule_style : @style.Style }
Widgetpub fn Markdown::focusable(Self) -> Bool
pub fn Markdown::handle(Self, Ctx, Msg) -> Bool
pub fn Markdown::hint(Self, @geom.Size) -> @geom.Size
pub fn Markdown::new(String, style? : @style.Style, heading_style? : @style.Style, code_style? : @style.Style, quote_style? : @style.Style, rule_style? : @style.Style) -> Self
pub fn Markdown::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Markdown::text(Self) -> String
pub fn Markdown::update(Self, String) -> Unit
typeMaskedInput
pub struct MaskedInput { mask : String filled : Array[String] mut at : Int32 mut focused : Bool placeholder : String style : @style.Style literal_style : @style.Style cursor_style : @style.Style }
A field ruled by a template: a phone number, a date, a licence key.
Letters and digits go into the places the mask opens for them and the literals between them are written for the user; the arrows move over the places, Backspace empties one and Enter submits.
Widgetpub fn MaskedInput::clear(Self) -> Unit
pub fn MaskedInput::cursor(Self) -> Int32
The place the caret is on.
pub fn MaskedInput::focusable(Self) -> Bool
pub fn MaskedInput::handle(Self, Ctx, Msg) -> Bool
pub fn MaskedInput::hint(Self, @geom.Size) -> @geom.Size
pub fn MaskedInput::is_complete(Self) -> Bool
Whether every place has something in it.
pub fn MaskedInput::new(String, placeholder? : String, style? : @style.Style, literal_style? : @style.Style, cursor_style? : @style.Style) -> Self
pub fn MaskedInput::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn MaskedInput::set(Self, String) -> Unit
Fill the places from a whole value, reading past the literals.
pub fn MaskedInput::text(Self) -> String
The value as it reads: what was typed, with the literals in place.
pub fn MaskedInput::values(Self) -> Array[String]
What was typed in the places the mask opens, in order.
typeMenu
pub struct Menu { mut items : Array[Item] mut highlighted : Int32 mut taken : Int32 mut focused : Bool style : @style.Style dim_style : @style.Style shortcut_style : @style.Style border_style : @style.Style highlight : @style.Style blurred_highlight : @style.Style }
A list of items in a frame: what drops from a menu bar, and what stands on its own as a popup.
The arrows move over the items, skipping rules and what is off, Enter takes the one highlighted and Escape closes without taking one.
Widgetpub fn Menu::focusable(Self) -> Bool
pub fn Menu::handle(Self, Ctx, Msg) -> Bool
pub fn Menu::highlighted(Self) -> Int32
pub fn Menu::hint(Self, @geom.Size) -> @geom.Size
pub fn Menu::items(Self) -> Array[Item]
pub fn Menu::new(items? : Array[Item], style? : @style.Style, dim_style? : @style.Style, shortcut_style? : @style.Style, border_style? : @style.Style, highlight? : @style.Style, blurred_highlight? : @style.Style) -> Self
pub fn Menu::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Menu::set_items(Self, Array[Item]) -> Unit
pub fn Menu::taken(Self) -> Int32?
The item taken, if one has been.
pub fn Menu::width_of(Self) -> Int32
The columns the widest item needs, frame included.
typeMenuBar
pub struct MenuBar { titles : Array[String] menus : Array[Menu] mut at : Int32 mut open : Int32 mut picked : (Int32, Int32)? mut focused : Bool style : @style.Style bar_style : @style.Style highlight : @style.Style open_style : @style.Style }
The titles along the top of a screen, and the list each one drops.
The bar is one row until a menu is open, when it grows to hold that menu underneath its title, the way a select grows to hold its options. The arrows move along the bar and then down the items, Enter opens and takes, and Escape closes.
Widgetpub fn MenuBar::add(Self, String, Array[Item]) -> Unit
pub fn MenuBar::close(Self) -> Unit
pub fn MenuBar::focusable(Self) -> Bool
pub fn MenuBar::handle(Self, Ctx, Msg) -> Bool
pub fn MenuBar::hint(Self, @geom.Size) -> @geom.Size
pub fn MenuBar::is_open(Self) -> Bool
Whether a list is showing, and which one.
pub fn MenuBar::new(style? : @style.Style, bar_style? : @style.Style, highlight? : @style.Style, open_style? : @style.Style) -> Self
pub fn MenuBar::opened(Self) -> Int32
pub fn MenuBar::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn MenuBar::taken(Self) -> (Int32, Int32)?
The menu and the item last taken, as a pair.
pub fn MenuBar::titles(Self) -> Array[String]
typeMessageBox
pub struct MessageBox { mut title : String mut message : String kind : DialogKind buttons : Array[String] mut highlighted : Int32 mut answered : Int32 mut focused : Bool style : @style.Style border_style : @style.Style title_style : @style.Style highlight : @style.Style }
A message and a row of buttons inside a frame with a title: the dialog a program puts up to ask something and wait for the answer.
The keys are the arrows to move between the buttons, Enter to take the one highlighted, the first letter of a button's label to take it, and Escape to close without answering.
Widgetpub fn MessageBox::chosen(Self) -> Int32?
The button taken, if any has been.
pub fn MessageBox::focusable(Self) -> Bool
pub fn MessageBox::handle(Self, Ctx, Msg) -> Bool
pub fn MessageBox::highlighted(Self) -> Int32
pub fn MessageBox::hint(Self, @geom.Size) -> @geom.Size
pub fn MessageBox::is_answered(Self) -> Bool
pub fn MessageBox::label(Self) -> String?
The label of the button taken, which is what a caller usually tests.
pub fn MessageBox::new(title? : String, message? : String, kind? : DialogKind, buttons? : Array[String], style? : @style.Style, border_style? : @style.Style, title_style? : @style.Style, highlight? : @style.Style) -> Self
pub fn MessageBox::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn MessageBox::set_message(Self, String) -> Unit
pub fn MessageBox::set_title(Self, String) -> Unit
typeMsg
pub(all) enum Msg { Key(@event.Key) Mouse(@event.Mouse) Paste(String) Focus(Bool) Tick(Int32) }
typeOptionList
pub struct OptionList { mut options : Array[Choice] mut highlighted : Int32 mut hover : Int32 mut offset : Int32 mut seen : Int32 mut follow : Bool mut focused : Bool style : @style.Style highlight : @style.Style blurred_highlight : @style.Style disabled_style : @style.Style hover_style : @style.Style separator_style : @style.Style }
Widgetpub fn OptionList::add_option(Self, Choice) -> Unit
pub fn OptionList::add_separator(Self) -> Unit
pub fn OptionList::clear_options(Self) -> Unit
pub fn OptionList::focusable(Self) -> Bool
pub fn OptionList::handle(Self, Ctx, Msg) -> Bool
pub fn OptionList::highlighted(Self) -> Int32
pub fn OptionList::hint(Self, @geom.Size) -> @geom.Size
pub fn OptionList::new(options? : Array[Choice], style? : @style.Style, highlight? : @style.Style, blurred_highlight? : @style.Style, disabled_style? : @style.Style, hover_style? : @style.Style, separator_style? : @style.Style) -> Self
pub fn OptionList::option_count(Self) -> Int32
pub fn OptionList::options(Self) -> Array[Choice]
pub fn OptionList::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn OptionList::set_disabled(Self, Int32, Bool) -> Unit
pub fn OptionList::set_options(Self, Array[Choice]) -> Unit
typeOut
pub(all) enum Out { Repaint(id~ : Int32) TakeFocus(id~ : Int32) Pressed(id~ : Int32) Changed(id~ : Int32, value~ : String) Submitted(id~ : Int32, value~ : String) Selected(id~ : Int32, index~ : Int32) MenuPicked(id~ : Int32, menu~ : Int32, index~ : Int32) Scrolled(id~ : Int32, x~ : Int32, y~ : Int32) Focused(id~ : Int32) Blurred(id~ : Int32) Toggled(id~ : Int32, on~ : Bool) Highlighted(id~ : Int32, index~ : Int32) ToggledAt(id~ : Int32, index~ : Int32, on~ : Bool) CellHighlighted(id~ : Int32, row~ : Int32, col~ : Int32) CellSelected(id~ : Int32, row~ : Int32, col~ : Int32) HeaderSelected(id~ : Int32, col~ : Int32) Dismissed(id~ : Int32) Quit }
typePaginator
pub struct Paginator { mut page : Int32 mut pages : Int32 style : @style.Style current_style : @style.Style arrow_style : @style.Style }
Which page of a longer list is on show: an arrow at each end and the pages between them, with the one you are on picked out.
The arrows step a page, Home and End go to the first and the last, and a click on a number goes to that page.
Widgetpub fn Paginator::focusable(Self) -> Bool
pub fn Paginator::handle(Self, Ctx, Msg) -> Bool
pub fn Paginator::hint(Self, @geom.Size) -> @geom.Size
pub fn Paginator::new(page? : Int32, pages? : Int32, style? : @style.Style, current_style? : @style.Style, arrow_style? : @style.Style) -> Self
pub fn Paginator::page(Self) -> Int32
The page on show, counted from nothing.
pub fn Paginator::pages(Self) -> Int32
How many pages there are.
pub fn Paginator::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Paginator::set_page(Self, Int32) -> Unit
Go to a page, held to the ones there are.
pub fn Paginator::set_pages(Self, Int32) -> Unit
How many pages there are, held to at least one, with the page on show kept inside them.
typePlaceholder
pub struct Placeholder { label : String mut variant : PlaceholderVariant colour : Int32 style : @style.Style }
Widgetpub fn Placeholder::cycle(Self) -> Unit
pub fn Placeholder::focusable(Self) -> Bool
pub fn Placeholder::handle(Self, Ctx, Msg) -> Bool
pub fn Placeholder::hint(Self, @geom.Size) -> @geom.Size
pub fn Placeholder::new(label? : String, variant? : PlaceholderVariant, colour? : Int32, style? : @style.Style) -> Self
pub fn Placeholder::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Placeholder::variant(Self) -> PlaceholderVariant
typePlaceholderVariant
pub(all) enum PlaceholderVariant { Default Size Text }
typePretty
pub struct Pretty { mut value : Value mut offset : Int32 mut focused : Bool indent : Int32 style : @style.Style key_style : @style.Style text_style : @style.Style number_style : @style.Style punct_style : @style.Style }
A value printed the way it reads: laid out with an indent, in the colours of what each part is, and on one line when it fits.
The arrows scroll a value taller than its box. A caller's own types come in as a Value, which is what the printer walks.
Widgetpub fn Pretty::focusable(Self) -> Bool
pub fn Pretty::handle(Self, Ctx, Msg) -> Bool
pub fn Pretty::hint(Self, @geom.Size) -> @geom.Size
pub fn Pretty::lines(Self, Int32) -> Array[Array[@strip.Seg]]
The printed value as lines of segments, laid out for a box width wide.
pub fn Pretty::new(value? : Value, indent? : Int32, style? : @style.Style, key_style? : @style.Style, text_style? : @style.Style, number_style? : @style.Style, punct_style? : @style.Style) -> Self
pub fn Pretty::offset(Self) -> Int32
pub fn Pretty::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Pretty::set(Self, Value) -> Unit
pub fn Pretty::value(Self) -> Value
typeProgress
pub struct Progress { mut value : Int32 mut total : Int32 style : @style.Style bar_style : @style.Style show_percent : Bool }
Widgetpub fn Progress::advance(Self, Int32) -> Unit
pub fn Progress::focusable(Self) -> Bool
pub fn Progress::handle(Self, Ctx, Msg) -> Bool
pub fn Progress::hint(Self, @geom.Size) -> @geom.Size
pub fn Progress::new(total? : Int32, style? : @style.Style, bar_style? : @style.Style, show_percent? : Bool) -> Self
pub fn Progress::percent(Self) -> Int32
pub fn Progress::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Progress::set(Self, Int32) -> Unit
pub fn Progress::set_total(Self, Int32) -> Unit
typeRadioButton
pub struct RadioButton { mut label : String mut value : Bool button_first : Bool on_style : @style.Style off_style : @style.Style label_style : @style.Style focus_style : @style.Style mut focused : Bool }
Widgetpub fn RadioButton::focusable(Self) -> Bool
pub fn RadioButton::handle(Self, Ctx, Msg) -> Bool
pub fn RadioButton::hint(Self, @geom.Size) -> @geom.Size
pub fn RadioButton::label(Self) -> String
pub fn RadioButton::new(String, value? : Bool, button_first? : Bool, on_style? : @style.Style, off_style? : @style.Style, label_style? : @style.Style, focus_style? : @style.Style) -> Self
pub fn RadioButton::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn RadioButton::set_label(Self, String) -> Unit
pub fn RadioButton::set_value(Self, Bool) -> Unit
Set the value without reporting it; a RadioSet uses this to turn the others off.
pub fn RadioButton::value(Self) -> Bool
typeRadioSet
pub struct RadioSet { buttons : Array[RadioButton] mut selected : Int32 mut pressed : Int32 mut offset : Int32 mut follow : Bool mut focused : Bool cursor : @style.Style blurred_cursor : @style.Style }
Radio buttons grouped into a set: turning one on turns the others off, the arrows move a cursor that is separate from which button is pressed, and pressing the pressed button again changes nothing. A click on a row moves the cursor there and presses it.
Widgetpub fn RadioSet::buttons(Self) -> Array[RadioButton]
pub fn RadioSet::focusable(Self) -> Bool
pub fn RadioSet::handle(Self, Ctx, Msg) -> Bool
pub fn RadioSet::hint(Self, @geom.Size) -> @geom.Size
pub fn RadioSet::new(Array[RadioButton], cursor? : @style.Style, blurred_cursor? : @style.Style) -> Self
pub fn RadioSet::pressed_index(Self) -> Int32
The index of the pressed button, or -1 when none is pressed.
pub fn RadioSet::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn RadioSet::selected_index(Self) -> Int32
The index the cursor rests on, or -1 when the set is empty.
pub fn RadioSet::set_pressed(Self, Int32) -> Unit
Press a button without reporting it; any other pressed button goes off.
pub fn RadioSet::set_selected(Self, Int32) -> Unit
typeRichLog
pub struct RichLog { mut lines : Array[@strip.Strip] mut width : Int32 max_lines : Int32? min_width : Int32 mut wrap : Bool mut auto_scroll : Bool mut stick : Bool mut seen : Int32 mut offset_x : Int32 mut offset_y : Int32 mut focused : Bool style : @style.Style }
Widgetpub fn RichLog::clear(Self) -> Unit
pub fn RichLog::focusable(Self) -> Bool
pub fn RichLog::handle(Self, Ctx, Msg) -> Bool
pub fn RichLog::hint(Self, @geom.Size) -> @geom.Size
pub fn RichLog::line_count(Self) -> Int32
pub fn RichLog::lines(Self) -> Array[@strip.Strip]
pub fn RichLog::new(max_lines? : Int32, min_width? : Int32, wrap? : Bool, auto_scroll? : Bool, style? : @style.Style) -> Self
pub fn RichLog::offset(Self) -> (Int32, Int32)
pub fn RichLog::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn RichLog::set_auto_scroll(Self, Bool) -> Unit
pub fn RichLog::set_wrap(Self, Bool) -> Unit
pub fn RichLog::write(Self, String, style? : @style.Style, width? : Int32, scroll_end? : Bool) -> Unit
typeRow
pub(all) struct Row { label : String cells : Array[String] }
pub fn Row::new(Array[String], label? : String) -> Self
typeRule
pub struct Rule { dir : RuleDir mut kind : RuleKind style : @style.Style }
Widgetpub fn Rule::focusable(Self) -> Bool
pub fn Rule::handle(Self, Ctx, Msg) -> Bool
pub fn Rule::hint(Self, @geom.Size) -> @geom.Size
pub fn Rule::horizontal(kind? : RuleKind, style? : @style.Style) -> Self
pub fn Rule::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Rule::set_kind(Self, RuleKind) -> Unit
pub fn Rule::vertical(kind? : RuleKind, style? : @style.Style) -> Self
typeRuleDir
pub(all) enum RuleDir { Horizontal Vertical }
typeRuleKind
pub(all) enum RuleKind { Ascii Blank Dashed Double Heavy Hidden None Solid Thick }
typeScrollbar
pub struct Scrollbar { mut position : Int32 mut content : Int32 mut viewport : Int32 vertical : Bool style : @style.Style thumb_style : @style.Style track_style : @style.Style }
A bar on its own: how much there is, how much of it shows, and how far into it the view has gone. It is driven by plain numbers, so it works with any view a caller keeps, not only with the scroll containers of the tree.
A click on the track goes to that part of the content, and the keys move by a line or by a view once the bar has been given focus.
Widgetpub fn Scrollbar::content(Self) -> Int32
pub fn Scrollbar::focusable(Self) -> Bool
pub fn Scrollbar::handle(Self, Ctx, Msg) -> Bool
pub fn Scrollbar::hint(Self, @geom.Size) -> @geom.Size
pub fn Scrollbar::is_needed(Self) -> Bool
Whether there is anything to scroll at all.
pub fn Scrollbar::is_vertical(Self) -> Bool
pub fn Scrollbar::max(Self) -> Int32
How far the view can go before it reaches the end.
pub fn Scrollbar::new(content? : Int32, viewport? : Int32, position? : Int32, vertical? : Bool, style? : @style.Style, thumb_style? : @style.Style, track_style? : @style.Style) -> Self
pub fn Scrollbar::position(Self) -> Int32
pub fn Scrollbar::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Scrollbar::set(Self, content~ : Int32, viewport~ : Int32, position~ : Int32) -> Unit
pub fn Scrollbar::thumb(Self, Int32) -> (Int32, Int32)
Where the thumb starts and how long it is, in a bar length cells long.
pub fn Scrollbar::viewport(Self) -> Int32
typeSelect
pub struct Select { options : Array[(String, String)] prompt : String allow_blank : Bool mut chosen : Int32 mut expanded : Bool mut highlighted : Int32 mut offset : Int32 mut seen : Int32 mut follow : Bool mut query : String mut focused : Bool style : @style.Style dim_style : @style.Style arrow_style : @style.Style highlight : @style.Style blurred_highlight : @style.Style }
Widgetpub fn Select::clear(Self) -> Unit
pub fn Select::expanded(Self) -> Bool
pub fn Select::focusable(Self) -> Bool
pub fn Select::handle(Self, Ctx, Msg) -> Bool
pub fn Select::hint(Self, @geom.Size) -> @geom.Size
pub fn Select::is_blank(Self) -> Bool
pub fn Select::new(options? : Array[(String, String)], prompt? : String, allow_blank? : Bool, value? : String, style? : @style.Style, dim_style? : @style.Style, arrow_style? : @style.Style, highlight? : @style.Style, blurred_highlight? : @style.Style) -> Self
pub fn Select::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Select::set_value(Self, String) -> Unit
pub fn Select::value(Self) -> String?
typeSelection
pub(all) struct Selection { prompt : String value : String initial : Bool disabled : Bool }
pub fn Selection::new(String, String, initial_state? : Bool, disabled? : Bool) -> Self
typeSelectionList
pub struct SelectionList { mut options : Array[Selection] mut states : Array[Bool] mut highlighted : Int32 mut hover : Int32 mut offset : Int32 mut seen : Int32 mut follow : Bool mut focused : Bool style : @style.Style highlight : @style.Style blurred_highlight : @style.Style disabled_style : @style.Style selected_style : @style.Style unselected_style : @style.Style }
Widgetpub fn SelectionList::deselect_all(Self) -> Unit
pub fn SelectionList::focusable(Self) -> Bool
pub fn SelectionList::handle(Self, Ctx, Msg) -> Bool
pub fn SelectionList::highlighted(Self) -> Int32
pub fn SelectionList::hint(Self, @geom.Size) -> @geom.Size
pub fn SelectionList::is_selected(Self, Int32) -> Bool
pub fn SelectionList::new(options? : Array[Selection], style? : @style.Style, highlight? : @style.Style, blurred_highlight? : @style.Style, disabled_style? : @style.Style, selected_style? : @style.Style, unselected_style? : @style.Style) -> Self
pub fn SelectionList::options(Self) -> Array[Selection]
pub fn SelectionList::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn SelectionList::select_all(Self) -> Unit
pub fn SelectionList::selected(Self) -> Array[String]
pub fn SelectionList::set_options(Self, Array[Selection]) -> Unit
pub fn SelectionList::set_selected(Self, Int32, Bool) -> Unit
pub fn SelectionList::toggle(Self, Int32) -> Unit
pub fn SelectionList::toggle_all(Self) -> Unit
typeShape
pub(all) enum Shape { Dot(Double, Double) Line(Double, Double, Double, Double) Rect(Double, Double, Double, Double) Circle(Double, Double, Double) }
One thing to draw, in the canvas's own coordinates: the range the canvas was given, not rows and columns.
typeSlider
pub struct Slider { mut value : Int32 low : Int32 high : Int32 step : Int32 mut focused : Bool style : @style.Style track_style : @style.Style bar_style : @style.Style thumb_style : @style.Style }
A number chosen along a line: the track, the thumb, and the value written after it.
The arrows move it by one step, Page Up and Page Down by ten, Home and End to the ends, and a click on the track goes to the place it landed on.
Widgetpub fn Slider::bounds(Self) -> (Int32, Int32)
Where the ends of the track are.
pub fn Slider::focusable(Self) -> Bool
pub fn Slider::handle(Self, Ctx, Msg) -> Bool
pub fn Slider::hint(Self, @geom.Size) -> @geom.Size
pub fn Slider::new(value? : Int32, low? : Int32, high? : Int32, step? : Int32, style? : @style.Style, track_style? : @style.Style, bar_style? : @style.Style, thumb_style? : @style.Style) -> Self
pub fn Slider::ratio(Self) -> Double
How far along the track the value is, from nothing to all of it.
pub fn Slider::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Slider::set_value(Self, Int32) -> Unit
Choose a number, held between the ends.
pub fn Slider::step(Self) -> Int32
How far one press of an arrow moves it.
pub fn Slider::value(Self) -> Int32
typeSlot
pub(all) enum Slot { Digit Letter Either Any }
What a place in a mask takes: a digit, a letter, either, or any character at all. Every other character in the mask is a literal, shown as it is written and stepped over.
pub fn Slot::glyph(Self) -> String
pub fn Slot::of(String) -> Self?
pub fn Slot::takes(Self, String) -> Bool
typeSparkline
pub struct Sparkline { mut data : Array[Double] summary : Summary min_colour : @style.Colour max_colour : @style.Colour style : @style.Style }
Widgetpub fn Sparkline::data(Self) -> Array[Double]
pub fn Sparkline::focusable(Self) -> Bool
pub fn Sparkline::handle(Self, Ctx, Msg) -> Bool
pub fn Sparkline::hint(Self, @geom.Size) -> @geom.Size
pub fn Sparkline::new(data? : Array[Double], summary? : Summary, min_colour? : @style.Colour, max_colour? : @style.Colour, style? : @style.Style) -> Self
pub fn Sparkline::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Sparkline::set(Self, Array[Double]) -> Unit
typeStatefulList
pub struct StatefulList { mut items : Array[String] state : ListState mut focused : Bool style : @style.Style highlight : @style.Style blurred_highlight : @style.Style }
A list of words drawn from a state the caller keeps: the choice and the scroll are the caller's, so two lists can share them or a caller can set them between frames.
The arrows move the choice and pull the view to it, a click chooses the row under the pointer, and the wheel scrolls the view on its own.
Widgetpub fn StatefulList::focusable(Self) -> Bool
pub fn StatefulList::handle(Self, Ctx, Msg) -> Bool
pub fn StatefulList::hint(Self, @geom.Size) -> @geom.Size
pub fn StatefulList::items(Self) -> Array[String]
pub fn StatefulList::new(items? : Array[String], state? : ListState, style? : @style.Style, highlight? : @style.Style, blurred_highlight? : @style.Style) -> Self
pub fn StatefulList::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn StatefulList::set_items(Self, Array[String]) -> Unit
pub fn StatefulList::state(Self) -> ListState
The state this list draws from and moves.
typeStatefulTable
pub struct StatefulTable { mut header : Array[String] mut rows : Array[Array[String]] state : TableState widths : Array[Int32]? mut focused : Bool style : @style.Style header_style : @style.Style highlight : @style.Style blurred_highlight : @style.Style column_highlight : @style.Style }
A table of cells drawn from a state the caller keeps, in the same way.
Widgetpub fn StatefulTable::columns(Self) -> Int32
How many columns there are: the widest row, or the header when it is longer.
pub fn StatefulTable::focusable(Self) -> Bool
pub fn StatefulTable::handle(Self, Ctx, Msg) -> Bool
pub fn StatefulTable::hint(Self, @geom.Size) -> @geom.Size
pub fn StatefulTable::new(rows? : Array[Array[String]], header? : Array[String], state? : TableState, widths? : Array[Int32], style? : @style.Style, header_style? : @style.Style, highlight? : @style.Style, blurred_highlight? : @style.Style, column_highlight? : @style.Style) -> Self
pub fn StatefulTable::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn StatefulTable::rows(Self) -> Array[Array[String]]
pub fn StatefulTable::set_header(Self, Array[String]) -> Unit
pub fn StatefulTable::set_rows(Self, Array[Array[String]]) -> Unit
pub fn StatefulTable::state(Self) -> TableState
typeStatic
pub struct Static { mut lines : Array[String] mut style : @style.Style align : Align }
Widgetpub fn Static::focusable(Self) -> Bool
pub fn Static::handle(Self, Ctx, Msg) -> Bool
pub fn Static::hint(Self, @geom.Size) -> @geom.Size
pub fn Static::new(String, style? : @style.Style, align? : Align) -> Self
pub fn Static::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Static::set(Self, String) -> Unit
pub fn Static::set_style(Self, @style.Style) -> Unit
pub fn Static::text(Self) -> String
typeSummary
pub(all) enum Summary { Maximum Minimum Mean Median Latest }
typeSwitch
pub struct Switch { mut value : Bool mut focused : Bool on_style : @style.Style off_style : @style.Style track : @style.Style focus_track : @style.Style }
The switch: a four-wide strip, half thumb and half track, the thumb on the left when off and on the right when on.
Widgetpub fn Switch::focusable(Self) -> Bool
pub fn Switch::handle(Self, Ctx, Msg) -> Bool
pub fn Switch::hint(Self, @geom.Size) -> @geom.Size
pub fn Switch::new(value? : Bool, on_style? : @style.Style, off_style? : @style.Style, track? : @style.Style, focus_track? : @style.Style) -> Self
pub fn Switch::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Switch::set_value(Self, Bool) -> Unit
Set the value without reporting it, for programmatic changes.
pub fn Switch::toggle(Self) -> Unit
pub fn Switch::value(Self) -> Bool
typeTabbedContent
pub struct TabbedContent { tabs : Tabs panes : Array[&Widget] }
Widgetpub fn TabbedContent::activate(Self, Int32) -> Unit
pub fn TabbedContent::active(Self) -> Int32
pub fn TabbedContent::focusable(Self) -> Bool
pub fn TabbedContent::from_tabs(Tabs, Array[&Widget]) -> Self
Tabbed content over a tab bar built by the caller, for a bar styled other than Tabs::new's defaults. Pane i shows under tab i.
pub fn TabbedContent::handle(Self, Ctx, Msg) -> Bool
pub fn TabbedContent::hint(Self, @geom.Size) -> @geom.Size
pub fn TabbedContent::new(labels? : Array[String], panes? : Array[&Widget], active? : Int32) -> Self
pub fn TabbedContent::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn TabbedContent::set_disabled(Self, Int32, Bool) -> Unit
typeTableState
pub(all) struct TableState { mut row : Int32 mut column : Int32 mut offset : Int32 mut seen : Int32 mut followed : Bool }
What a table knows and the caller keeps: the cell it is on, and how far the rows have been scrolled.
pub fn TableState::clear(Self) -> Unit
pub fn TableState::column(Self) -> Int32
pub fn TableState::follow(Self, Int32, Int32) -> Unit
pub fn TableState::is_set(Self) -> Bool
pub fn TableState::move_by(Self, Int32, Int32, Int32, Int32) -> Bool
pub fn TableState::new(row? : Int32, column? : Int32, offset? : Int32) -> Self
pub fn TableState::offset(Self) -> Int32
pub fn TableState::row(Self) -> Int32
pub fn TableState::scroll_by(Self, Int32, Int32) -> Bool
pub fn TableState::select(Self, Int32, Int32, Int32, Int32) -> Bool
Go to a cell, held to the ones there are.
typeTabs
pub struct Tabs { mut labels : Array[String] mut disabled : Array[Bool] mut active : Int32 mut focused : Bool style : @style.Style active_style : @style.Style bar_style : @style.Style bar_highlight : @style.Style focus_style : @style.Style }
Widgetpub fn Tabs::activate(Self, Int32) -> Unit
pub fn Tabs::active(Self) -> Int32
pub fn Tabs::focusable(Self) -> Bool
pub fn Tabs::handle(Self, Ctx, Msg) -> Bool
pub fn Tabs::hint(Self, @geom.Size) -> @geom.Size
pub fn Tabs::labels(Self) -> Array[String]
pub fn Tabs::new(labels? : Array[String], active? : Int32, style? : @style.Style, active_style? : @style.Style, bar_style? : @style.Style, bar_highlight? : @style.Style, focus_style? : @style.Style) -> Self
pub fn Tabs::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Tabs::set_disabled(Self, Int32, Bool) -> Unit
pub fn Tabs::set_labels(Self, Array[String]) -> Unit
typeTextArea
pub struct TextArea { mut lines : Array[String] mut row : Int32 mut col : Int32 mut anchor_row : Int32 mut anchor_col : Int32 mut selecting : Bool mut dragging : Bool mut offset_x : Int32 mut offset_y : Int32 mut seen_w : Int32 mut seen_h : Int32 mut focused : Bool indent_width : Int32 tab_indents : Bool show_line_numbers : Bool mut clipboard : String mut undo : Array[Snap] mut redo : Array[Snap] mut run : Bool mut follow : Bool history : Int32 style : @style.Style cursor_style : @style.Style selection_style : @style.Style gutter_style : @style.Style gutter_focus_style : @style.Style }
Widgetpub fn TextArea::clear_selection(Self) -> Unit
pub fn TextArea::cursor(Self) -> (Int32, Int32)
pub fn TextArea::focusable(Self) -> Bool
pub fn TextArea::handle(Self, Ctx, Msg) -> Bool
pub fn TextArea::has_selection(Self) -> Bool
pub fn TextArea::hint(Self, @geom.Size) -> @geom.Size
pub fn TextArea::insert(Self, String) -> Unit
pub fn TextArea::line_count(Self) -> Int32
pub fn TextArea::load_text(Self, String) -> Unit
pub fn TextArea::new(text? : String, indent_width? : Int32, tab_indents? : Bool, show_line_numbers? : Bool, style? : @style.Style, cursor_style? : @style.Style, selection_style? : @style.Style, gutter_style? : @style.Style, gutter_focus_style? : @style.Style, history? : Int32) -> Self
pub fn TextArea::offset(Self) -> (Int32, Int32)
pub fn TextArea::redo(Self) -> Bool
pub fn TextArea::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn TextArea::select_all(Self) -> Unit
pub fn TextArea::selected_text(Self) -> String
pub fn TextArea::text(Self) -> String
pub fn TextArea::undo(Self) -> Bool
typeToast
pub struct Toast { title : String mut message : String level : ToastLevel duration : Int32 mut elapsed : Int32 style : @style.Style title_style : @style.Style bar_info : @style.Style bar_warning : @style.Style bar_error : @style.Style }
Widgetpub fn Toast::bar_style(Self) -> @style.Style
pub fn Toast::expired(Self) -> Bool
pub fn Toast::focusable(Self) -> Bool
pub fn Toast::handle(Self, Ctx, Msg) -> Bool
pub fn Toast::hint(Self, @geom.Size) -> @geom.Size
pub fn Toast::new(String, title? : String, level? : ToastLevel, duration? : Int32, style? : @style.Style, title_style? : @style.Style, bar_info? : @style.Style, bar_warning? : @style.Style, bar_error? : @style.Style) -> Self
pub fn Toast::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Toast::set_message(Self, String) -> Unit
typeToastLevel
pub(all) enum ToastLevel { Information Warning Error }
typeTooltip
pub struct Tooltip { mut content : String mut style : @style.Style max_width : Int32 padding : Int32 }
Widgetpub fn Tooltip::focusable(Self) -> Bool
pub fn Tooltip::handle(Self, Ctx, Msg) -> Bool
pub fn Tooltip::hint(Self, @geom.Size) -> @geom.Size
pub fn Tooltip::new(String, style? : @style.Style, max_width? : Int32, padding? : Int32) -> Self
pub fn Tooltip::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Tooltip::set_content(Self, String) -> Unit
pub fn Tooltip::set_style(Self, @style.Style) -> Unit
pub fn Tooltip::wrapped(Self, Int32) -> Array[String]
typeTree
pub struct Tree { nodes : Array[TreeNode] mut show_root : Bool mut show_guides : Bool mut guide_depth : Int32 mut auto_expand : Bool mut cursor : Int32 mut hover : Int32 mut offset : Int32 mut seen : Int32 mut follow : Bool mut focused : Bool icon_collapsed : String icon_open : String icon_leaf : String dim_hidden : Bool style : @style.Style guide_style : @style.Style cursor_style : @style.Style hover_style : @style.Style }
Widgetpub fn Tree::add(Self, Int32, String, data? : String, expand? : Bool, allow_expand? : Bool) -> Int32
pub fn Tree::add_leaf(Self, Int32, String, data? : String) -> Int32
pub fn Tree::allow_expand(Self, Int32) -> Bool
pub fn Tree::children(Self, Int32) -> Array[Int32]
pub fn Tree::clear(Self) -> Unit
pub fn Tree::collapse(Self, Int32) -> Unit
pub fn Tree::collapse_all(Self, Int32) -> Unit
pub fn Tree::cursor_line(Self) -> Int32
pub fn Tree::cursor_node(Self) -> Int32
pub fn Tree::data(Self, Int32) -> String
pub fn Tree::expand(Self, Int32) -> Unit
pub fn Tree::expand_all(Self, Int32) -> Unit
pub fn Tree::focusable(Self) -> Bool
pub fn Tree::handle(Self, Ctx, Msg) -> Bool
pub fn Tree::hint(Self, @geom.Size) -> @geom.Size
pub fn Tree::is_expanded(Self, Int32) -> Bool
pub fn Tree::label(Self, Int32) -> String
pub fn Tree::line_count(Self) -> Int32
pub fn Tree::new(root_label~ : String, root_data? : String, show_root? : Bool, icon_collapsed? : String, icon_open? : String, icon_leaf? : String, dim_hidden? : Bool, style? : @style.Style, guide_style? : @style.Style, cursor_style? : @style.Style, hover_style? : @style.Style) -> Self
pub fn Tree::node(Self, Int32) -> TreeNode
pub fn Tree::remove_children(Self, Int32) -> Unit
pub fn Tree::render_line(Self, Int32, @geom.Size) -> @strip.Strip
pub fn Tree::reset(Self, String, data? : String) -> Unit
pub fn Tree::root_id(Self) -> Int32
pub fn Tree::set_allow_expand(Self, Int32, Bool) -> Unit
pub fn Tree::set_auto_expand(Self, Bool) -> Unit
pub fn Tree::set_data(Self, Int32, String) -> Unit
pub fn Tree::set_guide_depth(Self, Int32) -> Unit
pub fn Tree::set_label(Self, Int32, String) -> Unit
pub fn Tree::show_guides(Self, Bool) -> Unit
pub fn Tree::show_root(Self, Bool) -> Unit
typeTreeNode
pub struct TreeNode { mut label : String mut data : String mut expanded : Bool mut allow_expand : Bool mut loaded : Bool children : Array[Int32] parent : Int32 }
pub fn TreeNode::is_expanded(Self) -> Bool
pub fn TreeNode::label(Self) -> String
pub fn TreeNode::new(label~ : String, data? : String, expand? : Bool, allow_expand? : Bool, parent? : Int32) -> Self
typeValue
pub(all) enum Value { VNil VBool(Bool) VInt(Int32) VNum(Double) VStr(String) VArr(Array[Value]) VObj(Array[(String, Value)]) }
A value to print, as the shapes a caller's own data comes in.
pub fn Value::summary(Self) -> String
The one-line reading of a value, which is what is printed when the whole thing fits.
letascii
pub let ascii : Border
letcalendar_width
pub let calendar_width : Int32
Days are drawn in three cells, so a month is twenty-one cells wide.
letdouble
pub let double : Border
letheavy
pub let heavy : Border
letok
pub let ok : Array[String]
The buttons a dialog usually carries, as labels.
letok_cancel
pub let ok_cancel : Array[String]
letround
pub let round : Border
letthin
pub let thin : Border
letyes_no
pub let yes_no : Array[String]
letyes_no_cancel
pub let yes_no_cancel : Array[String]
fnalign_line
pub fn align_line(String, Int32, Align, @style.Style) -> @strip.Strip
fnclip_to
pub fn clip_to(String, Int32) -> String
fnframe
pub fn frame(Border, Int32, @geom.Size, @style.Style, @strip.Strip) -> @strip.Strip
fnlabel
pub fn label(String, style? : @style.Style) -> Static
appmoonbitstack/moonetui/app
Widget tree, focus ring and frame loop. The host calls step because wasm-gc has no async and a browser cannot block.
typeAnim
pub(all) struct Anim { from : @geom.Region to : @geom.Region start : Int32 ms : Int32 }
One node gliding from where it was to where the layout just put it. The times are milliseconds off the driver's clock.
pub fn Anim::at(Self, Int32) -> @geom.Region
Where the node sits at now: eased from the old place toward the new one, and landed once the span has passed.
typeApp
pub struct App[D] { driver : D plain : Bool quit : Array[@event.Key] mut root : Node parser : @input.Parser mut base : @style.Style mut sheet : @design.Stylesheet frame_ms : Int32 mut rects : Map[Int32, @geom.Region] mut bare : Map[Int32, @geom.Region] mut views : Map[Int32, View] mut styled : Map[Int32, @design.Resolved] inbox : Array[@widget.Out] handlers : Array[(@widget.Out) -> Bool] timers : Array[Timer] screens : Array[Screen] mut anims : Map[Int32, Anim] mut prev_bare : Map[Int32, @geom.Region] mut prev_rects : Map[Int32, @geom.Region] mut size : @geom.Size mut focus : Int32 mut hover : Int32 off : Array[Int32] mut prev : Array[@strip.Strip] mut scene : @comp.Scene damage : Array[Int32] mut wiped : Bool mut layout : Bool mut dirty : Bool mut running : Bool mut last_frame : Int32 mut pending_resize : @geom.Size? mut resize_at : Int32 mut measured : @geom.Size mut ticked : Int32 }
pub fn[D : @driver.Driver] App::after(Self[D], Int32, () -> Unit) -> Unit
pub fn[D] App::disable(Self[D], Int32) -> Unit
A disabled node takes no input, holds no focus, and can be restyled by the :disabled pseudo-class.
pub fn[D] App::drain(Self[D]) -> Array[@widget.Out]
pub fn[D] App::enable(Self[D], Int32) -> Unit
pub fn[D : @driver.Driver] App::every(Self[D], Int32, () -> Unit) -> Unit
Run fire every ms milliseconds of the driver's clock, until the app stops.
pub fn[D] App::focus_next(Self[D], Int32) -> Unit
pub fn[D] App::focused(Self[D]) -> Int32
pub fn[D] App::hovering(Self[D]) -> Int32
pub fn[D] App::is_disabled(Self[D], Int32) -> Bool
pub fn[D] App::new(D, Node, base? : @style.Style, sheet? : @design.Stylesheet, fps? : Int32, plain? : Bool, quit? : Array[@event.Key]) -> Self[D]
pub fn[D] App::on(Self[D], (@widget.Out) -> Bool) -> Unit
The app's message hook: every message a widget emits, and every focus or scroll move the app itself reports, passes here first. A handler that answers true claims the message and the built-in behaviour never runs.
pub fn[D] App::pop_screen(Self[D]) -> Unit
pub fn[D] App::post(Self[D], @widget.Out) -> Unit
Put a message in the stream the app drains from, as if a widget had sent it.
pub fn[D] App::push_screen(Self[D], Node) -> Unit
Cover the screen with a new tree: the one showing, and where its focus sits, is pushed down and comes back when popped.
pub fn[D] App::quit(Self[D]) -> Unit
pub fn[D] App::rect_of(Self[D], Int32) -> @geom.Region
pub fn[D] App::refresh(Self[D]) -> Unit
Draw the next frame whole. A host calls this after changing a widget behind its back; a widget that answers a key asks for its own rows instead.
pub fn[D] App::repaint(Self[D], Int32) -> Unit
Compose again the rows the node sits on, on the placements the last frame left behind. This is the cheap frame: a list that moved its cursor redraws its own rows and leaves the rest of the screen as it stands.
pub fn[D] App::repaint_region(Self[D], @geom.Region) -> Unit
Compose again the rows a part of the screen covers, for a host that has no node to name.
pub fn[D : @driver.Driver] App::run(Self[D]) -> Unit raise
pub fn[D] App::screen(Self[D]) -> Array[String]
pub fn[D] App::screen_depth(Self[D]) -> Int32
pub fn[D] App::set_sheet(Self[D], @design.Stylesheet) -> Unit
Restyle the whole tree with another stylesheet, as a theme switch does.
pub fn[D] App::set_theme(Self[D], @design.Theme) -> Unit
Restyle the whole tree with another theme: the colours it inherits, and the rules every role names. One call is a theme switch.
pub fn[D : @driver.Driver] App::start(Self[D]) -> Unit raise
pub fn[D : @driver.Driver] App::step(Self[D]) -> Bool raise
pub fn[D : @driver.Driver] App::stop(Self[D]) -> Unit raise
pub fn[D] App::swap_root(Self[D], Node) -> Unit
Swap the tree the app is showing, keeping the focus where it was. The frame loop redraws on the next step.
typeNode
pub enum Node { Leaf(id~ : Int32, widget~ : &@widget.Widget, box~ : @layout.Box, name~ : String, classes~ : Array[String], styles~ : @design.Styles) Stack(id~ : Int32, dir~ : @layout.Dir, box~ : @layout.Box, gap~ : Int32, kids~ : Array[Node], name~ : String, classes~ : Array[String], styles~ : @design.Styles) Grid(id~ : Int32, cols~ : Int32, rows~ : Int32, gutter~ : Int32, box~ : @layout.Box, kids~ : Array[Node], name~ : String, classes~ : Array[String], styles~ : @design.Styles) Scroll(id~ : Int32, kid~ : Node, box~ : @layout.Box, state~ : ScrollState, bar~ : @style.Style, name~ : String, classes~ : Array[String], styles~ : @design.Styles) }
pub fn Node::box(Self) -> @layout.Box
pub fn Node::contains_id(Self, Int32) -> Bool
pub fn Node::find(Self, Int32) -> &@widget.Widget?
pub fn Node::focus_ring(Self, theme? : Theme) -> Array[Int32]
pub fn Node::hint(Self, @geom.Size, @layout.Dir, theme? : Theme) -> Int32
pub fn Node::id(Self) -> Int32
pub fn Node::place(Self, @geom.Region, @geom.Region, @comp.Scene, Map[Int32, @geom.Region], styled? : Map[Int32, @design.Resolved], theme? : Theme, inherited? : @style.Style, views? : Map[Int32, View], bare? : Map[Int32, @geom.Region], offsets? : Map[Int32, @geom.Offset]) -> Unit
pub fn Node::resolve(Self, Theme, @style.Style) -> @design.Resolved
pub fn Node::scroll_around(Self, Int32) -> (Int32, ScrollState)?
The innermost scroll container holding this id, deepest first. A scroll counts itself, so the container holding key focus scrolls on the keys the widget under focus did not take.
typeScreen
pub(all) struct Screen { root : Node focus : Int32 }
typeScrollState
pub(all) struct ScrollState { mut x : Int32 mut y : Int32 mut vw : Int32 mut vh : Int32 mut cw : Int32 mut ch : Int32 }
pub fn ScrollState::max_x(Self) -> Int32
pub fn ScrollState::max_y(Self) -> Int32
pub fn ScrollState::new() -> Self
pub fn ScrollState::scroll_by(Self, dx? : Int32, dy? : Int32) -> Bool
pub fn ScrollState::scroll_to(Self, x? : Int32, y? : Int32) -> Bool
typeTheme
pub(all) struct Theme { sheet : @design.Stylesheet focus : Int32 hover : Int32 disabled : Array[Int32] base : @style.Style }
pub fn Theme::new(sheet? : @design.Stylesheet, focus? : Int32, hover? : Int32, disabled? : Array[Int32], base? : @style.Style) -> Self
typeTimer
pub(all) struct Timer { ms : Int32 at : Int32 repeat : Bool fire : () -> Unit }
typeView
pub(all) struct View { state : ScrollState bar : @style.Style vbar : Bool hbar : Bool }
letctrl_c
pub let ctrl_c : @event.Key
The quit key most terminal programs answer to. An application whose text fields want it for copying passes another list, or [] and quits itself.
letesc
pub let esc : @event.Key
Escape, which readers expect to leave a screen, and which is handed to the widget under the keyboard first: a dialog closes before the program does.
letq
pub let q : @event.Key
q, the other key readers try when they want out.
fncolumn
pub fn column(Int32, Array[Node], box? : @layout.Box, gap? : Int32, name? : String, classes? : Array[String], styles? : @design.Styles) -> Node
fngrid
pub fn grid(Int32, Array[Node], cols~ : Int32, rows? : Int32, gutter? : Int32, box? : @layout.Box, name? : String, classes? : Array[String], styles? : @design.Styles) -> Node
fnleaf
pub fn leaf(Int32, &@widget.Widget, box? : @layout.Box, name? : String, classes? : Array[String], styles? : @design.Styles) -> Node
fnrow
pub fn row(Int32, Array[Node], box? : @layout.Box, gap? : Int32, name? : String, classes? : Array[String], styles? : @design.Styles) -> Node
fnscroll
pub fn scroll(Int32, Node, box? : @layout.Box, state? : ScrollState, bar? : @style.Style, name? : String, classes? : Array[String], styles? : @design.Styles) -> Node
drivermoonbitstack/moonetui/driver
The seam to a terminal: write, read, raw mode, size, and a clock.
traitDriver
pub(open) trait Driver { fn start(Self) -> Unit raise Refused fn stop(Self) -> Unit raise Refused fn write(Self, String) -> Unit raise Refused fn flush(Self) -> Unit raise Refused fn size(Self) -> @geom.Size raise Refused fn poll(Self, Int32) -> Bytes raise Refused fn now(Self) -> Int32 }
typeHeadless
pub struct Headless { mut size : @geom.Size script : Array[Bytes] mut next : Int32 out : StringBuilder mut clock : Int32 tick : Int32 mut started : Bool mut stopped : Bool }
Driverpub fn Headless::clear_output(Self) -> Unit
pub fn Headless::flush(Self) -> Unit raise Refused
pub fn Headless::is_running(Self) -> Bool
pub fn Headless::new(@geom.Size, script? : Array[Bytes], tick? : Int32) -> Self
pub fn Headless::now(Self) -> Int32
pub fn Headless::output(Self) -> String
pub fn Headless::poll(Self, Int32) -> Bytes raise Refused
pub fn Headless::push(Self, Bytes) -> Unit
pub fn Headless::set_size(Self, @geom.Size) -> Unit
pub fn Headless::size(Self) -> @geom.Size raise Refused
pub fn Headless::start(Self) -> Unit raise Refused
pub fn Headless::stop(Self) -> Unit raise Refused
pub fn Headless::write(Self, String) -> Unit raise Refused
errorRefused
pub(all) suberror Refused { Io(String) }
letdisable_focus
pub let disable_focus : String
letdisable_mouse
pub let disable_mouse : String
letdisable_paste
pub let disable_paste : String
letdisable_resize
pub let disable_resize : String
letenable_focus
pub let enable_focus : String
letenable_mouse
pub let enable_mouse : String
letenable_paste
pub let enable_paste : String
letenable_resize
pub let enable_resize : String
letenter_alt
pub let enter_alt : String
letleave_alt
pub let leave_alt : String
fnenter
pub fn enter(alt? : Bool, mouse? : Bool, paste? : Bool, focus? : Bool, resize? : Bool) -> String
fnleave
pub fn leave(alt? : Bool, mouse? : Bool, paste? : Bool, focus? : Bool, resize? : Bool) -> String
driver/nativemoonbitstack/moonetui/driver/native
A real terminal through the C library; Windows runs in virtual terminal mode so one parser and one renderer serve both.
typeNativeTty
pub struct NativeTty { buffer : FixedArray[Byte] scratch : FixedArray[Int32] mut started : Bool mut raw : Bool }
@driver.Driverpub fn NativeTty::flush(Self) -> Unit raise @driver.Refused
pub fn NativeTty::is_raw(Self) -> Bool
pub fn NativeTty::new(buffer_size? : Int32) -> Self
pub fn NativeTty::now(Self) -> Int32
pub fn NativeTty::poll(Self, Int32) -> Bytes raise @driver.Refused
pub fn NativeTty::size(Self) -> @geom.Size raise @driver.Refused
pub fn NativeTty::start(Self) -> Unit raise @driver.Refused
pub fn NativeTty::stop(Self) -> Unit raise @driver.Refused
pub fn NativeTty::write(Self, String) -> Unit raise @driver.Refused
fnrun
pub fn run(() -> Bool raise) -> Unit raise
driver/nodemoonbitstack/moonetui/driver/node
Node's standard streams. Input arrives by callback, so poll drains a queue.
typeNodeTty
pub struct NodeTty { mut started : Bool }
@driver.Driverpub fn NodeTty::flush(Self) -> Unit raise @driver.Refused
pub fn NodeTty::new() -> Self
pub fn NodeTty::now(Self) -> Int32
pub fn NodeTty::poll(Self, Int32) -> Bytes raise @driver.Refused
pub fn NodeTty::size(Self) -> @geom.Size raise @driver.Refused
pub fn NodeTty::start(Self) -> Unit raise @driver.Refused
pub fn NodeTty::stop(Self) -> Unit raise @driver.Refused
pub fn NodeTty::write(Self, String) -> Unit raise @driver.Refused
fnpump
pub fn pump(Int32, () -> Bool) -> Unit
driver/webmoonbitstack/moonetui/driver/web
A terminal drawn on a canvas, reading the same escape stream a real one would.
fnpump
pub fn pump(() -> Bool) -> Unit
Call tick once per animation frame for as long as it returns true.
Nothing public matches that name.