From 1de4c9c10530eb6efbb9af06d5a2cf881ccd85af Mon Sep 17 00:00:00 2001 From: Florrie Date: Sat, 9 Dec 2017 23:45:05 -0400 Subject: Make ansi interpreter work with selective control sequences --- util/ansi.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/util/ansi.js b/util/ansi.js index 564fdf8..f3f4cbe 100644 --- a/util/ansi.js +++ b/util/ansi.js @@ -129,6 +129,7 @@ const ansi = { const chars = new Array(scrRows * scrCols).fill(blank) + let showCursor = true let cursorRow = 1 let cursorCol = 1 const attributes = [] @@ -144,6 +145,12 @@ const ansi = { charI++ + // Selective control sequences (look them up) - we can just skip the + // question mark. + if (text[charI] === '?') { + charI++ + } + const args = [] let val = '' while (isDigit(text[charI])) { @@ -165,6 +172,13 @@ const ansi = { cursorCol = args[1] } + // SM - Set Mode + if (text[charI] === 'h') { + if (args[0] === '25') { + showCursor = true + } + } + // ED - Erase Display (clearScreen) if (text[charI] === 'J') { // ESC[2J - erase whole display @@ -190,6 +204,13 @@ const ansi = { } } + // RM - Reset Mode + if (text[charI] === 'l') { + if (args[0] === '25') { + showCursor = false + } + } + // SGR - Select Graphic Rendition if (text[charI] === 'm') { for (let arg of args) { -- cgit 1.3.0-6-gf8a5