update files

This commit is contained in:
nuintun 2015-11-24 22:44:46 +08:00
parent 194867d5b8
commit 8c49cd09d1
3 changed files with 20 additions and 12 deletions

View File

@ -35,6 +35,10 @@ function clone(projects, index){
return util.clone(projects[index] || EMPTYPROJECT); return util.clone(projects[index] || EMPTYPROJECT);
} }
function scroll(element){
element.scrollTop = element.scrollHeight;
}
module.exports = Vue.component('app-main', { module.exports = Vue.component('app-main', {
template: fs.readFileSync(path.join(__dirname, 'app-main.html')).toString(), template: fs.readFileSync(path.join(__dirname, 'app-main.html')).toString(),
props: { props: {
@ -83,6 +87,7 @@ module.exports = Vue.component('app-main', {
exec: function (name, command){ exec: function (name, command){
console.log('run %s: %s', name, command); console.log('run %s: %s', name, command);
var xtermNode = this.$els.terminal;
var runtime = window.AppRuntime[this.project.name]; var runtime = window.AppRuntime[this.project.name];
var test = [ var test = [
@ -113,25 +118,24 @@ module.exports = Vue.component('app-main', {
'', '',
' \u001b[31mreturn\u001b[39m \u001b[37mhypernal\u001b[39m\u001b[90m;\u001b[39m', ' \u001b[31mreturn\u001b[39m \u001b[37mhypernal\u001b[39m\u001b[90m;\u001b[39m',
'\u001b[33m}\u001b[39m\u001b[90m;\u001b[39m', '\u001b[33m}\u001b[39m\u001b[90m;\u001b[39m',
'' new Date().toISOString()
]; ];
if (!runtime) { if (!runtime) {
var xterm = new Terminal({ var xterm = new Terminal();
cols: 220,
rows: 70
});
xterm.open(); xterm.open();
this.$els.terminal.appendChild(xterm.element); xtermNode.appendChild(xterm.element);
console.log(xterm); console.log(xterm);
test.forEach(function (line){ test.forEach(function (line){
xterm.writeln(line); xterm.write(line);
xterm.cursorNextLine([0]); scroll(xtermNode);
}); });
window.xterm = xterm;
window.AppRuntime[this.project.name] = { window.AppRuntime[this.project.name] = {
name: name, name: name,
command: command, command: command,
@ -140,7 +144,11 @@ module.exports = Vue.component('app-main', {
} else { } else {
test.forEach(function (line){ test.forEach(function (line){
runtime.xterm.writeln(line); runtime.xterm.writeln(line);
runtime.xterm.cursorNextLine([0]); console.log(runtime.xterm.rows);
if(runtime.xterm.y > 10){
runtime.xterm.eraseLine(0);
}
scroll(xtermNode);
}); });
} }
}, },

View File

@ -8,8 +8,8 @@ module.exports = function (Terminal){
Terminal.termName = 'xterm'; Terminal.termName = 'xterm';
Terminal.geometry = [80, 24]; Terminal.geometry = [80, 24];
Terminal.cursorBlink = true; Terminal.cursorBlink = true;
Terminal.visualBell = false; Terminal.visualBell = true;
Terminal.popOnBell = false; Terminal.popOnBell = true;
Terminal.scrollback = 1000; Terminal.scrollback = 1000;
Terminal.screenKeys = false; Terminal.screenKeys = false;
Terminal.programFeatures = false; Terminal.programFeatures = false;

View File

@ -3,8 +3,8 @@
*/ */
'use strict'; 'use strict';
// ignore warnings regarging == and != (coersion makes things work here appearently)
// ignore warnings regarging == and != (coersion makes things work here appearently)
module.exports = function (Terminal){ module.exports = function (Terminal){
Terminal.prototype.setupStops = function (i){ Terminal.prototype.setupStops = function (i){
if (i != null) { if (i != null) {