]> git.proxmox.com Git - mirror_xterm.js.git/commitdiff
Added macOS check to escape sequences and updated tests
authorBob Reid <bobreid@Bobs-MacBook-Pro.local>
Fri, 16 Dec 2016 20:03:49 +0000 (15:03 -0500)
committerBob Reid <bobreid@Bobs-MacBook-Pro.local>
Fri, 16 Dec 2016 20:03:49 +0000 (15:03 -0500)
src/test/test.js
src/xterm.js

index d8e931fbdd1eba3a3223a5ee1cc8621574e3f5de..370a4ec78f616b50fa2a17084b789d8ccdf52da7 100644 (file)
@@ -286,14 +286,33 @@ describe('xterm.js', function() {
     it('should return \\x1b[5B for ctrl+down', function() {
       assert.equal(xterm.evaluateKeyEscapeSequence({ ctrlKey: true, keyCode: 40 }).key, '\x1b[1;5B'); // CSI 5 B
     });
-    // Evalueate alt + arrow key movement, which is a feature of terminal emulators but not VT100
-    // http://unix.stackexchange.com/a/108106
-    it('should return \\x1b[5D for alt+left', function() {
-      assert.equal(xterm.evaluateKeyEscapeSequence({ altKey: true, keyCode: 37 }).key, '\x1b[1;5D'); // CSI 5 D
+
+    describe('On non-macOS platforms', function() {
+      beforeEach(function() {
+        xterm.browser.isMac = false;
+      });
+      // Evalueate alt + arrow key movement, which is a feature of terminal emulators but not VT100
+      // http://unix.stackexchange.com/a/108106
+      it('should return \\x1b[5D for alt+left', function() {
+        assert.equal(xterm.evaluateKeyEscapeSequence({ altKey: true, keyCode: 37 }).key, '\x1b[1;5D'); // CSI 5 D
+      });
+      it('should return \\x1b[5C for alt+right', function() {
+        assert.equal(xterm.evaluateKeyEscapeSequence({ altKey: true, keyCode: 39 }).key, '\x1b[1;5C'); // CSI 5 C
+      });
     });
-    it('should return \\x1b[5C for alt+right', function() {
-      assert.equal(xterm.evaluateKeyEscapeSequence({ altKey: true, keyCode: 39 }).key, '\x1b[1;5C'); // CSI 5 C
+
+    describe('On macOS platforms', function() {
+      beforeEach(function() {
+        xterm.browser.isMac = true;
+      });
+      it('should return \\x1bb for alt+left', function() {
+        assert.equal(xterm.evaluateKeyEscapeSequence({ altKey: true, keyCode: 37 }).key, '\x1bb'); // CSI 5 D
+      });
+      it('should return \\x1bf for alt+right', function() {
+        assert.equal(xterm.evaluateKeyEscapeSequence({ altKey: true, keyCode: 39 }).key, '\x1bf'); // CSI 5 C
+      });
     });
+
     it('should return \\x1b[5A for alt+up', function() {
       assert.equal(xterm.evaluateKeyEscapeSequence({ altKey: true, keyCode: 38 }).key, '\x1b[1;5A'); // CSI 5 A
     });
index 4bab820a2f025735a1d84e1f71da10e4a835e40a..a085fc7019b0d182f689812a5d1b557c65c85390 100644 (file)
@@ -2500,8 +2500,9 @@ Terminal.prototype.evaluateKeyEscapeSequence = function(ev) {
         result.key = '\x1b[1;' + (modifiers + 1) + 'D';
         // HACK: Make Alt + left-arrow behave like Ctrl + left-arrow: move one word backwards
         // http://unix.stackexchange.com/a/108106
+        // macOS uses different escape sequences than linux
         if (result.key == '\x1b[1;3D') {
-          result.key = '\x1bb';
+          result.key = (this.browser.isMac) ? '\x1bb' : '\x1b[1;5D';
         }
       } else if (this.applicationCursor) {
         result.key = '\x1bOD';
@@ -2515,8 +2516,9 @@ Terminal.prototype.evaluateKeyEscapeSequence = function(ev) {
         result.key = '\x1b[1;' + (modifiers + 1) + 'C';
         // HACK: Make Alt + right-arrow behave like Ctrl + right-arrow: move one word forward
         // http://unix.stackexchange.com/a/108106
+        // macOS uses different escape sequences than linux
         if (result.key == '\x1b[1;3C') {
-          result.key = '\x1bf';
+          result.key = (this.browser.isMac) ? '\x1bf' : '\x1b[1;5C';
         }
       } else if (this.applicationCursor) {
         result.key = '\x1bOC';