« get me outta code hell

isPageUp / isPageDown functions, simpler combo detection code - 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>2018-06-03 19:23:49 -0300
committerFlorrie <towerofnix@gmail.com>2018-06-03 19:23:49 -0300
commiteb82bbfef19343a154a77663426292c1e25f06e9 (patch)
tree2a7dfb6cc900462fcf919984e954a9b2bad045da /util
parent3386ff9428997fdcebab1f67cb83c82e4636be89 (diff)
isPageUp / isPageDown functions, simpler combo detection code
Diffstat (limited to 'util')
-rw-r--r--util/telchars.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/util/telchars.js b/util/telchars.js
index b39e17b..415eff8 100644
--- a/util/telchars.js
+++ b/util/telchars.js
@@ -31,10 +31,13 @@ const telchars = {
   isRight: buf => buf[0] === 0x1b && buf[2] === 0x43,
   isLeft: buf => buf[0] === 0x1b && buf[2] === 0x44,
 
-  isShiftUp: buf => buf[0] === 0x1b && compareBufStr(buf.slice(1), '[1;2A'),
-  isShiftDown: buf => buf[0] === 0x1b && compareBufStr(buf.slice(1), '[1;2B'),
-  isShiftRight: buf => buf[0] === 0x1b && compareBufStr(buf.slice(1), '[1;2C'),
-  isShiftLeft: buf => buf[0] === 0x1b && compareBufStr(buf.slice(1), '[1;2D'),
+  isShiftUp: buf => compareBufStr(buf, '\x1b[1;2A'),
+  isShiftDown: buf => compareBufStr(buf, '\x1b[1;2B'),
+  isShiftRight: buf => compareBufStr(buf, '\x1b[1;2C'),
+  isShiftLeft: buf => compareBufStr(buf, '\x1b[1;2D'),
+
+  isPageUp: buf => compareBufStr(buf, '\x1b[5~'),
+  isPageDown: buf => compareBufStr(buf, '\x1b[6~'),
 
   isCaselessLetter: (buf, letter) => compareBufStr(buf, letter.toLowerCase()) || compareBufStr(buf, letter.toUpperCase()),
 }