diff options
Diffstat (limited to 'util/ansi.js')
-rw-r--r-- | util/ansi.js | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/util/ansi.js b/util/ansi.js index 4e8abb0..997e824 100644 --- a/util/ansi.js +++ b/util/ansi.js @@ -216,7 +216,7 @@ export function isANSICommand(buffer, code = null) { export function interpret(text, scrRows, scrCols, { oldChars = null, oldLastChar = null, oldScrRows = null, oldScrCols = null, - oldCursorRow = 1, oldCursorCol = 1, oldShowCursor = true + oldCursorRow = 1, oldCursorCol = 1, oldShowingCursor = true } = {}) { // Interprets the given ansi code, more or less. @@ -235,7 +235,7 @@ export function interpret(text, scrRows, scrCols, { } } - let showCursor = oldShowCursor + let showingCursor = oldShowingCursor let cursorRow = oldCursorRow let cursorCol = oldCursorCol let attributes = [] @@ -282,7 +282,7 @@ export function interpret(text, scrRows, scrCols, { // SM - Set Mode if (text[charI] === 'h') { if (args[0] === '25') { - showCursor = true + showingCursor = true } } @@ -316,7 +316,7 @@ export function interpret(text, scrRows, scrCols, { // RM - Reset Mode if (text[charI] === 'l') { if (args[0] === '25') { - showCursor = false + showingCursor = false } } @@ -509,10 +509,12 @@ export function interpret(text, scrRows, scrCols, { // If the cursor is visible and wasn't before, or vice versa, we need to // show that: - if (showCursor && !oldShowCursor) { - result.push(showCursor()) - } else if (!showCursor && oldShowCursor) { - result.push(hideCursor()) + if (showingCursor !== oldShowingCursor) { + if (showingCursor) { + result.push(showCursor()) + } else { + result.push(hideCursor()) + } } return { @@ -522,7 +524,7 @@ export function interpret(text, scrRows, scrCols, { oldScrCols: scrCols, oldCursorRow: cursorRow, oldCursorCol: cursorCol, - oldShowCursor: showCursor, + oldShowingCursor: showingCursor, screen: result.join('') } } |