|
|
@@ -1,10 +1,11 @@
|
|
|
import deepEqual from 'deep-equal'
|
|
|
import { BehaviorSubject, filter, firstValueFrom, takeUntil } from 'rxjs'
|
|
|
import { Injector } from '@angular/core'
|
|
|
-import { ConfigService, getCSSFontFamily, getWindows10Build, HostAppService, HotkeysService, Platform, PlatformService, ThemesService } from 'tabby-core'
|
|
|
+import { ConfigService, getCSSFontFamily, getWindows10Build, HostAppService, HotkeysService, NotificationsService, Platform, PlatformService, ThemesService, TranslateService } from 'tabby-core'
|
|
|
import { Frontend, SearchOptions, SearchState } from './frontend'
|
|
|
import { Terminal, ITheme } from '@xterm/xterm'
|
|
|
import { FitAddon } from '@xterm/addon-fit'
|
|
|
+import { ClipboardAddon } from '@xterm/addon-clipboard'
|
|
|
import { LigaturesAddon } from '@xterm/addon-ligatures'
|
|
|
import { ISearchOptions, SearchAddon } from '@xterm/addon-search'
|
|
|
import { WebglAddon } from '@xterm/addon-webgl'
|
|
|
@@ -87,6 +88,8 @@ export class XTermFrontend extends Frontend {
|
|
|
private platformService: PlatformService
|
|
|
private hostApp: HostAppService
|
|
|
private themes: ThemesService
|
|
|
+ private notifications: NotificationsService
|
|
|
+ private translate: TranslateService
|
|
|
|
|
|
constructor (injector: Injector) {
|
|
|
super(injector)
|
|
|
@@ -95,11 +98,18 @@ export class XTermFrontend extends Frontend {
|
|
|
this.platformService = injector.get(PlatformService)
|
|
|
this.hostApp = injector.get(HostAppService)
|
|
|
this.themes = injector.get(ThemesService)
|
|
|
+ this.notifications = injector.get(NotificationsService)
|
|
|
+ this.translate = injector.get(TranslateService)
|
|
|
|
|
|
this.xterm = new Terminal({
|
|
|
allowTransparency: true,
|
|
|
allowProposedApi: true,
|
|
|
- overviewRulerWidth: 8,
|
|
|
+ overviewRuler: {
|
|
|
+ width: 8,
|
|
|
+ showBottomBorder: false,
|
|
|
+ showTopBorder: false,
|
|
|
+ },
|
|
|
+ reflowCursorLine: true,
|
|
|
windowsPty: process.platform === 'win32' ? {
|
|
|
backend: this.configService.store.terminal.useConPTY ? 'conpty' : 'winpty',
|
|
|
buildNumber: getWindows10Build(),
|
|
|
@@ -135,6 +145,15 @@ export class XTermFrontend extends Frontend {
|
|
|
this.xterm.loadAddon(this.fitAddon)
|
|
|
this.xterm.loadAddon(this.serializeAddon)
|
|
|
this.xterm.loadAddon(new Unicode11Addon())
|
|
|
+ this.xterm.loadAddon(new ClipboardAddon(undefined, {
|
|
|
+ readText: async () => {
|
|
|
+ return this.platformService.readClipboard()
|
|
|
+ },
|
|
|
+ writeText: async (_, text) => {
|
|
|
+ this.platformService.setClipboard({ text })
|
|
|
+ this.notifications.notice(this.translate.instant('Copied'))
|
|
|
+ },
|
|
|
+ }))
|
|
|
this.xterm.unicode.activeVersion = '11'
|
|
|
|
|
|
if (this.configService.store.terminal.sixel) {
|
|
|
@@ -200,7 +219,7 @@ export class XTermFrontend extends Frontend {
|
|
|
try {
|
|
|
if (this.xterm.element && getComputedStyle(this.xterm.element).getPropertyValue('height') !== 'auto') {
|
|
|
this.fitAddon.fit()
|
|
|
- this.xtermCore.viewport._refresh()
|
|
|
+ this.xterm.refresh(0, this.xterm.rows - 1)
|
|
|
}
|
|
|
} catch (e) {
|
|
|
// tends to throw when element wasn't shown yet
|
|
|
@@ -220,6 +239,7 @@ export class XTermFrontend extends Frontend {
|
|
|
const altBufferActive = this.xterm.buffer.active.type === 'alternate'
|
|
|
this.alternateScreenActive.next(altBufferActive)
|
|
|
})
|
|
|
+
|
|
|
}
|
|
|
|
|
|
async attach (host: HTMLElement, profile: BaseTerminalProfile): Promise<void> {
|
|
|
@@ -377,12 +397,17 @@ export class XTermFrontend extends Frontend {
|
|
|
background: getTerminalBackgroundColor(this.configService, this.themes, scheme) ?? '#00000000',
|
|
|
cursor: scheme.cursor,
|
|
|
cursorAccent: scheme.cursorAccent,
|
|
|
+ overviewRulerBorder: scheme.background,
|
|
|
}
|
|
|
|
|
|
for (let i = 0; i < COLOR_NAMES.length; i++) {
|
|
|
theme[COLOR_NAMES[i]] = scheme.colors[i]
|
|
|
}
|
|
|
|
|
|
+ theme.scrollbarSliderBackground = theme.brightBlack
|
|
|
+ theme.scrollbarSliderHoverBackground = theme.brightBlack
|
|
|
+ theme.scrollbarSliderHoverBackground = theme.brightBlack
|
|
|
+
|
|
|
if (!deepEqual(this.configuredTheme, theme)) {
|
|
|
this.xterm.options.theme = theme
|
|
|
this.configuredTheme = theme
|
|
|
@@ -404,9 +429,12 @@ export class XTermFrontend extends Frontend {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
- this.xtermCore.browser.isWindows = this.hostApp.platform === Platform.Windows
|
|
|
- this.xtermCore.browser.isLinux = this.hostApp.platform === Platform.Linux
|
|
|
- this.xtermCore.browser.isMac = this.hostApp.platform === Platform.macOS
|
|
|
+ this.xtermCore.browser = {
|
|
|
+ ...this.xtermCore.browser,
|
|
|
+ isWindows: this.hostApp.platform === Platform.Windows,
|
|
|
+ isLinux: this.hostApp.platform === Platform.Linux,
|
|
|
+ isMac: this.hostApp.platform === Platform.macOS,
|
|
|
+ }
|
|
|
|
|
|
this.xterm.options.fontFamily = getCSSFontFamily(config)
|
|
|
this.xterm.options.cursorStyle = {
|