diff options
author | Florrie <towerofnix@gmail.com> | 2017-12-10 11:17:00 -0400 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2017-12-10 11:17:00 -0400 |
commit | b821577ad665520ecc392cf3c6be7f9bc9545b0e (patch) | |
tree | ae9f5330892cc6d9969f738801c9ffa644d28472 | |
parent | ce20598ca90b922592e1ddf38eb8f218cc9daa73 (diff) |
Show/hide cursor in ANSI interpreter
-rw-r--r-- | util/ansi.js | 11 |
1 files changed, 10 insertions, 1 deletions
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('') } |