mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-25 21:58:33 +00:00
naming
This commit is contained in:
terminus-terminal/src
@@ -7,10 +7,10 @@ import { AppService, ConfigService, BaseTabComponent, ElectronService, HostAppSe
|
|||||||
import { IShell } from '../api'
|
import { IShell } from '../api'
|
||||||
import { Session, SessionsService } from '../services/sessions.service'
|
import { Session, SessionsService } from '../services/sessions.service'
|
||||||
import { TerminalService } from '../services/terminal.service'
|
import { TerminalService } from '../services/terminal.service'
|
||||||
import { TerminalContainersService } from '../services/terminalContainers.service'
|
import { TerminalFrontendService } from '../services/terminalFrontend.service'
|
||||||
|
|
||||||
import { TerminalDecorator, ResizeEvent, SessionOptions } from '../api'
|
import { TerminalDecorator, ResizeEvent, SessionOptions } from '../api'
|
||||||
import { TermContainer } from '../terminalContainers/termContainer'
|
import { Frontend } from '../frontends/frontend'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'terminalTab',
|
selector: 'terminalTab',
|
||||||
@@ -29,7 +29,7 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
@Input() zoom = 0
|
@Input() zoom = 0
|
||||||
@ViewChild('content') content
|
@ViewChild('content') content
|
||||||
@HostBinding('style.background-color') backgroundColor: string
|
@HostBinding('style.background-color') backgroundColor: string
|
||||||
termContainer: TermContainer
|
frontend: Frontend
|
||||||
sessionCloseSubscription: Subscription
|
sessionCloseSubscription: Subscription
|
||||||
hotkeysSubscription: Subscription
|
hotkeysSubscription: Subscription
|
||||||
htermVisible = false
|
htermVisible = false
|
||||||
@@ -39,10 +39,10 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
private contextMenu: any
|
private contextMenu: any
|
||||||
private termContainerSubscriptions: Subscription[] = []
|
private termContainerSubscriptions: Subscription[] = []
|
||||||
|
|
||||||
get input$ (): Observable<string> { return this.termContainer.input$ }
|
get input$ (): Observable<string> { return this.frontend.input$ }
|
||||||
get output$ (): Observable<string> { return this.output }
|
get output$ (): Observable<string> { return this.output }
|
||||||
get resize$ (): Observable<ResizeEvent> { return this.termContainer.resize$ }
|
get resize$ (): Observable<ResizeEvent> { return this.frontend.resize$ }
|
||||||
get alternateScreenActive$ (): Observable<boolean> { return this.termContainer.alternateScreenActive$ }
|
get alternateScreenActive$ (): Observable<boolean> { return this.frontend.alternateScreenActive$ }
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private zone: NgZone,
|
private zone: NgZone,
|
||||||
@@ -52,7 +52,7 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
private sessions: SessionsService,
|
private sessions: SessionsService,
|
||||||
private electron: ElectronService,
|
private electron: ElectronService,
|
||||||
private terminalService: TerminalService,
|
private terminalService: TerminalService,
|
||||||
private terminalContainersService: TerminalContainersService,
|
private terminalContainersService: TerminalFrontendService,
|
||||||
public config: ConfigService,
|
public config: ConfigService,
|
||||||
private toastr: ToastrService,
|
private toastr: ToastrService,
|
||||||
@Optional() @Inject(TerminalDecorator) private decorators: TerminalDecorator[],
|
@Optional() @Inject(TerminalDecorator) private decorators: TerminalDecorator[],
|
||||||
@@ -69,23 +69,23 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
}
|
}
|
||||||
switch (hotkey) {
|
switch (hotkey) {
|
||||||
case 'ctrl-c':
|
case 'ctrl-c':
|
||||||
if (this.termContainer.getSelection()) {
|
if (this.frontend.getSelection()) {
|
||||||
this.termContainer.copySelection()
|
this.frontend.copySelection()
|
||||||
this.termContainer.clearSelection()
|
this.frontend.clearSelection()
|
||||||
this.toastr.info('Copied')
|
this.toastr.info('Copied')
|
||||||
} else {
|
} else {
|
||||||
this.sendInput('\x03')
|
this.sendInput('\x03')
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 'copy':
|
case 'copy':
|
||||||
this.termContainer.copySelection()
|
this.frontend.copySelection()
|
||||||
this.toastr.info('Copied')
|
this.toastr.info('Copied')
|
||||||
break
|
break
|
||||||
case 'paste':
|
case 'paste':
|
||||||
this.paste()
|
this.paste()
|
||||||
break
|
break
|
||||||
case 'clear':
|
case 'clear':
|
||||||
this.termContainer.clear()
|
this.frontend.clear()
|
||||||
break
|
break
|
||||||
case 'zoom-in':
|
case 'zoom-in':
|
||||||
this.zoomIn()
|
this.zoomIn()
|
||||||
@@ -138,7 +138,7 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
})
|
})
|
||||||
|
|
||||||
this.sessionCloseSubscription = this.session.closed$.subscribe(() => {
|
this.sessionCloseSubscription = this.session.closed$.subscribe(() => {
|
||||||
this.termContainer.destroy()
|
this.frontend.destroy()
|
||||||
this.app.closeTab(this)
|
this.app.closeTab(this)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -153,16 +153,16 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
ngOnInit () {
|
ngOnInit () {
|
||||||
this.focused$.subscribe(() => {
|
this.focused$.subscribe(() => {
|
||||||
this.configure()
|
this.configure()
|
||||||
this.termContainer.focus()
|
this.frontend.focus()
|
||||||
})
|
})
|
||||||
|
|
||||||
this.termContainer = this.terminalContainersService.getContainer(this.session)
|
this.frontend = this.terminalContainersService.getFrontend(this.session)
|
||||||
|
|
||||||
this.termContainer.ready$.subscribe(() => {
|
this.frontend.ready$.subscribe(() => {
|
||||||
this.htermVisible = true
|
this.htermVisible = true
|
||||||
})
|
})
|
||||||
|
|
||||||
this.termContainer.resize$.pipe(first()).subscribe(async ({columns, rows}) => {
|
this.frontend.resize$.pipe(first()).subscribe(async ({columns, rows}) => {
|
||||||
if (!this.session.open) {
|
if (!this.session.open) {
|
||||||
this.initializeSession(columns, rows)
|
this.initializeSession(columns, rows)
|
||||||
}
|
}
|
||||||
@@ -174,8 +174,8 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
this.session.releaseInitialDataBuffer()
|
this.session.releaseInitialDataBuffer()
|
||||||
})
|
})
|
||||||
|
|
||||||
this.termContainer.configure(this.config.store)
|
this.frontend.configure(this.config.store)
|
||||||
this.termContainer.attach(this.content.nativeElement)
|
this.frontend.attach(this.content.nativeElement)
|
||||||
this.attachTermContainerHandlers()
|
this.attachTermContainerHandlers()
|
||||||
|
|
||||||
this.configure()
|
this.configure()
|
||||||
@@ -190,9 +190,9 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
})
|
})
|
||||||
}, 1000)
|
}, 1000)
|
||||||
|
|
||||||
this.termContainer.bell$.subscribe(() => {
|
this.frontend.bell$.subscribe(() => {
|
||||||
if (this.config.store.terminal.bell === 'visual') {
|
if (this.config.store.terminal.bell === 'visual') {
|
||||||
this.termContainer.visualBell()
|
this.frontend.visualBell()
|
||||||
}
|
}
|
||||||
if (this.config.store.terminal.bell === 'audible') {
|
if (this.config.store.terminal.bell === 'audible') {
|
||||||
this.bellPlayer.play()
|
this.bellPlayer.play()
|
||||||
@@ -213,7 +213,7 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
click: () => {
|
click: () => {
|
||||||
this.zone.run(() => {
|
this.zone.run(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.termContainer.copySelection()
|
this.frontend.copySelection()
|
||||||
this.toastr.info('Copied')
|
this.toastr.info('Copied')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -240,12 +240,12 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
attachTermContainerHandlers () {
|
attachTermContainerHandlers () {
|
||||||
this.detachTermContainerHandlers()
|
this.detachTermContainerHandlers()
|
||||||
this.termContainerSubscriptions = [
|
this.termContainerSubscriptions = [
|
||||||
this.termContainer.title$.subscribe(title => this.zone.run(() => this.setTitle(title))),
|
this.frontend.title$.subscribe(title => this.zone.run(() => this.setTitle(title))),
|
||||||
|
|
||||||
this.focused$.subscribe(() => this.termContainer.enableResizing = true),
|
this.focused$.subscribe(() => this.frontend.enableResizing = true),
|
||||||
this.blurred$.subscribe(() => this.termContainer.enableResizing = false),
|
this.blurred$.subscribe(() => this.frontend.enableResizing = false),
|
||||||
|
|
||||||
this.termContainer.mouseEvent$.subscribe(event => {
|
this.frontend.mouseEvent$.subscribe(event => {
|
||||||
if (event.type === 'mousedown') {
|
if (event.type === 'mousedown') {
|
||||||
if (event.which === 3) {
|
if (event.which === 3) {
|
||||||
if (this.config.store.terminal.rightClick === 'menu') {
|
if (this.config.store.terminal.rightClick === 'menu') {
|
||||||
@@ -275,11 +275,11 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
this.termContainer.input$.subscribe(data => {
|
this.frontend.input$.subscribe(data => {
|
||||||
this.sendInput(data)
|
this.sendInput(data)
|
||||||
}),
|
}),
|
||||||
|
|
||||||
this.termContainer.resize$.subscribe(({columns, rows}) => {
|
this.frontend.resize$.subscribe(({columns, rows}) => {
|
||||||
console.log(`Resizing to ${columns}x${rows}`)
|
console.log(`Resizing to ${columns}x${rows}`)
|
||||||
this.zone.run(() => {
|
this.zone.run(() => {
|
||||||
if (this.session.open) {
|
if (this.session.open) {
|
||||||
@@ -303,7 +303,7 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
} else {
|
} else {
|
||||||
this.setProgress(null)
|
this.setProgress(null)
|
||||||
}
|
}
|
||||||
this.termContainer.write(data)
|
this.frontend.write(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
paste () {
|
paste () {
|
||||||
@@ -320,7 +320,7 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
configure (): void {
|
configure (): void {
|
||||||
this.termContainer.configure(this.config.store)
|
this.frontend.configure(this.config.store)
|
||||||
|
|
||||||
if (this.config.store.terminal.background === 'colorScheme') {
|
if (this.config.store.terminal.background === 'colorScheme') {
|
||||||
if (this.config.store.terminal.colorScheme.background) {
|
if (this.config.store.terminal.colorScheme.background) {
|
||||||
@@ -333,21 +333,21 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
|
|
||||||
zoomIn () {
|
zoomIn () {
|
||||||
this.zoom++
|
this.zoom++
|
||||||
this.termContainer.setZoom(this.zoom)
|
this.frontend.setZoom(this.zoom)
|
||||||
}
|
}
|
||||||
|
|
||||||
zoomOut () {
|
zoomOut () {
|
||||||
this.zoom--
|
this.zoom--
|
||||||
this.termContainer.setZoom(this.zoom)
|
this.frontend.setZoom(this.zoom)
|
||||||
}
|
}
|
||||||
|
|
||||||
resetZoom () {
|
resetZoom () {
|
||||||
this.zoom = 0
|
this.zoom = 0
|
||||||
this.termContainer.setZoom(this.zoom)
|
this.frontend.setZoom(this.zoom)
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy () {
|
ngOnDestroy () {
|
||||||
this.termContainer.detach(this.content.nativeElement)
|
this.frontend.detach(this.content.nativeElement)
|
||||||
this.detachTermContainerHandlers()
|
this.detachTermContainerHandlers()
|
||||||
this.config.enabledServices(this.decorators).forEach(decorator => {
|
this.config.enabledServices(this.decorators).forEach(decorator => {
|
||||||
decorator.detach(this)
|
decorator.detach(this)
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { Observable, Subject, AsyncSubject, ReplaySubject, BehaviorSubject } from 'rxjs'
|
import { Observable, Subject, AsyncSubject, ReplaySubject, BehaviorSubject } from 'rxjs'
|
||||||
import { ResizeEvent } from '../api'
|
import { ResizeEvent } from '../api'
|
||||||
|
|
||||||
export abstract class TermContainer {
|
export abstract class Frontend {
|
||||||
enableResizing = true
|
enableResizing = true
|
||||||
protected ready = new AsyncSubject<void>()
|
protected ready = new AsyncSubject<void>()
|
||||||
protected title = new ReplaySubject<string>(1)
|
protected title = new ReplaySubject<string>(1)
|
@@ -1,7 +1,7 @@
|
|||||||
import { TermContainer } from './termContainer'
|
import { Frontend } from './frontend'
|
||||||
import { hterm, preferenceManager } from '../hterm'
|
import { hterm, preferenceManager } from '../hterm'
|
||||||
|
|
||||||
export class HTermContainer extends TermContainer {
|
export class HTermFrontend extends Frontend {
|
||||||
term: any
|
term: any
|
||||||
io: any
|
io: any
|
||||||
private htermIframe: HTMLElement
|
private htermIframe: HTMLElement
|
@@ -1,4 +1,4 @@
|
|||||||
import { TermContainer } from './termContainer'
|
import { Frontend } from './frontend'
|
||||||
import { Terminal, ITheme } from 'xterm'
|
import { Terminal, ITheme } from 'xterm'
|
||||||
import * as fit from 'xterm/lib/addons/fit/fit'
|
import * as fit from 'xterm/lib/addons/fit/fit'
|
||||||
import 'xterm/dist/xterm.css'
|
import 'xterm/dist/xterm.css'
|
||||||
@@ -6,7 +6,7 @@ import deepEqual = require('deep-equal')
|
|||||||
|
|
||||||
Terminal.applyAddon(fit)
|
Terminal.applyAddon(fit)
|
||||||
|
|
||||||
export class XTermContainer extends TermContainer {
|
export class XTermFrontend extends Frontend {
|
||||||
enableResizing = true
|
enableResizing = true
|
||||||
xterm: Terminal
|
xterm: Terminal
|
||||||
private configuredFontSize = 0
|
private configuredFontSize = 0
|
@@ -13,8 +13,8 @@ import { TerminalSettingsTabComponent } from './components/terminalSettingsTab.c
|
|||||||
import { ColorPickerComponent } from './components/colorPicker.component'
|
import { ColorPickerComponent } from './components/colorPicker.component'
|
||||||
|
|
||||||
import { SessionsService, BaseSession } from './services/sessions.service'
|
import { SessionsService, BaseSession } from './services/sessions.service'
|
||||||
|
import { TerminalFrontendService } from './services/terminalFrontend.service'
|
||||||
import { TerminalService } from './services/terminal.service'
|
import { TerminalService } from './services/terminal.service'
|
||||||
import { TerminalContainersService } from './services/terminalContainers.service'
|
|
||||||
|
|
||||||
import { ScreenPersistenceProvider } from './persistence/screen'
|
import { ScreenPersistenceProvider } from './persistence/screen'
|
||||||
import { TMuxPersistenceProvider } from './persistence/tmux'
|
import { TMuxPersistenceProvider } from './persistence/tmux'
|
||||||
@@ -50,8 +50,8 @@ import { hterm } from './hterm'
|
|||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
SessionsService,
|
SessionsService,
|
||||||
|
TerminalFrontendService,
|
||||||
TerminalService,
|
TerminalService,
|
||||||
TerminalContainersService,
|
|
||||||
|
|
||||||
{ provide: ToolbarButtonProvider, useClass: ButtonProvider, multi: true },
|
{ provide: ToolbarButtonProvider, useClass: ButtonProvider, multi: true },
|
||||||
{ provide: TabRecoveryProvider, useClass: RecoveryProvider, multi: true },
|
{ provide: TabRecoveryProvider, useClass: RecoveryProvider, multi: true },
|
||||||
@@ -125,4 +125,4 @@ export default class TerminalModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export * from './api'
|
export * from './api'
|
||||||
export { TerminalService, BaseSession, TerminalTabComponent, TerminalContainersService }
|
export { TerminalService, BaseSession, TerminalTabComponent, TerminalFrontendService }
|
||||||
|
@@ -10,10 +10,10 @@ export class PathDropDecorator extends TerminalDecorator {
|
|||||||
attach (terminal: TerminalTabComponent): void {
|
attach (terminal: TerminalTabComponent): void {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.subscriptions = [
|
this.subscriptions = [
|
||||||
terminal.termContainer.dragOver$.subscribe(event => {
|
terminal.frontend.dragOver$.subscribe(event => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
}),
|
}),
|
||||||
terminal.termContainer.drop$.subscribe(event => {
|
terminal.frontend.drop$.subscribe(event => {
|
||||||
for (let file of event.dataTransfer.files as any) {
|
for (let file of event.dataTransfer.files as any) {
|
||||||
this.injectPath(terminal, file.path)
|
this.injectPath(terminal, file.path)
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
const psNode = require('ps-node')
|
import psNode = require('ps-node')
|
||||||
let nodePTY
|
let nodePTY
|
||||||
import * as fs from 'mz/fs'
|
import * as fs from 'mz/fs'
|
||||||
import { Observable, Subject } from 'rxjs'
|
import { Observable, Subject } from 'rxjs'
|
||||||
import { first } from 'rxjs/operators'
|
import { first } from 'rxjs/operators'
|
||||||
import { Injectable, Inject } from '@angular/core'
|
import { Injectable, Inject } from '@angular/core'
|
||||||
import { Logger, LogService, ElectronService, ConfigService } from 'terminus-core'
|
import { Logger, LogService, ConfigService } from 'terminus-core'
|
||||||
import { exec } from 'mz/child_process'
|
import { exec } from 'mz/child_process'
|
||||||
|
|
||||||
import { SessionOptions, SessionPersistenceProvider } from '../api'
|
import { SessionOptions, SessionPersistenceProvider } from '../api'
|
||||||
@@ -202,7 +202,6 @@ export class SessionsService {
|
|||||||
constructor (
|
constructor (
|
||||||
@Inject(SessionPersistenceProvider) private persistenceProviders: SessionPersistenceProvider[],
|
@Inject(SessionPersistenceProvider) private persistenceProviders: SessionPersistenceProvider[],
|
||||||
private config: ConfigService,
|
private config: ConfigService,
|
||||||
electron: ElectronService,
|
|
||||||
log: LogService,
|
log: LogService,
|
||||||
) {
|
) {
|
||||||
nodePTY = require('node-pty-tmp')
|
nodePTY = require('node-pty-tmp')
|
||||||
|
@@ -1,23 +1,23 @@
|
|||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { ConfigService } from 'terminus-core'
|
import { ConfigService } from 'terminus-core'
|
||||||
import { TermContainer } from '../terminalContainers/termContainer'
|
import { Frontend } from '../frontends/frontend'
|
||||||
import { HTermContainer } from '../terminalContainers/htermContainer'
|
import { HTermFrontend } from '../frontends/htermFrontend'
|
||||||
import { XTermContainer } from '../terminalContainers/xtermContainer'
|
import { XTermFrontend } from '../frontends/xtermFrontend'
|
||||||
import { BaseSession } from '../services/sessions.service'
|
import { BaseSession } from '../services/sessions.service'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TerminalContainersService {
|
export class TerminalFrontendService {
|
||||||
private containers = new WeakMap<BaseSession, TermContainer>()
|
private containers = new WeakMap<BaseSession, Frontend>()
|
||||||
|
|
||||||
constructor (private config: ConfigService) { }
|
constructor (private config: ConfigService) { }
|
||||||
|
|
||||||
getContainer (session: BaseSession): TermContainer {
|
getFrontend (session: BaseSession): Frontend {
|
||||||
if (!this.containers.has(session)) {
|
if (!this.containers.has(session)) {
|
||||||
this.containers.set(
|
this.containers.set(
|
||||||
session,
|
session,
|
||||||
(this.config.store.terminal.frontend === 'xterm')
|
(this.config.store.terminal.frontend === 'xterm')
|
||||||
? new XTermContainer()
|
? new XTermFrontend()
|
||||||
: new HTermContainer()
|
: new HTermFrontend()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return this.containers.get(session)
|
return this.containers.get(session)
|
Reference in New Issue
Block a user