mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-27 06:49:53 +00:00
Merge branch 'webgl'
This commit is contained in:
commit
ac727885c4
@ -27,7 +27,7 @@
|
|||||||
"file-loader": "^0.11.2",
|
"file-loader": "^0.11.2",
|
||||||
"slug": "^1.1.0",
|
"slug": "^1.1.0",
|
||||||
"uuid": "^3.3.2",
|
"uuid": "^3.3.2",
|
||||||
"xterm": "3.14.2",
|
"xterm": "https://registry.npmjs.org/@terminus-term/xterm/-/xterm-3.14.1.tgz",
|
||||||
"xterm-addon-ligatures": "^0.1.0-beta-2"
|
"xterm-addon-ligatures": "^0.1.0-beta-2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
@ -1,3 +1,177 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2014 The xterm.js authors. All rights reserved.
|
||||||
|
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
||||||
|
* https://github.com/chjj/term.js
|
||||||
|
* @license MIT
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* Originally forked from (with the author's permission):
|
||||||
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
||||||
|
* http://bellard.org/jslinux/
|
||||||
|
* Copyright (c) 2011 Fabrice Bellard
|
||||||
|
* The original design remains. The terminal itself
|
||||||
|
* has been extended to include xterm CSI codes, among
|
||||||
|
* other features.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default styles for xterm.js
|
||||||
|
*/
|
||||||
|
|
||||||
|
.xterm {
|
||||||
|
font-feature-settings: "liga" 0;
|
||||||
|
position: relative;
|
||||||
|
user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm.focus,
|
||||||
|
.xterm:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-helpers {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
/**
|
||||||
|
* The z-index of the helpers must be higher than the canvases in order for
|
||||||
|
* IMEs to appear on top.
|
||||||
|
*/
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-helper-textarea {
|
||||||
|
/*
|
||||||
|
* HACK: to fix IE's blinking cursor
|
||||||
|
* Move textarea out of the screen to the far left, so that the cursor is not visible.
|
||||||
|
*/
|
||||||
|
position: absolute;
|
||||||
|
opacity: 0;
|
||||||
|
left: -9999em;
|
||||||
|
top: 0;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
z-index: -10;
|
||||||
|
/** Prevent wrapping so the IME appears against the textarea at the correct position */
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
resize: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .composition-view {
|
||||||
|
/* TODO: Composition position got messed up somewhere */
|
||||||
|
background: #000;
|
||||||
|
color: #FFF;
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
white-space: nowrap;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .composition-view.active {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-viewport {
|
||||||
|
/* On OS X this is required in order for the scroll bar to appear fully opaque */
|
||||||
|
background-color: #000;
|
||||||
|
overflow-y: scroll;
|
||||||
|
cursor: default;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-screen {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-screen canvas {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-scroll-area {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm-char-measure-element {
|
||||||
|
display: inline-block;
|
||||||
|
visibility: hidden;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: -9999em;
|
||||||
|
line-height: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm {
|
||||||
|
cursor: text;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm.enable-mouse-events {
|
||||||
|
/* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm.xterm-cursor-pointer {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm.column-select.focus {
|
||||||
|
/* Column selection mode */
|
||||||
|
cursor: crosshair;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-accessibility,
|
||||||
|
.xterm .xterm-message {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
z-index: 100;
|
||||||
|
color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm .live-region {
|
||||||
|
position: absolute;
|
||||||
|
left: -9999px;
|
||||||
|
width: 1px;
|
||||||
|
height: 1px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm-dim {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xterm-underline {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----*/
|
||||||
|
|
||||||
.xterm-viewport::-webkit-scrollbar {
|
.xterm-viewport::-webkit-scrollbar {
|
||||||
background: rgba(0, 0, 0, .125);
|
background: rgba(0, 0, 0, .125);
|
||||||
}
|
}
|
||||||
|
79
terminus-terminal/src/frontends/xtermAddonFit.ts
Normal file
79
terminus-terminal/src/frontends/xtermAddonFit.ts
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2017 The xterm.js authors. All rights reserved.
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Terminal, ITerminalAddon } from 'xterm';
|
||||||
|
|
||||||
|
interface ITerminalDimensions {
|
||||||
|
/**
|
||||||
|
* The number of rows in the terminal.
|
||||||
|
*/
|
||||||
|
rows: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of columns in the terminal.
|
||||||
|
*/
|
||||||
|
cols: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class FitAddon implements ITerminalAddon {
|
||||||
|
private _terminal: Terminal | undefined;
|
||||||
|
|
||||||
|
constructor() {}
|
||||||
|
|
||||||
|
public activate(terminal: Terminal): void {
|
||||||
|
this._terminal = terminal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public dispose(): void {}
|
||||||
|
|
||||||
|
public fit(): void {
|
||||||
|
const dims = this.proposeDimensions();
|
||||||
|
if (!dims || !this._terminal) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Remove reliance on private API
|
||||||
|
const core = (<any>this._terminal)._core;
|
||||||
|
|
||||||
|
// Force a full render
|
||||||
|
if (this._terminal.rows !== dims.rows || this._terminal.cols !== dims.cols) {
|
||||||
|
core._renderCoordinator.clear();
|
||||||
|
this._terminal.resize(dims.cols, dims.rows);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public proposeDimensions(): ITerminalDimensions | undefined {
|
||||||
|
if (!this._terminal) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this._terminal.element.parentElement) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Remove reliance on private API
|
||||||
|
const core = (<any>this._terminal)._core;
|
||||||
|
|
||||||
|
const parentElementStyle = window.getComputedStyle(this._terminal.element.parentElement);
|
||||||
|
const parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));
|
||||||
|
const parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')));
|
||||||
|
const elementStyle = window.getComputedStyle(this._terminal.element);
|
||||||
|
const elementPadding = {
|
||||||
|
top: parseInt(elementStyle.getPropertyValue('padding-top')),
|
||||||
|
bottom: parseInt(elementStyle.getPropertyValue('padding-bottom')),
|
||||||
|
right: parseInt(elementStyle.getPropertyValue('padding-right')),
|
||||||
|
left: parseInt(elementStyle.getPropertyValue('padding-left'))
|
||||||
|
};
|
||||||
|
const elementPaddingVer = elementPadding.top + elementPadding.bottom;
|
||||||
|
const elementPaddingHor = elementPadding.right + elementPadding.left;
|
||||||
|
const availableHeight = parentElementHeight - elementPaddingVer;
|
||||||
|
const availableWidth = parentElementWidth - elementPaddingHor - core.viewport.scrollBarWidth;
|
||||||
|
const geometry = {
|
||||||
|
cols: Math.floor(availableWidth / core._renderCoordinator.dimensions.actualCellWidth),
|
||||||
|
rows: Math.floor(availableHeight / core._renderCoordinator.dimensions.actualCellHeight)
|
||||||
|
};
|
||||||
|
return geometry;
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,8 @@
|
|||||||
import { Frontend } from './frontend'
|
import { Frontend } from './frontend'
|
||||||
import { Terminal, ITheme } from 'xterm'
|
import { Terminal, ITheme } from 'xterm'
|
||||||
import { fit } from 'xterm/src/addons/fit/fit'
|
import { FitAddon } from './xtermAddonFit'
|
||||||
import { enableLigatures } from 'xterm-addon-ligatures'
|
import { enableLigatures } from 'xterm-addon-ligatures'
|
||||||
import { SearchAddon, ISearchOptions } from './xtermSearchAddon'
|
import { SearchAddon, ISearchOptions } from './xtermSearchAddon'
|
||||||
import 'xterm/lib/xterm.css'
|
|
||||||
import './xterm.css'
|
import './xterm.css'
|
||||||
import deepEqual = require('deep-equal')
|
import deepEqual = require('deep-equal')
|
||||||
|
|
||||||
@ -18,13 +17,13 @@ export class XTermFrontend extends Frontend {
|
|||||||
private configuredTheme: ITheme = {}
|
private configuredTheme: ITheme = {}
|
||||||
private copyOnSelect = false
|
private copyOnSelect = false
|
||||||
private search = new SearchAddon()
|
private search = new SearchAddon()
|
||||||
|
private fitAddon = new FitAddon()
|
||||||
|
private opened = false
|
||||||
|
|
||||||
constructor () {
|
constructor () {
|
||||||
super()
|
super()
|
||||||
this.xterm = new Terminal({
|
this.xterm = new Terminal({
|
||||||
allowTransparency: true,
|
allowTransparency: true,
|
||||||
enableBold: true,
|
|
||||||
experimentalCharAtlas: 'dynamic',
|
|
||||||
})
|
})
|
||||||
this.xtermCore = (this.xterm as any)._core
|
this.xtermCore = (this.xterm as any)._core
|
||||||
|
|
||||||
@ -42,6 +41,7 @@ export class XTermFrontend extends Frontend {
|
|||||||
this.copySelection()
|
this.copySelection()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
this.xterm.loadAddon(this.fitAddon)
|
||||||
|
|
||||||
const keyboardEventHandler = (name: string, event: KeyboardEvent) => {
|
const keyboardEventHandler = (name: string, event: KeyboardEvent) => {
|
||||||
this.hotkeysService.pushKeystroke(name, event)
|
this.hotkeysService.pushKeystroke(name, event)
|
||||||
@ -74,7 +74,7 @@ export class XTermFrontend extends Frontend {
|
|||||||
|
|
||||||
this.resizeHandler = () => {
|
this.resizeHandler = () => {
|
||||||
try {
|
try {
|
||||||
fit(this.xterm)
|
this.fitAddon.fit()
|
||||||
} catch {
|
} catch {
|
||||||
// tends to throw when element wasn't shown yet
|
// tends to throw when element wasn't shown yet
|
||||||
}
|
}
|
||||||
@ -88,6 +88,12 @@ export class XTermFrontend extends Frontend {
|
|||||||
|
|
||||||
attach (host: HTMLElement): void {
|
attach (host: HTMLElement): void {
|
||||||
this.xterm.open(host)
|
this.xterm.open(host)
|
||||||
|
this.opened = true
|
||||||
|
;(this.xterm as any).loadWebgl(false)
|
||||||
|
if (this.configService.store.terminal.ligatures) {
|
||||||
|
enableLigatures(this.xterm)
|
||||||
|
}
|
||||||
|
|
||||||
this.ready.next(null)
|
this.ready.next(null)
|
||||||
this.ready.complete()
|
this.ready.complete()
|
||||||
|
|
||||||
@ -192,7 +198,7 @@ export class XTermFrontend extends Frontend {
|
|||||||
this.configuredTheme = theme
|
this.configuredTheme = theme
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.terminal.ligatures && this.xterm.element) {
|
if (this.opened && config.terminal.ligatures) {
|
||||||
enableLigatures(this.xterm)
|
enableLigatures(this.xterm)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ export class Session extends BaseSession {
|
|||||||
|
|
||||||
this.open = true
|
this.open = true
|
||||||
|
|
||||||
this.pty.on('data-buffered', data => {
|
this.pty.onData(data => {
|
||||||
data = this.processOSC1337(data)
|
data = this.processOSC1337(data)
|
||||||
this.emitOutput(data)
|
this.emitOutput(data)
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
@ -321,7 +321,7 @@ export class SessionsService {
|
|||||||
constructor (
|
constructor (
|
||||||
log: LogService,
|
log: LogService,
|
||||||
) {
|
) {
|
||||||
require('../bufferizedPTY')(nodePTY)
|
//require('../bufferizedPTY')(nodePTY)
|
||||||
this.logger = log.create('sessions')
|
this.logger = log.create('sessions')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,10 +254,9 @@ xterm-addon-ligatures@^0.1.0-beta-2:
|
|||||||
font-finder "^1.0.2"
|
font-finder "^1.0.2"
|
||||||
font-ligatures "^1.3.1"
|
font-ligatures "^1.3.1"
|
||||||
|
|
||||||
xterm@3.14.2:
|
"xterm@https://registry.npmjs.org/@terminus-term/xterm/-/xterm-3.14.1.tgz":
|
||||||
version "3.14.2"
|
version "3.14.1"
|
||||||
resolved "https://registry.yarnpkg.com/xterm/-/xterm-3.14.2.tgz#f1285288bdc7df7056ef4bde64311900748c3e5d"
|
resolved "https://registry.npmjs.org/@terminus-term/xterm/-/xterm-3.14.1.tgz#f3f7c0b4726fc60c22af17bac95c1b8058eca317"
|
||||||
integrity sha512-L50XMhfAC953/3EzmL+lq8jyD6CQ3SZ83UDrxalpKzE3d7Wo5JqehSd4yOrHYZYrijOT3pX6kBsZEI9uuZ1lmQ==
|
|
||||||
|
|
||||||
yallist@^2.1.2:
|
yallist@^2.1.2:
|
||||||
version "2.1.2"
|
version "2.1.2"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user