Add more CSI codes

This commit is contained in:
Daniel Imms
2017-01-12 21:33:28 -08:00
parent c43c3b411a
commit 9b66208029
4 changed files with 232 additions and 257 deletions
+221
View File
@@ -239,6 +239,17 @@ export class InputHandler implements IInputHandler {
this._terminal.y = row;
}
/**
* CSI Ps I
* Cursor Forward Tabulation Ps tab stops (default = 1) (CHT).
*/
public cursorForwardTab(params: number[]): void {
let param = params[0] || 1;
while (param--) {
this._terminal.x = this._terminal.nextStop();
}
}
/**
* CSI Ps J Erase in Display (ED).
* Ps = 0 -> Erase Below (default).
@@ -774,6 +785,183 @@ export class InputHandler implements IInputHandler {
}
}
/**
* CSI Pm l Reset Mode (RM).
* Ps = 2 -> Keyboard Action Mode (AM).
* Ps = 4 -> Replace Mode (IRM).
* Ps = 1 2 -> Send/receive (SRM).
* Ps = 2 0 -> Normal Linefeed (LNM).
* CSI ? Pm l
* DEC Private Mode Reset (DECRST).
* Ps = 1 -> Normal Cursor Keys (DECCKM).
* Ps = 2 -> Designate VT52 mode (DECANM).
* Ps = 3 -> 80 Column Mode (DECCOLM).
* Ps = 4 -> Jump (Fast) Scroll (DECSCLM).
* Ps = 5 -> Normal Video (DECSCNM).
* Ps = 6 -> Normal Cursor Mode (DECOM).
* Ps = 7 -> No Wraparound Mode (DECAWM).
* Ps = 8 -> No Auto-repeat Keys (DECARM).
* Ps = 9 -> Don't send Mouse X & Y on button press.
* Ps = 1 0 -> Hide toolbar (rxvt).
* Ps = 1 2 -> Stop Blinking Cursor (att610).
* Ps = 1 8 -> Don't print form feed (DECPFF).
* Ps = 1 9 -> Limit print to scrolling region (DECPEX).
* Ps = 2 5 -> Hide Cursor (DECTCEM).
* Ps = 3 0 -> Don't show scrollbar (rxvt).
* Ps = 3 5 -> Disable font-shifting functions (rxvt).
* Ps = 4 0 -> Disallow 80 -> 132 Mode.
* Ps = 4 1 -> No more(1) fix (see curses resource).
* Ps = 4 2 -> Disable Nation Replacement Character sets (DEC-
* NRCM).
* Ps = 4 4 -> Turn Off Margin Bell.
* Ps = 4 5 -> No Reverse-wraparound Mode.
* Ps = 4 6 -> Stop Logging. (This is normally disabled by a
* compile-time option).
* Ps = 4 7 -> Use Normal Screen Buffer.
* Ps = 6 6 -> Numeric keypad (DECNKM).
* Ps = 6 7 -> Backarrow key sends delete (DECBKM).
* Ps = 1 0 0 0 -> Don't send Mouse X & Y on button press and
* release. See the section Mouse Tracking.
* Ps = 1 0 0 1 -> Don't use Hilite Mouse Tracking.
* Ps = 1 0 0 2 -> Don't use Cell Motion Mouse Tracking.
* Ps = 1 0 0 3 -> Don't use All Motion Mouse Tracking.
* Ps = 1 0 0 4 -> Don't send FocusIn/FocusOut events.
* Ps = 1 0 0 5 -> Disable Extended Mouse Mode.
* Ps = 1 0 1 0 -> Don't scroll to bottom on tty output
* (rxvt).
* Ps = 1 0 1 1 -> Don't scroll to bottom on key press (rxvt).
* Ps = 1 0 3 4 -> Don't interpret "meta" key. (This disables
* the eightBitInput resource).
* Ps = 1 0 3 5 -> Disable special modifiers for Alt and Num-
* Lock keys. (This disables the numLock resource).
* Ps = 1 0 3 6 -> Don't send ESC when Meta modifies a key.
* (This disables the metaSendsEscape resource).
* Ps = 1 0 3 7 -> Send VT220 Remove from the editing-keypad
* Delete key.
* Ps = 1 0 3 9 -> Don't send ESC when Alt modifies a key.
* (This disables the altSendsEscape resource).
* Ps = 1 0 4 0 -> Do not keep selection when not highlighted.
* (This disables the keepSelection resource).
* Ps = 1 0 4 1 -> Use the PRIMARY selection. (This disables
* the selectToClipboard resource).
* Ps = 1 0 4 2 -> Disable Urgency window manager hint when
* Control-G is received. (This disables the bellIsUrgent
* resource).
* Ps = 1 0 4 3 -> Disable raising of the window when Control-
* G is received. (This disables the popOnBell resource).
* Ps = 1 0 4 7 -> Use Normal Screen Buffer, clearing screen
* first if in the Alternate Screen. (This may be disabled by
* the titeInhibit resource).
* Ps = 1 0 4 8 -> Restore cursor as in DECRC. (This may be
* disabled by the titeInhibit resource).
* Ps = 1 0 4 9 -> Use Normal Screen Buffer and restore cursor
* as in DECRC. (This may be disabled by the titeInhibit
* resource). This combines the effects of the 1 0 4 7 and 1 0
* 4 8 modes. Use this with terminfo-based applications rather
* than the 4 7 mode.
* Ps = 1 0 5 0 -> Reset terminfo/termcap function-key mode.
* Ps = 1 0 5 1 -> Reset Sun function-key mode.
* Ps = 1 0 5 2 -> Reset HP function-key mode.
* Ps = 1 0 5 3 -> Reset SCO function-key mode.
* Ps = 1 0 6 0 -> Reset legacy keyboard emulation (X11R6).
* Ps = 1 0 6 1 -> Reset keyboard emulation to Sun/PC style.
* Ps = 2 0 0 4 -> Reset bracketed paste mode.
*/
public resetMode(params: number[]): void {
if (params.length > 1) {
for (let i = 0; i < params.length; i++) {
this._terminal.resetMode(params[i]);
}
return;
}
if (!this._terminal.prefix) {
switch (params[0]) {
case 4:
this._terminal.insertMode = false;
break;
case 20:
// this._terminal.convertEol = false;
break;
}
} else if (this._terminal.prefix === '?') {
switch (params[0]) {
case 1:
this._terminal.applicationCursor = false;
break;
case 3:
if (this._terminal.cols === 132 && this._terminal.savedCols) {
this._terminal.resize(this._terminal.savedCols, this._terminal.rows);
}
delete this._terminal.savedCols;
break;
case 6:
this._terminal.originMode = false;
break;
case 7:
this._terminal.wraparoundMode = false;
break;
case 12:
// this.cursorBlink = false;
break;
case 66:
this._terminal.log('Switching back to normal keypad.');
this._terminal.applicationKeypad = false;
this._terminal.viewport.syncScrollArea();
break;
case 9: // X10 Mouse
case 1000: // vt200 mouse
case 1002: // button event mouse
case 1003: // any event mouse
this._terminal.x10Mouse = false;
this._terminal.vt200Mouse = false;
this._terminal.normalMouse = false;
this._terminal.mouseEvents = false;
this._terminal.element.style.cursor = '';
break;
case 1004: // send focusin/focusout events
this._terminal.sendFocus = false;
break;
case 1005: // utf8 ext mode mouse
this._terminal.utfMouse = false;
break;
case 1006: // sgr ext mode mouse
this._terminal.sgrMouse = false;
break;
case 1015: // urxvt ext mode mouse
this._terminal.urxvtMouse = false;
break;
case 25: // hide cursor
this._terminal.cursorHidden = true;
break;
case 1049: // alt screen buffer cursor
; // FALL-THROUGH
case 47: // normal screen buffer
case 1047: // normal screen buffer - clearing it first
if (this._terminal.normal) {
this._terminal.lines = this._terminal.normal.lines;
this._terminal.ybase = this._terminal.normal.ybase;
this._terminal.ydisp = this._terminal.normal.ydisp;
this._terminal.x = this._terminal.normal.x;
this._terminal.y = this._terminal.normal.y;
this._terminal.scrollTop = this._terminal.normal.scrollTop;
this._terminal.scrollBottom = this._terminal.normal.scrollBottom;
this._terminal.tabs = this._terminal.normal.tabs;
this._terminal.normal = null;
// if (params === 1049) {
// this.x = this.savedX;
// this.y = this.savedY;
// }
this._terminal.queueRefresh(0, this._terminal.rows - 1);
this._terminal.viewport.syncScrollArea();
this._terminal.showCursor();
}
break;
}
}
}
/**
* CSI Pm m Character Attributes (SGR).
* Ps = 0 -> Normal (default).
@@ -1026,4 +1214,37 @@ export class InputHandler implements IInputHandler {
}
}
/**
* CSI Ps ; Ps r
* Set Scrolling Region [top;bottom] (default = full size of win-
* dow) (DECSTBM).
* CSI ? Pm r
*/
public setScrollRegion(params: number[]): void {
if (this._terminal.prefix) return;
this._terminal.scrollTop = (params[0] || 1) - 1;
this._terminal.scrollBottom = (params[1] || this._terminal.rows) - 1;
this._terminal.x = 0;
this._terminal.y = 0;
}
/**
* CSI s
* Save cursor (ANSI.SYS).
*/
public saveCursor(params: number[]): void {
this._terminal.savedX = this._terminal.x;
this._terminal.savedY = this._terminal.y;
}
/**
* CSI u
* Restore cursor (ANSI.SYS).
*/
public restoreCursor(params: number[]): void {
this._terminal.x = this._terminal.savedX || 0;
this._terminal.y = this._terminal.savedY || 0;
}
}
+6
View File
@@ -44,6 +44,7 @@ export interface IInputHandler {
/** C0 HT */ tab(): void;
/** C0 SO */ shiftOut(): void;
/** C0 SI */ shiftIn(): void;
/** CSI @ */ insertChars(params);
/** CSI A */ cursorUp(params: number[]): void;
/** CSI B */ cursorDown(params: number[]): void;
@@ -53,6 +54,7 @@ export interface IInputHandler {
/** CSI F */ cursorPrecedingLine(params: number[]): void;
/** CSI G */ cursorCharAbsolute(params: number[]): void;
/** CSI H */ cursorPosition(params: number[]): void;
/** CSI I */ cursorForwardTab(params: number[]): void;
/** CSI J */ eraseInDisplay(params: number[]): void;
/** CSI K */ eraseInLine(params: number[]): void;
/** CSI L */ insertLines(params: number[]): void;
@@ -66,6 +68,10 @@ export interface IInputHandler {
/** CSI e */ VPositionRelative(params: number[]): void;
/** CSI f */ HVPosition(params: number[]): void;
/** CSI h */ setMode(params: number[]): void;
/** CSI l */ resetMode(params: number[]): void;
/** CSI m */ charAttributes(params: number[]): void;
/** CSI n */ deviceStatus(params: number[]): void;
/** CSI r */ setScrollRegion(params: number[]): void;
/** CSI s */ saveCursor(params: number[]): void;
/** CSI u */ restoreCursor(params: number[]): void;
}
+5 -31
View File
@@ -44,6 +44,7 @@ csiStateHandler['E'] = (handler, params) => handler.cursorNextLine(params);
csiStateHandler['F'] = (handler, params) => handler.cursorPrecedingLine(params);
csiStateHandler['G'] = (handler, params) => handler.cursorCharAbsolute(params);
csiStateHandler['H'] = (handler, params) => handler.cursorPosition(params);
csiStateHandler['I'] = (handler, params) => handler.cursorForwardTab(params);
csiStateHandler['J'] = (handler, params) => handler.eraseInDisplay(params);
csiStateHandler['K'] = (handler, params) => handler.eraseInLine(params);
csiStateHandler['L'] = (handler, params) => handler.insertLines(params);
@@ -57,8 +58,12 @@ csiStateHandler['d'] = (handler, params) => handler.linePosAbsolute(params);
csiStateHandler['e'] = (handler, params) => handler.VPositionRelative(params);
csiStateHandler['f'] = (handler, params) => handler.HVPosition(params);
csiStateHandler['h'] = (handler, params) => handler.setMode(params);
csiStateHandler['l'] = (handler, params) => handler.resetMode(params);
csiStateHandler['m'] = (handler, params) => handler.charAttributes(params);
csiStateHandler['n'] = (handler, params) => handler.deviceStatus(params);
csiStateHandler['r'] = (handler, params) => handler.setScrollRegion(params);
csiStateHandler['s'] = (handler, params) => handler.saveCursor(params);
csiStateHandler['u'] = (handler, params) => handler.restoreCursor(params);
enum ParserState {
NORMAL = 0,
@@ -554,42 +559,11 @@ export class Parser {
switch (ch) {
// CSI Pm l Reset Mode (RM).
// CSI ? Pm l
case 'l':
this._terminal.resetMode(this._terminal.params);
break;
// CSI Ps ; Ps r
// Set Scrolling Region [top;bottom] (default = full size of win-
// dow) (DECSTBM).
// CSI ? Pm r
case 'r':
this._terminal.setScrollRegion(this._terminal.params);
break;
// CSI s
// Save cursor (ANSI.SYS).
case 's':
this._terminal.saveCursor(this._terminal.params);
break;
// CSI u
// Restore cursor (ANSI.SYS).
case 'u':
this._terminal.restoreCursor(this._terminal.params);
break;
/**
* Lesser Used
*/
// CSI Ps I
// Cursor Forward Tabulation Ps tab stops (default = 1) (CHT).
case 'I':
this._terminal.cursorForwardTab(this._terminal.params);
break;
// CSI Ps S Scroll up Ps lines (default = 1) (SU).
case 'S':
this._terminal.scrollUp(this._terminal.params);
-226
View File
@@ -2326,236 +2326,10 @@ Terminal.prototype.tabSet = function() {
*/
/**
* CSI Pm l Reset Mode (RM).
* Ps = 2 -> Keyboard Action Mode (AM).
* Ps = 4 -> Replace Mode (IRM).
* Ps = 1 2 -> Send/receive (SRM).
* Ps = 2 0 -> Normal Linefeed (LNM).
* CSI ? Pm l
* DEC Private Mode Reset (DECRST).
* Ps = 1 -> Normal Cursor Keys (DECCKM).
* Ps = 2 -> Designate VT52 mode (DECANM).
* Ps = 3 -> 80 Column Mode (DECCOLM).
* Ps = 4 -> Jump (Fast) Scroll (DECSCLM).
* Ps = 5 -> Normal Video (DECSCNM).
* Ps = 6 -> Normal Cursor Mode (DECOM).
* Ps = 7 -> No Wraparound Mode (DECAWM).
* Ps = 8 -> No Auto-repeat Keys (DECARM).
* Ps = 9 -> Don't send Mouse X & Y on button press.
* Ps = 1 0 -> Hide toolbar (rxvt).
* Ps = 1 2 -> Stop Blinking Cursor (att610).
* Ps = 1 8 -> Don't print form feed (DECPFF).
* Ps = 1 9 -> Limit print to scrolling region (DECPEX).
* Ps = 2 5 -> Hide Cursor (DECTCEM).
* Ps = 3 0 -> Don't show scrollbar (rxvt).
* Ps = 3 5 -> Disable font-shifting functions (rxvt).
* Ps = 4 0 -> Disallow 80 -> 132 Mode.
* Ps = 4 1 -> No more(1) fix (see curses resource).
* Ps = 4 2 -> Disable Nation Replacement Character sets (DEC-
* NRCM).
* Ps = 4 4 -> Turn Off Margin Bell.
* Ps = 4 5 -> No Reverse-wraparound Mode.
* Ps = 4 6 -> Stop Logging. (This is normally disabled by a
* compile-time option).
* Ps = 4 7 -> Use Normal Screen Buffer.
* Ps = 6 6 -> Numeric keypad (DECNKM).
* Ps = 6 7 -> Backarrow key sends delete (DECBKM).
* Ps = 1 0 0 0 -> Don't send Mouse X & Y on button press and
* release. See the section Mouse Tracking.
* Ps = 1 0 0 1 -> Don't use Hilite Mouse Tracking.
* Ps = 1 0 0 2 -> Don't use Cell Motion Mouse Tracking.
* Ps = 1 0 0 3 -> Don't use All Motion Mouse Tracking.
* Ps = 1 0 0 4 -> Don't send FocusIn/FocusOut events.
* Ps = 1 0 0 5 -> Disable Extended Mouse Mode.
* Ps = 1 0 1 0 -> Don't scroll to bottom on tty output
* (rxvt).
* Ps = 1 0 1 1 -> Don't scroll to bottom on key press (rxvt).
* Ps = 1 0 3 4 -> Don't interpret "meta" key. (This disables
* the eightBitInput resource).
* Ps = 1 0 3 5 -> Disable special modifiers for Alt and Num-
* Lock keys. (This disables the numLock resource).
* Ps = 1 0 3 6 -> Don't send ESC when Meta modifies a key.
* (This disables the metaSendsEscape resource).
* Ps = 1 0 3 7 -> Send VT220 Remove from the editing-keypad
* Delete key.
* Ps = 1 0 3 9 -> Don't send ESC when Alt modifies a key.
* (This disables the altSendsEscape resource).
* Ps = 1 0 4 0 -> Do not keep selection when not highlighted.
* (This disables the keepSelection resource).
* Ps = 1 0 4 1 -> Use the PRIMARY selection. (This disables
* the selectToClipboard resource).
* Ps = 1 0 4 2 -> Disable Urgency window manager hint when
* Control-G is received. (This disables the bellIsUrgent
* resource).
* Ps = 1 0 4 3 -> Disable raising of the window when Control-
* G is received. (This disables the popOnBell resource).
* Ps = 1 0 4 7 -> Use Normal Screen Buffer, clearing screen
* first if in the Alternate Screen. (This may be disabled by
* the titeInhibit resource).
* Ps = 1 0 4 8 -> Restore cursor as in DECRC. (This may be
* disabled by the titeInhibit resource).
* Ps = 1 0 4 9 -> Use Normal Screen Buffer and restore cursor
* as in DECRC. (This may be disabled by the titeInhibit
* resource). This combines the effects of the 1 0 4 7 and 1 0
* 4 8 modes. Use this with terminfo-based applications rather
* than the 4 7 mode.
* Ps = 1 0 5 0 -> Reset terminfo/termcap function-key mode.
* Ps = 1 0 5 1 -> Reset Sun function-key mode.
* Ps = 1 0 5 2 -> Reset HP function-key mode.
* Ps = 1 0 5 3 -> Reset SCO function-key mode.
* Ps = 1 0 6 0 -> Reset legacy keyboard emulation (X11R6).
* Ps = 1 0 6 1 -> Reset keyboard emulation to Sun/PC style.
* Ps = 2 0 0 4 -> Reset bracketed paste mode.
*/
Terminal.prototype.resetMode = function(params) {
if (typeof params === 'object') {
var l = params.length
, i = 0;
for (; i < l; i++) {
this.resetMode(params[i]);
}
return;
}
if (!this.prefix) {
switch (params) {
case 4:
this.insertMode = false;
break;
case 20:
//this.convertEol = false;
break;
}
} else if (this.prefix === '?') {
switch (params) {
case 1:
this.applicationCursor = false;
break;
case 3:
if (this.cols === 132 && this.savedCols) {
this.resize(this.savedCols, this.rows);
}
delete this.savedCols;
break;
case 6:
this.originMode = false;
break;
case 7:
this.wraparoundMode = false;
break;
case 12:
// this.cursorBlink = false;
break;
case 66:
this.log('Switching back to normal keypad.');
this.applicationKeypad = false;
this.viewport.syncScrollArea();
break;
case 9: // X10 Mouse
case 1000: // vt200 mouse
case 1002: // button event mouse
case 1003: // any event mouse
this.x10Mouse = false;
this.vt200Mouse = false;
this.normalMouse = false;
this.mouseEvents = false;
this.element.style.cursor = '';
break;
case 1004: // send focusin/focusout events
this.sendFocus = false;
break;
case 1005: // utf8 ext mode mouse
this.utfMouse = false;
break;
case 1006: // sgr ext mode mouse
this.sgrMouse = false;
break;
case 1015: // urxvt ext mode mouse
this.urxvtMouse = false;
break;
case 25: // hide cursor
this.cursorHidden = true;
break;
case 1049: // alt screen buffer cursor
; // FALL-THROUGH
case 47: // normal screen buffer
case 1047: // normal screen buffer - clearing it first
if (this.normal) {
this.lines = this.normal.lines;
this.ybase = this.normal.ybase;
this.ydisp = this.normal.ydisp;
this.x = this.normal.x;
this.y = this.normal.y;
this.scrollTop = this.normal.scrollTop;
this.scrollBottom = this.normal.scrollBottom;
this.tabs = this.normal.tabs;
this.normal = null;
// if (params === 1049) {
// this.x = this.savedX;
// this.y = this.savedY;
// }
this.queueRefresh(0, this.rows - 1);
this.viewport.syncScrollArea();
this.showCursor();
}
break;
}
}
};
/**
* CSI Ps ; Ps r
* Set Scrolling Region [top;bottom] (default = full size of win-
* dow) (DECSTBM).
* CSI ? Pm r
*/
Terminal.prototype.setScrollRegion = function(params) {
if (this.prefix) return;
this.scrollTop = (params[0] || 1) - 1;
this.scrollBottom = (params[1] || this.rows) - 1;
this.x = 0;
this.y = 0;
};
/**
* CSI s
* Save cursor (ANSI.SYS).
*/
Terminal.prototype.saveCursor = function(params) {
this.savedX = this.x;
this.savedY = this.y;
};
/**
* CSI u
* Restore cursor (ANSI.SYS).
*/
Terminal.prototype.restoreCursor = function(params) {
this.x = this.savedX || 0;
this.y = this.savedY || 0;
};
/**
* Lesser Used
*/
/**
* CSI Ps I
* Cursor Forward Tabulation Ps tab stops (default = 1) (CHT).
*/
Terminal.prototype.cursorForwardTab = function(params) {
var param = params[0] || 1;
while (param--) {
this.x = this.nextStop();
}
};
/**