mirror of
https://github.com/Eugeny/tabby.git
synced 2025-10-04 14:04:56 +00:00
more platform changes
This commit is contained in:
@@ -3,7 +3,7 @@ import { first } from 'rxjs/operators'
|
||||
import colors from 'ansi-colors'
|
||||
import { NgZone, OnInit, OnDestroy, Injector, ViewChild, HostBinding, Input, ElementRef, InjectFlags } from '@angular/core'
|
||||
import { trigger, transition, style, animate, AnimationTriggerMetadata } from '@angular/animations'
|
||||
import { AppService, ConfigService, BaseTabComponent, ElectronService, HostAppService, HotkeysService, NotificationsService, Platform, LogService, Logger, TabContextMenuItemProvider, SplitTabComponent, SubscriptionContainer, MenuItemOptions, PlatformService } from 'terminus-core'
|
||||
import { AppService, ConfigService, BaseTabComponent, HostAppService, HotkeysService, NotificationsService, Platform, LogService, Logger, TabContextMenuItemProvider, SplitTabComponent, SubscriptionContainer, MenuItemOptions, PlatformService } from 'terminus-core'
|
||||
|
||||
import { BaseSession } from '../session'
|
||||
import { TerminalFrontendService } from '../services/terminalFrontend.service'
|
||||
@@ -82,7 +82,6 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
||||
protected app: AppService
|
||||
protected hostApp: HostAppService
|
||||
protected hotkeys: HotkeysService
|
||||
protected electron: ElectronService
|
||||
protected platform: PlatformService
|
||||
protected terminalContainersService: TerminalFrontendService
|
||||
protected notifications: NotificationsService
|
||||
@@ -135,7 +134,6 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
||||
this.app = injector.get(AppService)
|
||||
this.hostApp = injector.get(HostAppService)
|
||||
this.hotkeys = injector.get(HotkeysService)
|
||||
this.electron = injector.get(ElectronService)
|
||||
this.platform = injector.get(PlatformService)
|
||||
this.terminalContainersService = injector.get(TerminalFrontendService)
|
||||
this.notifications = injector.get(NotificationsService)
|
||||
@@ -359,7 +357,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
||||
}
|
||||
|
||||
async paste (): Promise<void> {
|
||||
let data = this.electron.clipboard.readText()
|
||||
let data = this.platform.readClipboard()
|
||||
if (this.config.store.terminal.bracketedPaste) {
|
||||
data = `\x1b[200~${data}\x1b[201~`
|
||||
}
|
||||
@@ -374,15 +372,13 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
||||
|
||||
if (data.includes('\r') && this.config.store.terminal.warnOnMultilinePaste) {
|
||||
const buttons = ['Paste', 'Cancel']
|
||||
const result = (await this.electron.showMessageBox(
|
||||
this.hostApp.getWindow(),
|
||||
const result = (await this.platform.showMessageBox(
|
||||
{
|
||||
type: 'warning',
|
||||
detail: data,
|
||||
message: `Paste multiple lines?`,
|
||||
buttons,
|
||||
defaultId: 0,
|
||||
cancelId: 1,
|
||||
}
|
||||
)).response
|
||||
if (result === 1) {
|
||||
@@ -463,7 +459,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
||||
cwd = await this.session.getWorkingDirectory()
|
||||
}
|
||||
if (cwd) {
|
||||
this.electron.clipboard.writeText(cwd)
|
||||
this.platform.setClipboard({ text: cwd })
|
||||
this.notifications.notice('Copied')
|
||||
} else {
|
||||
this.notifications.error('Shell does not support current path detection')
|
||||
|
@@ -2,7 +2,7 @@
|
||||
import deepEqual from 'deep-equal'
|
||||
|
||||
import { Component, Inject, Input, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core'
|
||||
import { ConfigService, HostAppService, ElectronService } from 'terminus-core'
|
||||
import { ConfigService, PlatformService } from 'terminus-core'
|
||||
import { TerminalColorSchemeProvider } from '../api/colorSchemeProvider'
|
||||
import { TerminalColorScheme } from '../api/interfaces'
|
||||
|
||||
@@ -26,8 +26,7 @@ export class ColorSchemeSettingsTabComponent {
|
||||
constructor (
|
||||
@Inject(TerminalColorSchemeProvider) private colorSchemeProviders: TerminalColorSchemeProvider[],
|
||||
private changeDetector: ChangeDetectorRef,
|
||||
private hostApp: HostAppService,
|
||||
private electron: ElectronService,
|
||||
private platform: PlatformService,
|
||||
public config: ConfigService,
|
||||
) { }
|
||||
|
||||
@@ -76,8 +75,7 @@ export class ColorSchemeSettingsTabComponent {
|
||||
}
|
||||
|
||||
async deleteScheme (scheme: TerminalColorScheme) {
|
||||
if ((await this.electron.showMessageBox(
|
||||
this.hostApp.getWindow(),
|
||||
if ((await this.platform.showMessageBox(
|
||||
{
|
||||
type: 'warning',
|
||||
message: `Delete "${scheme.name}"?`,
|
||||
|
@@ -2,13 +2,14 @@ import * as fs from 'fs'
|
||||
import { Injectable } from '@angular/core'
|
||||
import { TerminalDecorator } from '../api/decorator'
|
||||
import { BaseTerminalTabComponent } from '../api/baseTerminalTab.component'
|
||||
import { ElectronService, HostAppService } from 'terminus-core'
|
||||
import { ElectronService, HostAppService, PlatformService } from 'terminus-core'
|
||||
|
||||
/** @hidden */
|
||||
@Injectable()
|
||||
export class DebugDecorator extends TerminalDecorator {
|
||||
constructor (
|
||||
private electron: ElectronService,
|
||||
private platform: PlatformService,
|
||||
private hostApp: HostAppService,
|
||||
) {
|
||||
super()
|
||||
@@ -93,7 +94,7 @@ export class DebugDecorator extends TerminalDecorator {
|
||||
|
||||
private async doCopyState (terminal: BaseTerminalTabComponent) {
|
||||
const data = '```' + JSON.stringify(terminal.frontend!.saveState()) + '```'
|
||||
this.electron.clipboard.writeText(data)
|
||||
this.platform.setClipboard({ text: data })
|
||||
}
|
||||
|
||||
private async doLoadState (terminal: BaseTerminalTabComponent) {
|
||||
@@ -104,7 +105,7 @@ export class DebugDecorator extends TerminalDecorator {
|
||||
}
|
||||
|
||||
private async doPasteState (terminal: BaseTerminalTabComponent) {
|
||||
let data = this.electron.clipboard.readText()
|
||||
let data = this.platform.readClipboard()
|
||||
if (data) {
|
||||
if (data.startsWith('`')) {
|
||||
data = data.substring(3, data.length - 3)
|
||||
@@ -119,7 +120,7 @@ export class DebugDecorator extends TerminalDecorator {
|
||||
|
||||
private async doCopyOutput (buffer: string) {
|
||||
const data = '```' + JSON.stringify(buffer) + '```'
|
||||
this.electron.clipboard.writeText(data)
|
||||
this.platform.setClipboard({ text: data })
|
||||
}
|
||||
|
||||
private async doLoadOutput (terminal: BaseTerminalTabComponent) {
|
||||
@@ -130,7 +131,7 @@ export class DebugDecorator extends TerminalDecorator {
|
||||
}
|
||||
|
||||
private async doPasteOutput (terminal: BaseTerminalTabComponent) {
|
||||
let data = this.electron.clipboard.readText()
|
||||
let data = this.platform.readClipboard()
|
||||
if (data) {
|
||||
if (data.startsWith('`')) {
|
||||
data = data.substring(3, data.length - 3)
|
||||
|
Reference in New Issue
Block a user