mirror of
https://github.com/nuintun/command-manager.git
synced 2025-06-07 03:14:07 +08:00
update files
This commit is contained in:
parent
93b8d9342b
commit
8d2af4a433
@ -180,6 +180,7 @@ require('./lib/esc/tabSet.js')(Terminal);
|
||||
|
||||
require('./lib/charsets.js')(Terminal);
|
||||
require('./lib/csi/charAttributes')(Terminal);
|
||||
require('./lib/csi/erase')(Terminal);
|
||||
require('./lib/csi/insert-delete')(Terminal);
|
||||
require('./lib/csi/position')(Terminal);
|
||||
require('./lib/csi/cursor')(Terminal);
|
||||
|
73
static/js/terminal/lib/csi/erase.js
Normal file
73
static/js/terminal/lib/csi/erase.js
Normal file
@ -0,0 +1,73 @@
|
||||
/**
|
||||
* Created by nuintun on 2015/11/24.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = function (Terminal){
|
||||
// CSI Ps J Erase in Display (ED).
|
||||
// Ps = 0 -> Erase Below (default).
|
||||
// Ps = 1 -> Erase Above.
|
||||
// Ps = 2 -> Erase All.
|
||||
// Ps = 3 -> Erase Saved Lines (xterm).
|
||||
// CSI ? Ps J
|
||||
// Erase in Display (DECSED).
|
||||
// Ps = 0 -> Selective Erase Below (default).
|
||||
// Ps = 1 -> Selective Erase Above.
|
||||
// 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
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
// CSI Ps K Erase in Line (EL).
|
||||
// Ps = 0 -> Erase to Right (default).
|
||||
// Ps = 1 -> Erase to Left.
|
||||
// Ps = 2 -> Erase All.
|
||||
// CSI ? Ps K
|
||||
// Erase in Line (DECSEL).
|
||||
// Ps = 0 -> Selective Erase to Right (default).
|
||||
// Ps = 1 -> Selective Erase to Left.
|
||||
// Ps = 2 -> Selective Erase All.
|
||||
Terminal.prototype.eraseInLine = function (params){
|
||||
switch (params[0]) {
|
||||
case 0:
|
||||
this.eraseRight(this.x, this.y);
|
||||
break;
|
||||
case 1:
|
||||
this.eraseLeft(this.x, this.y);
|
||||
break;
|
||||
case 2:
|
||||
this.eraseLine(this.y);
|
||||
break;
|
||||
}
|
||||
};
|
||||
};
|
@ -5,6 +5,9 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (Terminal){
|
||||
/**
|
||||
* log
|
||||
*/
|
||||
Terminal.prototype.log = function (){
|
||||
if (!this.debug) return;
|
||||
|
||||
@ -15,6 +18,9 @@ module.exports = function (Terminal){
|
||||
window.console.log.apply(window.console, args);
|
||||
};
|
||||
|
||||
/**
|
||||
* error
|
||||
*/
|
||||
Terminal.prototype.error = function (){
|
||||
if (!this.debug) return;
|
||||
|
||||
|
@ -5,10 +5,19 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (Terminal){
|
||||
/**
|
||||
* eraseAttr
|
||||
* @returns {number}
|
||||
*/
|
||||
Terminal.prototype.eraseAttr = function (){
|
||||
return (this.defAttr & ~0x1ff) | (this.curAttr & 0x1ff);
|
||||
};
|
||||
|
||||
/**
|
||||
* eraseRight
|
||||
* @param x
|
||||
* @param y
|
||||
*/
|
||||
Terminal.prototype.eraseRight = function (x, y){
|
||||
var line = this.lines[this.ybase + y];
|
||||
var ch = [this.eraseAttr(), ' '];
|
||||
@ -20,6 +29,11 @@ module.exports = function (Terminal){
|
||||
this.updateRange(y);
|
||||
};
|
||||
|
||||
/**
|
||||
* eraseLeft
|
||||
* @param x
|
||||
* @param y
|
||||
*/
|
||||
Terminal.prototype.eraseLeft = function (x, y){
|
||||
var line = this.lines[this.ybase + y];
|
||||
var ch = [this.eraseAttr(), ' '];
|
||||
@ -31,73 +45,11 @@ module.exports = function (Terminal){
|
||||
this.updateRange(y);
|
||||
};
|
||||
|
||||
/**
|
||||
* eraseLine
|
||||
* @param y
|
||||
*/
|
||||
Terminal.prototype.eraseLine = function (y){
|
||||
this.eraseRight(0, y);
|
||||
};
|
||||
|
||||
// CSI Ps J Erase in Display (ED).
|
||||
// Ps = 0 -> Erase Below (default).
|
||||
// Ps = 1 -> Erase Above.
|
||||
// Ps = 2 -> Erase All.
|
||||
// Ps = 3 -> Erase Saved Lines (xterm).
|
||||
// CSI ? Ps J
|
||||
// Erase in Display (DECSED).
|
||||
// Ps = 0 -> Selective Erase Below (default).
|
||||
// Ps = 1 -> Selective Erase Above.
|
||||
// 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
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
// CSI Ps K Erase in Line (EL).
|
||||
// Ps = 0 -> Erase to Right (default).
|
||||
// Ps = 1 -> Erase to Left.
|
||||
// Ps = 2 -> Erase All.
|
||||
// CSI ? Ps K
|
||||
// Erase in Line (DECSEL).
|
||||
// Ps = 0 -> Selective Erase to Right (default).
|
||||
// Ps = 1 -> Selective Erase to Left.
|
||||
// Ps = 2 -> Selective Erase All.
|
||||
Terminal.prototype.eraseInLine = function (params){
|
||||
switch (params[0]) {
|
||||
case 0:
|
||||
this.eraseRight(this.x, this.y);
|
||||
break;
|
||||
case 1:
|
||||
this.eraseLeft(this.x, this.y);
|
||||
break;
|
||||
case 2:
|
||||
this.eraseLine(this.y);
|
||||
break;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -7,6 +7,9 @@
|
||||
module.exports = function (Terminal){
|
||||
Terminal.focus = null;
|
||||
|
||||
/**
|
||||
* focus
|
||||
*/
|
||||
Terminal.prototype.focus = function (){
|
||||
if (Terminal.focus === this) return;
|
||||
|
||||
@ -25,6 +28,9 @@ module.exports = function (Terminal){
|
||||
Terminal.focus = this;
|
||||
};
|
||||
|
||||
/**
|
||||
* blur
|
||||
*/
|
||||
Terminal.prototype.blur = function (){
|
||||
if (Terminal.focus !== this) return;
|
||||
|
||||
|
@ -26,7 +26,7 @@ function isBoldBroken(){
|
||||
|
||||
module.exports = function (Terminal){
|
||||
/**
|
||||
* Open Terminal
|
||||
* open
|
||||
*/
|
||||
Terminal.prototype.open = function (){
|
||||
var div;
|
||||
|
@ -5,12 +5,19 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (Terminal){
|
||||
/**
|
||||
* updateRange
|
||||
* @param y
|
||||
*/
|
||||
Terminal.prototype.updateRange = function (y){
|
||||
if (y < this.refreshStart) this.refreshStart = y;
|
||||
|
||||
if (y > this.refreshEnd) this.refreshEnd = y;
|
||||
};
|
||||
|
||||
/**
|
||||
* maxRange
|
||||
*/
|
||||
Terminal.prototype.maxRange = function (){
|
||||
this.refreshStart = 0;
|
||||
this.refreshEnd = this.rows - 1;
|
||||
|
@ -5,10 +5,7 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (Terminal){
|
||||
/**
|
||||
* Rendering Engine
|
||||
*/
|
||||
|
||||
// Rendering Engine
|
||||
// In the screen buffer, each character
|
||||
// is stored as a an array with a character
|
||||
// and a 32-bit integer.
|
||||
@ -18,6 +15,12 @@ module.exports = function (Terminal){
|
||||
// Next 9 bits: foreground color (0-511).
|
||||
// Next 14 bits: a mask for misc.
|
||||
// flags: 1=bold, 2=underline, 4=blink, 8=inverse, 16=invisible
|
||||
|
||||
/**
|
||||
* refresh
|
||||
* @param start
|
||||
* @param end
|
||||
*/
|
||||
Terminal.prototype.refresh = function (start, end){
|
||||
var parent = this.element.parentNode;
|
||||
var x, y, i, line, out, ch, width, data, attr, fgColor, bgColor, flags, row;
|
||||
|
@ -5,6 +5,11 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (Terminal){
|
||||
/**
|
||||
* resize
|
||||
* @param x
|
||||
* @param y
|
||||
*/
|
||||
Terminal.prototype.resize = function (x, y){
|
||||
var line, element, i, j, ch;
|
||||
|
||||
|
@ -5,6 +5,9 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (Terminal){
|
||||
/**
|
||||
* scroll
|
||||
*/
|
||||
Terminal.prototype.scroll = function (){
|
||||
var row;
|
||||
|
||||
@ -45,6 +48,10 @@ module.exports = function (Terminal){
|
||||
this.updateRange(this.scrollBottom);
|
||||
};
|
||||
|
||||
/**
|
||||
* scrollDisp
|
||||
* @param disp
|
||||
*/
|
||||
Terminal.prototype.scrollDisp = function (disp){
|
||||
this.ydisp += disp;
|
||||
|
||||
|
@ -5,6 +5,11 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (Terminal){
|
||||
/**
|
||||
* setgCharset
|
||||
* @param g
|
||||
* @param charset
|
||||
*/
|
||||
Terminal.prototype.setgCharset = function (g, charset){
|
||||
this.charsets[g] = charset;
|
||||
|
||||
|
@ -5,6 +5,10 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (Terminal){
|
||||
/**
|
||||
* setgLevel
|
||||
* @param g
|
||||
*/
|
||||
Terminal.prototype.setgLevel = function (g){
|
||||
this.glevel = g;
|
||||
this.charset = this.charsets[g];
|
||||
|
@ -5,6 +5,11 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (Terminal){
|
||||
/**
|
||||
* isWide
|
||||
* @param ch
|
||||
* @returns {boolean}
|
||||
*/
|
||||
Terminal.prototype.isWide = function isWide(ch){
|
||||
if (ch <= '\uff00') return false;
|
||||
|
||||
@ -17,10 +22,20 @@ module.exports = function (Terminal){
|
||||
|| (ch >= '\uffe8' && ch <= '\uffee');
|
||||
};
|
||||
|
||||
/**
|
||||
* ch
|
||||
* @param cur
|
||||
* @returns {string[]}
|
||||
*/
|
||||
Terminal.prototype.ch = function (cur){
|
||||
return cur ? [this.eraseAttr(), ' '] : [this.defAttr, ' '];
|
||||
};
|
||||
|
||||
/**
|
||||
* is
|
||||
* @param term
|
||||
* @returns {boolean}
|
||||
*/
|
||||
Terminal.prototype.is = function (term){
|
||||
var name = this.termName;
|
||||
|
||||
|
@ -7,6 +7,10 @@
|
||||
var states = require('./states');
|
||||
|
||||
module.exports = function (Terminal){
|
||||
/**
|
||||
* send
|
||||
* @param data
|
||||
*/
|
||||
Terminal.prototype.send = function (data){
|
||||
var context = this;
|
||||
|
||||
@ -21,8 +25,12 @@ module.exports = function (Terminal){
|
||||
this.queue += data;
|
||||
};
|
||||
|
||||
/**
|
||||
* bell
|
||||
*/
|
||||
Terminal.prototype.bell = function (){
|
||||
var snd = new Audio('bell.wav'); // buffers automatically when created
|
||||
// buffers automatically when created
|
||||
var snd = new Audio('bell.wav');
|
||||
|
||||
snd.play();
|
||||
|
||||
@ -39,6 +47,10 @@ module.exports = function (Terminal){
|
||||
if (this.popOnBell) this.focus();
|
||||
};
|
||||
|
||||
/**
|
||||
* write
|
||||
* @param data
|
||||
*/
|
||||
Terminal.prototype.write = function (data){
|
||||
var l = data.length;
|
||||
var i = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user