« get me outta code hell

Expose xterm alternate screen - tui-lib - Pure Node.js library for making visual command-line programs (ala vim, ncdu)
about summary refs log tree commit diff
path: root/util
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2019-01-25 09:10:14 -0400
committerFlorrie <towerofnix@gmail.com>2019-01-25 09:10:14 -0400
commit6ca4f2e08d323b26940704eca89bdc71b4ed0160 (patch)
treebed14fba13e38f04659155d9eb1b17c0159188c1 /util
parent0c38fb468621b3860fc9c7deb12ae464c57996e8 (diff)
Expose xterm alternate screen
Diffstat (limited to 'util')
-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.