diff --git a/static/js/components/app-main/index.js b/static/js/components/app-main/index.js index b8e757e..243d989 100644 --- a/static/js/components/app-main/index.js +++ b/static/js/components/app-main/index.js @@ -35,6 +35,10 @@ function clone(projects, index){ return util.clone(projects[index] || EMPTYPROJECT); } +function scroll(element){ + element.scrollTop = element.scrollHeight; +} + module.exports = Vue.component('app-main', { template: fs.readFileSync(path.join(__dirname, 'app-main.html')).toString(), props: { @@ -83,6 +87,7 @@ module.exports = Vue.component('app-main', { exec: function (name, command){ console.log('run %s: %s', name, command); + var xtermNode = this.$els.terminal; var runtime = window.AppRuntime[this.project.name]; 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[33m}\u001b[39m\u001b[90m;\u001b[39m', - '' + new Date().toISOString() ]; if (!runtime) { - var xterm = new Terminal({ - cols: 220, - rows: 70 - }); + var xterm = new Terminal(); xterm.open(); - this.$els.terminal.appendChild(xterm.element); + xtermNode.appendChild(xterm.element); console.log(xterm); test.forEach(function (line){ - xterm.writeln(line); - xterm.cursorNextLine([0]); + xterm.write(line); + scroll(xtermNode); }); + window.xterm = xterm; + window.AppRuntime[this.project.name] = { name: name, command: command, @@ -140,7 +144,11 @@ module.exports = Vue.component('app-main', { } else { test.forEach(function (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); }); } }, diff --git a/static/js/terminal/lib/options.js b/static/js/terminal/lib/options.js index 2253e3a..1c9aef6 100644 --- a/static/js/terminal/lib/options.js +++ b/static/js/terminal/lib/options.js @@ -8,8 +8,8 @@ module.exports = function (Terminal){ Terminal.termName = 'xterm'; Terminal.geometry = [80, 24]; Terminal.cursorBlink = true; - Terminal.visualBell = false; - Terminal.popOnBell = false; + Terminal.visualBell = true; + Terminal.popOnBell = true; Terminal.scrollback = 1000; Terminal.screenKeys = false; Terminal.programFeatures = false; diff --git a/static/js/terminal/lib/stops.js b/static/js/terminal/lib/stops.js index 071be9f..07d6959 100644 --- a/static/js/terminal/lib/stops.js +++ b/static/js/terminal/lib/stops.js @@ -3,8 +3,8 @@ */ '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){ Terminal.prototype.setupStops = function (i){ if (i != null) {