« 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--ui/Root.js5
-rw-r--r--util/ansi.js4
-rw-r--r--util/telchars.js4
3 files changed, 9 insertions, 4 deletions
diff --git a/ui/Root.js b/ui/Root.js
index 3bd4767..8242f7a 100644
--- a/ui/Root.js
+++ b/ui/Root.js
@@ -29,13 +29,14 @@ module.exports = class Root extends DisplayElement {
 
   handleData(buffer) {
     if (telc.isMouse(buffer)) {
-      const { button, line, col } = telc.parseMouse(buffer)
+      const allData = telc.parseMouse(buffer)
+      const { button, line, col } = allData
       const topEl = this.getElementAt(col - 1, line - 1)
       if (topEl) {
         //console.log('Clicked', topEl.constructor.name, 'of', topEl.parent.constructor.name)
         this.eachAncestor(topEl, el => {
           if (typeof el.clicked === 'function') {
-            return el.clicked(button) === false
+            return el.clicked(button, allData) === false
           }
         })
       }
diff --git a/util/ansi.js b/util/ansi.js
index f30e6ff..d58684f 100644
--- a/util/ansi.js
+++ b/util/ansi.js
@@ -107,11 +107,11 @@ const ansi = {
   },
 
   startTrackingMouse() {
-    return `${ESC}[?1000h`
+    return `${ESC}[?1002h`
   },
 
   stopTrackingMouse() {
-    return `${ESC}[?1000l`
+    return `${ESC}[?1002l`
   },
 
   requestCursorPosition() {
diff --git a/util/telchars.js b/util/telchars.js
index b099f65..68294bf 100644
--- a/util/telchars.js
+++ b/util/telchars.js
@@ -39,11 +39,15 @@ const telchars = {
       if (num & 1) button = 'scroll-down'
       else button = 'scroll-up'
     } else {
+      const drag = num & 32
       const bits = num & 3
       if (bits === 0) button = 'left'
       else if (bits === 1) button = 'middle'
       else if (bits === 2) button = 'right'
       else if (bits === 3) button = 'release'
+      if (drag) {
+        button = 'drag-' + button
+      }
     }
 
     const shift = !!(num & 4)