Commit 7281fa8d authored by Egmont Koblinger's avatar Egmont Koblinger

emulation: Migrating from terminfo: single-byte control codes

Hardwire the behavior of single-byte control codes (newline, tab etc.) and
closely related ones (e.g. tab stops), rather than relying on terminfo.

Implement CSI n I (n tabs).
parent ac4cce65
......@@ -38,13 +38,20 @@
#define CR "\015"
#define SO "\016"
#define SI "\017"
#define DEL "\177"
/* From some really old XTerm docs we had at the office, and an updated
* version at Moy, Gildea, and Dickey. */
struct _vte_capability_string _vte_xterm_capability_strings[] = {
{ENQ, "return-terminal-status", 0},
{BEL, "bell", 0},
{BS, "backspace", 0},
{TAB, "tab", 0},
{LF, "line-feed", 0},
{VT, "vertical-tab", 0},
{FF, "form-feed", 0},
{CR, "carriage-return", 0},
{DEL, "backspace", 0},
{ESC " F", "7-bit-controls", 0},
{ESC " G", "8-bit-controls", 0},
......@@ -116,6 +123,7 @@ struct _vte_capability_string _vte_xterm_capability_strings[] = {
{CSI ";%dH", "cursor-position-top-row", 0},
{CSI "%d;%dH", "cursor-position", 0},
{CSI "I", "cursor-forward-tabulation", 0},
{CSI "%dI", "cursor-forward-tabulation", 0},
{CSI "J", "erase-in-display", 0},
{CSI "%dJ", "erase-in-display", 0},
{CSI "?J", "selective-erase-in-display", 0},
......
......@@ -147,17 +147,17 @@ struct vteseq_2_struct {
"RI", VTE_SEQUENCE_HANDLER(vte_sequence_handler_RI)
#"RX", VTE_SEQUENCE_HANDLER_NULL
#"SA", VTE_SEQUENCE_HANDLER_NULL
"SF", VTE_SEQUENCE_HANDLER(vte_sequence_handler_SF)
"SR", VTE_SEQUENCE_HANDLER(vte_sequence_handler_SR)
#"SF", VTE_SEQUENCE_HANDLER(vte_sequence_handler_SF)
#"SR", VTE_SEQUENCE_HANDLER(vte_sequence_handler_SR)
#"SX", VTE_SEQUENCE_HANDLER_NULL
"UP", VTE_SEQUENCE_HANDLER(vte_sequence_handler_UP)
#"XF", VTE_SEQUENCE_HANDLER_NULL
"ae", VTE_SEQUENCE_HANDLER(vte_sequence_handler_ae)
"al", VTE_SEQUENCE_HANDLER(vte_sequence_handler_al)
"as", VTE_SEQUENCE_HANDLER(vte_sequence_handler_as)
"bc", VTE_SEQUENCE_HANDLER(vte_sequence_handler_le)
"bl", VTE_SEQUENCE_HANDLER(vte_sequence_handler_bl)
"bt", VTE_SEQUENCE_HANDLER(vte_sequence_handler_bt)
#"bc", VTE_SEQUENCE_HANDLER(vte_sequence_handler_le)
#"bl", VTE_SEQUENCE_HANDLER(vte_sequence_handler_bl)
#"bt", VTE_SEQUENCE_HANDLER(vte_sequence_handler_bt)
"cS", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cS)
"cb", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cb)
"cc", VTE_SEQUENCE_HANDLER(vte_sequence_handler_noop)
......@@ -166,14 +166,14 @@ struct vteseq_2_struct {
"ch", VTE_SEQUENCE_HANDLER(vte_sequence_handler_ch)
"cl", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cl)
"cm", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cm)
"cr", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cr)
#"cr", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cr)
"cs", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cs)
"ct", VTE_SEQUENCE_HANDLER(vte_sequence_handler_ct)
#"ct", VTE_SEQUENCE_HANDLER(vte_sequence_handler_ct)
"cv", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cv)
"dc", VTE_SEQUENCE_HANDLER(vte_sequence_handler_dc)
"dl", VTE_SEQUENCE_HANDLER(vte_sequence_handler_dl)
"dm", VTE_SEQUENCE_HANDLER(vte_sequence_handler_noop)
"do", VTE_SEQUENCE_HANDLER(vte_sequence_handler_do)
#"do", VTE_SEQUENCE_HANDLER(vte_sequence_handler_do)
#"ds", VTE_SEQUENCE_HANDLER_NULL
"eA", VTE_SEQUENCE_HANDLER(vte_sequence_handler_eA)
"ec", VTE_SEQUENCE_HANDLER(vte_sequence_handler_ec)
......@@ -219,7 +219,7 @@ struct vteseq_2_struct {
#"kS", VTE_SEQUENCE_HANDLER(vte_sequence_handler_complain_key)
#"kT", VTE_SEQUENCE_HANDLER(vte_sequence_handler_complain_key)
#"ka", VTE_SEQUENCE_HANDLER(vte_sequence_handler_complain_key)
"kb", VTE_SEQUENCE_HANDLER(vte_sequence_handler_kb)
#"kb", VTE_SEQUENCE_HANDLER(vte_sequence_handler_kb)
#"kd", VTE_SEQUENCE_HANDLER(vte_sequence_handler_complain_key)
"ke", VTE_SEQUENCE_HANDLER(vte_sequence_handler_ke)
#"kh", VTE_SEQUENCE_HANDLER(vte_sequence_handler_complain_key)
......@@ -239,7 +239,7 @@ struct vteseq_2_struct {
#"l8", VTE_SEQUENCE_HANDLER_NULL
#"l9", VTE_SEQUENCE_HANDLER_NULL
#"la", VTE_SEQUENCE_HANDLER_NULL
"le", VTE_SEQUENCE_HANDLER(vte_sequence_handler_le)
#"le", VTE_SEQUENCE_HANDLER(vte_sequence_handler_le)
"ll", VTE_SEQUENCE_HANDLER(vte_sequence_handler_ll)
"mb", VTE_SEQUENCE_HANDLER(vte_sequence_handler_mb)
"md", VTE_SEQUENCE_HANDLER(vte_sequence_handler_md)
......@@ -251,7 +251,7 @@ struct vteseq_2_struct {
"mp", VTE_SEQUENCE_HANDLER(vte_sequence_handler_mp)
"mr", VTE_SEQUENCE_HANDLER(vte_sequence_handler_mr)
"nd", VTE_SEQUENCE_HANDLER(vte_sequence_handler_nd)
"nw", VTE_SEQUENCE_HANDLER(vte_sequence_handler_nw)
#"nw", VTE_SEQUENCE_HANDLER(vte_sequence_handler_nw)
#"pO", VTE_SEQUENCE_HANDLER_NULL
#"pc", VTE_SEQUENCE_HANDLER_NULL
#"pf", VTE_SEQUENCE_HANDLER_NULL
......@@ -272,11 +272,11 @@ struct vteseq_2_struct {
#"sa", VTE_SEQUENCE_HANDLER_NULL
"sc", VTE_SEQUENCE_HANDLER(vte_sequence_handler_sc)
"se", VTE_SEQUENCE_HANDLER(vte_sequence_handler_se)
"sf", VTE_SEQUENCE_HANDLER(vte_sequence_handler_sf)
#"sf", VTE_SEQUENCE_HANDLER(vte_sequence_handler_sf)
"so", VTE_SEQUENCE_HANDLER(vte_sequence_handler_so)
"sr", VTE_SEQUENCE_HANDLER(vte_sequence_handler_sr)
"st", VTE_SEQUENCE_HANDLER(vte_sequence_handler_st)
"ta", VTE_SEQUENCE_HANDLER(vte_sequence_handler_ta)
#"sr", VTE_SEQUENCE_HANDLER(vte_sequence_handler_sr)
#"st", VTE_SEQUENCE_HANDLER(vte_sequence_handler_st)
#"ta", VTE_SEQUENCE_HANDLER(vte_sequence_handler_ta)
"te", VTE_SEQUENCE_HANDLER(vte_sequence_handler_noop)
"ti", VTE_SEQUENCE_HANDLER(vte_sequence_handler_noop)
#"ts", VTE_SEQUENCE_HANDLER_NULL
......
......@@ -21,10 +21,15 @@ struct vteseq_n_struct {
%%
#"..rp", VTE_SEQUENCE_HANDLER_NULL
#"..sa", VTE_SEQUENCE_HANDLER_NULL
"line-feed", VTE_SEQUENCE_HANDLER(vte_sequence_handler_line_feed)
"carriage-return", VTE_SEQUENCE_HANDLER(vte_sequence_handler_carriage_return)
"bell", VTE_SEQUENCE_HANDLER(vte_sequence_handler_bell)
"backspace", VTE_SEQUENCE_HANDLER(vte_sequence_handler_backspace)
"tab", VTE_SEQUENCE_HANDLER(vte_sequence_handler_tab)
"index", VTE_SEQUENCE_HANDLER(vte_sequence_handler_index)
"decset", VTE_SEQUENCE_HANDLER(vte_sequence_handler_decset)
#"repeat", VTE_SEQUENCE_HANDLER_NULL
"tab-set", VTE_SEQUENCE_HANDLER(vte_sequence_handler_st)
"tab-set", VTE_SEQUENCE_HANDLER(vte_sequence_handler_tab_set)
"decreset", VTE_SEQUENCE_HANDLER(vte_sequence_handler_decreset)
"set-mode", VTE_SEQUENCE_HANDLER(vte_sequence_handler_set_mode)
"cursor-up", VTE_SEQUENCE_HANDLER(vte_sequence_handler_UP)
......@@ -61,7 +66,7 @@ struct vteseq_n_struct {
#"dec-media-copy", VTE_SEQUENCE_HANDLER_NULL
"restore-cursor", VTE_SEQUENCE_HANDLER(vte_sequence_handler_rc)
"set-icon-title", VTE_SEQUENCE_HANDLER(vte_sequence_handler_set_icon_title)
"cursor-back-tab", VTE_SEQUENCE_HANDLER(vte_sequence_handler_bt)
"cursor-back-tab", VTE_SEQUENCE_HANDLER(vte_sequence_handler_back_tab)
"cursor-backward", VTE_SEQUENCE_HANDLER(vte_sequence_handler_LE)
"cursor-position", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cursor_position)
"cursor-position-top-row", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cursor_position_top_row)
......@@ -124,7 +129,7 @@ struct vteseq_n_struct {
#"enable-locator-reporting", VTE_SEQUENCE_HANDLER_NULL
#"request-locator-position", VTE_SEQUENCE_HANDLER_NULL
"cursor-character-absolute", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cursor_character_absolute)
"cursor-forward-tabulation", VTE_SEQUENCE_HANDLER(vte_sequence_handler_ta)
"cursor-forward-tabulation", VTE_SEQUENCE_HANDLER(vte_sequence_handler_cursor_forward_tabulation)
#"double-height-bottom-half", VTE_SEQUENCE_HANDLER_NULL
"set-icon-and-window-title", VTE_SEQUENCE_HANDLER(vte_sequence_handler_set_icon_and_window_title)
#"selective-erase-in-display", VTE_SEQUENCE_HANDLER_NULL
......
......@@ -991,7 +991,7 @@ vte_sequence_handler_as (VteTerminal *terminal, GValueArray *params)
/* Beep. */
static void
vte_sequence_handler_bl (VteTerminal *terminal, GValueArray *params)
vte_sequence_handler_bell (VteTerminal *terminal, GValueArray *params)
{
_vte_terminal_beep (terminal);
g_signal_emit_by_name(terminal, "beep");
......@@ -999,7 +999,7 @@ vte_sequence_handler_bl (VteTerminal *terminal, GValueArray *params)
/* Backtab. */
static void
vte_sequence_handler_bt (VteTerminal *terminal, GValueArray *params)
vte_sequence_handler_back_tab (VteTerminal *terminal, GValueArray *params)
{
long newcol;
......@@ -1217,7 +1217,7 @@ vte_sequence_handler_cm (VteTerminal *terminal, GValueArray *params)
/* Carriage return. */
static void
vte_sequence_handler_cr (VteTerminal *terminal, GValueArray *params)
vte_sequence_handler_carriage_return (VteTerminal *terminal, GValueArray *params)
{
terminal->pvt->screen->cursor_current.col = 0;
}
......@@ -1315,16 +1315,6 @@ vte_sequence_handler_cS (VteTerminal *terminal, GValueArray *params)
screen->insert_delta + end);
}
/* Clear all tab stops. */
static void
vte_sequence_handler_ct (VteTerminal *terminal, GValueArray *params)
{
if (terminal->pvt->tabstops != NULL) {
g_hash_table_destroy(terminal->pvt->tabstops);
terminal->pvt->tabstops = NULL;
}
}
/* Move the cursor to the lower left-hand corner. */
static void
vte_sequence_handler_cursor_lower_left (VteTerminal *terminal, GValueArray *params)
......@@ -1569,7 +1559,7 @@ vte_sequence_handler_ei (VteTerminal *terminal, GValueArray *params)
static void
vte_sequence_handler_form_feed (VteTerminal *terminal, GValueArray *params)
{
vte_sequence_handler_index (terminal, params);
vte_sequence_handler_line_feed (terminal, params);
}
/* Move the cursor to the home position. */
......@@ -1613,16 +1603,7 @@ vte_sequence_handler_im (VteTerminal *terminal, GValueArray *params)
static void
vte_sequence_handler_index (VteTerminal *terminal, GValueArray *params)
{
vte_sequence_handler_sf (terminal, params);
}
/* Send me a backspace key sym, will you? Guess that the application meant
* to send the cursor back one position. */
static void
vte_sequence_handler_kb (VteTerminal *terminal, GValueArray *params)
{
/* Move the cursor left. */
vte_sequence_handler_le (terminal, params);
vte_sequence_handler_line_feed (terminal, params);
}
/* Keypad mode end. */
......@@ -1641,7 +1622,7 @@ vte_sequence_handler_ks (VteTerminal *terminal, GValueArray *params)
/* Cursor left. */
static void
vte_sequence_handler_le (VteTerminal *terminal, GValueArray *params)
vte_sequence_handler_backspace (VteTerminal *terminal, GValueArray *params)
{
VteScreen *screen;
......@@ -1657,7 +1638,7 @@ vte_sequence_handler_le (VteTerminal *terminal, GValueArray *params)
static void
vte_sequence_handler_LE (VteTerminal *terminal, GValueArray *params)
{
vte_sequence_handler_multiple(terminal, params, vte_sequence_handler_le);
vte_sequence_handler_multiple(terminal, params, vte_sequence_handler_backspace);
}
/* Move the cursor to the lower left corner of the display. */
......@@ -1751,13 +1732,6 @@ vte_sequence_handler_noop (VteTerminal *terminal, GValueArray *params)
{
}
/* Carriage return command(?). */
static void
vte_sequence_handler_nw (VteTerminal *terminal, GValueArray *params)
{
vte_sequence_handler_cr (terminal, params);
}
/* Restore cursor (position). */
static void
vte_sequence_handler_rc (VteTerminal *terminal, GValueArray *params)
......@@ -1772,13 +1746,6 @@ vte_sequence_handler_rc (VteTerminal *terminal, GValueArray *params)
terminal->pvt->row_count - 1);
}
/* Cursor down, with scrolling. */
static void
vte_sequence_handler_reverse_index (VteTerminal *terminal, GValueArray *params)
{
vte_sequence_handler_sr (terminal, params);
}
/* Cursor right N characters. */
static void
vte_sequence_handler_RI (VteTerminal *terminal, GValueArray *params)
......@@ -1939,19 +1906,11 @@ vte_sequence_handler_se (VteTerminal *terminal, GValueArray *params)
/* Cursor down, with scrolling. */
static void
vte_sequence_handler_sf (VteTerminal *terminal, GValueArray *params)
vte_sequence_handler_line_feed (VteTerminal *terminal, GValueArray *params)
{
_vte_terminal_cursor_down (terminal);
}
/* Cursor down, with scrolling. */
static void
vte_sequence_handler_SF (VteTerminal *terminal, GValueArray *params)
{
/* XXX implement this directly in _vte_terminal_cursor_down */
vte_sequence_handler_multiple(terminal, params, vte_sequence_handler_sf);
}
/* Standout start. */
static void
vte_sequence_handler_so (VteTerminal *terminal, GValueArray *params)
......@@ -1959,9 +1918,9 @@ vte_sequence_handler_so (VteTerminal *terminal, GValueArray *params)
terminal->pvt->screen->defaults.attr.reverse = 1;
}
/* Cursor up, scrolling if need be. */
/* Cursor up 1 line, with scrolling. */
static void
vte_sequence_handler_sr (VteTerminal *terminal, GValueArray *params)
vte_sequence_handler_reverse_index (VteTerminal *terminal, GValueArray *params)
{
long start, end;
VteScreen *screen;
......@@ -1996,16 +1955,9 @@ vte_sequence_handler_sr (VteTerminal *terminal, GValueArray *params)
terminal->pvt->text_modified_flag = TRUE;
}
/* Cursor up, with scrolling. */
static void
vte_sequence_handler_SR (VteTerminal *terminal, GValueArray *params)
{
vte_sequence_handler_multiple(terminal, params, vte_sequence_handler_sr);
}
/* Set tab stop in the current column. */
static void
vte_sequence_handler_st (VteTerminal *terminal, GValueArray *params)
vte_sequence_handler_tab_set (VteTerminal *terminal, GValueArray *params)
{
if (terminal->pvt->tabstops == NULL) {
terminal->pvt->tabstops = g_hash_table_new(NULL, NULL);
......@@ -2016,7 +1968,7 @@ vte_sequence_handler_st (VteTerminal *terminal, GValueArray *params)
/* Tab. */
static void
vte_sequence_handler_ta (VteTerminal *terminal, GValueArray *params)
vte_sequence_handler_tab (VteTerminal *terminal, GValueArray *params)
{
VteScreen *screen;
long old_len, newcol, col;
......@@ -2105,6 +2057,12 @@ vte_sequence_handler_ta (VteTerminal *terminal, GValueArray *params)
}
}
static void
vte_sequence_handler_cursor_forward_tabulation (VteTerminal *terminal, GValueArray *params)
{
vte_sequence_handler_multiple_r(terminal, params, vte_sequence_handler_tab);
}
/* Clear tabs selectively. */
static void
vte_sequence_handler_tab_clear (VteTerminal *terminal, GValueArray *params)
......@@ -2218,7 +2176,7 @@ vte_sequence_handler_ve (VteTerminal *terminal, GValueArray *params)
static void
vte_sequence_handler_vertical_tab (VteTerminal *terminal, GValueArray *params)
{
vte_sequence_handler_index (terminal, params);
vte_sequence_handler_line_feed (terminal, params);
}
/* Cursor invisible. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment