Merge branch 'v3' into zmodem
This commit is contained in:
+10
-3
@@ -307,6 +307,15 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
|
||||
return (offset / Math.abs(offset)) + Math.round(offset * (DRAG_SCROLL_MAX_SPEED - 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the selection manager should force selection, regardless of
|
||||
* whether the terminal is in mouse events mode.
|
||||
* @param event The mouse event.
|
||||
*/
|
||||
public shouldForceSelection(event: MouseEvent): boolean {
|
||||
return Browser.isMac ? event.altKey : event.shiftKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles te mousedown event, setting up for a new selection.
|
||||
* @param event The mousedown event.
|
||||
@@ -325,9 +334,7 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
|
||||
|
||||
// Allow selection when using a specific modifier key, even when disabled
|
||||
if (!this._enabled) {
|
||||
const shouldForceSelection = Browser.isMac ? event.altKey : event.shiftKey;
|
||||
|
||||
if (!shouldForceSelection) {
|
||||
if (!this.shouldForceSelection(event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+36
-1
@@ -943,7 +943,12 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
|
||||
ev.preventDefault();
|
||||
this.focus();
|
||||
|
||||
if (!this.mouseEvents) return;
|
||||
// Don't send the mouse button to the pty if mouse events are disabled or
|
||||
// if the selection manager is having selection forced (ie. a modifier is
|
||||
// held).
|
||||
if (!this.mouseEvents || this.selectionManager.shouldForceSelection(ev)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// send the button
|
||||
sendButton(ev);
|
||||
@@ -1417,6 +1422,36 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
|
||||
};
|
||||
const modifiers = (ev.shiftKey ? 1 : 0) | (ev.altKey ? 2 : 0) | (ev.ctrlKey ? 4 : 0) | (ev.metaKey ? 8 : 0);
|
||||
switch (ev.keyCode) {
|
||||
case 0:
|
||||
if (ev.key === 'UIKeyInputUpArrow') {
|
||||
if (this.applicationCursor) {
|
||||
result.key = C0.ESC + 'OA';
|
||||
} else {
|
||||
result.key = C0.ESC + '[A';
|
||||
}
|
||||
}
|
||||
else if (ev.key === 'UIKeyInputLeftArrow') {
|
||||
if (this.applicationCursor) {
|
||||
result.key = C0.ESC + 'OD';
|
||||
} else {
|
||||
result.key = C0.ESC + '[D';
|
||||
}
|
||||
}
|
||||
else if (ev.key === 'UIKeyInputRightArrow') {
|
||||
if (this.applicationCursor) {
|
||||
result.key = C0.ESC + 'OC';
|
||||
} else {
|
||||
result.key = C0.ESC + '[C';
|
||||
}
|
||||
}
|
||||
else if (ev.key === 'UIKeyInputDownArrow') {
|
||||
if (this.applicationCursor) {
|
||||
result.key = C0.ESC + 'OB';
|
||||
} else {
|
||||
result.key = C0.ESC + '[B';
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
// backspace
|
||||
if (ev.shiftKey) {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"rootDir": ".",
|
||||
"outDir": "../../../lib/addons/winptyCompat/",
|
||||
"sourceMap": true,
|
||||
"removeComments": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Copyright (c) 2017 The xterm.js authors. All rights reserved.
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
declare var exports: any;
|
||||
declare var define: any;
|
||||
|
||||
(function (addon) {
|
||||
if (typeof window !== 'undefined' && 'Terminal' in window) {
|
||||
/**
|
||||
* Plain browser environment
|
||||
*/
|
||||
addon((<any>window).Terminal);
|
||||
} else if (typeof exports === 'object' && typeof module === 'object') {
|
||||
/**
|
||||
* CommonJS environment
|
||||
*/
|
||||
module.exports = addon(require('../../Terminal').Terminal);
|
||||
} else if (typeof define === 'function') {
|
||||
/**
|
||||
* Require.js is available
|
||||
*/
|
||||
define(['../../xterm'], addon);
|
||||
}
|
||||
})((Terminal: any) => {
|
||||
Terminal.prototype.winptyCompatInit = function(): void {
|
||||
// Don't do anything when the platform is not Windows
|
||||
const isWindows = ['Windows', 'Win16', 'Win32', 'WinCE'].indexOf(navigator.platform) >= 0;
|
||||
if (!isWindows) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Winpty does not support wraparound mode which means that lines will never
|
||||
// be marked as wrapped. This causes issues for things like copying a line
|
||||
// retaining the wrapped new line characters or if consumers are listening
|
||||
// in on the data stream.
|
||||
//
|
||||
// The workaround for this is to listen to every incoming line feed and mark
|
||||
// the line as wrapped if the last character in the previous line is not a
|
||||
// space. This is certainly not without its problems, but generally on
|
||||
// Windows when text reaches the end of the terminal it's likely going to be
|
||||
// wrapped.
|
||||
this.on('lineFeed', () => {
|
||||
const line = this.buffer.lines.get(this.buffer.ybase + this.buffer.y - 1);
|
||||
const lastChar = line[this.cols - 1];
|
||||
if (lastChar[3] !== 32 /* ' ' */) {
|
||||
const nextLine = this.buffer.lines.get(this.buffer.ybase + this.buffer.y);
|
||||
(<any>nextLine).isWrapped = true;
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -15,12 +15,12 @@ const DIM_OPACITY = 0.5;
|
||||
export abstract class BaseRenderLayer implements IRenderLayer {
|
||||
private _canvas: HTMLCanvasElement;
|
||||
protected _ctx: CanvasRenderingContext2D;
|
||||
private _scaledCharWidth: number;
|
||||
private _scaledCharHeight: number;
|
||||
private _scaledCellWidth: number;
|
||||
private _scaledCellHeight: number;
|
||||
private _scaledCharLeft: number;
|
||||
private _scaledCharTop: number;
|
||||
private _scaledCharWidth: number = 0;
|
||||
private _scaledCharHeight: number = 0;
|
||||
private _scaledCellWidth: number = 0;
|
||||
private _scaledCellHeight: number = 0;
|
||||
private _scaledCharLeft: number = 0;
|
||||
private _scaledCharTop: number = 0;
|
||||
|
||||
private _charAtlas: HTMLCanvasElement | ImageBitmap;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user