class

Tui::Buffer

Inherits Reference / Object

Constructors

new(width : Int32, height : Int32)
Source

Instance methods

clear(cell : Cell = Cell.empty) : Nil

Clear buffer with optional cell

Source
debug_dump

Debug dump: show non-space characters with positions

Source
draw_box(x : Int32, y : Int32, w : Int32, h : Int32, style : Style = Style.default, border_style : BorderStyle = BorderStyle::Light) : Nil

Draw a box using BorderStyle enum

Source
draw_box(x : Int32, y : Int32, w : Int32, h : Int32, style : Style, border_style : Symbol) : Nil

Legacy overload accepting Symbol for backwards compatibility

Source
draw_hline(x : Int32, y : Int32, length : Int32, char : Char = '─', style : Style = Style.default) : Nil

Draw a horizontal line

Source
draw_string(x : Int32, y : Int32, text : String, style : Style = Style.default) : Int32

Draw a string at position (with Unicode width support)

Source
draw_vline(x : Int32, y : Int32, length : Int32, char : Char = '│', style : Style = Style.default) : Nil

Draw a vertical line

Source
fill(x : Int32, y : Int32, w : Int32, h : Int32, cell : Cell = Cell.empty) : Nil

Fill a rectangle

Source
flush(io : IO) : Nil

Flush changes to IO (typically STDOUT)

Source
get(x : Int32, y : Int32) : Cell

Get a cell at position

Source
height
Source
in_bounds?(x : Int32, y : Int32) : Bool

Check if position is within bounds

Source
invalidate

Force full redraw on next flush

Source
invalidate_region(x : Int32, y : Int32, width : Int32, height : Int32) : Nil

Force redraw of a specific region

Source
resize(new_width : Int32, new_height : Int32) : Nil

Resize buffer

Source
save_ansi(path : String) : Nil

Save buffer as ANSI-colored text file

Source
set(x : Int32, y : Int32, cell : Cell) : Nil

Set a cell at position

Source
set(x : Int32, y : Int32, char : Char, style : Style = Style.default) : Int32

Set a cell with char and style (auto-detects wide characters) Returns the display width of the character (1 or 2)

Source
set(x : Int32, y : Int32, text : String, style : Style = Style.default) : Int32

Set a cell with grapheme and style (auto-detects wide graphemes) Returns the display width of the grapheme (1 or 2)

Source
set_wide(x : Int32, y : Int32, char : Char, style : Style = Style.default) : Int32

Set a wide character (handles 2-cell characters like emoji/CJK) Note: set(x, y, char, style) now auto-detects wide chars, so this is mainly for explicit use or backwards compatibility

Source
set_wide(x : Int32, y : Int32, text : String, style : Style = Style.default) : Int32
Source
to_ansi

Get buffer content with ANSI color codes (for visual debugging)

Source
to_grid

Get buffer as simple grid for analysis (returns array of rows) Continuation cells (second half of wide chars) are skipped to match terminal display

Source
to_s(io : IO) : Nil

Get buffer content as string (for testing)

Source
width
Source