diff --git a/src/InputHandler.ts b/src/InputHandler.ts index c04f11137..5868f0dc5 100644 --- a/src/InputHandler.ts +++ b/src/InputHandler.ts @@ -32,6 +32,7 @@ const GLEVEL: {[key: string]: number} = {'(': 0, ')': 1, '*': 2, '+': 3, '-': 1, * Document common VT features here that are currently unsupported */ // @vt: unsupported DCS SIXEL "SIXEL Graphics" "DCS Ps ; Ps ; Ps ; q Pt ST" "Draw SIXEL image starting at cursor position." +// @vt: unsupported OSC 1 "Set Icon Name" "OSC 1 ; Pt BEL" "Set icon name." /** * Max length of the UTF32 input buffer. Real memory consumption is 4 times higher. @@ -201,200 +202,77 @@ export class InputHandler extends Disposable implements IInputHandler { * CSI handler */ this._parser.setCsiHandler({final: '@'}, params => this.insertChars(params)); - // @vt: supported CSI SL "Scroll Left" "CSI Ps SP @" "Scroll viewport `Ps` times to the left." this._parser.setCsiHandler({intermediates: ' ', final: '@'}, params => this.scrollLeft(params)); - // @vt: supported CSI CUU "Cursor Up" "CSI Ps A" "Move cursor `Ps` times up (default=1)." this._parser.setCsiHandler({final: 'A'}, params => this.cursorUp(params)); - // @vt: supported CSI SR "Scroll Right" "CSI Ps SP A" "Scroll viewport `Ps` times to the right." this._parser.setCsiHandler({intermediates: ' ', final: 'A'}, params => this.scrollRight(params)); - // @vt: supported CSI CUD "Cursor Down" "CSI Ps B" "Move cursor `Ps` times down (default=1)." this._parser.setCsiHandler({final: 'B'}, params => this.cursorDown(params)); - // @vt: supported CSI CUF "Cursor Forward" "CSI Ps C" "Move cursor `Ps` times forward (default=1)." this._parser.setCsiHandler({final: 'C'}, params => this.cursorForward(params)); - // @vt: supported CSI CUB "Cursor Backward" "CSI Ps D" "Move cursor `Ps` times backward (default=1)." this._parser.setCsiHandler({final: 'D'}, params => this.cursorBackward(params)); - // @vt: supported CSI CNL "Cursor Next Line" "CSI Ps E" "Move cursor `Ps` times down (default=1) and to the first column." this._parser.setCsiHandler({final: 'E'}, params => this.cursorNextLine(params)); - // @vt: supported CSI CPL "Cursor Backward" "CSI Ps F" "Move cursor `Ps` times up (default=1) and to the first column." this._parser.setCsiHandler({final: 'F'}, params => this.cursorPrecedingLine(params)); - // @vt: supported CSI CHA "Cursor Horizontal Absolute" "CSI Ps G" "Move cursor to `Ps`-th column of the active row (default=1)." this._parser.setCsiHandler({final: 'G'}, params => this.cursorCharAbsolute(params)); - // @vt: supported CSI CUP "Cursor Position" "CSI Ps ; Ps H" "Set cursor to position [`Ps`, `Ps`]." this._parser.setCsiHandler({final: 'H'}, params => this.cursorPosition(params)); - // @vt: supported CSI CHT "Cursor Horizontal Tabulation" "CSI Ps I" "Move cursor `Ps` times tabs forward (default=1)." this._parser.setCsiHandler({final: 'I'}, params => this.cursorForwardTab(params)); - /** - * @vt: supported CSI ED "Erase In Display" "CSI Ps J" "Erase various parts of the viewport." - * TODO: document different modes... - */ this._parser.setCsiHandler({final: 'J'}, params => this.eraseInDisplay(params)); - // @vt: partly CSI DECSED "Selective Erase In Display" "CSI ? Ps J" "Currently the same as ED." this._parser.setCsiHandler({prefix: '?', final: 'J'}, params => this.eraseInDisplay(params)); - /** - * @vt: supported CSI EL "Erase In Line" "CSI Ps K" "Erase various parts of the active row." - * TODO: document different modes... - */ this._parser.setCsiHandler({final: 'K'}, params => this.eraseInLine(params)); - // @vt: partly CSI DECSEL "Selective Erase In Line" "CSI ? Ps K" "Currently the same as EL." this._parser.setCsiHandler({prefix: '?', final: 'K'}, params => this.eraseInLine(params)); - // @vt: supported CSI IL "Insert Line" "CSI Ps L" "Insert `Ps` blank lines at active row (default=1)." this._parser.setCsiHandler({final: 'L'}, params => this.insertLines(params)); - // @vt: supported CSI DL "Delete Line" "CSI Ps M" "Delete `Ps` lines at active row (default=1)." this._parser.setCsiHandler({final: 'M'}, params => this.deleteLines(params)); - // @vt: supported CSI DCH "Delete Character" "CSI Ps P" "Delete `Ps` characters in the active row (default=1)." this._parser.setCsiHandler({final: 'P'}, params => this.deleteChars(params)); - // @vt: supported CSI SU "Scroll Up" "CSI Ps S" "Scroll `Ps` lines up (default=1)." this._parser.setCsiHandler({final: 'S'}, params => this.scrollUp(params)); - // @vt: supported CSI SD "Scroll Down" "CSI Ps T" "Scroll `Ps` lines down (default=1)." this._parser.setCsiHandler({final: 'T'}, params => this.scrollDown(params)); - // @vt: supported CSI ECH "Erase Character" "CSI Ps X" "Erase `Ps` characters from current cursor position to hte right (default=1)." this._parser.setCsiHandler({final: 'X'}, params => this.eraseChars(params)); - // @vt: supported CSI CBT "Cursor Backward Tabulation" "CSI Ps Z" "Move cursor `Ps` tabs backward (default=1)." this._parser.setCsiHandler({final: 'Z'}, params => this.cursorBackwardTab(params)); - // @vt: supported CSI HPA "Horizontal Position Absolute" "CSI Ps `" "Same as CHA." this._parser.setCsiHandler({final: '`'}, params => this.charPosAbsolute(params)); - // @vt: supported CSI HPR "Horizontal Position Relative" "CSI Ps a" "Same as CUF." this._parser.setCsiHandler({final: 'a'}, params => this.hPositionRelative(params)); - /** - * @vt: supported CSI REP "Repeat Preceding Character" "CSI Ps b" "Repeat preceding character `Ps` times (default=1)." - * Has no effect if the sequence does not follow a printed character (NOOP for any other sequence in between). - * TODO: document character limitations due to xterm compliance - */ this._parser.setCsiHandler({final: 'b'}, params => this.repeatPrecedingCharacter(params)); - /** - * @vt: supported CSI DA1 "Primary Device Attributes" "CSI c" "Send primary device attributes." - * TODO: Describe response... - */ this._parser.setCsiHandler({final: 'c'}, params => this.sendDeviceAttributesPrimary(params)); - /** - * @vt: supported CSI DA2 "Secondary Device Attributes" "CSI > c" "Send primary device attributes." - * TODO: Describe response... - */ this._parser.setCsiHandler({prefix: '>', final: 'c'}, params => this.sendDeviceAttributesSecondary(params)); - // @vt: supported CSI VPA "Vertical Position Absolute" "CSI Ps d" "Move cursor to `Ps`-th row (default=1)." this._parser.setCsiHandler({final: 'd'}, params => this.linePosAbsolute(params)); - // @vt: supported CSI VPR "Vertical Position Relative" "CSI Ps e" "Move cursor `Ps` times down (default=1)." this._parser.setCsiHandler({final: 'e'}, params => this.vPositionRelative(params)); - // @vt: supported CSI HVP "Horizontal and Vertical Position" "CSI Ps ; Ps f" "Same as CUP." this._parser.setCsiHandler({final: 'f'}, params => this.hVPosition(params)); - // @vt: supported CSI TBC "Tab Clear" "CSI Ps g" "Clear tab stops at current position (0) or all (3) (default=0)." this._parser.setCsiHandler({final: 'g'}, params => this.tabClear(params)); - /** - * @vt: partly CSI SM "Set Mode" "CSI Pm h" "Set various terminal attributes." - * TODO: Describe all supported attributes. - */ this._parser.setCsiHandler({final: 'h'}, params => this.setMode(params)); - /** - * @vt: partly CSI DECSET "DEC Private Set Mode" "CSI ? Pm h" "Set various terminal attributes." - * TODO: Describe all supported attributes. - */ this._parser.setCsiHandler({prefix: '?', final: 'h'}, params => this.setModePrivate(params)); - /** - * @vt: partly CSI RM "Reset Mode" "CSI Pm l" "Set various terminal attributes." - * TODO: Describe all supported attributes. - */ this._parser.setCsiHandler({final: 'l'}, params => this.resetMode(params)); - /** - * @vt: partly CSI DECRST "DEC Private Reset Mode" "CSI ? Pm l" "Reset various terminal attributes." - * TODO: Describe all supported attributes. - */ this._parser.setCsiHandler({prefix: '?', final: 'l'}, params => this.resetModePrivate(params)); - /** - * @vt: partly CSI SGR "Select Graphic Rendition" "CSI Pm m" "Reset various text attributes." - * Detailed description goes here... - */ this._parser.setCsiHandler({final: 'm'}, params => this.charAttributes(params)); - // @vt: supported CSI DSR "Device Status Report" "CSI Ps n" "Request cursor position (CPR) with `Ps` = 6." this._parser.setCsiHandler({final: 'n'}, params => this.deviceStatus(params)); - // @vt: partly CSI DECDSR "DEC Device Status Report" "CSI ? Ps n" "Only CPR is supported (same as DSR)." this._parser.setCsiHandler({prefix: '?', final: 'n'}, params => this.deviceStatusPrivate(params)); - /** - * @vt: supported CSI DECSTR "Soft Terminal Reset" "CSI ! p" "Reset several terminal attributes to initial state." - * There are two terminal reset sequences - RIS and DECSTR. While RIS performs almost a full terminal bootstrap, - * DECSTR only resets certain attributes. For most needs DECSTR should be sufficient. - * Attributes reset to default values: - * - TODO: list attributes here ... - */ this._parser.setCsiHandler({intermediates: '!', final: 'p'}, params => this.softReset(params)); - /** - * @vt: supported CSI DECSCUSR "Set Cursor Style" "CSI Ps SP q" "Set cursor style." - * Supported cursor styles (note that most renderers dont implement the blink feature, - * thus will show the steady variant instead): - * - empty, 0 or 1: steady block - * - 2: blink block - * - 3: steady underline - * - 4: blink underline - * - 5: steady bar - * - 6: blink bar - */ this._parser.setCsiHandler({intermediates: ' ', final: 'q'}, params => this.setCursorStyle(params)); - /** - * @vt: supported CSI DECSTBM "Set Top and Bottom Margin" "CSI Ps ; Ps r" "Set top and bottom margins of the viewport [top;bottom] (default = viewport size)." - * TODO: document specialties like dependent cursor commands and scrolling... - */ this._parser.setCsiHandler({final: 'r'}, params => this.setScrollRegion(params)); - // @vt: partly CSI SCOSC "Save Cursor" "CSI s" "Save cursor position, charmap and text attributes." this._parser.setCsiHandler({final: 's'}, params => this.saveCursor(params)); - // @vt: partly CSI SCORC "Restore Cursor" "CSI u" "Restore cursor position, charmap and text attributes." this._parser.setCsiHandler({final: 'u'}, params => this.restoreCursor(params)); - // @vt: supported CSI DECIC "Insert Columns" "CSI Ps ' }" "Insert `Ps` columns at cursor position." this._parser.setCsiHandler({intermediates: '\'', final: '}'}, params => this.insertColumns(params)); - // @vt: supported CSI DECDC "Delete Columns" "CSI Ps ' ~" "Delete `Ps` columns at cursor position." this._parser.setCsiHandler({intermediates: '\'', final: '~'}, params => this.deleteColumns(params)); /** * execute handler */ - /** - * @vt: supported C0 BEL "Bell" "\a" "Ring the bell." - * The behavior of the bell is further customizable with `ITerminalOptions.bellStyle` - * and `ITerminalOptions.bellSound`. - */ this._parser.setExecuteHandler(C0.BEL, () => this.bell()); - // @vt: supported C0 LF "Line Feed" "\n" "Move the cursor one row down, scrolling if needed." this._parser.setExecuteHandler(C0.LF, () => this.lineFeed()); - // @vt: supported C0 VT "Vertical Tabulation" "\v" "Treated as LF." this._parser.setExecuteHandler(C0.VT, () => this.lineFeed()); - // @vt: supported C0 FF "Form Feed" "\f" "Treated as LF." this._parser.setExecuteHandler(C0.FF, () => this.lineFeed()); - // @vt: supported C0 CR "Carriage Return" "\r" "Move the cursor to the beginning of the row." this._parser.setExecuteHandler(C0.CR, () => this.carriageReturn()); - // @vt: supported C0 BS "Backspace" "\b" "Move the cursor one position to the left." this._parser.setExecuteHandler(C0.BS, () => this.backspace()); - // @vt: supported C0 HT "Horizontal Tabulation" "\t" "Move the cursor to the next character tab stop." this._parser.setExecuteHandler(C0.HT, () => this.tab()); - /** - * @vt: partly C0 SO "Shift Out" "\x0e" "Switch to an alternative character set." - * TODO: document supported native character sets and support limitations ... - */ this._parser.setExecuteHandler(C0.SO, () => this.shiftOut()); - // @vt: supported C0 SI "Shift In" "\x0f" "Return to regular character set after Shift Out." this._parser.setExecuteHandler(C0.SI, () => this.shiftIn()); // FIXME: What do to with missing? Old code just added those to print. - // @vt: supported C1 IND "Index" "\x84" "Move the cursor one line down scrolling if needed." this._parser.setExecuteHandler(C1.IND, () => this.index()); - // @vt: supported C1 NEL "Next Line" "\x85" "Move the cursor to the beginning of the next row." this._parser.setExecuteHandler(C1.NEL, () => this.nextLine()); - // @vt: supported C1 HTS "Horizontal Tabulation Set" "\x88" "Places a tab stop at the current cursor position." this._parser.setExecuteHandler(C1.HTS, () => this.tabSet()); /** * OSC handler */ // 0 - icon name + title - /** - * @vt: partly OSC 0 "Set Windows Title and Icon Name" "OSC 0 ; Pt BEL" "Set window title and icon name." - * Icon name is not supported. For Window Title see below. - */ this._parser.setOscHandler(0, new OscHandler((data: string) => this.setTitle(data))); // 1 - icon name - // @vt: unsupported OSC 1 "Set Icon Name" "OSC 1 ; Pt BEL" "Set icon name." // 2 - title - /** - * @vt: supported OSC 2 "Set Windows Title" "OSC 2 ; Pt BEL" "Set window title." - * xterm.js does not manipulate the title directly, instead exposes changes via the event `Terminal.onTitleChange`. - */ this._parser.setOscHandler(2, new OscHandler((data: string) => this.setTitle(data))); // 3 - set property X in the form "prop=value" // 4 - Change Color Number @@ -432,15 +310,10 @@ export class InputHandler extends Disposable implements IInputHandler { /** * ESC handlers */ - // @vt: supported ESC SC "Save Cursor" "ESC 7" "Save cursor position, charmap and text attributes." this._parser.setEscHandler({final: '7'}, () => this.saveCursor()); - // @vt: supported ESC RC "Restore Cursor" "ESC 8" "Restore cursor position, charmap and text attributes." this._parser.setEscHandler({final: '8'}, () => this.restoreCursor()); - // @vt: supported ESC IND "Index" "ESC D" "Move the cursor one line down scrolling if needed." this._parser.setEscHandler({final: 'D'}, () => this.index()); - // @vt: supported ESC NEL "Next Line" "ESC E" "Move the cursor to the beginning of the next row." this._parser.setEscHandler({final: 'E'}, () => this.nextLine()); - // @vt: supported ESC HTS "Horizontal Tabulation Set" "ESC H" "Places a tab stop at the current cursor position." this._parser.setEscHandler({final: 'H'}, () => this.tabSet()); // @vt: supported ESC IR "Reverse Index" "ESC M" "Move the cursor one line up scrolling if needed." this._parser.setEscHandler({final: 'M'}, () => this.reverseIndex()); @@ -463,7 +336,6 @@ export class InputHandler extends Disposable implements IInputHandler { this._parser.setEscHandler({intermediates: '.', final: flag}, () => this.selectCharset('.' + flag)); this._parser.setEscHandler({intermediates: '/', final: flag}, () => this.selectCharset('/' + flag)); // TODO: supported? } - // @vt: supported ESC DECALN "Screen Alignment Pattern" "ESC # 8" "Fill viewport with a test pattern (E)." this._parser.setEscHandler({intermediates: '#', final: '8'}, () => this.screenAlignmentPattern()); /** @@ -696,6 +568,10 @@ export class InputHandler extends Disposable implements IInputHandler { /** * BEL * Bell (Ctrl-G). + * + * @vt: supported C0 BEL "Bell" "\a" "Ring the bell." + * The behavior of the bell is further customizable with `ITerminalOptions.bellStyle` + * and `ITerminalOptions.bellSound`. */ public bell(): void { this._onRequestBell.fire(); @@ -704,7 +580,11 @@ export class InputHandler extends Disposable implements IInputHandler { /** * LF * Line Feed or New Line (NL). (LF is Ctrl-J). + * + * @vt: supported C0 LF "Line Feed" "\n" "Move the cursor one row down, scrolling if needed." */ + // @vt: supported C0 VT "Vertical Tabulation" "\v" "Treated as LF." + // @vt: supported C0 FF "Form Feed" "\f" "Treated as LF." public lineFeed(): void { // make buffer local for faster access const buffer = this._bufferService.buffer; @@ -732,6 +612,8 @@ export class InputHandler extends Disposable implements IInputHandler { /** * CR * Carriage Return (Ctrl-M). + * + * @vt: supported C0 CR "Carriage Return" "\r" "Move the cursor to the beginning of the row." */ public carriageReturn(): void { this._bufferService.buffer.x = 0; @@ -740,6 +622,8 @@ export class InputHandler extends Disposable implements IInputHandler { /** * BS * Backspace (Ctrl-H). + * + * @vt: supported C0 BS "Backspace" "\b" "Move the cursor one position to the left." */ public backspace(): void { this._restrictCursor(); @@ -751,6 +635,8 @@ export class InputHandler extends Disposable implements IInputHandler { /** * TAB * Horizontal Tab (HT) (Ctrl-I). + * + * @vt: supported C0 HT "Horizontal Tabulation" "\t" "Move the cursor to the next character tab stop." */ public tab(): void { if (this._bufferService.buffer.x >= this._bufferService.cols) { @@ -767,6 +653,9 @@ export class InputHandler extends Disposable implements IInputHandler { * SO * Shift Out (Ctrl-N) -> Switch to Alternate Character Set. This invokes the * G1 character set. + * + * @vt: partly C0 SO "Shift Out" "\x0e" "Switch to an alternative character set." + * TODO: document supported native character sets and support limitations ... */ public shiftOut(): void { this._charsetService.setgLevel(1); @@ -776,6 +665,8 @@ export class InputHandler extends Disposable implements IInputHandler { * SI * Shift In (Ctrl-O) -> Switch to Standard Character Set. This invokes the G0 * character set (the default). + * + * @vt: supported C0 SI "Shift In" "\x0f" "Return to regular character set after Shift Out." */ public shiftIn(): void { this._charsetService.setgLevel(0); @@ -821,6 +712,8 @@ export class InputHandler extends Disposable implements IInputHandler { /** * CSI Ps A * Cursor Up Ps Times (default = 1) (CUU). + * + * @vt: supported CSI CUU "Cursor Up" "CSI Ps A" "Move cursor `Ps` times up (default=1)." */ public cursorUp(params: IParams): void { // stop at scrollTop @@ -835,6 +728,8 @@ export class InputHandler extends Disposable implements IInputHandler { /** * CSI Ps B * Cursor Down Ps Times (default = 1) (CUD). + * + * @vt: supported CSI CUD "Cursor Down" "CSI Ps B" "Move cursor `Ps` times down (default=1)." */ public cursorDown(params: IParams): void { // stop at scrollBottom @@ -849,6 +744,8 @@ export class InputHandler extends Disposable implements IInputHandler { /** * CSI Ps C * Cursor Forward Ps Times (default = 1) (CUF). + * + * @vt: supported CSI CUF "Cursor Forward" "CSI Ps C" "Move cursor `Ps` times forward (default=1)." */ public cursorForward(params: IParams): void { this._moveCursor(params.params[0] || 1, 0); @@ -857,6 +754,8 @@ export class InputHandler extends Disposable implements IInputHandler { /** * CSI Ps D * Cursor Backward Ps Times (default = 1) (CUB). + * + * @vt: supported CSI CUB "Cursor Backward" "CSI Ps D" "Move cursor `Ps` times backward (default=1)." */ public cursorBackward(params: IParams): void { this._moveCursor(-(params.params[0] || 1), 0); @@ -866,6 +765,8 @@ export class InputHandler extends Disposable implements IInputHandler { * CSI Ps E * Cursor Next Line Ps Times (default = 1) (CNL). * Other than cursorDown (CUD) also set the cursor to first column. + * + * @vt: supported CSI CNL "Cursor Next Line" "CSI Ps E" "Move cursor `Ps` times down (default=1) and to the first column." */ public cursorNextLine(params: IParams): void { this.cursorDown(params); @@ -876,6 +777,8 @@ export class InputHandler extends Disposable implements IInputHandler { * CSI Ps F * Cursor Previous Line Ps Times (default = 1) (CPL). * Other than cursorUp (CUU) also set the cursor to first column. + * + * @vt: supported CSI CPL "Cursor Backward" "CSI Ps F" "Move cursor `Ps` times up (default=1) and to the first column." */ public cursorPrecedingLine(params: IParams): void { this.cursorUp(params); @@ -885,6 +788,8 @@ export class InputHandler extends Disposable implements IInputHandler { /** * CSI Ps G * Cursor Character Absolute [column] (default = [row,1]) (CHA). + * + * @vt: supported CSI CHA "Cursor Horizontal Absolute" "CSI Ps G" "Move cursor to `Ps`-th column of the active row (default=1)." */ public cursorCharAbsolute(params: IParams): void { this._setCursor((params.params[0] || 1) - 1, this._bufferService.buffer.y); @@ -893,6 +798,8 @@ export class InputHandler extends Disposable implements IInputHandler { /** * CSI Ps ; Ps H * Cursor Position [row;column] (default = [1,1]) (CUP). + * + * @vt: supported CSI CUP "Cursor Position" "CSI Ps ; Ps H" "Set cursor to position [`Ps`, `Ps`] (default = [1, 1])." */ public cursorPosition(params: IParams): void { this._setCursor( @@ -906,6 +813,8 @@ export class InputHandler extends Disposable implements IInputHandler { * CSI Pm ` Character Position Absolute * [column] (default = [row,1]) (HPA). * Currently same functionality as CHA. + * + * @vt: supported CSI HPA "Horizontal Position Absolute" "CSI Ps `" "Same as CHA." */ public charPosAbsolute(params: IParams): void { this._setCursor((params.params[0] || 1) - 1, this._bufferService.buffer.y); @@ -915,6 +824,8 @@ export class InputHandler extends Disposable implements IInputHandler { * CSI Pm a Character Position Relative * [columns] (default = [row,col+1]) (HPR) * Currently same functionality as CUF. + * + * @vt: supported CSI HPR "Horizontal Position Relative" "CSI Ps a" "Same as CUF." */ public hPositionRelative(params: IParams): void { this._moveCursor(params.params[0] || 1, 0); @@ -923,6 +834,8 @@ export class InputHandler extends Disposable implements IInputHandler { /** * CSI Pm d Vertical Position Absolute (VPA) * [row] (default = [1,column]) + * + * @vt: supported CSI VPA "Vertical Position Absolute" "CSI Ps d" "Move cursor to `Ps`-th row (default=1)." */ public linePosAbsolute(params: IParams): void { this._setCursor(this._bufferService.buffer.x, (params.params[0] || 1) - 1); @@ -932,6 +845,8 @@ export class InputHandler extends Disposable implements IInputHandler { * CSI Pm e Vertical Position Relative (VPR) * [rows] (default = [row+1,column]) * reuse CSI Ps B ? + * + * @vt: supported CSI VPR "Vertical Position Relative" "CSI Ps e" "Move cursor `Ps` times down (default=1)." */ public vPositionRelative(params: IParams): void { this._moveCursor(0, params.params[0] || 1); @@ -942,6 +857,8 @@ export class InputHandler extends Disposable implements IInputHandler { * Horizontal and Vertical Position [row;column] (default = * [1,1]) (HVP). * Same as CUP. + * + * @vt: supported CSI HVP "Horizontal and Vertical Position" "CSI Ps ; Ps f" "Same as CUP." */ public hVPosition(params: IParams): void { this.cursorPosition(params); @@ -954,6 +871,8 @@ export class InputHandler extends Disposable implements IInputHandler { * Potentially: * Ps = 2 -> Clear Stops on Line. * http://vt100.net/annarbor/aaa-ug/section6.html + * + * @vt: supported CSI TBC "Tab Clear" "CSI Ps g" "Clear tab stops at current position (0) or all (3) (default=0)." */ public tabClear(params: IParams): void { const param = params.params[0]; @@ -967,6 +886,8 @@ export class InputHandler extends Disposable implements IInputHandler { /** * CSI Ps I * Cursor Forward Tabulation Ps tab stops (default = 1) (CHT). + * + * @vt: supported CSI CHT "Cursor Horizontal Tabulation" "CSI Ps I" "Move cursor `Ps` times tabs forward (default=1)." */ public cursorForwardTab(params: IParams): void { if (this._bufferService.buffer.x >= this._bufferService.cols) { @@ -980,6 +901,8 @@ export class InputHandler extends Disposable implements IInputHandler { /** * CSI Ps Z Cursor Backward Tabulation Ps tab stops (default = 1) (CBT). + * + * @vt: supported CSI CBT "Cursor Backward Tabulation" "CSI Ps Z" "Move cursor `Ps` tabs backward (default=1)." */ public cursorBackwardTab(params: IParams): void { if (this._bufferService.buffer.x >= this._bufferService.cols) { @@ -1038,7 +961,11 @@ export class InputHandler extends Disposable implements IInputHandler { * Ps = 0 -> Selective Erase Below (default). * Ps = 1 -> Selective Erase Above. * Ps = 2 -> Selective Erase All. + * + * @vt: supported CSI ED "Erase In Display" "CSI Ps J" "Erase various parts of the viewport." + * TODO: document different modes... */ + // @vt: partly CSI DECSED "Selective Erase In Display" "CSI ? Ps J" "Currently the same as ED." public eraseInDisplay(params: IParams): void { this._restrictCursor(); let j; @@ -1098,7 +1025,11 @@ export class InputHandler extends Disposable implements IInputHandler { * Ps = 0 -> Selective Erase to Right (default). * Ps = 1 -> Selective Erase to Left. * Ps = 2 -> Selective Erase All. + * + * @vt: supported CSI EL "Erase In Line" "CSI Ps K" "Erase various parts of the active row." + * TODO: document different modes... */ + // @vt: partly CSI DECSEL "Selective Erase In Line" "CSI ? Ps K" "Currently the same as EL." public eraseInLine(params: IParams): void { this._restrictCursor(); switch (params.params[0]) { @@ -1118,6 +1049,8 @@ export class InputHandler extends Disposable implements IInputHandler { /** * CSI Ps L * Insert Ps Line(s) (default = 1) (IL). + * + * @vt: supported CSI IL "Insert Line" "CSI Ps L" "Insert `Ps` blank lines at active row (default=1)." */ public insertLines(params: IParams): void { this._restrictCursor(); @@ -1148,6 +1081,8 @@ export class InputHandler extends Disposable implements IInputHandler { /** * CSI Ps M * Delete Ps Line(s) (default = 1) (DL). + * + * @vt: supported CSI DL "Delete Line" "CSI Ps M" "Delete `Ps` lines at active row (default=1)." */ public deleteLines(params: IParams): void { this._restrictCursor(); @@ -1197,6 +1132,8 @@ export class InputHandler extends Disposable implements IInputHandler { /** * CSI Ps P * Delete Ps Character(s) (default = 1) (DCH). + * + * @vt: supported CSI DCH "Delete Character" "CSI Ps P" "Delete `Ps` characters in the active row (default=1)." */ public deleteChars(params: IParams): void { this._restrictCursor(); @@ -1214,6 +1151,8 @@ export class InputHandler extends Disposable implements IInputHandler { /** * CSI Ps S Scroll up Ps lines (default = 1) (SU). + * + * @vt: supported CSI SU "Scroll Up" "CSI Ps S" "Scroll `Ps` lines up (default=1)." */ public scrollUp(params: IParams): void { let param = params.params[0] || 1; @@ -1230,6 +1169,8 @@ export class InputHandler extends Disposable implements IInputHandler { /** * CSI Ps T Scroll down Ps lines (default = 1) (SD). + * + * @vt: supported CSI SD "Scroll Down" "CSI Ps T" "Scroll `Ps` lines down (default=1)." */ public scrollDown(params: IParams): void { let param = params.params[0] || 1; @@ -1257,6 +1198,8 @@ export class InputHandler extends Disposable implements IInputHandler { * * Supported: * - always left shift (no line orientation setting respected) + * + * @vt: supported CSI SL "Scroll Left" "CSI Ps SP @" "Scroll viewport `Ps` times to the left." */ public scrollLeft(params: IParams): void { const buffer = this._bufferService.buffer; @@ -1285,6 +1228,8 @@ export class InputHandler extends Disposable implements IInputHandler { * * Supported: * - always right shift (no line orientation setting respected) + * + * @vt: supported CSI SR "Scroll Right" "CSI Ps SP A" "Scroll viewport `Ps` times to the right." */ public scrollRight(params: IParams): void { const buffer = this._bufferService.buffer; @@ -1303,6 +1248,8 @@ export class InputHandler extends Disposable implements IInputHandler { /** * CSI Pm ' } * Insert Ps Column(s) (default = 1) (DECIC), VT420 and up. + * + * @vt: supported CSI DECIC "Insert Columns" "CSI Ps ' }" "Insert `Ps` columns at cursor position." */ public insertColumns(params: IParams): void { const buffer = this._bufferService.buffer; @@ -1321,6 +1268,8 @@ export class InputHandler extends Disposable implements IInputHandler { /** * CSI Pm ' ~ * Delete Ps Column(s) (default = 1) (DECDC), VT420 and up. + * + * @vt: supported CSI DECDC "Delete Columns" "CSI Ps ' ~" "Delete `Ps` columns at cursor position." */ public deleteColumns(params: IParams): void { const buffer = this._bufferService.buffer; @@ -1339,6 +1288,8 @@ export class InputHandler extends Disposable implements IInputHandler { /** * CSI Ps X * Erase Ps Character(s) (default = 1) (ECH). + * + * @vt: supported CSI ECH "Erase Character" "CSI Ps X" "Erase `Ps` characters from current cursor position to hte right (default=1)." */ public eraseChars(params: IParams): void { this._restrictCursor(); @@ -1375,6 +1326,10 @@ export class InputHandler extends Disposable implements IInputHandler { * * Note: To get reset on a valid sequence working correctly without much runtime penalty, * the preceding codepoint is stored on the parser in `this.print` and reset during `parser.parse`. + * + * @vt: supported CSI REP "Repeat Preceding Character" "CSI Ps b" "Repeat preceding character `Ps` times (default=1)." + * Has no effect if the sequence does not follow a printed character (NOOP for any other sequence in between). + * TODO: document character limitations due to xterm compliance */ public repeatPrecedingCharacter(params: IParams): void { if (!this._parser.precedingCodepoint) { @@ -1425,6 +1380,9 @@ export class InputHandler extends Disposable implements IInputHandler { * More information: * xterm/charproc.c - line 2012, for more information. * vim responds with ^[[?0c or ^[[?1c after the terminal's response (?) + * + * @vt: supported CSI DA1 "Primary Device Attributes" "CSI c" "Send primary device attributes." + * TODO: Describe response... */ public sendDeviceAttributesPrimary(params: IParams): void { if (params.params[0] > 0) { @@ -1436,6 +1394,10 @@ export class InputHandler extends Disposable implements IInputHandler { this._coreService.triggerDataEvent(C0.ESC + '[?6c'); } } + /** + * @vt: supported CSI DA2 "Secondary Device Attributes" "CSI > c" "Send primary device attributes." + * TODO: Describe response... + */ public sendDeviceAttributesSecondary(params: IParams): void { if (params.params[0] > 0) { return; @@ -1541,6 +1503,9 @@ export class InputHandler extends Disposable implements IInputHandler { * Ps = 2 0 0 4 -> Set bracketed paste mode. * Modes: * http: *vt100.net/docs/vt220-rm/chapter4.html + * + * @vt: partly CSI SM "Set Mode" "CSI Pm h" "Set various terminal attributes." + * TODO: Describe all supported attributes. */ public setMode(params: IParams): void { for (let i = 0; i < params.length; i++) { @@ -1554,6 +1519,10 @@ export class InputHandler extends Disposable implements IInputHandler { } } } + /** + * @vt: partly CSI DECSET "DEC Private Set Mode" "CSI ? Pm h" "Set various terminal attributes." + * TODO: Describe all supported attributes. + */ public setModePrivate(params: IParams): void { for (let i = 0; i < params.length; i++) { switch (params.params[i]) { @@ -1723,6 +1692,9 @@ export class InputHandler extends Disposable implements IInputHandler { * 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. + * + * @vt: partly CSI RM "Reset Mode" "CSI Pm l" "Set various terminal attributes." + * TODO: Describe all supported attributes. */ public resetMode(params: IParams): void { for (let i = 0; i < params.length; i++) { @@ -1736,6 +1708,10 @@ export class InputHandler extends Disposable implements IInputHandler { } } } + /** + * @vt: partly CSI DECRST "DEC Private Reset Mode" "CSI ? Pm l" "Reset various terminal attributes." + * TODO: Describe all supported attributes. + */ public resetModePrivate(params: IParams): void { for (let i = 0; i < params.length; i++) { switch (params.params[i]) { @@ -1947,6 +1923,9 @@ export class InputHandler extends Disposable implements IInputHandler { * Ps. * Ps = 4 8 ; 5 ; Ps -> Set background color to the second * Ps. + * + * @vt: partly CSI SGR "Select Graphic Rendition" "CSI Pm m" "Set/Reset various text attributes." + * Detailed description goes here... */ public charAttributes(params: IParams): void { // Optimize a single SGR0. @@ -2068,6 +2047,8 @@ export class InputHandler extends Disposable implements IInputHandler { * Ps = 5 3 -> Report Locator status as * CSI ? 5 3 n Locator available, if compiled-in, or * CSI ? 5 0 n No Locator, if not. + * + * @vt: supported CSI DSR "Device Status Report" "CSI Ps n" "Request cursor position (CPR) with `Ps` = 6." */ public deviceStatus(params: IParams): void { switch (params.params[0]) { @@ -2084,6 +2065,7 @@ export class InputHandler extends Disposable implements IInputHandler { } } + // @vt: partly CSI DECDSR "DEC Device Status Report" "CSI ? Ps n" "Only CPR is supported (same as DSR)." public deviceStatusPrivate(params: IParams): void { // modern xterm doesnt seem to // respond to any of these except ?6, 6, and 5 @@ -2116,6 +2098,12 @@ export class InputHandler extends Disposable implements IInputHandler { /** * CSI ! p Soft terminal reset (DECSTR). * http://vt100.net/docs/vt220-rm/table4-10.html + * + * @vt: supported CSI DECSTR "Soft Terminal Reset" "CSI ! p" "Reset several terminal attributes to initial state." + * There are two terminal reset sequences - RIS and DECSTR. While RIS performs almost a full terminal bootstrap, + * DECSTR only resets certain attributes. For most needs DECSTR should be sufficient. + * Attributes reset to default values: + * - TODO: list attributes here ... */ public softReset(params: IParams): void { this._coreService.isCursorHidden = false; @@ -2138,6 +2126,15 @@ export class InputHandler extends Disposable implements IInputHandler { * Ps = 4 -> steady underline. * Ps = 5 -> blinking bar (xterm). * Ps = 6 -> steady bar (xterm). + * + * @vt: supported CSI DECSCUSR "Set Cursor Style" "CSI Ps SP q" "Set cursor style." + * Supported cursor styles (TODO: add note about `options.cursorBlink`): + * - empty, 0 or 1: steady block + * - 2: blink block + * - 3: steady underline + * - 4: blink underline + * - 5: steady bar + * - 6: blink bar */ public setCursorStyle(params: IParams): void { const param = params.params[0] || 1; @@ -2163,6 +2160,9 @@ export class InputHandler extends Disposable implements IInputHandler { * CSI Ps ; Ps r * Set Scrolling Region [top;bottom] (default = full size of win- * dow) (DECSTBM). + * + * @vt: supported CSI DECSTBM "Set Top and Bottom Margin" "CSI Ps ; Ps r" "Set top and bottom margins of the viewport [top;bottom] (default = viewport size)." + * TODO: document specialties like dependent cursor commands and scrolling... */ public setScrollRegion(params: IParams): void { const top = params.params[0] || 1; @@ -2184,7 +2184,10 @@ export class InputHandler extends Disposable implements IInputHandler { * CSI s * ESC 7 * Save cursor (ANSI.SYS). + * + * @vt: partly CSI SCOSC "Save Cursor" "CSI s" "Save cursor position, charmap and text attributes." */ + // @vt: supported ESC SC "Save Cursor" "ESC 7" "Save cursor position, charmap and text attributes." public saveCursor(params?: IParams): void { this._bufferService.buffer.savedX = this._bufferService.buffer.x; this._bufferService.buffer.savedY = this._bufferService.buffer.ybase + this._bufferService.buffer.y; @@ -2198,7 +2201,10 @@ export class InputHandler extends Disposable implements IInputHandler { * CSI u * ESC 8 * Restore cursor (ANSI.SYS). + * + * @vt: partly CSI SCORC "Restore Cursor" "CSI u" "Restore cursor position, charmap and text attributes." */ + // @vt: supported ESC RC "Restore Cursor" "ESC 8" "Restore cursor position, charmap and text attributes." public restoreCursor(params?: IParams): void { this._bufferService.buffer.x = this._bufferService.buffer.savedX || 0; this._bufferService.buffer.y = Math.max(this._bufferService.buffer.savedY - this._bufferService.buffer.ybase, 0); @@ -2216,6 +2222,13 @@ export class InputHandler extends Disposable implements IInputHandler { * OSC 0; ST (set icon name + window title) * OSC 2; ST (set window title) * Proxy to set window title. Icon name is not supported. + * + * @vt: partly OSC 0 "Set Windows Title and Icon Name" "OSC 0 ; Pt BEL" "Set window title and icon name." + * Icon name is not supported. For Window Title see below. + */ + /** + * @vt: supported OSC 2 "Set Windows Title" "OSC 2 ; Pt BEL" "Set window title." + * xterm.js does not manipulate the title directly, instead exposes changes via the event `Terminal.onTitleChange`. */ public setTitle(data: string): void { this._terminal.handleTitle(data); @@ -2226,7 +2239,10 @@ export class InputHandler extends Disposable implements IInputHandler { * C1.NEL * DEC mnemonic: NEL (https://vt100.net/docs/vt510-rm/NEL) * Moves cursor to first position on next line. + * + * @vt: supported C1 NEL "Next Line" "\x85" "Move the cursor to the beginning of the next row." */ + // @vt: supported ESC NEL "Next Line" "ESC E" "Move the cursor to the beginning of the next row." public nextLine(): void { this._bufferService.buffer.x = 0; this.index(); @@ -2298,7 +2314,10 @@ export class InputHandler extends Disposable implements IInputHandler { * C1.IND * DEC mnemonic: IND (https://vt100.net/docs/vt510-rm/IND.html) * Moves the cursor down one line in the same column. + * + * @vt: supported C1 IND "Index" "\x84" "Move the cursor one line down scrolling if needed." */ + // @vt: supported ESC IND "Index" "ESC D" "Move the cursor one line down scrolling if needed." public index(): void { this._restrictCursor(); const buffer = this._bufferService.buffer; @@ -2318,7 +2337,10 @@ export class InputHandler extends Disposable implements IInputHandler { * DEC mnemonic: HTS (https://vt100.net/docs/vt510-rm/HTS.html) * Sets a horizontal tab stop at the column position indicated by * the value of the active column when the terminal receives an HTS. + * + * @vt: supported C1 HTS "Horizontal Tabulation Set" "\x88" "Places a tab stop at the current cursor position." */ + // @vt: supported ESC HTS "Horizontal Tabulation Set" "ESC H" "Places a tab stop at the current cursor position." public tabSet(): void { this._bufferService.buffer.tabs[this._bufferService.buffer.x] = true; } @@ -2390,8 +2412,8 @@ export class InputHandler extends Disposable implements IInputHandler { * DEC mnemonic: DECALN (https://vt100.net/docs/vt510-rm/DECALN.html) * This control function fills the complete screen area with * a test pattern (E) used for adjusting screen alignment. - * - * TODO: move DECALN into compat addon + * + * @vt: supported ESC DECALN "Screen Alignment Pattern" "ESC # 8" "Fill viewport with a test pattern (E)." */ public screenAlignmentPattern(): void { // prepare cell data