« get me outta code hell

tui-lib - Pure Node.js library for making visual command-line programs (ala vim, ncdu)
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--util/ansi.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/util/ansi.js b/util/ansi.js
index e7f7642..f30e6ff 100644
--- a/util/ansi.js
+++ b/util/ansi.js
@@ -123,6 +123,20 @@ const ansi = {
     return `${ESC}[6n`
   },
 
+  enableAlternateScreen() {
+    // Enables alternate screen:
+    // "Xterm maintains two screen buffers.  The normal screen buffer allows
+    // you to scroll back to view saved lines of output up to the maximum set
+    // by the saveLines resource.  The alternate screen buffer is exactly as
+    // large as the display, contains no additional saved lines."
+
+    return `${ESC}[?1049h`
+  },
+
+  disableAlternateScreen() {
+    return `${ESC}[?1049l`
+  },
+
   measureColumns(text) {
     // Returns the number of columns the given text takes.