|
|
@@ -1,8 +1,8 @@
|
|
|
import { Frontend } from './frontend'
|
|
|
-import { Terminal, ITheme } from '@terminus-term/xterm'
|
|
|
-import * as fit from '@terminus-term/xterm/src/addons/fit/fit'
|
|
|
+import { Terminal, ITheme } from 'xterm'
|
|
|
+import * as fit from 'xterm/src/addons/fit/fit'
|
|
|
import * as ligatures from 'xterm-addon-ligatures-tmp'
|
|
|
-import '@terminus-term/xterm/lib/xterm.css'
|
|
|
+import 'xterm/lib/xterm.css'
|
|
|
import './xterm.css'
|
|
|
import deepEqual = require('deep-equal')
|
|
|
|
|
|
@@ -12,6 +12,7 @@ Terminal.applyAddon(ligatures)
|
|
|
export class XTermFrontend extends Frontend {
|
|
|
enableResizing = true
|
|
|
xterm: Terminal
|
|
|
+ xtermCore: any
|
|
|
private configuredFontSize = 0
|
|
|
private zoom = 0
|
|
|
private resizeHandler: () => void
|
|
|
@@ -24,6 +25,7 @@ export class XTermFrontend extends Frontend {
|
|
|
allowTransparency: true,
|
|
|
enableBold: true,
|
|
|
})
|
|
|
+ this.xtermCore = (this.xterm as any)._core
|
|
|
|
|
|
this.xterm.on('data', data => {
|
|
|
this.input.next(data)
|
|
|
@@ -39,6 +41,19 @@ export class XTermFrontend extends Frontend {
|
|
|
this.copySelection()
|
|
|
}
|
|
|
})
|
|
|
+ this.xterm.attachCustomKeyEventHandler((event: KeyboardEvent) => {
|
|
|
+ if ((event.getModifierState('Control') || event.getModifierState('Meta')) && event.key.toLowerCase() === 'v') {
|
|
|
+ event.preventDefault()
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (event.getModifierState('Meta') && event.key.startsWith('Arrow')) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ })
|
|
|
+
|
|
|
+ this.xtermCore._scrollToBottom = this.xtermCore.scrollToBottom.bind(this.xtermCore)
|
|
|
+ this.xtermCore.scrollToBottom = () => null
|
|
|
}
|
|
|
|
|
|
attach (host: HTMLElement): void {
|
|
|
@@ -88,23 +103,19 @@ export class XTermFrontend extends Frontend {
|
|
|
}
|
|
|
|
|
|
visualBell (): void {
|
|
|
- (this.xterm as any).bell()
|
|
|
+ this.xtermCore.bell()
|
|
|
}
|
|
|
|
|
|
scrollToBottom (): void {
|
|
|
- this.xterm.scrollToBottom()
|
|
|
+ this.xtermCore._scrollToBottom()
|
|
|
}
|
|
|
|
|
|
configure (config: any): void {
|
|
|
- if (this.resizeHandler) {
|
|
|
- setTimeout(() => {
|
|
|
- try {
|
|
|
- this.resizeHandler()
|
|
|
- } catch (e) {
|
|
|
- // fit() might throw if xterm isn't fully attached yet
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
+ setTimeout(() => {
|
|
|
+ if (this.xterm.cols && this.xterm.rows) {
|
|
|
+ this.resizeHandler()
|
|
|
+ }
|
|
|
+ })
|
|
|
this.xterm.setOption('fontFamily', `"${config.terminal.font}", "monospace-fallback", monospace`)
|
|
|
this.xterm.setOption('bellStyle', config.terminal.bell)
|
|
|
this.xterm.setOption('cursorStyle', {
|