Fix tests
This commit is contained in:
@@ -11,8 +11,9 @@
|
|||||||
|
|
||||||
import { contains } from './Generic.js';
|
import { contains } from './Generic.js';
|
||||||
|
|
||||||
let userAgent = navigator.userAgent;
|
let isNode = (typeof navigator == 'undefined') ? true : false;
|
||||||
let platform = navigator.platform;
|
let userAgent = (isNode) ? 'node' : navigator.userAgent;
|
||||||
|
let platform = (isNode) ? 'node' : navigator.platform;
|
||||||
|
|
||||||
export let isFirefox = !!~userAgent.indexOf('Firefox');
|
export let isFirefox = !!~userAgent.indexOf('Firefox');
|
||||||
export let isMSIE = !!~userAgent.indexOf('MSIE');
|
export let isMSIE = !!~userAgent.indexOf('MSIE');
|
||||||
@@ -20,7 +21,7 @@ export let isMSIE = !!~userAgent.indexOf('MSIE');
|
|||||||
// Find the users platform. We use this to interpret the meta key
|
// Find the users platform. We use this to interpret the meta key
|
||||||
// and ISO third level shifts.
|
// and ISO third level shifts.
|
||||||
// http://stackoverflow.com/q/19877924/577598
|
// http://stackoverflow.com/q/19877924/577598
|
||||||
export let isMac = contains(platform, ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K']);
|
export let isMac = contains(['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'], platform);
|
||||||
export let isIpad = platform === 'iPad';
|
export let isIpad = platform === 'iPad';
|
||||||
export let isIphone = platform === 'iPhone';
|
export let isIphone = platform === 'iPhone';
|
||||||
export let isMSWindows = contains(platform, ['Windows', 'Win16', 'Win32', 'WinCE']);
|
export let isMSWindows = contains(['Windows', 'Win16', 'Win32', 'WinCE'], platform);
|
||||||
|
|||||||
@@ -9,11 +9,11 @@
|
|||||||
* @module xterm/utils/Generic
|
* @module xterm/utils/Generic
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export let contains = function(el, arr) {
|
/**
|
||||||
for (var i = 0; i < arr.length; i += 1) {
|
* Return if the given array contains the given element
|
||||||
if (el === arr[i]) {
|
* @param {Array} array The array to search for the given element.
|
||||||
return true;
|
* @param {Object} el The element to look for into the array
|
||||||
}
|
*/
|
||||||
}
|
export let contains = function(arr, el) {
|
||||||
return false;
|
return arr.indexOf(el) >= 0;
|
||||||
};
|
};
|
||||||
|
|||||||
+7
-6
@@ -35,7 +35,7 @@ import { CompositionHelper } from './CompositionHelper.js';
|
|||||||
import { EventEmitter } from './EventEmitter.js';
|
import { EventEmitter } from './EventEmitter.js';
|
||||||
import { Viewport } from './Viewport.js';
|
import { Viewport } from './Viewport.js';
|
||||||
import { rightClickHandler, pasteHandler, copyHandler } from './handlers/Clipboard.js';
|
import { rightClickHandler, pasteHandler, copyHandler } from './handlers/Clipboard.js';
|
||||||
import { isFirefox, isMSIE, isMac, isIpad, isIphone, isMSWindows } from './utils/Browser';
|
import * as Browser from './utils/Browser';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Terminal Emulation References:
|
* Terminal Emulation References:
|
||||||
@@ -79,6 +79,7 @@ function Terminal(options) {
|
|||||||
return new Terminal(arguments[0], arguments[1], arguments[2]);
|
return new Terminal(arguments[0], arguments[1], arguments[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.browser = Browser;
|
||||||
self.cancel = Terminal.cancel;
|
self.cancel = Terminal.cancel;
|
||||||
|
|
||||||
EventEmitter.call(this);
|
EventEmitter.call(this);
|
||||||
@@ -453,7 +454,7 @@ Terminal.prototype.initGlobal = function() {
|
|||||||
rightClickHandler.call(this, ev, term);
|
rightClickHandler.call(this, ev, term);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFirefox || isMSIE) {
|
if (term.browser.isFirefox || term.browser.isMSIE) {
|
||||||
on(this.element, 'mousedown', function (ev) {
|
on(this.element, 'mousedown', function (ev) {
|
||||||
if (ev.button == 2) {
|
if (ev.button == 2) {
|
||||||
rightClickHandlerWrapper(ev);
|
rightClickHandlerWrapper(ev);
|
||||||
@@ -835,7 +836,7 @@ Terminal.prototype.bindMouse = function() {
|
|||||||
? ev.which - 1
|
? ev.which - 1
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
if (isMSIE) {
|
if (self.browser.isMSIE) {
|
||||||
button = button === 1 ? 0 : button === 4 ? 1 : button;
|
button = button === 1 ? 0 : button === 4 ? 1 : button;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -2704,7 +2705,7 @@ Terminal.prototype.evaluateKeyEscapeSequence = function(ev) {
|
|||||||
// ^] - group sep
|
// ^] - group sep
|
||||||
result.key = String.fromCharCode(29);
|
result.key = String.fromCharCode(29);
|
||||||
}
|
}
|
||||||
} else if (!isMac && ev.altKey && !ev.ctrlKey && !ev.metaKey) {
|
} else if (!this.browser.isMac && ev.altKey && !ev.ctrlKey && !ev.metaKey) {
|
||||||
// On Mac this is a third level shift. Use <Esc> instead.
|
// On Mac this is a third level shift. Use <Esc> instead.
|
||||||
if (ev.keyCode >= 65 && ev.keyCode <= 90) {
|
if (ev.keyCode >= 65 && ev.keyCode <= 90) {
|
||||||
result.key = '\x1b' + String.fromCharCode(ev.keyCode + 32);
|
result.key = '\x1b' + String.fromCharCode(ev.keyCode + 32);
|
||||||
@@ -4913,8 +4914,8 @@ function indexOf(obj, el) {
|
|||||||
|
|
||||||
function isThirdLevelShift(term, ev) {
|
function isThirdLevelShift(term, ev) {
|
||||||
var thirdLevelKey =
|
var thirdLevelKey =
|
||||||
(isMac && ev.altKey && !ev.ctrlKey && !ev.metaKey) ||
|
(term.browser.isMac && ev.altKey && !ev.ctrlKey && !ev.metaKey) ||
|
||||||
(isMSWindows && ev.altKey && ev.ctrlKey && !ev.metaKey);
|
(term.browser.isMSWindows && ev.altKey && ev.ctrlKey && !ev.metaKey);
|
||||||
|
|
||||||
if (ev.type == 'keypress') {
|
if (ev.type == 'keypress') {
|
||||||
return thirdLevelKey;
|
return thirdLevelKey;
|
||||||
|
|||||||
+1
-1
@@ -368,7 +368,7 @@ describe('xterm.js', function() {
|
|||||||
|
|
||||||
describe('On Mac OS', function() {
|
describe('On Mac OS', function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
xterm.isMac = true;
|
xterm.browser.isMac = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not interfere with the alt key on keyDown', function() {
|
it('should not interfere with the alt key on keyDown', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user