module

Tput::Output::Text

Inherits Tput::Macros / Crystallabs::Helpers::Logging / Crystallabs::Helpers::Alias_Methods

Constants

Log = ::Log.for((self.name.gsub("::", '.')).underscore)

Instance methods

_attr(param : Array | String, val = true)

NOTE this function is a mess. Rework and improve.

NOTE: sun-color may not allow multiple params for SGR.

Allow printing to IO instead of returning strings. I suppose the places where this is called from should make it quite suitable to do so.

XXX see if these attributes can somehow be combined with Crystal's functionality in Colorize. Also make this accept enum values rather than parsing a string.

Source
backspace

Moves the cursor one position to the left.

Aliases: kbs, bs

Source
carriage_return

Moves the cursor to column 0.

Aliases: cr

Source
char_attributes(param, val)

CSI Pm m Character Attributes (SGR). Ps = 0 -> Normal (default). Ps = 1 -> Bold. Ps = 4 -> Underlined. Ps = 5 -> Blink (appears as Bold). Ps = 7 -> Inverse. Ps = 8 -> Invisible, i.e., hidden (VT300). Ps = 2 2 -> Normal (neither bold nor faint). Ps = 2 4 -> Not underlined. Ps = 2 5 -> Steady (not blinking). Ps = 2 7 -> Positive (not inverse). Ps = 2 8 -> Visible, i.e., not hidden (VT300). Ps = 3 0 -> Set foreground color to Black. Ps = 3 1 -> Set foreground color to Red. Ps = 3 2 -> Set foreground color to Green. Ps = 3 3 -> Set foreground color to Yellow. Ps = 3 4 -> Set foreground color to Blue. Ps = 3 5 -> Set foreground color to Magenta. Ps = 3 6 -> Set foreground color to Cyan. Ps = 3 7 -> Set foreground color to White. Ps = 3 9 -> Set foreground color to default (original). Ps = 4 0 -> Set background color to Black. Ps = 4 1 -> Set background color to Red. Ps = 4 2 -> Set background color to Green. Ps = 4 3 -> Set background color to Yellow. Ps = 4 4 -> Set background color to Blue. Ps = 4 5 -> Set background color to Magenta. Ps = 4 6 -> Set background color to Cyan. Ps = 4 7 -> Set background color to White. Ps = 4 9 -> Set background color to default (original).

If 16-color support is compiled, the following apply. Assume that xterm's resources are set so that the ISO color codes are the first 8 of a set of 16. Then the aixterm colors are the bright versions of the ISO colors: Ps = 9 0 -> Set foreground color to Black. Ps = 9 1 -> Set foreground color to Red. Ps = 9 2 -> Set foreground color to Green. Ps = 9 3 -> Set foreground color to Yellow. Ps = 9 4 -> Set foreground color to Blue. Ps = 9 5 -> Set foreground color to Magenta. Ps = 9 6 -> Set foreground color to Cyan. Ps = 9 7 -> Set foreground color to White. Ps = 1 0 0 -> Set background color to Black. Ps = 1 0 1 -> Set background color to Red. Ps = 1 0 2 -> Set background color to Green. Ps = 1 0 3 -> Set background color to Yellow. Ps = 1 0 4 -> Set background color to Blue. Ps = 1 0 5 -> Set background color to Magenta. Ps = 1 0 6 -> Set background color to Cyan. Ps = 1 0 7 -> Set background color to White.

If xterm is compiled with the 16-color support disabled, it supports the following, from rxvt: Ps = 1 0 0 -> Set foreground and background color to default.

If 88- or 256-color support is compiled, the following apply. Ps = 3 8 ; 5 ; Ps -> Set foreground color to the second Ps. Ps = 4 8 ; 5 ; Ps -> Set background color to the second Ps.

Source
delete_chars(param = 1)

CSI Ps P Delete Ps Character(s) (default = 1) (DCH).

Source
delete_columns(n = 1)

Deletes n times columns, starting with the column that has the cursor.

As columns are deleted, the remaining columns between the cursor and the right margin move to the left. The terminal adds blank columns with no visual character attributes at the right margin.

Has no effect outside the scrolling margins.

CSI P m SP ~
Delete P s Column(s) (default = 1) (DECDC), VT420 and up

NOTE xterm doesn't enable this code by default.

Aliases: decdc

Source
delete_line(param : Int = 1)

Delete line(s). CSI Ps M Delete Ps Line(s) (default = 1) (DL).

Source
echo(text, attr = nil)
Source
erase_character(param : Int = 1)

Erase character(s). CSI Ps X Erase Ps Character(s) (default = 1) (ECH).

Source
erase_in_line(param = LineDirection::Right)

Erase in line. CSI Ps K Erase in Line (EL). Ps = 0 -> Erase to Right (default). Ps = 1 -> Erase to Left. Ps = 2 -> Erase All. CSI ? Ps K Erase in Line (DECSEL). Ps = 0 -> Selective Erase to Right (default). Ps = 1 -> Selective Erase to Left. Ps = 2 -> Selective Erase All.

Source
form_feed

Moves the cursor one row down without changing the column position.

TODO What about scrolling?

Aliases: ff

Source
horizontal_tabulation_set

Places a tab stop at the current cursor position.

ESC H Tab Set (HTS is 0x88).

Aliases: horizontal_tab_set, hts

Source
insert_chars(param = 1)

CSI Ps @ Insert Ps (Blank) Character(s) (default = 1) (ICH). XXX switch to adjust_xy

Source
insert_columns(n = 1)

Inserts n times columns into the scrolling region, starting with the column that has the cursor.

As columns are inserted, the columns between the cursor and the right margin move to the right. Columns are inserted blank with no visual character attributes.

Has no effect outside the scrolling margins.

CSI P m SP }
Insert P s Column(s) (default = 1) (DECIC), VT420 and up.

NOTE: xterm doesn't enable this code by default.

Aliases: decic

Source
insert_line(param : Int = 1)

Insert line(s). CSI Ps L Insert Ps Line(s) (default = 1) (IL).

Source
line_feed

Moves the cursor one row down and to column 0, scrolling if needed.

Scrolling is restricted to scroll margins and will only happen on the bottom line.

TODO Adjusting internal data based on scrolling is not yet supported. (Whether scroll offsets need to be adjusted internally is yet to be checked.)

Aliases: feed, lf, next_line, nel

Source
line_height

ESC # 3 DEC line height/width XXX is this supposed to return result?

Source
repeat_preceding_character(param = 1)

CSI Ps b Repeat the preceding graphic character Ps times (REP).

Source
sel_data(a, b)

OSC Ps ; Pt ST OSC Ps ; Pt BEL Sel data

Source
set_background(color, val)
Source
set_char_protection_attr(param = 0)

CSI Ps " q Select character protection attribute (DECSCA). Valid values for the parameter: Ps = 0 -> DECSED and DECSEL can erase (default). Ps = 1 -> DECSED and DECSEL cannot erase. Ps = 2 -> DECSED and DECSEL can erase.

Source
set_foreground(color, val)
Source
shift_in

Switches back to regular character set after #shift_out.

Aliases: si

Source
shift_out

Switches to an alternative character set.

Aliases: so

Source
simple_insert(str, i = 1, attr = nil)

Writes string str (repeated i times and with attr attributes)

Source
tab_clear(param = 0)

CSI Ps g Tab Clear (TBC). Ps = 0 -> Clear Current Column (default). Ps = 3 -> Clear All. Potentially: Ps = 2 -> Clear Stops on Line. http:#vt100.net/annarbor/aaa-ug/section6.html

Source
text(text, attr)
Source
vertical_tab

Moves the cursor one row down without changing the column position.

TODO What about scrolling?

Aliases: vtab, vt

Source