From 85c892c218c5529efd01569b7dc9b1123ae53582 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Thu, 6 Jul 2017 21:16:20 -0700 Subject: [PATCH 1/8] Don't refresh terminal when scrollDisp doesn't scroll Fixes #765 --- src/xterm.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/xterm.js b/src/xterm.js index dc3b940b..ab9c5320 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -1237,12 +1237,12 @@ Terminal.prototype.scrollDisp = function(disp, suppressScrollEvent) { this.userScrolling = false; } - this.ydisp += disp; + const oldYdisp = this.ydisp; + this.ydisp = Math.max(Math.min(this.ydisp + disp, this.ybase), 0); - if (this.ydisp > this.ybase) { - this.ydisp = this.ybase; - } else if (this.ydisp < 0) { - this.ydisp = 0; + // No change occurred, don't trigger scroll/refresh + if (oldYdisp === this.ydisp) { + return; } if (!suppressScrollEvent) { From 27fcd7c260e4678386dc46db8f8d5bd4191fb547 Mon Sep 17 00:00:00 2001 From: Kirill Merkushev Date: Sun, 9 Jul 2017 13:18:03 +0300 Subject: [PATCH 2/8] Real world case: Selenoid UI http://aerokube.com/selenoid-ui/latest/#_logs https://github.com/aerokube/selenoid-ui/blob/master/web/src/components/Log/index.js --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d77d51e0..37b8fc0e 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,8 @@ Xterm.js is used in several world-class applications to provide great terminal e - [**Eclipse Orion**](https://orionhub.org): A modern, open source software development environment that runs in the cloud. Code, deploy and run in the cloud. - [**Gravitational Teleport**](https://github.com/gravitational/teleport): Gravitational Teleport is a modern SSH server for remotely accessing clusters of Linux servers via SSH or HTTPS. - [**Hexlet**](https://en.hexlet.io): Practical programming courses (JavaScript, PHP, Unix, databases, functional programming). A steady path from the first line of code to the first job. +- [**Selenoid UI**](https://github.com/aerokube/selenoid-ui): Simple UI for the scallable golang implementation of Selenium Hub named Selenoid. We use XTerm for streaming logs over websockets from docker containers. + Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it in our list. From 29545a90c671179f1f721e70246f43921293798f Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Mon, 10 Jul 2017 14:46:25 -0700 Subject: [PATCH 3/8] Add search.exclude setting for vscode workspace --- .vscode/settings.json | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..657f9915 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "search.exclude": { + "**/node_modules": true, + "**/bower_components": true, + "**/dist": true, + "**/build": true, + "**/lib": true + } +} \ No newline at end of file From e287edb6fe0f3ff0efa00afc9f2b1eaf385f3e12 Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Tue, 11 Jul 2017 09:48:11 +0200 Subject: [PATCH 4/8] Add Portainer.io as a real world use case --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 37b8fc0e..12d7ae9e 100644 --- a/README.md +++ b/README.md @@ -30,15 +30,16 @@ Xterm.js is used in several world-class applications to provide great terminal e - [**Codenvy**](http://www.codenvy.com): Cloud workspaces for development teams. - [**CoderPad**](https://coderpad.io): Online interviewing platform for programmers. Run code in many programming languages, with results displayed by `xterm.js`. - [**WebSSH2**](https://github.com/billchurch/WebSSH2): A web based SSH2 client using `xterm.js`, socket.io, and ssh2. -- [**Spyder Terminal**](https://github.com/spyder-ide/spyder-terminal): A full fledged system terminal embedded on Spyder IDE. +- [**Spyder Terminal**](https://github.com/spyder-ide/spyder-terminal): A full fledged system terminal embedded on Spyder IDE. - [**Cloud Commander**](https://cloudcmd.io "Cloud Commander"): Orthodox web file manager with console and editor. - [**Codevolve**](https://www.codevolve.com "Codevolve"): Online platform for interactive coding and web development courses. Live container-backed terminal uses `xterm.js`. - [**RStudio**](https://www.rstudio.com/products/RStudio "RStudio"): RStudio is an integrated development environment (IDE) for R. - [**Terminal for Atom**](https://github.com/jsmecham/atom-terminal-tab): A simple terminal for the Atom text editor. - [**Eclipse Orion**](https://orionhub.org): A modern, open source software development environment that runs in the cloud. Code, deploy and run in the cloud. - [**Gravitational Teleport**](https://github.com/gravitational/teleport): Gravitational Teleport is a modern SSH server for remotely accessing clusters of Linux servers via SSH or HTTPS. -- [**Hexlet**](https://en.hexlet.io): Practical programming courses (JavaScript, PHP, Unix, databases, functional programming). A steady path from the first line of code to the first job. +- [**Hexlet**](https://en.hexlet.io): Practical programming courses (JavaScript, PHP, Unix, databases, functional programming). A steady path from the first line of code to the first job. - [**Selenoid UI**](https://github.com/aerokube/selenoid-ui): Simple UI for the scallable golang implementation of Selenium Hub named Selenoid. We use XTerm for streaming logs over websockets from docker containers. +- [**Portainer**](https://github.com/portainer/portainer): Simple management UI for Docker. Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it in our list. From 38de6cb46a64da47b125c05200b89a7db855ec09 Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Tue, 11 Jul 2017 09:49:22 +0200 Subject: [PATCH 5/8] Update Portainer URL --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 12d7ae9e..0fee6527 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Xterm.js is used in several world-class applications to provide great terminal e - [**Gravitational Teleport**](https://github.com/gravitational/teleport): Gravitational Teleport is a modern SSH server for remotely accessing clusters of Linux servers via SSH or HTTPS. - [**Hexlet**](https://en.hexlet.io): Practical programming courses (JavaScript, PHP, Unix, databases, functional programming). A steady path from the first line of code to the first job. - [**Selenoid UI**](https://github.com/aerokube/selenoid-ui): Simple UI for the scallable golang implementation of Selenium Hub named Selenoid. We use XTerm for streaming logs over websockets from docker containers. -- [**Portainer**](https://github.com/portainer/portainer): Simple management UI for Docker. +- [**Portainer**](https://portainer.io): Simple management UI for Docker. Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it in our list. From e59d1f7a98a11df7ed19d6c077cc291e257b14e8 Mon Sep 17 00:00:00 2001 From: stuicey Date: Tue, 11 Jul 2017 16:08:39 +0100 Subject: [PATCH 6/8] Add SSHy as real-world use --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0fee6527..f885dfce 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ Xterm.js is used in several world-class applications to provide great terminal e - [**Hexlet**](https://en.hexlet.io): Practical programming courses (JavaScript, PHP, Unix, databases, functional programming). A steady path from the first line of code to the first job. - [**Selenoid UI**](https://github.com/aerokube/selenoid-ui): Simple UI for the scallable golang implementation of Selenium Hub named Selenoid. We use XTerm for streaming logs over websockets from docker containers. - [**Portainer**](https://portainer.io): Simple management UI for Docker. +- [**SSHy**](https://github.com/stuicey/SSHy): HTML5 Based SSHv2 Web Client with E2E encryption utilising `xterm.js`, SJCL & websockets. Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it in our list. From 9bd52820e7649e6230fc8829b82eb0674b82a427 Mon Sep 17 00:00:00 2001 From: thomas Date: Tue, 11 Jul 2017 20:13:13 +0200 Subject: [PATCH 7/8] use evt.detail as mouse counter --- src/SelectionManager.ts | 52 +++-------------------------------------- 1 file changed, 3 insertions(+), 49 deletions(-) diff --git a/src/SelectionManager.ts b/src/SelectionManager.ts index f13549b2..4440ea4f 100644 --- a/src/SelectionManager.ts +++ b/src/SelectionManager.ts @@ -86,23 +86,6 @@ export class SelectionManager extends EventEmitter { */ private _dragScrollAmount: number; - /** - * The last time the mousedown event fired, this is used to track double and - * triple clicks. - */ - private _lastMouseDownTime: number; - - /** - * The last position the mouse was clicked [x, y]. - */ - private _lastMousePosition: [number, number]; - - /** - * The number of clicks of the mousedown event. This is used to keep track of - * double and triple clicks. - */ - private _clickCount: number; - /** * The current selection mode. */ @@ -135,7 +118,6 @@ export class SelectionManager extends EventEmitter { this.enable(); this._model = new SelectionModel(_terminal); - this._lastMouseDownTime = 0; this._activeSelectionMode = SelectionMode.NORMAL; } @@ -396,16 +378,14 @@ export class SelectionManager extends EventEmitter { // Reset drag scroll state this._dragScrollAmount = 0; - this._setMouseClickCount(event); - if (event.shiftKey) { this._onShiftClick(event); } else { - if (this._clickCount === 1) { + if (event.detail === 1) { this._onSingleClick(event); - } else if (this._clickCount === 2) { + } else if (event.detail === 2) { this._onDoubleClick(event); - } else if (this._clickCount === 3) { + } else if (event.detail === 3) { this._onTripleClick(event); } } @@ -491,32 +471,6 @@ export class SelectionManager extends EventEmitter { } } - /** - * Sets the number of clicks for the current mousedown event based on the time - * and position of the last mousedown event. - * @param event The mouse event. - */ - private _setMouseClickCount(event: MouseEvent): void { - let currentTime = (new Date()).getTime(); - if (currentTime - this._lastMouseDownTime > CLEAR_MOUSE_DOWN_TIME || this._distanceFromLastMousePosition(event) > CLEAR_MOUSE_DISTANCE) { - this._clickCount = 0; - } - this._lastMouseDownTime = currentTime; - this._lastMousePosition = [event.pageX, event.pageY]; - this._clickCount++; - } - - /** - * Gets the maximum number of pixels in each direction the mouse has moved. - * @param event The mouse event. - */ - private _distanceFromLastMousePosition(event: MouseEvent): number { - const result = Math.max( - Math.abs(this._lastMousePosition[0] - event.pageX), - Math.abs(this._lastMousePosition[1] - event.pageY)); - return result; - } - /** * Handles the mousemove event when the mouse button is down, recording the * end of the selection and refreshing the selection. From 27f0eaf71d3b509fd9a15e53922bbb49a81d2967 Mon Sep 17 00:00:00 2001 From: Christof Marti Date: Tue, 11 Jul 2017 15:27:41 -0700 Subject: [PATCH 8/8] Check if we still need to measure the char size (fixes #785) --- src/xterm.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/xterm.js b/src/xterm.js index ab9c5320..cf777477 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -1939,6 +1939,10 @@ Terminal.prototype.resize = function(x, y) { , addToY; if (x === this.cols && y === this.rows) { + // Check if we still need to measure the char size (fixes #785). + if (!this.charMeasure.width || !this.charMeasure.height) { + this.charMeasure.measure(); + } return; }