diff --git a/src/console.js b/src/console.js index 2d503df..68eec40 100644 --- a/src/console.js +++ b/src/console.js @@ -26,7 +26,8 @@ module.exports = class Console extends blessed.element { }); this.statusView = blessed.text({ - parent: this.inputView, + parent: this, + top: "100%-1", width: 0, right: 0, align: 'right', @@ -108,6 +109,7 @@ module.exports = class Console extends blessed.element { this.statusView.content = ''; this.statusView.width = 0; } + this.inputView.right = this.statusView.content.length; } log(line) { diff --git a/src/text_prompt.js b/src/text_prompt.js index 86c9d2f..8a38521 100644 --- a/src/text_prompt.js +++ b/src/text_prompt.js @@ -15,6 +15,7 @@ module.exports = class TextPrompt extends blessed.box { Object.assign( { keyable: true, + wrap: false, }, opts, ), @@ -35,7 +36,7 @@ module.exports = class TextPrompt extends blessed.box { input: rl_input, output: rl_output, terminal: true, - completer: opts.completer, + //completer: opts.completer, historySize: opts.historySize || 5000, }); this.prompt = opts.prompt; @@ -100,7 +101,7 @@ module.exports = class TextPrompt extends blessed.box { // Push any leftover output flush(); - this.setContent(this.rl._prompt + this.rl.line); + this.updateDisplay(); this.screen.render(); }); @@ -124,7 +125,12 @@ module.exports = class TextPrompt extends blessed.box { } }); this.screen.program.showCursor(); - this.setContent(this.rl._prompt); + this.hscroll = 0; + this.updateDisplay(); + } + + updateDisplay() { + this.setContent(this.rl._prompt + this.rl.line.slice(this.hscroll)); } setPrompt(prompt) { @@ -136,7 +142,15 @@ module.exports = class TextPrompt extends blessed.box { let { cols: cx, rows: cy } = this.rl._getCursorPos(); let pos = this._getPos(); - cx += pos.aleft; + // Horizontal scrolling for long input lines + let hscroll = Math.max(0, cx - (pos.aleft + pos.width - 1)); + if (hscroll != this.hscroll) { + this.hscroll = hscroll; + this.updateDisplay(); + this.screen.render(); + } + + cx += pos.aleft - this.hscroll; cy += pos.atop; if (cy === this.screen.program.y && cx === this.screen.program.x) {