update files

This commit is contained in:
nuintun 2015-11-24 22:00:46 +08:00
parent 085a5cf350
commit 32ae3adceb
24 changed files with 149 additions and 142 deletions

View File

@ -7,10 +7,9 @@
module.exports = function (Terminal){
Terminal.prototype.blankLine = function (cur){
var attr = cur ? this.curAttr : this.defAttr;
var ch = [attr, ' '],
line = [],
i = 0;
var ch = [attr, ' '];
var line = [];
var i = 0;
for (; i < this.cols; i++) {
line[i] = ch;

View File

@ -5,9 +5,7 @@
'use strict';
module.exports = function (Terminal){
Terminal.charsets = {};
// DEC Special Character and Line Drawing Set.
// http://vt100.net/docs/vt102-ug/table5-13.html
// A lot of curses apps use this if they see TERM=xterm.
@ -49,7 +47,6 @@ module.exports = function (Terminal){
'}': '\u00a3', // '£'
'~': '\u00b7' // '·'
};
Terminal.charsets.UK = null; // (A
Terminal.charsets.US = null; // (B (USASCII)
Terminal.charsets.Dutch = null; // (4
@ -63,5 +60,4 @@ module.exports = function (Terminal){
Terminal.charsets.Swedish = null; // (H or (7
Terminal.charsets.Swiss = null; // (=
Terminal.charsets.ISOLatin = null; // /A
};

View File

@ -5,7 +5,6 @@
'use strict';
module.exports = function (Terminal){
// Colors 0-15
Terminal.colors = [
// dark:
@ -17,18 +16,20 @@ module.exports = function (Terminal){
// Colors 16-255
// Much thanks to TooTallNate for writing this.
Terminal.colors = (function (){
var colors = Terminal.colors,
r = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff],
i;
var colors = Terminal.colors;
var r = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff];
var i;
// 16-231
i = 0;
for (; i < 216; i++) {
out(r[(i / 36) % 6 | 0], r[(i / 6) % 6 | 0], r[i % 6]);
}
// 232-255 (grey)
i = 0;
for (; i < 24; i++) {
r = 8 + i * 10;
out(r, r, r);
@ -40,6 +41,7 @@ module.exports = function (Terminal){
function hex(c){
c = c.toString(16);
return c.length < 2 ? '0' + c : c;
}

View File

@ -5,7 +5,6 @@
'use strict';
module.exports = function (Terminal){
// CSI Pm m Character Attributes (SGR).
// Ps = 0 -> Normal (default).
// Ps = 1 -> Bold.

View File

@ -7,14 +7,14 @@
module.exports = function (Terminal){
// CSI s
// Save cursor (ANSI.SYS).
Terminal.prototype.saveCursor = function (params){
Terminal.prototype.saveCursor = function (){
this.savedX = this.x;
this.savedY = this.y;
};
// CSI u
// Restore cursor (ANSI.SYS).
Terminal.prototype.restoreCursor = function (params){
Terminal.prototype.restoreCursor = function (){
this.x = this.savedX || 0;
this.y = this.savedY || 0;
};
@ -23,8 +23,11 @@ module.exports = function (Terminal){
// Cursor Up Ps Times (default = 1) (CUU).
Terminal.prototype.cursorUp = function (params){
var param = params[0];
if (param < 1) param = 1;
this.y -= param;
if (this.y < 0) this.y = 0;
};
@ -32,8 +35,11 @@ module.exports = function (Terminal){
// Cursor Down Ps Times (default = 1) (CUD).
Terminal.prototype.cursorDown = function (params){
var param = params[0];
if (param < 1) param = 1;
this.y += param;
if (this.y >= this.rows) {
this.y = this.rows - 1;
}
@ -43,8 +49,11 @@ module.exports = function (Terminal){
// Cursor Forward Ps Times (default = 1) (CUF).
Terminal.prototype.cursorForward = function (params){
var param = params[0];
if (param < 1) param = 1;
this.x += param;
if (this.x >= this.cols) {
this.x = this.cols - 1;
}
@ -54,8 +63,11 @@ module.exports = function (Terminal){
// Cursor Backward Ps Times (default = 1) (CUB).
Terminal.prototype.cursorBackward = function (params){
var param = params[0];
if (param < 1) param = 1;
this.x -= param;
if (this.x < 0) this.x = 0;
};
@ -93,11 +105,15 @@ module.exports = function (Terminal){
// same as CSI Ps B ?
Terminal.prototype.cursorNextLine = function (params){
var param = params[0];
if (param < 1) param = 1;
this.y += param;
if (this.y >= this.rows) {
this.y = this.rows - 1;
}
this.x = 0;
};
@ -106,9 +122,13 @@ module.exports = function (Terminal){
// reuse CSI Ps A ?
Terminal.prototype.cursorPrecedingLine = function (params){
var param = params[0];
if (param < 1) param = 1;
this.y -= param;
if (this.y < 0) this.y = 0;
this.x = 0;
};
@ -116,7 +136,9 @@ module.exports = function (Terminal){
// Cursor Character Absolute [column] (default = [row,1]) (CHA).
Terminal.prototype.cursorCharAbsolute = function (params){
var param = params[0];
if (param < 1) param = 1;
this.x = param - 1;
};
@ -124,6 +146,7 @@ module.exports = function (Terminal){
// 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();
}
@ -132,9 +155,9 @@ module.exports = function (Terminal){
// CSI Ps Z Cursor Backward Tabulation Ps tab stops (default = 1) (CBT).
Terminal.prototype.cursorBackwardTab = function (params){
var param = params[0] || 1;
while (param--) {
this.x = this.prevStop();
}
};
};

View File

@ -12,6 +12,7 @@ module.exports = function (Terminal){
var param, row, j, ch;
param = params[0];
if (param < 1) param = 1;
row = this.y + this.ybase;
@ -30,9 +31,10 @@ module.exports = function (Terminal){
var param, row, j;
param = params[0];
if (param < 1) param = 1;
row = this.y + this.ybase;
if (param < 1) param = 1;
row = this.y + this.ybase;
j = this.rows - 1 - this.scrollBottom;
j = this.rows - 1 + this.ybase - j + 1;
@ -54,9 +56,10 @@ module.exports = function (Terminal){
var param, row, j;
param = params[0];
if (param < 1) param = 1;
row = this.y + this.ybase;
if (param < 1) param = 1;
row = this.y + this.ybase;
j = this.rows - 1 - this.scrollBottom;
j = this.rows - 1 + this.ybase - j;
@ -78,6 +81,7 @@ module.exports = function (Terminal){
var param, row, ch;
param = params[0];
if (param < 1) param = 1;
row = this.y + this.ybase;
@ -95,6 +99,7 @@ module.exports = function (Terminal){
var param, row, j, ch;
param = params[0];
if (param < 1) param = 1;
row = this.y + this.ybase;

View File

@ -9,8 +9,11 @@ module.exports = function (Terminal){
// [column] (default = [row,1]) (HPA).
Terminal.prototype.charPosAbsolute = function (params){
var param = params[0];
if (param < 1) param = 1;
this.x = param - 1;
if (this.x >= this.cols) {
this.x = this.cols - 1;
}
@ -21,8 +24,11 @@ module.exports = function (Terminal){
// reuse CSI Ps C ?
Terminal.prototype.HPositionRelative = function (params){
var param = params[0];
if (param < 1) param = 1;
this.x += param;
if (this.x >= this.cols) {
this.x = this.cols - 1;
}
@ -32,8 +38,11 @@ module.exports = function (Terminal){
// Line Position Absolute [row] (default = [1,column]) (VPA).
Terminal.prototype.linePosAbsolute = function (params){
var param = params[0];
if (param < 1) param = 1;
this.y = param - 1;
if (this.y >= this.rows) {
this.y = this.rows - 1;
}
@ -43,8 +52,11 @@ module.exports = function (Terminal){
// reuse CSI Ps B ?
Terminal.prototype.VPositionRelative = function (params){
var param = params[0];
if (param < 1) param = 1;
this.y += param;
if (this.y >= this.rows) {
this.y = this.rows - 1;
}
@ -55,14 +67,17 @@ module.exports = function (Terminal){
// [1,1]) (HVP).
Terminal.prototype.HVPosition = function (params){
if (params[0] < 1) params[0] = 1;
if (params[1] < 1) params[1] = 1;
this.y = params[0] - 1;
if (this.y >= this.rows) {
this.y = this.rows - 1;
}
this.x = params[1] - 1;
if (this.x >= this.cols) {
this.x = this.cols - 1;
}

View File

@ -7,9 +7,9 @@
module.exports = function (Terminal){
// CSI Ps b Repeat the preceding graphic character Ps times (REP).
Terminal.prototype.repeatPrecedingCharacter = function (params){
var param = params[0] || 1,
line = this.lines[this.ybase + this.y],
ch = line[this.x - 1] || [this.defAttr, ' '];
var param = params[0] || 1;
var line = this.lines[this.ybase + this.y];
var ch = line[this.x - 1] || [this.defAttr, ' '];
while (param--) line[this.x++] = ch;
};

View File

@ -7,7 +7,7 @@
module.exports = function (Terminal){
// CSI ! p Soft terminal reset (DECSTR).
// http://vt100.net/docs/vt220-rm/table4-10.html
Terminal.prototype.softReset = function (params){
Terminal.prototype.softReset = function (){
this.cursorHidden = false;
this.insertMode = false;
this.originMode = false;

View File

@ -13,6 +13,7 @@ module.exports = function (Terminal){
// http://vt100.net/annarbor/aaa-ug/section6.html
Terminal.prototype.tabClear = function (params){
var param = params[0];
if (param <= 0) {
delete this.tabs[this.x];
} else if (param === 3) {

View File

@ -7,6 +7,7 @@
module.exports = function (Terminal){
Terminal.prototype.cursorBlink = function (){
if (Terminal.focus !== this) return;
this.cursorState ^= 1;
this.refresh(this.y, this.y);
};
@ -15,24 +16,26 @@ module.exports = function (Terminal){
if (!this.cursorState) {
this.cursorState = 1;
this.refresh(this.y, this.y);
} else {
// Temporarily disabled:
// this.refreshBlink();
}
};
Terminal.prototype.startBlink = function (){
if (!Terminal.cursorBlink) return;
var self = this;
this._blinker = function (){
self.cursorBlink();
};
this._blink = setInterval(this._blinker, 500);
};
Terminal.prototype.refreshBlink = function (){
if (!Terminal.cursorBlink) return;
clearInterval(this._blink);
this._blink = setInterval(this._blinker, 500);
};
};

View File

@ -7,15 +7,21 @@
module.exports = function (Terminal){
Terminal.prototype.log = function (){
if (!Terminal.debug) return;
if (!window.console || !window.console.log) return;
var args = Array.prototype.slice.call(arguments);
window.console.log.apply(window.console, args);
};
Terminal.prototype.error = function (){
if (!Terminal.debug) return;
if (!window.console || !window.console.error) return;
var args = Array.prototype.slice.call(arguments);
window.console.error.apply(window.console, args);
};
};

View File

@ -6,8 +6,8 @@
module.exports = function (Terminal){
Terminal.prototype.eraseRight = function (x, y){
var line = this.lines[this.ybase + y],
ch = [this.curAttr, ' ']; // xterm
var line = this.lines[this.ybase + y];
var ch = [this.curAttr, ' ']; // xterm
for (; x < this.cols; x++) {
line[x] = ch;
@ -17,10 +17,11 @@ module.exports = function (Terminal){
};
Terminal.prototype.eraseLeft = function (x, y){
var line = this.lines[this.ybase + y],
ch = [this.curAttr, ' ']; // xterm
var line = this.lines[this.ybase + y];
var ch = [this.curAttr, ' ']; // xterm
x++;
while (x--) line[x] = ch;
this.updateRange(y);
@ -42,27 +43,33 @@ module.exports = function (Terminal){
// Ps = 2 -> Selective Erase All.
Terminal.prototype.eraseInDisplay = function (params){
var j;
switch (params[0]) {
case 0:
this.eraseRight(this.x, this.y);
j = this.y + 1;
for (; j < this.rows; j++) {
this.eraseLine(j);
}
break;
case 1:
this.eraseLeft(this.x, this.y);
j = this.y;
while (j--) {
this.eraseLine(j);
}
break;
case 2:
j = this.rows;
while (j--) this.eraseLine(j);
break;
case 3:
; // no saved lines
// no saved lines
break;
}
};

View File

@ -3,35 +3,43 @@
*/
'use strict';
var states = require('../states');
module.exports = function (Terminal){
// ESC D Index (IND is 0x84).
Terminal.prototype.index = function (){
this.y++;
if (this.y > this.scrollBottom) {
this.y--;
this.scroll();
}
this.state = states.normal;
};
// ESC M Reverse Index (RI is 0x8d).
Terminal.prototype.reverseIndex = function (){
var j;
this.y--;
if (this.y < this.scrollTop) {
this.y++;
// possibly move the code below to term.reverseScroll();
// test: echo -ne '\e[1;1H\e[44m\eM\e[0m'
// blankLine(true) is xterm/linux behavior
this.lines.splice(this.y + this.ybase, 0, this.blankLine(true));
j = this.rows - 1 - this.scrollBottom;
this.lines.splice(this.rows - 1 + this.ybase - j + 1, 1);
// this.maxRange();
this.updateRange(this.scrollTop);
this.updateRange(this.scrollBottom);
}
this.state = states.normal;
};
};

View File

@ -5,7 +5,6 @@
'use strict';
module.exports = function (Terminal){
// ESC c Full Reset (RIS).
Terminal.prototype.reset = function (){
Terminal.call(this, this.cols, this.rows);

View File

@ -6,7 +6,6 @@
var states = require('../states');
module.exports = function (Terminal){
// ESC H Tab Set (HTS is 0x88).
Terminal.prototype.tabSet = function (){
this.tabs[this.x] = true;

View File

@ -8,12 +8,19 @@
// use it in the terminal.
function isBoldBroken(){
var el = document.createElement('span');
el.innerHTML = 'hello world';
document.body.appendChild(el);
var w1 = el.scrollWidth;
el.style.fontWeight = 'bold';
var w2 = el.scrollWidth;
document.body.removeChild(el);
return w1 !== w2;
}
@ -21,11 +28,9 @@ module.exports = function (Terminal){
/**
* Open Terminal
*/
Terminal.prototype.open = function (){
var self = this,
i = 0,
div;
var i = 0;
var div;
this.element = document.createElement('div');
this.element.className = 'terminal';
@ -33,6 +38,7 @@ module.exports = function (Terminal){
for (; i < this.rows; i++) {
div = document.createElement('div');
this.element.appendChild(div);
this.children.push(div);
}

View File

@ -7,7 +7,9 @@
function addRowsOnDemand(){
while (this.y >= this.rows) {
this.lines.push(this.blankLine());
var div = document.createElement('div');
this.element.appendChild(div);
this.children.push(div);
@ -18,7 +20,9 @@ function addRowsOnDemand(){
module.exports = function (Terminal){
Terminal.prototype.updateRange = function (y){
if (y < this.refreshStart) this.refreshStart = y;
if (y > this.refreshEnd) this.refreshEnd = y;
addRowsOnDemand.bind(this)();
};

View File

@ -5,7 +5,6 @@
'use strict';
module.exports = function (Terminal){
/**
* Rendering Engine
*/
@ -19,7 +18,6 @@ module.exports = function (Terminal){
// Next 9 bits: foreground color (0-511).
// Next 14 bits: a mask for misc. flags:
// 1=bold, 2=underline, 4=inverse
Terminal.prototype.refresh = function (start, end){
var x, y, i, line, out, ch, width, data, attr, fgColor, bgColor, flags, row, parent;
@ -28,8 +26,8 @@ module.exports = function (Terminal){
for (; y <= end; y++) {
row = y + this.ydisp;
line = this.lines[row];
if (!line) {
// simple solution in case we have more lines than rows
// could be improved to instead remove first line (and related html element)
@ -57,6 +55,7 @@ module.exports = function (Terminal){
if (attr !== this.defAttr) {
out += '</span>';
}
if (data !== this.defAttr) {
if (data === -1) {
out += '<span class="reverse-video">';
@ -71,6 +70,7 @@ module.exports = function (Terminal){
if (!Terminal.brokenBold) {
out += 'font-weight:bold;';
}
// see: XTerm*boldColors
if (fgColor < 8) fgColor += 8;
}

View File

@ -7,6 +7,7 @@
module.exports = function (Terminal){
Terminal.prototype.setgCharset = function (g, charset){
this.charsets[g] = charset;
if (this.glevel === g) {
this.charset = charset;
}

View File

@ -5,11 +5,11 @@
'use strict';
module.exports = {
normal: 0
, escaped: 1
, csi: 2
, osc: 3
, charset: 4
, dcs: 5
, ignore: 6
normal: 0,
escaped: 1,
csi: 2,
osc: 3,
charset: 4,
dcs: 5,
ignore: 6
};

View File

@ -6,7 +6,6 @@
// ignore warnings regarging == and != (coersion makes things work here appearently)
module.exports = function (Terminal){
Terminal.prototype.setupStops = function (i){
if (i != null) {
if (!this.tabs[i]) {
@ -24,13 +23,17 @@ module.exports = function (Terminal){
Terminal.prototype.prevStop = function (x){
if (x == null) x = this.x;
while (!this.tabs[--x] && x > 0);
while (!this.tabs[--x] && x > 0) {}
return x >= this.cols ? this.cols - 1 : x < 0 ? 0 : x;
};
Terminal.prototype.nextStop = function (x){
if (x == null) x = this.x;
while (!this.tabs[++x] && x < this.cols);
while (!this.tabs[++x] && x < this.cols) {}
return x >= this.cols ? this.cols - 1 : x < 0 ? 0 : x;
};
};

View File

@ -11,7 +11,7 @@ module.exports = function (Terminal){
Terminal.prototype.is = function (term){
var name = this.termName || Terminal.termName;
return (name + '')
.indexOf(term) === 0;
return (name + '').indexOf(term) === 0;
};
};

View File

@ -19,41 +19,47 @@ function fixIndent(data){
.split('\n')
.map(function (line){
var count = 0;
while (line.charAt(0) === ' ') {
line = line.slice(1);
count++;
}
while (count--) {
line = '&nbsp;' + line;
}
return line;
})
.join('\r\n');
}
module.exports = function (Terminal){
Terminal.prototype.bell = function (){
var snd = new Audio("bell.wav"); // buffers automatically when created
snd.play();
if (!Terminal.visualBell) return;
var self = this;
this.element.style.borderColor = 'white';
setTimeout(function (){
self.element.style.borderColor = '';
}, 10);
if (Terminal.popOnBell) this.focus();
};
Terminal.prototype.write = function (data){
data = fixLinefeed(data);
data = fixIndent(data);
var l = data.length,
i = 0,
cs, ch;
var l = data.length;
var i = 0;
var cs, ch;
this.refreshStart = this.y;
this.refreshEnd = this.y;
@ -63,22 +69,16 @@ module.exports = function (Terminal){
this.maxRange();
}
// this.log(JSON.stringify(data.replace(/\x1b/g, '^[')));
for (; i < l; i++) {
ch = data[i];
switch (this.state) {
case states.normal:
switch (ch) {
// '\0'
// case '\0':
// break;
// '\a'
case '\x07':
this.bell();
break;
// '\n', '\v', '\f'
case '\n':
case '\x0b':
@ -86,47 +86,42 @@ module.exports = function (Terminal){
if (this.convertEol) {
this.x = 0;
}
this.y++;
break;
// '\r'
case '\r':
this.x = 0;
break;
// '\b'
case '\x08':
if (this.x > 0) {
this.x--;
}
break;
// '\t'
case '\t':
this.x = this.nextStop();
break;
// shift out
case '\x0e':
this.setgLevel(1);
break;
// shift in
case '\x0f':
this.setgLevel(0);
break;
// '\e'
case '\x1b':
this.state = states.escaped;
break;
default:
// ' '
if (ch >= ' ') {
if (this.charset && this.charset[ch]) {
ch = this.charset[ch];
}
if (this.x >= this.cols) {
this.x = 0;
this.y++;
@ -150,38 +145,32 @@ module.exports = function (Terminal){
this.currentParam = 0;
this.state = states.csi;
break;
// ESC ] Operating System Command ( OSC is 0x9d).
case ']':
this.params = [];
this.currentParam = 0;
this.state = states.osc;
break;
// ESC P Device Control String ( DCS is 0x90).
case 'P':
this.params = [];
this.currentParam = 0;
this.state = states.dcs;
break;
// ESC _ Application Program Command ( APC is 0x9f).
case '_':
this.stateType = 'apc';
this.state = states.ignore;
break;
// ESC ^ Privacy Message ( PM is 0x9e).
case '^':
this.stateType = 'pm';
this.state = states.ignore;
break;
// ESC c Full Reset (RIS).
case 'c':
this.reset();
break;
// ESC E Next Line ( NEL is 0x85).
// ESC D Index ( IND is 0x84).
case 'E':
@ -190,22 +179,20 @@ module.exports = function (Terminal){
case 'D':
this.index();
break;
// ESC M Reverse Index ( RI is 0x8d).
case 'M':
this.reverseIndex();
break;
// ESC % Select default/utf-8 character set.
// @ = default, G = utf-8
case '%':
//this.charset = null;
this.setgLevel(0);
this.setgCharset(0, Terminal.charsets.US);
this.state = states.normal;
i++;
break;
// ESC (,),*,+,-,. Designate G0-G2 Character Set.
case '(':
// <-- this seems to get all the attention
@ -236,7 +223,6 @@ module.exports = function (Terminal){
}
this.state = states.charset;
break;
// Designate G3 Character Set (VT300).
// A = ISO Latin-1 Supplemental.
// Not implemented.
@ -245,7 +231,6 @@ module.exports = function (Terminal){
this.state = states.charset;
i--;
break;
// ESC N
// Single Shift Select of G2 Character Set
// ( SS2 is 0x8e). This affects next character only.
@ -281,51 +266,43 @@ module.exports = function (Terminal){
case '~':
this.setgLevel(1);
break;
// ESC 7 Save Cursor (DECSC).
case '7':
this.saveCursor();
this.state = states.normal;
break;
// ESC 8 Restore Cursor (DECRC).
case '8':
this.restoreCursor();
this.state = states.normal;
break;
// ESC # 3 DEC line height/width
case '#':
this.state = states.normal;
i++;
break;
// ESC H Tab Set (HTS is 0x88).
case 'H':
this.tabSet();
break;
// ESC = Application Keypad (DECPAM).
case '=':
this.log('Serial port requested application keypad.');
this.applicationKeypad = true;
this.state = states.normal;
break;
// ESC > Normal Keypad (DECPNM).
case '>':
this.log('Switching back to normal keypad.');
this.applicationKeypad = false;
this.state = states.normal;
break;
default:
this.state = states.normal;
this.error('Unknown ESC control: %s.', ch);
break;
}
break;
case states.charset:
switch (ch) {
case '0':
@ -393,11 +370,12 @@ module.exports = function (Terminal){
cs = Terminal.charsets.US;
break;
}
this.setgCharset(this.gcharset, cs);
this.gcharset = null;
this.state = states.normal;
break;
case states.osc:
// OSC Ps ; Pt ST
// OSC Ps ; Pt BEL
@ -418,7 +396,6 @@ module.exports = function (Terminal){
if (this.handleTitle) {
this.handleTitle(this.title);
}
}
break;
case 3:
@ -483,7 +460,6 @@ module.exports = function (Terminal){
}
}
break;
case states.csi:
// '?', '>', '!'
if (ch === '?' || ch === '>' || ch === '!') {
@ -517,51 +493,42 @@ module.exports = function (Terminal){
case 'A':
this.cursorUp(this.params);
break;
// CSI Ps B
// Cursor Down Ps Times (default = 1) (CUD).
case 'B':
this.cursorDown(this.params);
break;
// CSI Ps C
// Cursor Forward Ps Times (default = 1) (CUF).
case 'C':
this.cursorForward(this.params);
break;
// CSI Ps D
// Cursor Backward Ps Times (default = 1) (CUB).
case 'D':
this.cursorBackward(this.params);
break;
// CSI Ps ; Ps H
// Cursor Position [row;column] (default = [1,1]) (CUP).
case 'H':
this.cursorPos(this.params);
break;
// CSI Ps J Erase in Display (ED).
case 'J':
this.eraseInDisplay(this.params);
break;
// CSI Ps K Erase in Line (EL).
case 'K':
this.eraseInLine(this.params);
break;
// CSI Pm m Character Attributes (SGR).
case 'm':
this.charAttributes(this.params);
break;
// CSI Ps n Device Status Report (DSR).
case 'n':
this.deviceStatus(this.params);
break;
/**
* Additions
*/
@ -571,61 +538,51 @@ module.exports = function (Terminal){
case '@':
this.insertChars(this.params);
break;
// CSI Ps E
// Cursor Next Line Ps Times (default = 1) (CNL).
case 'E':
this.cursorNextLine(this.params);
break;
// CSI Ps F
// Cursor Preceding Line Ps Times (default = 1) (CNL).
case 'F':
this.cursorPrecedingLine(this.params);
break;
// CSI Ps G
// Cursor Character Absolute [column] (default = [row,1]) (CHA).
case 'G':
this.cursorCharAbsolute(this.params);
break;
// CSI Ps L
// Insert Ps Line(s) (default = 1) (IL).
case 'L':
this.insertLines(this.params);
break;
// CSI Ps M
// Delete Ps Line(s) (default = 1) (DL).
case 'M':
this.deleteLines(this.params);
break;
// CSI Ps P
// Delete Ps Character(s) (default = 1) (DCH).
case 'P':
this.deleteChars(this.params);
break;
// CSI Ps X
// Erase Ps Character(s) (default = 1) (ECH).
case 'X':
this.eraseChars(this.params);
break;
// CSI Pm ` Character Position Absolute
// [column] (default = [row,1]) (HPA).
case '`':
this.charPosAbsolute(this.params);
break;
// 141 61 a * HPR -
// Horizontal Position Relative
case 'a':
this.HPositionRelative(this.params);
break;
// CSI P s c
// Send Device Attributes (Primary DA).
// CSI > P s c
@ -633,37 +590,31 @@ module.exports = function (Terminal){
case 'c':
//- this.sendDeviceAttributes(this.params);
break;
// CSI Pm d
// Line Position Absolute [row] (default = [1,column]) (VPA).
case 'd':
this.linePosAbsolute(this.params);
break;
// 145 65 e * VPR - Vertical Position Relative
case 'e':
this.VPositionRelative(this.params);
break;
// CSI Ps ; Ps f
// Horizontal and Vertical Position [row;column] (default =
// [1,1]) (HVP).
case 'f':
this.HVPosition(this.params);
break;
// CSI Pm h Set Mode (SM).
// CSI ? Pm h - mouse escape codes, cursor escape codes
case 'h':
//- this.setMode(this.params);
break;
// CSI Pm l Reset Mode (RM).
// CSI ? Pm l
case 'l':
//- this.resetMode(this.params);
break;
// CSI Ps ; Ps r
// Set Scrolling Region [top;bottom] (default = full size of win-
// dow) (DECSTBM).
@ -671,19 +622,16 @@ module.exports = function (Terminal){
case 'r':
//- this.setScrollRegion(this.params);
break;
// CSI s
// Save cursor (ANSI.SYS).
case 's':
this.saveCursor(this.params);
break;
// CSI u
// Restore cursor (ANSI.SYS).
case 'u':
this.restoreCursor(this.params);
break;
/**
* Lesser Used
*/
@ -693,12 +641,10 @@ module.exports = function (Terminal){
case 'I':
this.cursorForwardTab(this.params);
break;
// CSI Ps S Scroll up Ps lines (default = 1) (SU).
case 'S':
//- this.scrollUp(this.params);
break;
// CSI Ps T Scroll down Ps lines (default = 1) (SD).
// CSI Ps ; Ps ; Ps ; Ps ; Ps T
// CSI > Ps; Ps T
@ -707,18 +653,15 @@ module.exports = function (Terminal){
//- this.scrollDown(this.params);
}
break;
// CSI Ps Z
// Cursor Backward Tabulation Ps tab stops (default = 1) (CBT).
case 'Z':
this.cursorBackwardTab(this.params);
break;
// CSI Ps b Repeat the preceding graphic character Ps times (REP).
case 'b':
this.repeatPrecedingCharacter(this.params);
break;
// CSI Ps g Tab Clear (TBC).
case 'g':
this.tabClear(this.params);
@ -730,7 +673,6 @@ module.exports = function (Terminal){
break;
}
break;
default:
this.error('Unknown CSI code: %s.', ch);
break;
@ -739,7 +681,6 @@ module.exports = function (Terminal){
this.prefix = '';
this.postfix = '';
break;
case states.dcs:
if (ch === '\x1b' || ch === '\x07') {
if (ch === '\x1b') i++;
@ -748,47 +689,37 @@ module.exports = function (Terminal){
// User-Defined Keys (DECUDK).
case '':
break;
// Request Status String (DECRQSS).
// test: echo -e '\eP$q"p\e\\'
case '$q':
var pt = this.currentParam,
valid = false;
switch (pt) {
// DECSCA
case '"q':
pt = '0"q';
break;
// DECSCL
case '"p':
pt = '61"p';
break;
// DECSTBM
case 'r':
pt = '' + (this.scrollTop + 1) + ';' + (this.scrollBottom + 1) + 'r';
break;
// SGR
case 'm':
pt = '0m';
break;
default:
this.error('Unknown DCS Pt: %s.', pt);
pt = '';
break;
}
//- this.send('\x1bP' + valid + '$r' + pt + '\x1b\\');
break;
// Set Termcap/Terminfo Data (xterm, experimental).
case '+p':
break;
default:
this.error('Unknown DCS prefix: %s.', this.prefix);
break;
@ -809,7 +740,6 @@ module.exports = function (Terminal){
this.currentParam += ch;
}
break;
case states.ignore:
// For PM and APC.
if (ch === '\x1b' || ch === '\x07') {
@ -831,6 +761,7 @@ module.exports = function (Terminal){
Terminal.prototype.writeln = function (data){
// at times spaces appear in between escape chars and fixIndent fails us, so we fix it here
data = data.replace(/ /g, '&nbsp;');
// adding empty char before line break ensures that empty lines render properly
this.write(data + ' \r\n');
};