class

Smith::UI::Terminal

Inherits Reference < Object

Terminal size query and raw-mode handling. Wraps the few ioctls and termios calls the UI needs, so everything else deals in plain methods.

Constants

DEFAULT_HEIGHT = 24
DEFAULT_WIDTH = 80
TIOCGWINSZ = {% if (flag?(:darwin)) || (flag?(:bsd)) %} 0x40087468_u64 {% elsif flag?(:linux) %} 0x5413_u64 {% else %} 0_u64 {% end %}

Constructors

new(io : IO = STDOUT, input : IO = STDIN, color : Bool = true, width : Int32 | Nil = nil, height : Int32 | Nil = nil)
Source

Instance methods

clear_line
Source
clear_resize!
Source
color?
Source
cursor_to_column(n : Int32) : Nil
Source
cursor_up(n : Int32) : Nil
Source
enter!
Source
height
Source
hide_cursor
Source
install_winch_handler
Source
leave!
Source
mark_resized!

The window changed size. Set from the SIGWINCH handler above; specs drive it directly, having no window to drag.

Source
newline
Source
raw?
Source
read_key(timeout : Time::Span = 50.milliseconds) : Key

Reads a key, waiting at most timeout. Returns Tick when nothing arrived in that window, Resized when the window changed, Eof when the input is gone for good.

Source
resized?
Source
show_cursor
Source
size
Source
width
Source
write(text : String) : Nil
Source
write_line(line : StyledLine) : Nil
Source