Skip to content

Commit

Permalink
Implement terminal scroll bar
Browse files Browse the repository at this point in the history
Fixes #6602
  • Loading branch information
Tyriar committed Aug 8, 2016
1 parent 590f21f commit 2e10189
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 4 deletions.
4 changes: 2 additions & 2 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"vscode-debugprotocol": "1.11.0",
"vscode-textmate": "2.0.1",
"winreg": "1.2.0",
"xterm": "git+https://github.com/sourcelair/xterm.js.git#65b2be7",
"xterm": "git+https://github.com/sourcelair/xterm.js.git#e7c7160",
"yauzl": "2.3.1"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

.monaco-workbench .panel.integrated-terminal .xterm-viewport {
/* Use the hack presented in http://stackoverflow.com/a/38748186/1156119 to get opacity transitions working on the scrollbar */
background-color: rgba(121, 121, 121, 0);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
transition: background-color 800ms linear;
}

.monaco-workbench .panel.integrated-terminal .xterm-viewport::-webkit-scrollbar {
width: 10px;
}

.monaco-workbench .panel.integrated-terminal .xterm-viewport::-webkit-scrollbar-track {
opacity: 0;
}

.monaco-workbench .panel.integrated-terminal .xterm-viewport::-webkit-scrollbar-thumb {
background-color: inherit;
}

.monaco-workbench .panel.integrated-terminal .xterm.focus .xterm-viewport,
.monaco-workbench .panel.integrated-terminal .xterm:focus .xterm-viewport,
.monaco-workbench .panel.integrated-terminal .xterm:hover .xterm-viewport {
transition: opacity 100ms linear;
background-color: rgba(121, 121, 121, 0.4);
}

.monaco-workbench .panel.integrated-terminal .xterm .xterm-viewport::-webkit-scrollbar-thumb:hover {
transition: opacity 0ms linear;
background-color: rgba(100, 100, 100, .7);
}

.monaco-workbench .panel.integrated-terminal .xterm .xterm-viewport::-webkit-scrollbar-thumb:window-inactive {
background-color: inherit;
}
21 changes: 21 additions & 0 deletions src/vs/workbench/parts/terminal/electron-browser/media/xterm.css
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,27 @@
}
}

.monaco-workbench .panel.integrated-terminal .xterm .xterm-viewport {
overflow-y: scroll;
}

.monaco-workbench .panel.integrated-terminal .xterm .xterm-rows {
position: absolute;
left: 0;
bottom: 0;
}

.monaco-workbench .panel.integrated-terminal .xterm .xterm-scroll-area {
visibility: hidden;
}

.monaco-workbench .panel.integrated-terminal .xterm .xterm-char-measure-element {
display: inline-block;
visibility: hidden;
position: absolute;
left: -9999em;
}

.monaco-workbench .panel.integrated-terminal .xterm .xterm-bold {
font-weight: bold;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import 'vs/css!./media/scrollbar';
import 'vs/css!./media/terminal';
import 'vs/css!./media/xterm';
import * as panel from 'vs/workbench/browser/panel';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,13 @@ export class TerminalInstance {
if (!dimension.height) { // Minimized
return;
}
let cols = Math.floor(dimension.width / this.font.charWidth);
let leftPadding = parseInt(getComputedStyle(document.querySelector('.terminal-outer-container')).paddingLeft.split('px')[0], 10);
let innerWidth = dimension.width - leftPadding;
let cols = Math.floor(innerWidth / this.font.charWidth);
let rows = Math.floor(dimension.height / this.font.charHeight);
if (this.xterm) {
this.xterm.resize(cols, rows);
this.xterm.element.style.width = innerWidth + 'px';
}
if (this.terminalProcess.process.connected) {
this.terminalProcess.process.send({
Expand Down

0 comments on commit 2e10189

Please sign in to comment.