mirror of
https://github.com/nuintun/command-manager.git
synced 2025-06-08 04:04:04 +08:00
update files
This commit is contained in:
parent
d50a32f882
commit
d9d77434d6
@ -132,7 +132,7 @@ module.exports = Vue.component('app-main', {
|
|||||||
console.log(xterm);
|
console.log(xterm);
|
||||||
|
|
||||||
xterm.write(test);
|
xterm.write(test);
|
||||||
scroll(xtermNode);
|
//scroll(xtermNode);
|
||||||
|
|
||||||
window.xterm = xterm;
|
window.xterm = xterm;
|
||||||
|
|
||||||
@ -143,12 +143,8 @@ module.exports = Vue.component('app-main', {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
runtime.xterm.write(test);
|
runtime.xterm.write(test);
|
||||||
if (runtime.xterm.lines.length > 10) {
|
|
||||||
runtime.xterm.deleteLines([10]);
|
|
||||||
runtime.xterm.refresh(0, runtime.xterm.lines.length - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
scroll(xtermNode);
|
//scroll(xtermNode);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setting: function (){
|
setting: function (){
|
||||||
|
@ -112,5 +112,6 @@ require('./lib/csi/cursor')(Terminal);
|
|||||||
require('./lib/csi/repeatPrecedingCharacter')(Terminal);
|
require('./lib/csi/repeatPrecedingCharacter')(Terminal);
|
||||||
require('./lib/csi/tabClear')(Terminal);
|
require('./lib/csi/tabClear')(Terminal);
|
||||||
require('./lib/csi/softReset')(Terminal);
|
require('./lib/csi/softReset')(Terminal);
|
||||||
|
require('./lib/csi/scroll')(Terminal);
|
||||||
|
|
||||||
require('./lib/charsets.js')(Terminal);
|
require('./lib/charsets.js')(Terminal);
|
||||||
|
@ -74,6 +74,44 @@ module.exports = function (Terminal){
|
|||||||
this.updateRange(this.scrollBottom);
|
this.updateRange(this.scrollBottom);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// CSI P m SP }
|
||||||
|
// Insert P s Column(s) (default = 1) (DECIC), VT420 and up.
|
||||||
|
// NOTE: xterm doesn't enable this code by default.
|
||||||
|
Terminal.prototype.insertColumns = function (params){
|
||||||
|
var param = params[0];
|
||||||
|
var l = this.ybase + this.rows;
|
||||||
|
var ch = [this.eraseAttr(), ' ']; // xterm
|
||||||
|
var i;
|
||||||
|
|
||||||
|
while (param--) {
|
||||||
|
for (i = this.ybase; i < l; i++) {
|
||||||
|
this.lines[i].splice(this.x + 1, 0, ch);
|
||||||
|
this.lines[i].pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.maxRange();
|
||||||
|
};
|
||||||
|
|
||||||
|
// CSI P m SP ~
|
||||||
|
// Delete P s Column(s) (default = 1) (DECDC), VT420 and up
|
||||||
|
// NOTE: xterm doesn't enable this code by default.
|
||||||
|
Terminal.prototype.deleteColumns = function (params){
|
||||||
|
var param = params[0];
|
||||||
|
var l = this.ybase + this.rows;
|
||||||
|
var ch = [this.eraseAttr(), ' ']; // xterm
|
||||||
|
var i;
|
||||||
|
|
||||||
|
while (param--) {
|
||||||
|
for (i = this.ybase; i < l; i++) {
|
||||||
|
this.lines[i].splice(this.x, 1);
|
||||||
|
this.lines[i].push(ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.maxRange();
|
||||||
|
};
|
||||||
|
|
||||||
// CSI Ps P
|
// CSI Ps P
|
||||||
// Delete Ps Character(s) (default = 1) (DCH).
|
// Delete Ps Character(s) (default = 1) (DCH).
|
||||||
Terminal.prototype.deleteChars = function (params){
|
Terminal.prototype.deleteChars = function (params){
|
||||||
|
33
static/js/terminal/lib/csi/scroll.js
Normal file
33
static/js/terminal/lib/csi/scroll.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/**
|
||||||
|
* Created by nuintun on 2015/11/25.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = function (Terminal){
|
||||||
|
// CSI Ps S Scroll up Ps lines (default = 1) (SU).
|
||||||
|
Terminal.prototype.scrollUp = function (params){
|
||||||
|
var param = params[0] || 1;
|
||||||
|
|
||||||
|
while (param--) {
|
||||||
|
this.lines.splice(this.ybase + this.scrollTop, 1);
|
||||||
|
this.lines.splice(this.ybase + this.scrollBottom, 0, this.blankLine());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updateRange(this.scrollTop);
|
||||||
|
this.updateRange(this.scrollBottom);
|
||||||
|
};
|
||||||
|
|
||||||
|
// CSI Ps T Scroll down Ps lines (default = 1) (SD).
|
||||||
|
Terminal.prototype.scrollDown = function (params){
|
||||||
|
var param = params[0] || 1;
|
||||||
|
|
||||||
|
while (param--) {
|
||||||
|
this.lines.splice(this.ybase + this.scrollBottom, 1);
|
||||||
|
this.lines.splice(this.ybase + this.scrollTop, 0, this.blankLine());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updateRange(this.scrollTop);
|
||||||
|
this.updateRange(this.scrollBottom);
|
||||||
|
};
|
||||||
|
};
|
@ -5,6 +5,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = function (Terminal){
|
module.exports = function (Terminal){
|
||||||
|
Terminal.prototype.eraseAttr = function (){
|
||||||
|
return (this.defAttr & ~0x1ff) | (this.curAttr & 0x1ff);
|
||||||
|
};
|
||||||
|
|
||||||
Terminal.prototype.eraseRight = function (x, y){
|
Terminal.prototype.eraseRight = function (x, y){
|
||||||
var line = this.lines[this.ybase + y];
|
var line = this.lines[this.ybase + y];
|
||||||
var ch = [this.curAttr, ' ']; // xterm
|
var ch = [this.curAttr, ' ']; // xterm
|
||||||
|
@ -16,14 +16,23 @@ module.exports = function (Terminal){
|
|||||||
// Second value:
|
// Second value:
|
||||||
// Next 9 bits: background color (0-511).
|
// Next 9 bits: background color (0-511).
|
||||||
// Next 9 bits: foreground color (0-511).
|
// Next 9 bits: foreground color (0-511).
|
||||||
// Next 14 bits: a mask for misc. flags:
|
// Next 14 bits: a mask for misc.
|
||||||
// 1=bold, 2=underline, 4=inverse
|
// flags: 1=bold, 2=underline, 4=blink, 8=inverse, 16=invisible
|
||||||
Terminal.prototype.refresh = function (start, end){
|
Terminal.prototype.refresh = function (start, end){
|
||||||
var x, y, i, line, out, ch, width, data, attr, fgColor, bgColor, flags, row, parent;
|
var parent = this.element.parentNode;
|
||||||
|
var x, y, i, line, out, ch, width, data, attr, fgColor, bgColor, flags, row;
|
||||||
|
|
||||||
|
if (parent && end - start >= this.rows / 2) {
|
||||||
|
parent.removeChild(this.element);
|
||||||
|
}
|
||||||
|
|
||||||
width = this.cols;
|
width = this.cols;
|
||||||
y = start;
|
y = start;
|
||||||
|
|
||||||
|
if (end >= this.lines.length) {
|
||||||
|
end = this.lines.length - 1;
|
||||||
|
}
|
||||||
|
|
||||||
for (; y <= end; y++) {
|
for (; y <= end; y++) {
|
||||||
row = y + this.ydisp;
|
row = y + this.ydisp;
|
||||||
line = this.lines[row];
|
line = this.lines[row];
|
||||||
@ -65,7 +74,8 @@ module.exports = function (Terminal){
|
|||||||
fgColor = (data >> 9) & 0x1ff;
|
fgColor = (data >> 9) & 0x1ff;
|
||||||
flags = data >> 18;
|
flags = data >> 18;
|
||||||
|
|
||||||
if (flags & 1) {
|
// bold
|
||||||
|
if ((flags & 1)) {
|
||||||
if (!Terminal.brokenBold) {
|
if (!Terminal.brokenBold) {
|
||||||
out += 'font-weight:bold;';
|
out += 'font-weight:bold;';
|
||||||
}
|
}
|
||||||
@ -74,10 +84,35 @@ module.exports = function (Terminal){
|
|||||||
if (fgColor < 8) fgColor += 8;
|
if (fgColor < 8) fgColor += 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & 2) {
|
// underline
|
||||||
|
if ((flags & 2)) {
|
||||||
out += 'text-decoration:underline;';
|
out += 'text-decoration:underline;';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// blink
|
||||||
|
if ((flags & 4)) {
|
||||||
|
if ((flags & 2)) {
|
||||||
|
out = out.slice(0, -1);
|
||||||
|
out += ' blink;';
|
||||||
|
} else {
|
||||||
|
out += 'text-decoration:blink;';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// inverse
|
||||||
|
if ((flags & 8)) {
|
||||||
|
bgColor = (data >> 9) & 0x1ff;
|
||||||
|
fgColor = data & 0x1ff;
|
||||||
|
// Should inverse just be before the
|
||||||
|
// above boldColors effect instead?
|
||||||
|
if ((flags & 1) && fgColor < 8) fgColor += 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
// invisible
|
||||||
|
if ((flags & 16)) {
|
||||||
|
out += 'visibility:hidden;';
|
||||||
|
}
|
||||||
|
|
||||||
if (bgColor !== 256) {
|
if (bgColor !== 256) {
|
||||||
out += 'background-color:' + Terminal.colors[bgColor] + ';';
|
out += 'background-color:' + Terminal.colors[bgColor] + ';';
|
||||||
}
|
}
|
||||||
@ -105,6 +140,8 @@ module.exports = function (Terminal){
|
|||||||
if (ch <= ' ') {
|
if (ch <= ' ') {
|
||||||
out += ' ';
|
out += ' ';
|
||||||
} else {
|
} else {
|
||||||
|
if (this.isWide(ch)) i++;
|
||||||
|
|
||||||
out += ch;
|
out += ch;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -5,6 +5,46 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = function (Terminal){
|
module.exports = function (Terminal){
|
||||||
|
Terminal.prototype.scroll = function (){
|
||||||
|
var row;
|
||||||
|
|
||||||
|
if (++this.ybase === this.scrollback) {
|
||||||
|
this.ybase = this.ybase / 2 | 0;
|
||||||
|
this.lines = this.lines.slice(-(this.ybase + this.rows) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.ydisp = this.ybase;
|
||||||
|
|
||||||
|
// last line
|
||||||
|
row = this.ybase + this.rows - 1;
|
||||||
|
|
||||||
|
// subtract the bottom scroll region
|
||||||
|
row -= this.rows - 1 - this.scrollBottom;
|
||||||
|
|
||||||
|
if (row === this.lines.length) {
|
||||||
|
// potential optimization:
|
||||||
|
// pushing is faster than splicing
|
||||||
|
// when they amount to the same
|
||||||
|
// behavior.
|
||||||
|
this.lines.push(this.blankLine());
|
||||||
|
} else {
|
||||||
|
// add our new line
|
||||||
|
this.lines.splice(row, 0, this.blankLine());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.scrollTop !== 0) {
|
||||||
|
if (this.ybase !== 0) {
|
||||||
|
this.ybase--;
|
||||||
|
this.ydisp = this.ybase;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.lines.splice(this.ybase + this.scrollTop, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updateRange(this.scrollTop);
|
||||||
|
this.updateRange(this.scrollBottom);
|
||||||
|
};
|
||||||
|
|
||||||
Terminal.prototype.scrollDisp = function (disp){
|
Terminal.prototype.scrollDisp = function (disp){
|
||||||
this.ydisp += disp;
|
this.ydisp += disp;
|
||||||
|
|
||||||
|
@ -5,6 +5,18 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = function (Terminal){
|
module.exports = function (Terminal){
|
||||||
|
Terminal.prototype.isWide = function isWide(ch){
|
||||||
|
if (ch <= '\uff00') return false;
|
||||||
|
|
||||||
|
return (ch >= '\uff01' && ch <= '\uffbe')
|
||||||
|
|| (ch >= '\uffc2' && ch <= '\uffc7')
|
||||||
|
|| (ch >= '\uffca' && ch <= '\uffcf')
|
||||||
|
|| (ch >= '\uffd2' && ch <= '\uffd7')
|
||||||
|
|| (ch >= '\uffda' && ch <= '\uffdc')
|
||||||
|
|| (ch >= '\uffe0' && ch <= '\uffe6')
|
||||||
|
|| (ch >= '\uffe8' && ch <= '\uffee');
|
||||||
|
};
|
||||||
|
|
||||||
Terminal.prototype.ch = function (cur){
|
Terminal.prototype.ch = function (cur){
|
||||||
return cur ? [this.curAttr, ' '] : [this.defAttr, ' '];
|
return cur ? [this.curAttr, ' '] : [this.defAttr, ' '];
|
||||||
};
|
};
|
||||||
|
@ -87,7 +87,13 @@ module.exports = function (Terminal){
|
|||||||
this.x = 0;
|
this.x = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Implement eat_newline_glitch.
|
||||||
this.y++;
|
this.y++;
|
||||||
|
|
||||||
|
if (this.y > this.scrollBottom) {
|
||||||
|
this.y--;
|
||||||
|
this.scroll();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
// '\r'
|
// '\r'
|
||||||
case '\r':
|
case '\r':
|
||||||
@ -128,11 +134,25 @@ module.exports = function (Terminal){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: this prevents errors from being thrown, but needs a proper fix
|
// FIXME: this prevents errors from being thrown, but needs a proper fix
|
||||||
if (this.lines[this.y + this.ybase])
|
if (this.lines[this.y + this.ybase]) {
|
||||||
this.lines[this.y + this.ybase][this.x] = [this.curAttr, ch];
|
this.lines[this.y + this.ybase][this.x] = [this.curAttr, ch];
|
||||||
|
}
|
||||||
|
|
||||||
this.x++;
|
this.x++;
|
||||||
|
|
||||||
this.updateRange(this.y);
|
this.updateRange(this.y);
|
||||||
|
|
||||||
|
if (this.isWide(ch)) {
|
||||||
|
var j = this.y + this.ybase;
|
||||||
|
|
||||||
|
if (this.cols < 2 || this.x >= this.cols) {
|
||||||
|
this.lines[j][this.x - 1] = [this.curAttr, ' '];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.lines[j][this.x] = [this.curAttr, ' '];
|
||||||
|
this.x++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -453,6 +473,7 @@ module.exports = function (Terminal){
|
|||||||
this.currentParam = this.currentParam * 10 + ch.charCodeAt(0) - 48;
|
this.currentParam = this.currentParam * 10 + ch.charCodeAt(0) - 48;
|
||||||
} else if (ch === ';') {
|
} else if (ch === ';') {
|
||||||
this.params.push(this.currentParam);
|
this.params.push(this.currentParam);
|
||||||
|
|
||||||
this.currentParam = '';
|
this.currentParam = '';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -643,14 +664,14 @@ module.exports = function (Terminal){
|
|||||||
break;
|
break;
|
||||||
// CSI Ps S Scroll up Ps lines (default = 1) (SU).
|
// CSI Ps S Scroll up Ps lines (default = 1) (SU).
|
||||||
case 'S':
|
case 'S':
|
||||||
//- this.scrollUp(this.params);
|
this.scrollUp(this.params);
|
||||||
break;
|
break;
|
||||||
// CSI Ps T Scroll down Ps lines (default = 1) (SD).
|
// CSI Ps T Scroll down Ps lines (default = 1) (SD).
|
||||||
// CSI Ps ; Ps ; Ps ; Ps ; Ps T
|
// CSI Ps ; Ps ; Ps ; Ps ; Ps T
|
||||||
// CSI > Ps; Ps T
|
// CSI > Ps; Ps T
|
||||||
case 'T':
|
case 'T':
|
||||||
if (this.params.length < 2 && !this.prefix) {
|
if (this.params.length < 2 && !this.prefix) {
|
||||||
//- this.scrollDown(this.params);
|
this.scrollDown(this.params);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// CSI Ps Z
|
// CSI Ps Z
|
||||||
|
Loading…
x
Reference in New Issue
Block a user