mirror of
https://github.com/nuintun/command-manager.git
synced 2025-06-07 11:34:05 +08:00
update files
This commit is contained in:
parent
07eb2b8b48
commit
26c6e9635d
@ -53,36 +53,24 @@ function scroll(xterm, parent){
|
|||||||
* @param xtermNode
|
* @param xtermNode
|
||||||
*/
|
*/
|
||||||
function createXTerm(name, xtermNode){
|
function createXTerm(name, xtermNode){
|
||||||
var timer;
|
|
||||||
var runtime = window.AppRuntime[name];
|
var runtime = window.AppRuntime[name];
|
||||||
|
|
||||||
|
xtermNode.innerHTML = '';
|
||||||
|
|
||||||
if (runtime) {
|
if (runtime) {
|
||||||
runtime.xterm.focus();
|
runtime.xterm.focus();
|
||||||
|
xtermNode.appendChild(runtime.xterm.element);
|
||||||
} else {
|
} else {
|
||||||
var xterm = new Terminal({
|
var xterm = new Terminal({
|
||||||
rows: 66,
|
rows: 66,
|
||||||
scrollback: 66,
|
scrollback: 66,
|
||||||
convertEOL: true,
|
convertEOL: true,
|
||||||
fgColor: 'inherit',
|
fgColor: 'inherit',
|
||||||
bgColor: 'transparent',
|
bgColor: 'transparent'
|
||||||
onscreen: function (screen){
|
|
||||||
if (this.isFocused()) {
|
|
||||||
setImmediate(function (){
|
|
||||||
xtermNode.innerHTML = screen;
|
|
||||||
scroll(xterm, xtermNode);
|
|
||||||
});
|
|
||||||
//clearTimeout(timer);
|
|
||||||
|
|
||||||
//timer = setTimeout(function (){
|
|
||||||
// xtermNode.innerHTML = screen;
|
|
||||||
//}, 0);
|
|
||||||
//
|
|
||||||
//scroll(xterm, xtermNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
xterm.open();
|
xterm.open();
|
||||||
|
xtermNode.appendChild(xterm.element);
|
||||||
|
|
||||||
window.AppRuntime[name] = {
|
window.AppRuntime[name] = {
|
||||||
xterm: xterm
|
xterm: xterm
|
||||||
@ -193,10 +181,13 @@ module.exports = Vue.component('app-main', {
|
|||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
ipc.on('emulator', function (event, type, project, data){
|
ipc.on('emulator', function (event, type, project, data){
|
||||||
|
var xtermNode = context.$els.terminal;
|
||||||
var runtime = window.AppRuntime[project.name];
|
var runtime = window.AppRuntime[project.name];
|
||||||
|
|
||||||
if (runtime) {
|
if (runtime) {
|
||||||
|
xtermNode.innerHTML = '';
|
||||||
runtime.xterm.write(data + '');
|
runtime.xterm.write(data + '');
|
||||||
|
xtermNode.appendChild(runtime.xterm.element);
|
||||||
} else {
|
} else {
|
||||||
event.sender.send('emulator', project, 'stop');
|
event.sender.send('emulator', project, 'stop');
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ function Terminal(options){
|
|||||||
this.charsets = [null];
|
this.charsets = [null];
|
||||||
|
|
||||||
// misc
|
// misc
|
||||||
this.element = null;
|
this.screen = null;
|
||||||
this.children = [];
|
this.children = [];
|
||||||
this.refreshStart = null;
|
this.refreshStart = null;
|
||||||
this.refreshEnd = null;
|
this.refreshEnd = null;
|
||||||
|
@ -15,16 +15,16 @@ module.exports = function (Terminal){
|
|||||||
this.writable = false;
|
this.writable = false;
|
||||||
this.write = function (){};
|
this.write = function (){};
|
||||||
this.ondata = function (){};
|
this.ondata = function (){};
|
||||||
this.ondataTitle = function (){};
|
this.ontitle = function (){};
|
||||||
|
|
||||||
if (this.element) {
|
if (this.screen) {
|
||||||
var parent = this.element.parentNode;
|
var parent = this.screen.parentNode;
|
||||||
|
|
||||||
if (parent) {
|
if (parent) {
|
||||||
parent.removeChild(this.element);
|
parent.removeChild(this.screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.element = null;
|
this.screen = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -157,7 +157,7 @@ module.exports = function (Terminal){
|
|||||||
// -this.vt200Mouse = params === 1000;
|
// -this.vt200Mouse = params === 1000;
|
||||||
// -this.normalMouse = params > 1000;
|
// -this.normalMouse = params > 1000;
|
||||||
// -this.mouseEvents = true;
|
// -this.mouseEvents = true;
|
||||||
// -this.element.style.cursor = 'default';
|
// -this.screen.style.cursor = 'default';
|
||||||
break;
|
break;
|
||||||
// send focusin/focusout events
|
// send focusin/focusout events
|
||||||
case 1004:
|
case 1004:
|
||||||
@ -364,7 +364,7 @@ module.exports = function (Terminal){
|
|||||||
// -this.vt200Mouse = false;
|
// -this.vt200Mouse = false;
|
||||||
// -this.normalMouse = false;
|
// -this.normalMouse = false;
|
||||||
// -this.mouseEvents = false;
|
// -this.mouseEvents = false;
|
||||||
// -this.element.style.cursor = '';
|
// -this.screen.style.cursor = '';
|
||||||
break;
|
break;
|
||||||
// send focusin/focusout events
|
// send focusin/focusout events
|
||||||
case 1004:
|
case 1004:
|
||||||
|
@ -9,21 +9,20 @@ module.exports = function (Terminal){
|
|||||||
Terminal.prototype.reset = function (){
|
Terminal.prototype.reset = function (){
|
||||||
var parent;
|
var parent;
|
||||||
|
|
||||||
if (this.element) {
|
if (this.screen) {
|
||||||
parent = this.element.parentNode;
|
parent = this.screen.parentNode;
|
||||||
|
|
||||||
if (parent) {
|
if (parent) {
|
||||||
parent.removeChild(this.element);
|
parent.removeChild(this.screen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Terminal.call(this, this.options);
|
Terminal.call(this, this.options);
|
||||||
|
|
||||||
this.open();
|
this.open();
|
||||||
this.refresh(0, this.rows - 1);
|
|
||||||
|
|
||||||
if (parent) {
|
if (parent) {
|
||||||
parent.appendChild(this.element);
|
parent.appendChild(this.screen);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -32,16 +32,16 @@ module.exports = function (Terminal){
|
|||||||
var div;
|
var div;
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
|
||||||
this.element = document.createElement('div');
|
this.screen = document.createElement('div');
|
||||||
this.element.className = 'ui-terminal';
|
this.screen.className = 'ui-terminal';
|
||||||
this.element.style.outline = 'none';
|
this.screen.style.outline = 'none';
|
||||||
|
|
||||||
this.element.setAttribute('tabindex', '0');
|
this.screen.setAttribute('tabindex', '0');
|
||||||
this.element.setAttribute('spellcheck', 'false');
|
this.screen.setAttribute('spellcheck', 'false');
|
||||||
|
|
||||||
// sync default bg/fg colors
|
// sync default bg/fg colors
|
||||||
this.element.style.backgroundColor = this.bgColor;
|
this.screen.style.backgroundColor = this.bgColor;
|
||||||
this.element.style.color = this.fgColor;
|
this.screen.style.color = this.fgColor;
|
||||||
|
|
||||||
// Create the lines for our terminal.
|
// Create the lines for our terminal.
|
||||||
this.children = [];
|
this.children = [];
|
||||||
@ -49,7 +49,7 @@ module.exports = function (Terminal){
|
|||||||
for (; i < this.rows; i++) {
|
for (; i < this.rows; i++) {
|
||||||
div = document.createElement('div');
|
div = document.createElement('div');
|
||||||
|
|
||||||
this.element.appendChild(div);
|
this.screen.appendChild(div);
|
||||||
this.children.push(div);
|
this.children.push(div);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,12 +22,12 @@ module.exports = function (Terminal){
|
|||||||
* @param end
|
* @param end
|
||||||
*/
|
*/
|
||||||
Terminal.prototype.refresh = function (start, end){
|
Terminal.prototype.refresh = function (start, end){
|
||||||
var parent = this.element ? this.element.parentNode : null;
|
var parent = this.screen ? this.screen.parentNode : null;
|
||||||
var optimize = parent && end - start >= this.rows / 2;
|
var optimize = parent && end - start >= this.rows / 2;
|
||||||
var x, y, i, line, out, ch, width, data, attr, fgColor, bgColor, flags, row;
|
var x, y, i, line, out, ch, width, data, attr, fgColor, bgColor, flags, row;
|
||||||
|
|
||||||
if (optimize) {
|
if (optimize) {
|
||||||
parent.removeChild(this.element);
|
parent.removeChild(this.screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
width = this.cols;
|
width = this.cols;
|
||||||
@ -154,7 +154,7 @@ module.exports = function (Terminal){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (optimize) {
|
if (optimize) {
|
||||||
parent.appendChild(this.element);
|
parent.appendChild(this.screen);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -11,7 +11,7 @@ module.exports = function (Terminal){
|
|||||||
* @param y
|
* @param y
|
||||||
*/
|
*/
|
||||||
Terminal.prototype.resize = function (x, y){
|
Terminal.prototype.resize = function (x, y){
|
||||||
var line, element, i, j, ch;
|
var line, screen, i, j, ch;
|
||||||
|
|
||||||
if (x < 1) x = 1;
|
if (x < 1) x = 1;
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ module.exports = function (Terminal){
|
|||||||
j = this.rows;
|
j = this.rows;
|
||||||
|
|
||||||
if (j < y) {
|
if (j < y) {
|
||||||
element = this.element;
|
screen = this.screen;
|
||||||
|
|
||||||
while (j++ < y) {
|
while (j++ < y) {
|
||||||
if (this.lines.length < y + this.ybase) {
|
if (this.lines.length < y + this.ybase) {
|
||||||
@ -58,7 +58,7 @@ module.exports = function (Terminal){
|
|||||||
if (this.children.length < y) {
|
if (this.children.length < y) {
|
||||||
line = this.document.createElement('div');
|
line = this.document.createElement('div');
|
||||||
|
|
||||||
element.appendChild(line);
|
screen.appendChild(line);
|
||||||
|
|
||||||
this.children.push(line);
|
this.children.push(line);
|
||||||
}
|
}
|
||||||
@ -70,11 +70,11 @@ module.exports = function (Terminal){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.children.length > y) {
|
if (this.children.length > y) {
|
||||||
element = this.children.pop();
|
screen = this.children.pop();
|
||||||
|
|
||||||
if (!element) continue;
|
if (!screen) continue;
|
||||||
|
|
||||||
element.parentNode.removeChild(element);
|
screen.parentNode.removeChild(screen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,10 @@ module.exports = function (Terminal){
|
|||||||
|
|
||||||
var context = this;
|
var context = this;
|
||||||
|
|
||||||
this.element.style.borderColor = 'white';
|
this.screen.style.borderColor = 'white';
|
||||||
|
|
||||||
setTimeout(function (){
|
setTimeout(function (){
|
||||||
context.element.style.borderColor = '';
|
context.screen.style.borderColor = '';
|
||||||
}, 10);
|
}, 10);
|
||||||
|
|
||||||
if (this.popOnBell) this.focus();
|
if (this.popOnBell) this.focus();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user