class TUI::Screen

Defined in:

tui/core/screen.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def at(row : Int32, col : Int32, s : String) : Nil #

Write directly into the back buffer at absolute terminal coordinates. For App-level drawing that isn't owned by any single widget (status bar, dividers between panes).


[View source]
def blit(x : Int32, y : Int32, buffer : Buffer) : Nil #

Composite a widget's local buffer onto the back buffer at (x, y). x/y are 1-based terminal coordinates (matching Widget#x/#y convention). Cells landing outside the currently active #with_clip rect (if any) are silently dropped, same "out of bounds is a no-op, not an error" convention Buffer#set_cell already uses for the screen's own edges.


[View source]
def cell(row : Int32, col : Int32) : BufferCell #

Read back a cell from the back buffer — the one composited widgets have just blitted into, before the next #flush swaps it to front. Exists for specs to assert on composited output; app code should never need to read cells back out of the screen it just drew.


[View source]
def cols : Int32 #

[View source]
def flush : Nil #

Diff @back against @front, emit only changed cells, then swap.

The real terminal cursor stays hidden across frames — apps draw their own selection highlight (reverse-video rows, block glyphs for text input) rather than relying on the terminal's cursor to convey position. A caller that needs the native cursor visible (e.g. a text field mid-edit) should show it and move it itself after calling flush, then hide it again before the next flush.


[View source]
def refresh_size : Nil #

[View source]
def rows : Int32 #

Current terminal size in character cells, refreshed by #refresh_size on resize. 0-based row/col math elsewhere in this class treats these as the exclusive upper bound.


[View source]
def status_bar(row : Int32, text : String) : Nil #

Status bar: fill entire row with reverse-video text (absolute coords).


[View source]
def status_bar_style : Style #

Applied to the whole row drawn by #status_bar.


[View source]
def status_bar_style=(status_bar_style : Style) #

Applied to the whole row drawn by #status_bar.


[View source]
def vline(x : Int32, y : Int32, h : Int32) : Nil #

Draw a vertical line at absolute terminal coordinates, e.g. a divider between two side-by-side widget panes.


[View source]
def with_clip(rect : ClipRect, & : -> Nil) : Nil #

Bounds every #blit inside block to rect, intersected with whatever clip is already active (so a clip can only narrow, never widen, no matter how many containers are nested). Always restores the previous clip afterward, even if block raises, so a container's own clip can never leak past its own #composite call. Default (@clip nil) is "no bound" — existing callers that never call #with_clip see zero behavior change.


[View source]