class Tput
- Tput
- Reference
- Object
Overview
Many Tput methods correspond to terminal sequences. Often times methods are named according to their purpose, and then aliased to the names of sequences used behind the scenes.
For example, method #delete_columns is directly implemented using sequence decdc.
Therefore, it is also accessible under the alias #decdc.
Furthermore, for understanding the instructions on terminal sequences, the following names are important:
ESC - Sequence starting with ESC (\e)
CSI - Control Sequence Introducer: sequence starting with ESC [ (7bit) or CSI (\x9B, 8bit)
DCS - Device Control String: sequence starting with ESC P (7bit) or DCS (\x90, 8bit)
OSC - Operating System Command: sequence starting with ESC ] (7bit) or OSC (\x9D, 8bit)
C0: single byte command (7bit control codes, byte range \x00 .. \x1F, \x7F)
C1: single byte command (8bit control codes, byte range \x80 .. \x9F)
Some sequences accept arguments. Their naming and types correspond to those used in XTerm documentation:
Ps: A single (usually optional) numeric parameter, composed of one or more decimal digits.
Pm: A multiple numeric parameter composed of any number of single numeric parameters, separated by ";", e.g. ` Ps ; Ps ; … `.
Pt: A text parameter composed of printable characters.
In all of the examples above, spaces exist just for clarity and are not part of actual escape sequences. For example, in "ESC [" or " Ps ; Ps ;" there are no actual spaces.
Included Modules
- Crystallabs::Helpers::Logging
- JSON::Serializable
- Tput::ACSC
- Tput::Coordinates
- Tput::Input
- Tput::Keyboard
- Tput::Namespace
- Tput::Output
- Tput::Probe
- Tput::Response
Defined in:
tput.crtput/acsc.cr
tput/coordinates.cr
tput/dump.cr
tput/emulator.cr
tput/features.cr
tput/input.cr
tput/key_event.cr
tput/keyboard.cr
tput/keys.cr
tput/mouse.cr
tput/namespace.cr
tput/output.cr
tput/output/bell.cr
tput/output/charset.cr
tput/output/colors.cr
tput/output/cursor.cr
tput/output/emulator.cr
tput/output/misc.cr
tput/output/mouse.cr
tput/output/rectangles.cr
tput/output/screen.cr
tput/output/scrolling.cr
tput/output/terminal.cr
tput/output/text.cr
tput/probe.cr
tput/response.cr
tput/unicode.cr
Constant Summary
-
CSI7 =
"\e[" -
CSI8 =
"\x9B" -
DCS7 =
"\eP" -
DCS8 =
"\x90" -
DEFAULT_SCREEN_SIZE =
Size.new(80, 24) -
ESC =
"\e" -
Log =
::Log.for((self.name.gsub("::", '.')).underscore) -
OSC7 =
"\e]" -
OSC8 =
"\x9D" -
VERSION =
"1.0.8"
Constructors
- .new(pull : JSON::PullParser)
- .new(terminfo : Nil | Unibilium = nil, input : IO = STDIN, output : IO = STDOUT, error : IO = STDERR, force_unicode = nil, use_buffer : Bool = Superconf.tput_use_buffer, screen_size = nil, probe = Superconf.tput_probe)
Class Method Summary
-
.build_detections(pairs, sources : Hash(String, String)) : Hash(String, Detection)
Builds a
{name => Detection}map, pairing each stringified value with its recorded provenance from sources (or"unknown").
Instance Method Summary
- #_exiting=(_exiting : Bool)
- #_exiting? : Bool
-
#_saved : Hash(String | Symbol | UInt64, Tput::Namespace::CursorState)
Internal cursor-save state.
-
#_saved=(_saved : Hash(String | Symbol | UInt64, Tput::Namespace::CursorState))
Internal cursor-save state.
- #_title : String
-
#aliases : Array(String)
Terminfo aliases for
#name(downcased), e.g. -
#attr_cache_limit : Int32
Upper bound on
@_attr_cache; once reached, the oldest-inserted entry is evicted before each new insert. -
#attr_cache_limit=(attr_cache_limit : Int32)
Upper bound on
@_attr_cache; once reached, the oldest-inserted entry is evicted before each new insert. -
#bracketed_paste_enabled? : Bool
Whether bracketed paste (DEC 2004) is currently enabled.
-
#capture(&) : String
Captures the escape sequences emitted by the block and returns them as a
String, instead of writing them to the terminal. - #cursor : Point
- #cursor_hidden? : Bool
-
#detections : Hash(String, Hash(String, Detection))
All detected emulator + feature information, each value paired with a description of how it was determined.
-
#dump(io : IO = STDOUT) : Nil
Dumps all detected emulator and feature information to io (STDOUT by default) in an aligned, human-readable report.
- #emulator : Emulator
- #emulator? : Emulator | Nil
- #error : IO
- #error=(error : IO)
- #features : Features
- #features? : Features | Nil
- #force_unicode? : Bool
- #has?(&)
-
#in_band_resize_enabled? : Bool
Whether in-band resize notifications (DEC 2048) are currently enabled.
- #input : IO
- #input=(input : IO)
- #is_alt : Bool
-
#keyboard_protocol : KeyboardProtocol | Nil
The enhanced keyboard protocol currently enabled (tracked by
#enable_keyboard_protocol/#disable_keyboard_protocol), ornilwhen only the always-availableLegacybaseline is active. -
#mouse_cell_pixels : Tuple(Int32, Int32) | Nil
When SGR-Pixels (DEC private mode 1016) mouse reporting is active, the terminal's cell size in pixels (
{cell_w, cell_h}) used to derive cell coordinates from the pixel coordinates the terminal now reports;nil(the default) means pixel mode is off and\e[<…M/mreports are decoded as ordinary SGR (1006) cell coordinates. -
#mouse_cell_pixels=(mouse_cell_pixels : Tuple(Int32, Int32) | Nil)
When SGR-Pixels (DEC private mode 1016) mouse reporting is active, the terminal's cell size in pixels (
{cell_w, cell_h}) used to derive cell coordinates from the pixel coordinates the terminal now reports;nil(the default) means pixel mode is off and\e[<…M/mreports are decoded as ordinary SGR (1006) cell coordinates. -
#mouse_enabled? : Bool
Whether xterm mouse reporting is currently enabled (tracked by
#enable_mouse/#disable_mouse). -
#mouse_focus_enabled? : Bool?
Whether FocusIn/FocusOut reporting (DEC private mode 1004) is currently enabled (tracked by
#enable_mouse/#disable_mouse). -
#name : String
Resolved primary terminal name — from the loaded terminfo entry, else
$TERM, else the"xterm"fallback — downcased. - #name?(nam : String)
- #name?(*names)
- #output : IO
- #output=(output : IO)
-
#pause(callback : Proc | Nil = nil) : Proc(Nil)
Suspends the program's use of the terminal: saves the cursor, leaves the alternate buffer, shows the cursor, disables mouse reporting, and returns input to cooked mode, leaving the terminal usable by another program (a shell,
$EDITOR, …). -
#put(&)
Outputs a string capability to
@output, if it exists. -
#put_extended(name : String, *args)
Like
#put, but resolves a user-defined (extended) string capability by name and runs it with the given arguments. -
#read_timeout : Time::Span
Timeout when reading escape sequences: an ESC on input could be a lone ESC key or the start of an escape sequence, so we wait this long for more input before treating it as a key press (same approach Vi and others use).
-
#restore_terminal : Nil
Restores the terminal to the state it was in before the program took it over: shows the cursor, leaves the alternate buffer, disables mouse reporting, returns input to cooked mode.
- #resume
- #ret : IO | Nil
- #ret=(ret : IO | Nil)
- #saved_cursor : Point | Nil
- #screen : Size
- #scroll_bottom : Int32
- #scroll_top : Int32
- #shim : Unibilium::Terminfo::Shim | Nil
- #sigtstp(callback)
- #terminfo : Unibilium | Nil
- #use_buffer? : Bool
Instance methods inherited from module Tput::Response
da(param = "", timeout : Time::Span = RESPONSE_TIMEOUT)
da,
da2(timeout : Time::Span = RESPONSE_TIMEOUT)
da2,
decreqtparm(param = 0, timeout : Time::Span = RESPONSE_TIMEOUT)
decreqtparm,
decrqlp(param = "", timeout : Time::Span = RESPONSE_TIMEOUT)
decrqlp,
device_status(param = 0, dec = false, timeout : Time::Span = RESPONSE_TIMEOUT) : Array(Int32) | Nil
device_status,
dsr(param = 0, dec = false, timeout : Time::Span = RESPONSE_TIMEOUT)
dsr,
get_cell_size_pixels(timeout : Time::Span = RESPONSE_TIMEOUT) : Tuple(Int32, Int32) | Nil
get_cell_size_pixels,
get_clipboard(selection : String = "c", timeout : Time::Span = RESPONSE_TIMEOUT) : String | Nil
get_clipboard,
get_cursor(timeout : Time::Span = RESPONSE_TIMEOUT)
get_cursor,
get_cursor_color(timeout : Time::Span = RESPONSE_TIMEOUT) : RGB | Nil
get_cursor_color,
get_text_area_size(timeout : Time::Span = RESPONSE_TIMEOUT)
get_text_area_size,
get_text_area_size_pixels(timeout : Time::Span = RESPONSE_TIMEOUT) : Tuple(Int32, Int32) | Nil
get_text_area_size_pixels,
get_text_params(param : Int32, timeout : Time::Span = RESPONSE_TIMEOUT) : String | Nil
get_text_params,
get_window_size(timeout : Time::Span = RESPONSE_TIMEOUT) : Tuple(Int32, Int32) | Nil
get_window_size,
read_clipboard_response(io : IO, timeout : Time::Span) : String | Nil
read_clipboard_response,
read_color_scheme_response(io : IO, timeout : Time::Span) : ColorScheme | Nil
read_color_scheme_response,
read_cursor_color_response(io : IO, timeout : Time::Span) : RGB | Nil
read_cursor_color_response,
read_cursor_response(io : IO, timeout : Time::Span) : Point | Nil
read_cursor_response,
read_decrqm_response(io : IO, timeout : Time::Span, mode : Int32) : Bool | Nil
read_decrqm_response,
read_device_attributes_response(io : IO, timeout : Time::Span) : Array(Int32) | Nil
read_device_attributes_response,
read_device_status_response(io : IO, timeout : Time::Span) : Array(Int32) | Nil
read_device_status_response,
read_locator_position_response(io : IO, timeout : Time::Span) : Array(Int32) | Nil
read_locator_position_response,
read_pixel_size_response(io : IO, timeout : Time::Span) : Tuple(Int32, Int32) | Nilread_pixel_size_response(io : IO, timeout : Time::Span, *codes : Int32) : Tuple(Int32, Int32) | Nil read_pixel_size_response, read_request_parameters_response(io : IO, timeout : Time::Span) : Array(Int32) | Nil read_request_parameters_response, read_text_params_response(io : IO, timeout : Time::Span, param : Int32) : String | Nil read_text_params_response, read_window_size_response(io : IO, timeout : Time::Span) : Tuple(Int32, Int32) | Nil read_window_size_response, read_xtgettcap_response(io : IO, timeout : Time::Span, expected : Int32 = 1) : Hash(String, String) | Nil read_xtgettcap_response, read_xtversion_response(io : IO, timeout : Time::Span) : String | Nil read_xtversion_response, report_cursor(timeout : Time::Span = RESPONSE_TIMEOUT) : Point | Nil report_cursor, req_mouse_pos(param = "", timeout : Time::Span = RESPONSE_TIMEOUT) req_mouse_pos, request_color_scheme(timeout : Time::Span = RESPONSE_TIMEOUT) : ColorScheme | Nil request_color_scheme, request_locator_position(param = "", timeout : Time::Span = RESPONSE_TIMEOUT) : Array(Int32) | Nil request_locator_position, request_parameters(param = 0, timeout : Time::Span = RESPONSE_TIMEOUT) : Array(Int32) | Nil request_parameters, request_termcap(*names : String, timeout : Time::Span = RESPONSE_TIMEOUT) : Hash(String, String) | Nil request_termcap, request_terminal_version(timeout : Time::Span = RESPONSE_TIMEOUT) : String | Nil request_terminal_version, save_reported_cursor(timeout : Time::Span = RESPONSE_TIMEOUT) : Bool save_reported_cursor, secondary_device_attributes(timeout : Time::Span = RESPONSE_TIMEOUT) : Array(Int32) | Nil secondary_device_attributes, send_device_attributes(param = "", timeout : Time::Span = RESPONSE_TIMEOUT) : Array(Int32) | Nil send_device_attributes, supports_color_scheme_notifications?(timeout : Time::Span = RESPONSE_TIMEOUT) : Bool | Nil supports_color_scheme_notifications?, supports_grapheme_clustering?(timeout : Time::Span = RESPONSE_TIMEOUT) : Bool | Nil supports_grapheme_clustering?, supports_in_band_resize?(timeout : Time::Span = RESPONSE_TIMEOUT) : Bool | Nil supports_in_band_resize?, supports_private_mode?(mode : Int32, timeout : Time::Span = RESPONSE_TIMEOUT) : Bool | Nil supports_private_mode?, supports_synchronized_output?(timeout : Time::Span = RESPONSE_TIMEOUT) : Bool | Nil supports_synchronized_output?, xtgettcap(*names : String, timeout : Time::Span = RESPONSE_TIMEOUT) xtgettcap, xtversion(timeout : Time::Span = RESPONSE_TIMEOUT) xtversion
Instance methods inherited from module Tput::Probe
build_probe_cleanup : String
build_probe_cleanup,
build_probe_query : String
build_probe_query,
probe!(timeout : Time::Span = 3.seconds) : Bool
probe!,
probe_capable? : Bool
probe_capable?,
probe_consume(io : IO, timeout : Time::Span) : ProbeResult
probe_consume
Instance methods inherited from module Tput::Keyboard
best_keyboard_protocol : KeyboardProtocol
best_keyboard_protocol,
disable_keyboard_protocol : Nil
disable_keyboard_protocol,
disable_kitty_keyboard : Nil
disable_kitty_keyboard,
disable_modify_other_keys : Nil
disable_modify_other_keys,
enable_keyboard_protocol(events : Bool = false) : KeyboardProtocol
enable_keyboard_protocol,
enable_kitty_keyboard(flags : KittyKeyboard = KittyKeyboard::DisambiguateEscapeCodes) : Nil
enable_kitty_keyboard,
enable_modify_other_keys(level : Int32 = 2) : Nil
enable_modify_other_keys,
excluded_keyboard_protocols : Array(KeyboardProtocol)
excluded_keyboard_protocols,
keyboard_candidates : Array(KeyboardProtocol)
keyboard_candidates,
keyboard_protocol_supported?(protocol : KeyboardProtocol) : Bool
keyboard_protocol_supported?
Instance methods inherited from module Tput::Input
disable_bracketed_paste : Nil
disable_bracketed_paste,
disable_in_band_resize : Nil
disable_in_band_resize,
enable_bracketed_paste : Nil
enable_bracketed_paste,
enable_in_band_resize : Nil
enable_in_band_resize,
listen(& : InputEvent -> Nil)
listen,
next_char(timeout : Bool = false, &)
next_char,
with_raw_input(&)
with_raw_input,
with_sync_output(&)
with_sync_output
Instance methods inherited from module Tput::Output
_oprint(*args)
_oprint,
_owrite(*args)
_owrite,
_pad_write(code : Bytes) : Bool
_pad_write,
_print(*args)_print(& : IO -> Nil) _print, _tprint(data) _tprint, _with_io(& : IO -> Nil) _with_io, _write(*args) _write, flush flush
Instance methods inherited from module Tput::Output::Terminal
decrqm(param = "")
decrqm,
decrqmp(param = "")
decrqmp,
decrst(*arguments)
decrst,
decscl(*arguments)
decscl,
decset(*arguments)
decset,
disable_keypad
disable_keypad,
enable_keypad
enable_keypad,
manipulate_window(*arguments)
manipulate_window,
maximize_window
maximize_window,
request_ansi_mode(param = "")
request_ansi_mode,
request_private_mode(param = "")
request_private_mode,
reset
reset,
reset_mode(*arguments)
reset_mode,
resize_window(height, width)
resize_window,
restore_private_values(*arguments)
restore_private_values,
rm(*arguments)
rm,
save_private_values(*arguments)
save_private_values,
set_conformance_level(*arguments)
set_conformance_level,
set_mode(*arguments)
set_mode,
sm(*arguments)
sm,
soft_reset
soft_reset,
xtwinops(*arguments)
xtwinops
Instance methods inherited from module Tput::Output::Screen
alternate_buffer
alternate_buffer,
clear
clear,
ed(param = Erase::Below)
ed,
erase_in_display(param = Erase::Below)
erase_in_display,
normal_buffer
normal_buffer
Instance methods inherited from module Tput::Output::Mouse
decefr(*arguments)
decefr,
decelr(*arguments)
decelr,
decsle(*arguments)
decsle,
disable_mouse(focus : Bool = false)
disable_mouse,
enable_filter_rectangle(*arguments)
enable_filter_rectangle,
enable_locator_reporting(*arguments)
enable_locator_reporting,
enable_mouse(focus : Bool | Nil = nil, pixels : Tuple(Int32, Int32) | Bool | Nil = nil)
enable_mouse,
set_locator_events(*arguments)
set_locator_events,
set_mouse(x10 : Bool | Nil = nil, vt200 : Bool | Nil = nil, vt200_hilite : Bool | Nil = nil, cell_motion : Bool | Nil = nil, all_motion : Bool | Nil = nil, send_focus : Bool | Nil = nil, utf : Bool | Nil = nil, sgr : Bool | Nil = nil, urxvt : Bool | Nil = nil, pixels : Bool | Nil = nil, dec : Bool | Nil = nil, pterm : Bool | Nil = nil, jsbterm : Bool | Nil = nil, normal : Bool | Nil = nil, hilite_tracking : Bool | Nil = nil)
set_mouse
Instance methods inherited from module Tput::Output::Rectangles
copy_rectangle(*arguments)
copy_rectangle,
deccara(*arguments)
deccara,
deccra(*arguments)
deccra,
decera(top = 0, left = 0, bottom = @screen.height - 1, right = @screen.width - 1)
decera,
decfra(*arguments)
decfra,
decrara(*arguments)
decrara,
decsace(param = 0)
decsace,
decsera(top = 0, left = 0, bottom = @screen.height - 1, right = @screen.width - 1)
decsera,
erase_rectangle(top = 0, left = 0, bottom = @screen.height - 1, right = @screen.width - 1)
erase_rectangle,
fill_rectangle(*arguments)
fill_rectangle,
reverse_attr_in_rectangle(*arguments)
reverse_attr_in_rectangle,
select_change_extent(param = 0)
select_change_extent,
selective_erase_rectangle(top = 0, left = 0, bottom = @screen.height - 1, right = @screen.width - 1)
selective_erase_rectangle,
set_attr_in_rectangle(*arguments)
set_attr_in_rectangle
Instance methods inherited from module Tput::Output::Bell
bell
bell,
decsmbv=(param : Volume)
decsmbv=,
decswbv=(param : Volume)
decswbv=,
margin_bell_volume=(param : Volume)
margin_bell_volume=,
warning_bell_volume=(param : Volume)
warning_bell_volume=
Instance methods inherited from module Tput::Output::Colors
dynamic_colors(param)
dynamic_colors,
reset_colors(param = "")
reset_colors
Instance methods inherited from module Tput::Output::Emulator
begin_hyperlink(uri : String, id : String | Nil = nil) : Nil
begin_hyperlink,
begin_synchronized_update : Nil
begin_synchronized_update,
clear_clipboard(selection : String = "c") : Nil
clear_clipboard,
copy_to_clipboard(text)
copy_to_clipboard,
disable_color_scheme_notifications : Nil
disable_color_scheme_notifications,
disable_grapheme_clustering : Nil
disable_grapheme_clustering,
disable_modifiers(param = "")
disable_modifiers,
enable_color_scheme_notifications : Nil
enable_color_scheme_notifications,
enable_grapheme_clustering : Nil
enable_grapheme_clustering,
end_hyperlink : Nil
end_hyperlink,
end_synchronized_update : Nil
end_synchronized_update,
hyperlink(text : String, uri : String, id : String | Nil = nil) : Nil
hyperlink,
mouse_cursor_shape(name : String)mouse_cursor_shape(shape : MouseCursorShape) mouse_cursor_shape, progress(progress : Int32 = 0, state : Int32 = 1) : Nil progress, report_cwd(path : String, host : String = "") : Nil report_cwd, request_clipboard(selection : String = "c") : Nil request_clipboard, reset_mouse_cursor_shape reset_mouse_cursor_shape, reset_title_modes(*arguments) reset_title_modes, set_clipboard(text : String, selection : String = "c") : Nil set_clipboard, set_pointer_mode(param = "") set_pointer_mode, set_resources(*arguments) set_resources, set_title_mode_feature(*arguments) set_title_mode_feature, synchronized_update(&) synchronized_update, title=(title : String) title=
Instance methods inherited from module Tput::Output::Charset
charset=(charset : C | Nil)
charset=,
enable_acs
enable_acs,
enter_alt_charset_mode
enter_alt_charset_mode,
exit_alt_charset_mode
exit_alt_charset_mode,
set_g(val)
set_g
Instance methods inherited from module Tput::Output::Scrolling
decstbm(top : Int = 0, bottom : Int = (@screen.height - 1))
decstbm,
index
index,
reverse_index
reverse_index,
scroll_down(param = 1)
scroll_down,
scroll_up(param = 1)
scroll_up,
sd(param = 1)
sd,
set_scroll_region(top : Int = 0, bottom : Int = (@screen.height - 1))
set_scroll_region,
su(param = 1)
su
Instance methods inherited from module Tput::Output::Misc
decll(param = 0)
decll,
escape
escape,
load_leds(param = 0)
load_leds,
mc(*arguments)
mc,
mc0
mc0,
mc4
mc4,
mc5
mc5,
mc5p
mc5p,
media_copy(*arguments)
media_copy,
null
null,
repeat(str, i = 1)
repeat
Instance methods inherited from module Tput::Output::Text
_attr(param : Array | String, val = true)
_attr,
attr(param, val)
attr,
backspace
backspace,
bg(color, val)
bg,
carriage_return
carriage_return,
char_attributes(param, val)
char_attributes,
dch(param = 1)
dch,
decdc(n = 1)
decdc,
decic(n = 1)
decic,
decsca(param = 0)
decsca,
delete_chars(param = 1)
delete_chars,
delete_columns(n = 1)
delete_columns,
delete_line(param : Int = 1)
delete_line,
dl(param : Int = 1)
dl,
ech(param : Int = 1)
ech,
echo(text, attr = nil)
echo,
el(param = LineDirection::Right)
el,
erase_character(param : Int = 1)
erase_character,
erase_chars(param : Int = 1)
erase_chars,
erase_in_line(param = LineDirection::Right)
erase_in_line,
fg(color, val)
fg,
form_feed
form_feed,
horizontal_tabulation_set
horizontal_tabulation_set,
ich(param = 1)
ich,
il(param : Int = 1)
il,
insert_chars(param = 1)
insert_chars,
insert_columns(n = 1)
insert_columns,
insert_line(param : Int = 1)
insert_line,
line_feed
line_feed,
line_height
line_height,
rep(param = 1)
rep,
repeat_preceding_character(param = 1)
repeat_preceding_character,
rpc(param = 1)
rpc,
sel_data(a, b)
sel_data,
set_background(color, val)
set_background,
set_char_protection_attr(param = 0)
set_char_protection_attr,
set_foreground(color, val)
set_foreground,
sgr(param, val)
sgr,
shift_in
shift_in,
shift_out
shift_out,
simple_insert(str, i = 1, attr = nil)
simple_insert,
tab_clear(param = 0)
tab_clear,
tbc(param = 0)
tbc,
text(text, attr)
text,
vertical_tab
vertical_tab
Instance methods inherited from module Tput::Output::Cursor
back(param = 1)
back,
cbt(param = 1)
cbt,
cha(point : Point)cha(param = 0) cha, char_pos_absolute(param = 0) char_pos_absolute, cht(param = 1) cht, cnl(param = 1) cnl, cpl(param = 1) cpl, cub(param = 1) cub, cud(param = 1) cud, cuf(param : Int = 1) cuf, cup(row : Int = 0, column : Int = 0)
cup(point : Tput::Point) cup, cursor_backward(param = 1) cursor_backward, cursor_backward_tab(param = 1) cursor_backward_tab, cursor_char_absolute(point : Point)
cursor_char_absolute(param = 0) cursor_char_absolute, cursor_color(color : String)
cursor_color(color : Color) cursor_color, cursor_down(param = 1) cursor_down, cursor_forward(param : Int = 1) cursor_forward, cursor_forward_tab(param = 1) cursor_forward_tab, cursor_line_absolute(point : Point)
cursor_line_absolute(param = 0) cursor_line_absolute, cursor_move(point : Point)
cursor_move(x = 0, y = 0) cursor_move, cursor_move_to(point : Point)
cursor_move_to(x = 0, y = 0) cursor_move_to, cursor_next_line(param = 1) cursor_next_line, cursor_pos(row : Int = 0, column : Int = 0)
cursor_pos(point : Tput::Point) cursor_pos, cursor_position(row : Int = 0, column : Int = 0)
cursor_position(point : Tput::Point) cursor_position, cursor_preceding_line(param = 1) cursor_preceding_line, cursor_previous_line(param = 1) cursor_previous_line, cursor_right(param : Int = 1) cursor_right, cursor_shape(shape, blink = false) cursor_shape, cursor_up(param = 1) cursor_up, cuu(param = 1) cuu, decscusr(style = CursorStyle::SteadyBlock) decscusr, down(param = 1) down, dynamic_cursor_color(param) dynamic_cursor_color, forward(param : Int = 1) forward, h_position_relative(param = 1) h_position_relative, hide_cursor hide_cursor, hpa(param = 0) hpa, hpr(param = 1) hpr, hv_position(row = 0, col = 0) hv_position, hvp(row = 0, col = 0) hvp, left(param = 1) left, line_absolute(point : Point)
line_absolute(param = 0) line_absolute, line_pos_absolute(point : Point)
line_pos_absolute(param = 0) line_pos_absolute, lrestore_cursor(key = :local, hide = false) lrestore_cursor, lsave_cursor(key = :local) lsave_cursor, move(point : Point)
move(x = 0, y = 0) move, omove(point : Point)
omove(x = 0, y = 0) omove, parm_right_cursor(param : Int = 1) parm_right_cursor, pos(row : Int = 0, column : Int = 0)
pos(point : Tput::Point) pos, reset_cursor reset_cursor, reset_cursor_color reset_cursor_color, restore_cursor(key : String | Nil = nil, hide : Bool = false) restore_cursor, restore_cursor_a restore_cursor_a, restore_reported_cursor restore_reported_cursor, right(param : Int = 1) right, rmove(dx, dy)
rmove(point : Point) rmove, rsetx(dx) rsetx, rsety(dy) rsety, save_cursor(key : String | Nil = nil) save_cursor, save_cursor_a save_cursor_a, sc(key : String | Nil = nil) sc, set_cursor_style(style = CursorStyle::SteadyBlock) set_cursor_style, set_x(point : Point)
set_x(param = 0) set_x, set_y(point : Point)
set_y(param = 0) set_y, setx(point : Point)
setx(param = 0) setx, sety(point : Point)
sety(param = 0) sety, setyx(row : Int = 0, column : Int = 0)
setyx(point : Tput::Point) setyx, show_cursor show_cursor, up(param = 1) up, v_position_relative(param = 1) v_position_relative, vpa(point : Point)
vpa(param = 0) vpa, vpr(param = 1) vpr
Instance methods inherited from module Tput::Coordinates
_adjust_xy_abs(x = 0, y = 0)
_adjust_xy_abs,
_adjust_xy_rel(x = 0, y = 0)
_adjust_xy_rel,
_ncoords
_ncoords,
get_screen_size
get_screen_size,
reset_screen_size
reset_screen_size
Constructor Detail
Class Method Detail
Builds a {name => Detection} map, pairing each stringified value with its
recorded provenance from sources (or "unknown"). Shared by the emulator
and feature static-detection reports.
:nodoc:
Instance Method Detail
Internal cursor-save state. Keys can be Symbol/UInt64, which aren't valid JSON object keys, so it's excluded from serialization.
Internal cursor-save state. Keys can be Symbol/UInt64, which aren't valid JSON object keys, so it's excluded from serialization.
Terminfo aliases for #name (downcased), e.g. ["xterm-256color"]. Empty
when no terminfo entry is loaded.
Upper bound on @_attr_cache; once reached, the oldest-inserted entry is
evicted before each new insert. 0 disables the attribute cache entirely.
Upper bound on @_attr_cache; once reached, the oldest-inserted entry is
evicted before each new insert. 0 disables the attribute cache entirely.
Whether bracketed paste (DEC 2004) is currently enabled. Tracked so #pause
can restore it on resume. See Tput::Input#enable_bracketed_paste.
Captures the escape sequences emitted by the block and returns them as a
String, instead of writing them to the terminal.
Equivalent of Blessed's Program#out(name, *args) dispatcher. Crystal has
no by-name dynamic dispatch (and out is a reserved word), so a block is
used instead:
seq = tput.capture &.cursor_pos(1, 2) # => "\e[2;3H"
# or:
seq = tput.capture { |t| t.cursor_pos 1, 2; t.bell }
Output is captured regardless of internal buffering, by temporarily
redirecting @output. Anything already buffered is flushed to the real
output first, so only what the block emits is captured.
All detected emulator + feature information, each value paired with a
description of how it was determined. Suitable for to_pretty_json.
Dumps all detected emulator and feature information to io (STDOUT by default) in an aligned, human-readable report. Each line shows the setting name, its value, and how the value was determined (env var, constructor option, terminfo, probing, or a default).
tput = Tput.new terminfo
tput.probe! # optional: fills in the live-probed colors/width
tput.dump
Whether in-band resize notifications (DEC 2048) are currently enabled.
Tracked so #pause can restore them on resume.
The enhanced keyboard protocol currently enabled (tracked by
#enable_keyboard_protocol/#disable_keyboard_protocol), or nil when only
the always-available Legacy baseline is active. Used by #pause. See
Tput::Keyboard.
When SGR-Pixels (DEC private mode 1016) mouse reporting is active, the
terminal's cell size in pixels ({cell_w, cell_h}) used to derive cell
coordinates from the pixel coordinates the terminal now reports; nil
(the default) means pixel mode is off and \e[<…M/m reports are decoded
as ordinary SGR (1006) cell coordinates. Set by #enable_mouse/
#set_mouse and consulted by the mouse parser (#read_sgr).
When SGR-Pixels (DEC private mode 1016) mouse reporting is active, the
terminal's cell size in pixels ({cell_w, cell_h}) used to derive cell
coordinates from the pixel coordinates the terminal now reports; nil
(the default) means pixel mode is off and \e[<…M/m reports are decoded
as ordinary SGR (1006) cell coordinates. Set by #enable_mouse/
#set_mouse and consulted by the mouse parser (#read_sgr).
Whether xterm mouse reporting is currently enabled (tracked by
#enable_mouse/#disable_mouse). Used by #pause to restore it on resume.
Whether FocusIn/FocusOut reporting (DEC private mode 1004) is currently
enabled (tracked by #enable_mouse/#disable_mouse). Kept so #disable_mouse
and #_teardown_terminal can turn mode 1004 back off, and so #pause can
restore it on resume.
Resolved primary terminal name — from the loaded terminfo entry, else
$TERM, else the "xterm" fallback — downcased.
Suspends the program's use of the terminal: saves the cursor, leaves the
alternate buffer, shows the cursor, disables mouse reporting, and returns
input to cooked mode, leaving the terminal usable by another program (a
shell, $EDITOR, …). Returns — and stores in @_resume — a continuation
that #resume (or #sigtstp's SIGCONT handler) invokes to restore
everything.
The caller must not emit output between #pause and #resume; the
dominant use (#sigtstp) suspends the whole process, so this is automatic.
Outputs a string capability to @output, if it exists. Requires the
instance to be initialized with Terminfo data; returns nil otherwise.
put &.smcup?
put &.cursor_pos?(10, 20)
Like #put, but resolves a user-defined (extended) string capability by
name and runs it with the given arguments.
Predefined Terminfo capabilities are exposed via the shim (used through
#put), but capabilities such as Cr (reset cursor color), Cs (set
cursor color), or Ms (store data in the clipboard) exist only as
terminfo extensions. This looks one up by name, formats it with args,
and writes the result.
Returns true if the capability existed and was written, nil/false
otherwise (no Terminfo data, or the extension is not defined).
put_extended "Cr" # reset cursor color, if the terminal defines Cr
put_extended "Cs", "white" # set cursor color
Timeout when reading escape sequences: an ESC on input could be a lone ESC key or the start of an escape sequence, so we wait this long for more input before treating it as a key press (same approach Vi and others use). Default is 400ms, matching Qt.
Restores the terminal to the state it was in before the program took it over: shows the cursor, leaves the alternate buffer, disables mouse reporting, returns input to cooked mode. For clean teardown on exit. (Listener/instance bookkeeping is the caller's concern.)