diff --git a/web/app/ui/terminal.js b/web/app/ui/terminal.js index ab10d5a1..cee41b55 100644 --- a/web/app/ui/terminal.js +++ b/web/app/ui/terminal.js @@ -6,6 +6,7 @@ export function Terminal(win, commandProcessor, variantsSupplier) { win.onShowCallback = function() { input.focus(); }; + win.root.click(() => input.focus()); this.history = []; this.historyPointer = 0; const setHistory = () => { @@ -13,7 +14,6 @@ export function Terminal(win, commandProcessor, variantsSupplier) { input.val(this.history[this.historyPointer]); }; - input.keydown((e) => { function consumeEvent() { e.preventDefault(); @@ -41,6 +41,7 @@ export function Terminal(win, commandProcessor, variantsSupplier) { variants = variants.slice(0,limit); } autocompleteArea.text(variants.join(' ') + more); + this.scrollToTheEnd(); } } consumeEvent(); @@ -71,13 +72,18 @@ export function Terminal(win, commandProcessor, variantsSupplier) { } this.historyPointer = this.history.length; } - this.out.parent().scrollTop(this.out.height()); + this.scrollToTheEnd(); } }); } +Terminal.prototype.scrollToTheEnd = function() { + this.out.parent().scrollTop(this.out.height()); +}; + Terminal.prototype.print = function(text) { this.win.root.find('.terminal-output').append($('
', {text, 'class': 'terminal-commandResult'})); + this.scrollToTheEnd(); }; function sharedStartOfSortedArray(array){