Skip to content
Snippets Groups Projects
Commit 2c3b4091 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Add support for DECSC/DECRC

This allows for a way to save/restore the cursor position when
DECLRMM is enabled.

Saves to the same variables as SCOSC/SCORC.
parent 8fa4bc94
No related branches found
No related tags found
No related merge requests found
Pipeline #8802 failed
...@@ -92,6 +92,16 @@ Control codes are in the following format: + ...@@ -92,6 +92,16 @@ Control codes are in the following format: +
`ESC {'0'` to `'~'}` `ESC {'0'` to `'~'}`
Legal combinations which are not handled are silently dropped. Legal combinations which are not handled are silently dropped.
=== `ESC 7` Save Cursor (`DECSC`)
Saves the current cursor position same as `CSI s`
SOURCE: <<VT102>>
=== `ESC 8` Restore Cursor (`DECRC`)
Restores the current cursor position same as `CSI u`
SOURCE: <<VT102>>
=== `ESC E` Next Line (`NEL`) === `ESC E` Next Line (`NEL`)
Moves to the line home position of the next line. Moves to the line home position of the next line.
(Same as `CR` `LF`) (Same as `CR` `LF`)
......
...@@ -4277,6 +4277,19 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int * ...@@ -4277,6 +4277,19 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
} }
} }
break; break;
case '7': // Save cursor position
CURR_XY(&cterm->save_xpos, &cterm->save_ypos);
break;
case '8': // Restore cursor positi9on
if(cterm->save_ypos>0 && cterm->save_ypos<=cterm->height
&& cterm->save_xpos>0 && cterm->save_xpos<=cterm->width) {
// TODO: What to do about the window when position is restored...
// Absolute position stored? Relative?
if(cterm->save_ypos < CURR_MINY || cterm->save_ypos > CURR_MAXY || cterm->save_xpos < CURR_MINX || cterm->save_xpos > CURR_MAXX)
break;
gotoxy(cterm->save_xpos, cterm->save_ypos);
}
break;
case 'E': // Next Line case 'E': // Next Line
clear_lcf(cterm); clear_lcf(cterm);
adjust_currpos(cterm, INT_MIN, 1, 1); adjust_currpos(cterm, INT_MIN, 1, 1);
...@@ -4724,7 +4737,7 @@ cterm_reset(struct cterminal *cterm) ...@@ -4724,7 +4737,7 @@ cterm_reset(struct cterminal *cterm)
struct cterminal* cterm_init(int height, int width, int xpos, int ypos, int backlines, int backcols, struct vmem_cell *scrollback, int emulation) struct cterminal* cterm_init(int height, int width, int xpos, int ypos, int backlines, int backcols, struct vmem_cell *scrollback, int emulation)
{ {
char *revision="$Revision: 1.320 $"; char *revision="$Revision: 1.321 $";
char *in; char *in;
char *out; char *out;
struct cterminal *cterm; struct cterminal *cterm;
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
* *
* Note that SCOSC and SCORC are not standard and conflict with the DEC * Note that SCOSC and SCORC are not standard and conflict with the DEC
* left/right margin settings (DECLRMM). If this becomes an issue, they * left/right margin settings (DECLRMM). If this becomes an issue, they
* can be emulated via cusros position query. * can be emulated via cusros position query. There's also the VT100
* DECSC/DECRC (ESC8/ESC8) that may work when DECLRMM works.
* *
* CUU - ESC[A Cursor Up (With count) * CUU - ESC[A Cursor Up (With count)
* CUD - ESC[B Cursor Down (With count) * CUD - ESC[B Cursor Down (With count)
......
...@@ -1073,6 +1073,14 @@ var tests = [ ...@@ -1073,6 +1073,14 @@ var tests = [
console.write("\x1b[u"); console.write("\x1b[u");
return check_xy(2,2); return check_xy(2,2);
}}, }},
{'name':'DECSC', 'func':function() {
console.gotoxy(2,2);
console.write("\x1b7");
console.gotoxy(1,1);
console.write(' ');
console.write("\x1b8");
return check_xy(2,2);
}},
{'name':'CT24BC', 'func':function() { {'name':'CT24BC', 'func':function() {
if (!interactive) if (!interactive)
return null; return null;
...@@ -1131,6 +1139,14 @@ var tests = [ ...@@ -1131,6 +1139,14 @@ var tests = [
console.write("\x1b[u"); console.write("\x1b[u");
return check_xy(2,2); return check_xy(2,2);
}}, }},
{'name':'DECRC', 'func':function() {
console.gotoxy(2,2);
console.write("\x1b7");
console.gotoxy(1,1);
console.write(' ');
console.write("\x1b8");
return check_xy(2,2);
}},
{'name':'DECTABSR', 'func':function() { {'name':'DECTABSR', 'func':function() {
console.write("\x1b[2$w"); console.write("\x1b[2$w");
var seq = read_ansi_string(500); var seq = read_ansi_string(500);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment