]> git.proxmox.com Git - mirror_xterm.js.git/commitdiff
fixing arrow key sequences
authorJörg Breitbart <jerch@rockborn.de>
Thu, 21 Jul 2016 10:39:36 +0000 (12:39 +0200)
committerJörg Breitbart <jerch@rockborn.de>
Thu, 21 Jul 2016 10:39:36 +0000 (12:39 +0200)
src/xterm.js

index d88ddf49e7edd2f61b746d75363f4ec70526a376..de32690eb3f59aca4bf84b9f634205b21277e979 100644 (file)
         // The number of characters to scroll, if this is defined it will cancel the event
         scrollDisp: undefined
       };
+      var modifiers = ev.shiftKey << 0 | ev.altKey << 1 | ev.ctrlKey << 2 | ev.metaKey << 3;
       switch (ev.keyCode) {
         // backspace
         case 8:
           break;
         // left-arrow
         case 37:
-          if (ev.altKey) {
-            result.key = '\x1bb' // Jump a word back
-            result.cancel = true;
-            break;
-          }
-          if (ev.ctrlKey) {
-            result.key = '\x1b[5D'; // Jump a word back
-            break;
-          }
-          if (this.applicationCursor) {
-            result.key = '\x1bOD'; // SS3 as ^[O for 7-bit
-            break;
-          }
-          result.key = '\x1b[D';
+          if (modifiers)
+            result.key = '\x1b[1;' + (modifiers + 1) + 'D';
+          else if (this.applicationCursor)
+            result.key = '\x1bOD';
+          else
+            result.key = '\x1b[D';
           break;
         // right-arrow
         case 39:
-          if (ev.altKey) {
-            result.key = '\x1bf' // Jump a word forward
-            result.cancel = true;
-            break;
-          }
-          if (ev.ctrlKey) {
-            result.key = '\x1b[5C'; // Jump a word forward
-            break;
-          }
-          if (this.applicationCursor) {
+          if (modifiers)
+            result.key = '\x1b[1;' + (modifiers + 1) + 'C';
+          else if (this.applicationCursor)
             result.key = '\x1bOC';
-            break;
-          }
-          result.key = '\x1b[C';
+          else
+            result.key = '\x1b[C';
           break;
         // up-arrow
         case 38:
-          if (this.applicationCursor) {
+          if (modifiers)
+            result.key = '\x1b[1;' + (modifiers + 1) + 'A';
+          else if (this.applicationCursor)
             result.key = '\x1bOA';
-            break;
-          }
-          if (ev.ctrlKey) {
-            result.scrollDisp = -1;
-          } else {
+          else
             result.key = '\x1b[A';
-          }
           break;
         // down-arrow
         case 40:
-          if (this.applicationCursor) {
+          if (modifiers)
+            result.key = '\x1b[1;' + (modifiers + 1) + 'B';
+          else if (this.applicationCursor)
             result.key = '\x1bOB';
-            break;
-          }
-          if (ev.ctrlKey) {
-            result.scrollDisp = 1;
-          } else {
+          else
             result.key = '\x1b[B';
-          }
           break;
         // insert
         case 45:
         case 46: result.key = '\x1b[3~'; break;
         // home
         case 36:
-          if (this.applicationKeypad) {
+          if (modifiers)
+            result.key = '\x1b[1;' + (modifiers + 1) + 'H';
+          else if (this.applicationCursor)
             result.key = '\x1bOH';
-            break;
-          }
-          result.key = '\x1bOH';
+          else
+            result.key = '\x1b[H';
           break;
         // end
         case 35:
-          if (this.applicationKeypad) {
+          if (modifiers)
+            result.key = '\x1b[1;' + (modifiers + 1) + 'F';
+          else if (this.applicationCursor)
             result.key = '\x1bOF';
-            break;
-          }
-          result.key = '\x1bOF';
+          else
+            result.key = '\x1b[F';
           break;
         // page up
         case 33: