From b821577ad665520ecc392cf3c6be7f9bc9545b0e Mon Sep 17 00:00:00 2001 From: Florrie Date: Sun, 10 Dec 2017 11:17:00 -0400 Subject: Show/hide cursor in ANSI interpreter --- util/ansi.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'util/ansi.js') diff --git a/util/ansi.js b/util/ansi.js index a303cd6..9645f0d 100644 --- a/util/ansi.js +++ b/util/ansi.js @@ -121,7 +121,7 @@ const ansi = { interpret(text, scrRows, scrCols, { oldChars = null, oldLastChar = null, - oldCursorRow = 0, oldCursorCol = 0 + oldCursorRow = 0, oldCursorCol = 0, oldShowCursor = true } = {}) { // Interprets the given ansi code, more or less. @@ -406,10 +406,19 @@ const ansi = { result.push(ansi.moveCursor(cursorRow, cursorCol)) } + // If the cursor is visible and wasn't before, or vice versa, we need to + // show that: + if (showCursor && !oldShowCursor) { + result.push(ansi.showCursor()) + } else if (!showCursor && oldShowCursor) { + result.push(ansi.hideCursor()) + } + return { oldChars: newChars.slice(), oldCursorRow: cursorRow, oldCursorCol: cursorCol, + oldShowCursor: showCursor, oldLastChar: Object.assign({}, lastChar), screen: result.join('') } -- cgit 1.3.0-6-gf8a5