README

mizchi/tui/render does not have a README file

#
App

pub struct App {
width : Int
height : Int
prev_buffer : CharBuffer?
last_layout :
Layout
?
handlers :
EventHandlers

}

App manages the render loop and diff-based updates

#
App::clear_prev_buffer

fn App::clear_prev_buffer(self : App) -> Unit

Clear the previous buffer to force a full re-render on next render call

#
App::create_render_effect

fn App::create_render_effect(self : App, render_fn : () ->
Component
, output_fn : (String) -> Unit) -> (() -> Unit)

Create a reactive effect that re-renders when signals change Returns a dispose function

#
App::dispatch_click

fn App::dispatch_click(self : App, event :
MouseEvent
, handlers : Map[String, () -> Unit]) -> String?

Dispatch a click event to handlers based on hit test result Returns the clicked component ID if found, None otherwise

#
App::dispatch_click_from_component

fn App::dispatch_click_from_component(self : App, event :
MouseEvent
, component :
Component
) -> String?

Dispatch a click event using Component's click_handlers Returns the clicked component ID if found and handler was invoked, None otherwise

#
App::dispatch_click_with_result

Dispatch a click event, returns hit result for custom handling

#
App::dispatch_hover

fn App::dispatch_hover(self : App, event :
MouseEvent
) -> String?

Dispatch hover event - returns hovered component ID on Move/Drag events

#
App::find_by_id

fn App::find_by_id(self : App, id : String) ->
HitTestResult
?

Find component by ID

#
App::handle_mouse

fn App::handle_mouse(self : App, event :
MouseEvent
) -> Bool

Handle a mouse event Returns true if an event handler was invoked

#
App::hit_test

fn App::hit_test(self : App, x : Int, y : Int) ->
HitTestResult
?

Perform hit test at coordinates

#
App::init_terminal

fn App::init_terminal() -> String

Initialize terminal (enter alt screen, hide cursor)

#
App::new

fn App::new(width : Int, height : Int) -> App

#
App::on_click

fn App::on_click(self : App, id : String, handler : () -> Unit) -> Unit

Register a click handler for a component ID

#
App::render

fn App::render(self : App, component :
Component
) -> String

Render a component tree to ANSI string

#
App::render_frame

fn App::render_frame(self : App, component :
Component
) -> String

Render with cursor hidden and positioned at origin

#
App::render_with_offset

fn App::render_with_offset(self : App, component :
Component
, row_offset? : Int, col_offset? : Int) -> String

Render a component tree with a cursor offset (no screen clear)

#
App::restore_terminal

fn App::restore_terminal() -> String

Restore terminal (show cursor, leave alt screen)

#
CharBuffer

pub struct CharBuffer {
width : Int
height : Int
cells : Array[CharCell]
}

Character-based framebuffer

#
CharBuffer::clear

fn CharBuffer::clear(self : CharBuffer) -> Unit

#
CharBuffer::clone

fn CharBuffer::clone(self : CharBuffer) -> CharBuffer

Clone the buffer

#
CharBuffer::diff_to_ansi

fn CharBuffer::diff_to_ansi(self : CharBuffer, prev : CharBuffer) -> String

Optimized ANSI output with diff (only output changed cells)

#
CharBuffer::diff_to_ansi_offset

fn CharBuffer::diff_to_ansi_offset(self : CharBuffer, prev : CharBuffer, row_offset : Int, col_offset : Int) -> String

Optimized ANSI output with diff and an offset

#
CharBuffer::fill_bg

fn CharBuffer::fill_bg(self : CharBuffer, x : Int, y : Int, w : Int, h : Int, bg :
Color
) -> Unit

Fill background color and overwrite content with spaces This allows overlays to properly cover underlying content

#
CharBuffer::fill_rect

fn CharBuffer::fill_rect(self : CharBuffer, x : Int, y : Int, w : Int, h : Int, cell : CharCell) -> Unit

#
CharBuffer::get_cell

fn CharBuffer::get_cell(self : CharBuffer, x : Int, y : Int) -> CharCell

#
CharBuffer::new

fn CharBuffer::new(width : Int, height : Int) -> CharBuffer

#
CharBuffer::set_cell

fn CharBuffer::set_cell(self : CharBuffer, x : Int, y : Int, cell : CharCell) -> Unit

#
CharBuffer::to_ansi

fn CharBuffer::to_ansi(self : CharBuffer) -> String

Convert CharBuffer to ANSI-encoded string

#
CharBuffer::to_ansi_offset

fn CharBuffer::to_ansi_offset(self : CharBuffer, row_offset : Int, col_offset : Int) -> String

Convert CharBuffer to ANSI-encoded string with an offset

#
CharBuffer::write_text

fn CharBuffer::write_text(self : CharBuffer, x : Int, y : Int, text : String, style : TextStyle, max_width : Int) -> Int

#
CharBuffer::write_text_wrapped

fn CharBuffer::write_text_wrapped(self : CharBuffer, x : Int, y : Int, text : String, style : TextStyle, max_width : Int, max_height : Int) -> Int

#
CharCell

pub(all) struct CharCell {
char : Char
fg :
Color

bg :
Color

bold : Bool
underline : Bool
reverse : Bool
}

A single character cell in the terminal
impl Eq for CharCell

#
CharCell::default

fn CharCell::default() -> CharCell

#
CharCell::from_char

fn CharCell::from_char(c : Char) -> CharCell

#
CharCell::styled

#
TextStyle

pub(all) struct TextStyle {
fg :
Color

bg :
Color

bold : Bool
underline : Bool
}

Text style for writing text

#
TextStyle::default

fn TextStyle::default() -> TextStyle

#
ansi_bg_256

fn ansi_bg_256(color_idx : Int) -> String

#
ansi_bg_color

fn ansi_bg_color(color :
Color
) -> String

#
ansi_bg_reset

fn ansi_bg_reset() -> String

Reset background color to default

#
ansi_bold

fn ansi_bold() -> String

#
ansi_clear_line

fn ansi_clear_line() -> String

#
ansi_clear_screen

fn ansi_clear_screen() -> String

#
ansi_dim

fn ansi_dim() -> String

#
ansi_enter_alt_screen

fn ansi_enter_alt_screen() -> String

#
ansi_fg_256

fn ansi_fg_256(color_idx : Int) -> String

#
ansi_fg_black

fn ansi_fg_black() -> String

#
ansi_fg_blue

fn ansi_fg_blue() -> String

#
ansi_fg_color

fn ansi_fg_color(color :
Color
) -> String

#
ansi_fg_cyan

fn ansi_fg_cyan() -> String

#
ansi_fg_gray

fn ansi_fg_gray() -> String

Dim gray (bright black)

#
ansi_fg_green

fn ansi_fg_green() -> String

#
ansi_fg_magenta

fn ansi_fg_magenta() -> String

#
ansi_fg_red

fn ansi_fg_red() -> String

#
ansi_fg_white

fn ansi_fg_white() -> String

#
ansi_fg_yellow

fn ansi_fg_yellow() -> String

#
ansi_full_reset

fn ansi_full_reset() -> String

Full terminal reset sequence for recovering from corrupted state

#
ansi_hide_cursor

fn ansi_hide_cursor() -> String

#
ansi_leave_alt_screen

fn ansi_leave_alt_screen() -> String

#
ansi_move_down

fn ansi_move_down(n? : Int) -> String

Move cursor down by n lines

#
ansi_move_left

fn ansi_move_left(n? : Int) -> String

Move cursor left by n columns

#
ansi_move_right

fn ansi_move_right(n? : Int) -> String

Move cursor right by n columns

#
ansi_move_to

fn ansi_move_to(row : Int, col : Int) -> String

#
ansi_move_up

fn ansi_move_up(n? : Int) -> String

Move cursor up by n lines

#
ansi_reset

fn ansi_reset() -> String

#
ansi_reset_attrs

fn ansi_reset_attrs() -> String

Reset all terminal attributes (colors, styles)

#
ansi_reverse

fn ansi_reverse() -> String

#
ansi_show_cursor

fn ansi_show_cursor() -> String

#
ansi_underline

fn ansi_underline() -> String

#
color_to_256

fn color_to_256(color :
Color
) -> Int

#
compute_layout

fn compute_layout(node :
Node
, width : Int, height : Int) ->
Layout

Compute layout using layout tree with character-based viewport

#
compute_layout_max_content

fn compute_layout_max_content(node :
Node
, width : Int, height : Int) ->
Layout

Compute layout in intrinsic (MaxContent) mode. Useful for shrink-wrapped overlays/popups.

#
disable_mouse

fn disable_mouse() -> String

#
disable_mouse_all

fn disable_mouse_all() -> String

Disable mouse motion tracking

#
enable_mouse

fn enable_mouse() -> String

#
enable_mouse_all

fn enable_mouse_all() -> String

Enable mouse with motion tracking (reports move events even without button press)

#
render_layout

fn render_layout(buf : CharBuffer, layout :
Layout
, styles :
RenderStyleMap
, texts :
TextContentMap
, offset_x : Int, offset_y : Int) -> Unit

Render Layout to CharBuffer

#
render_once

fn render_once(width : Int, height : Int, component :
Component
) -> String

Simple render function for one-shot rendering (no reactivity)

#
render_to_ansi

fn render_to_ansi(layout :
Layout
, styles :
RenderStyleMap
, texts :
TextContentMap
, width : Int, height : Int) -> String

Quick render function: Layout -> ANSI string

#
rgb_to_256

fn rgb_to_256(r : Int, g : Int, b : Int) -> Int

Convert RGB color to 256-color palette index

#
run_app

fn run_app(width : Int, height : Int, render_fn : () ->
Component
, output_fn : (String) -> Unit) -> (() -> Unit)

Full-screen app helper: sets up alt screen and handles cleanup

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io