From 7af14c5699ace7294de99a9f5e43d60b23e38f2a Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Sun, 26 Aug 2018 13:23:57 +0200 Subject: [PATCH] naming --- .../src/components/terminalTab.component.ts | 68 +++++++++---------- .../frontend.ts} | 2 +- .../htermFrontend.ts} | 4 +- .../xtermFrontend.ts} | 4 +- terminus-terminal/src/index.ts | 6 +- terminus-terminal/src/pathDrop.ts | 4 +- .../src/services/sessions.service.ts | 5 +- ...service.ts => terminalFrontend.service.ts} | 16 ++--- 8 files changed, 54 insertions(+), 55 deletions(-) rename terminus-terminal/src/{terminalContainers/termContainer.ts => frontends/frontend.ts} (98%) rename terminus-terminal/src/{terminalContainers/htermContainer.ts => frontends/htermFrontend.ts} (98%) rename terminus-terminal/src/{terminalContainers/xtermContainer.ts => frontends/xtermFrontend.ts} (97%) rename terminus-terminal/src/services/{terminalContainers.service.ts => terminalFrontend.service.ts} (50%) diff --git a/terminus-terminal/src/components/terminalTab.component.ts b/terminus-terminal/src/components/terminalTab.component.ts index af5c35aa..fd3aac84 100644 --- a/terminus-terminal/src/components/terminalTab.component.ts +++ b/terminus-terminal/src/components/terminalTab.component.ts @@ -7,10 +7,10 @@ import { AppService, ConfigService, BaseTabComponent, ElectronService, HostAppSe import { IShell } from '../api' import { Session, SessionsService } from '../services/sessions.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 { TermContainer } from '../terminalContainers/termContainer' +import { Frontend } from '../frontends/frontend' @Component({ selector: 'terminalTab', @@ -29,7 +29,7 @@ export class TerminalTabComponent extends BaseTabComponent { @Input() zoom = 0 @ViewChild('content') content @HostBinding('style.background-color') backgroundColor: string - termContainer: TermContainer + frontend: Frontend sessionCloseSubscription: Subscription hotkeysSubscription: Subscription htermVisible = false @@ -39,10 +39,10 @@ export class TerminalTabComponent extends BaseTabComponent { private contextMenu: any private termContainerSubscriptions: Subscription[] = [] - get input$ (): Observable { return this.termContainer.input$ } + get input$ (): Observable { return this.frontend.input$ } get output$ (): Observable { return this.output } - get resize$ (): Observable { return this.termContainer.resize$ } - get alternateScreenActive$ (): Observable { return this.termContainer.alternateScreenActive$ } + get resize$ (): Observable { return this.frontend.resize$ } + get alternateScreenActive$ (): Observable { return this.frontend.alternateScreenActive$ } constructor ( private zone: NgZone, @@ -52,7 +52,7 @@ export class TerminalTabComponent extends BaseTabComponent { private sessions: SessionsService, private electron: ElectronService, private terminalService: TerminalService, - private terminalContainersService: TerminalContainersService, + private terminalContainersService: TerminalFrontendService, public config: ConfigService, private toastr: ToastrService, @Optional() @Inject(TerminalDecorator) private decorators: TerminalDecorator[], @@ -69,23 +69,23 @@ export class TerminalTabComponent extends BaseTabComponent { } switch (hotkey) { case 'ctrl-c': - if (this.termContainer.getSelection()) { - this.termContainer.copySelection() - this.termContainer.clearSelection() + if (this.frontend.getSelection()) { + this.frontend.copySelection() + this.frontend.clearSelection() this.toastr.info('Copied') } else { this.sendInput('\x03') } break case 'copy': - this.termContainer.copySelection() + this.frontend.copySelection() this.toastr.info('Copied') break case 'paste': this.paste() break case 'clear': - this.termContainer.clear() + this.frontend.clear() break case 'zoom-in': this.zoomIn() @@ -138,7 +138,7 @@ export class TerminalTabComponent extends BaseTabComponent { }) this.sessionCloseSubscription = this.session.closed$.subscribe(() => { - this.termContainer.destroy() + this.frontend.destroy() this.app.closeTab(this) }) } @@ -153,16 +153,16 @@ export class TerminalTabComponent extends BaseTabComponent { ngOnInit () { this.focused$.subscribe(() => { 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.termContainer.resize$.pipe(first()).subscribe(async ({columns, rows}) => { + this.frontend.resize$.pipe(first()).subscribe(async ({columns, rows}) => { if (!this.session.open) { this.initializeSession(columns, rows) } @@ -174,8 +174,8 @@ export class TerminalTabComponent extends BaseTabComponent { this.session.releaseInitialDataBuffer() }) - this.termContainer.configure(this.config.store) - this.termContainer.attach(this.content.nativeElement) + this.frontend.configure(this.config.store) + this.frontend.attach(this.content.nativeElement) this.attachTermContainerHandlers() this.configure() @@ -190,9 +190,9 @@ export class TerminalTabComponent extends BaseTabComponent { }) }, 1000) - this.termContainer.bell$.subscribe(() => { + this.frontend.bell$.subscribe(() => { if (this.config.store.terminal.bell === 'visual') { - this.termContainer.visualBell() + this.frontend.visualBell() } if (this.config.store.terminal.bell === 'audible') { this.bellPlayer.play() @@ -213,7 +213,7 @@ export class TerminalTabComponent extends BaseTabComponent { click: () => { this.zone.run(() => { setTimeout(() => { - this.termContainer.copySelection() + this.frontend.copySelection() this.toastr.info('Copied') }) }) @@ -240,12 +240,12 @@ export class TerminalTabComponent extends BaseTabComponent { attachTermContainerHandlers () { this.detachTermContainerHandlers() 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.blurred$.subscribe(() => this.termContainer.enableResizing = false), + this.focused$.subscribe(() => this.frontend.enableResizing = true), + this.blurred$.subscribe(() => this.frontend.enableResizing = false), - this.termContainer.mouseEvent$.subscribe(event => { + this.frontend.mouseEvent$.subscribe(event => { if (event.type === 'mousedown') { if (event.which === 3) { 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.termContainer.resize$.subscribe(({columns, rows}) => { + this.frontend.resize$.subscribe(({columns, rows}) => { console.log(`Resizing to ${columns}x${rows}`) this.zone.run(() => { if (this.session.open) { @@ -303,7 +303,7 @@ export class TerminalTabComponent extends BaseTabComponent { } else { this.setProgress(null) } - this.termContainer.write(data) + this.frontend.write(data) } paste () { @@ -320,7 +320,7 @@ export class TerminalTabComponent extends BaseTabComponent { } 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.colorScheme.background) { @@ -333,21 +333,21 @@ export class TerminalTabComponent extends BaseTabComponent { zoomIn () { this.zoom++ - this.termContainer.setZoom(this.zoom) + this.frontend.setZoom(this.zoom) } zoomOut () { this.zoom-- - this.termContainer.setZoom(this.zoom) + this.frontend.setZoom(this.zoom) } resetZoom () { this.zoom = 0 - this.termContainer.setZoom(this.zoom) + this.frontend.setZoom(this.zoom) } ngOnDestroy () { - this.termContainer.detach(this.content.nativeElement) + this.frontend.detach(this.content.nativeElement) this.detachTermContainerHandlers() this.config.enabledServices(this.decorators).forEach(decorator => { decorator.detach(this) diff --git a/terminus-terminal/src/terminalContainers/termContainer.ts b/terminus-terminal/src/frontends/frontend.ts similarity index 98% rename from terminus-terminal/src/terminalContainers/termContainer.ts rename to terminus-terminal/src/frontends/frontend.ts index f52d7e35..253a9d3c 100644 --- a/terminus-terminal/src/terminalContainers/termContainer.ts +++ b/terminus-terminal/src/frontends/frontend.ts @@ -1,7 +1,7 @@ import { Observable, Subject, AsyncSubject, ReplaySubject, BehaviorSubject } from 'rxjs' import { ResizeEvent } from '../api' -export abstract class TermContainer { +export abstract class Frontend { enableResizing = true protected ready = new AsyncSubject() protected title = new ReplaySubject(1) diff --git a/terminus-terminal/src/terminalContainers/htermContainer.ts b/terminus-terminal/src/frontends/htermFrontend.ts similarity index 98% rename from terminus-terminal/src/terminalContainers/htermContainer.ts rename to terminus-terminal/src/frontends/htermFrontend.ts index 42fbd128..5023cae2 100644 --- a/terminus-terminal/src/terminalContainers/htermContainer.ts +++ b/terminus-terminal/src/frontends/htermFrontend.ts @@ -1,7 +1,7 @@ -import { TermContainer } from './termContainer' +import { Frontend } from './frontend' import { hterm, preferenceManager } from '../hterm' -export class HTermContainer extends TermContainer { +export class HTermFrontend extends Frontend { term: any io: any private htermIframe: HTMLElement diff --git a/terminus-terminal/src/terminalContainers/xtermContainer.ts b/terminus-terminal/src/frontends/xtermFrontend.ts similarity index 97% rename from terminus-terminal/src/terminalContainers/xtermContainer.ts rename to terminus-terminal/src/frontends/xtermFrontend.ts index d3799b58..6f6cf129 100644 --- a/terminus-terminal/src/terminalContainers/xtermContainer.ts +++ b/terminus-terminal/src/frontends/xtermFrontend.ts @@ -1,4 +1,4 @@ -import { TermContainer } from './termContainer' +import { Frontend } from './frontend' import { Terminal, ITheme } from 'xterm' import * as fit from 'xterm/lib/addons/fit/fit' import 'xterm/dist/xterm.css' @@ -6,7 +6,7 @@ import deepEqual = require('deep-equal') Terminal.applyAddon(fit) -export class XTermContainer extends TermContainer { +export class XTermFrontend extends Frontend { enableResizing = true xterm: Terminal private configuredFontSize = 0 diff --git a/terminus-terminal/src/index.ts b/terminus-terminal/src/index.ts index e1fed22e..5f27c1fb 100644 --- a/terminus-terminal/src/index.ts +++ b/terminus-terminal/src/index.ts @@ -13,8 +13,8 @@ import { TerminalSettingsTabComponent } from './components/terminalSettingsTab.c import { ColorPickerComponent } from './components/colorPicker.component' import { SessionsService, BaseSession } from './services/sessions.service' +import { TerminalFrontendService } from './services/terminalFrontend.service' import { TerminalService } from './services/terminal.service' -import { TerminalContainersService } from './services/terminalContainers.service' import { ScreenPersistenceProvider } from './persistence/screen' import { TMuxPersistenceProvider } from './persistence/tmux' @@ -50,8 +50,8 @@ import { hterm } from './hterm' ], providers: [ SessionsService, + TerminalFrontendService, TerminalService, - TerminalContainersService, { provide: ToolbarButtonProvider, useClass: ButtonProvider, multi: true }, { provide: TabRecoveryProvider, useClass: RecoveryProvider, multi: true }, @@ -125,4 +125,4 @@ export default class TerminalModule { } export * from './api' -export { TerminalService, BaseSession, TerminalTabComponent, TerminalContainersService } +export { TerminalService, BaseSession, TerminalTabComponent, TerminalFrontendService } diff --git a/terminus-terminal/src/pathDrop.ts b/terminus-terminal/src/pathDrop.ts index c5d24b8b..88b98f49 100644 --- a/terminus-terminal/src/pathDrop.ts +++ b/terminus-terminal/src/pathDrop.ts @@ -10,10 +10,10 @@ export class PathDropDecorator extends TerminalDecorator { attach (terminal: TerminalTabComponent): void { setTimeout(() => { this.subscriptions = [ - terminal.termContainer.dragOver$.subscribe(event => { + terminal.frontend.dragOver$.subscribe(event => { event.preventDefault() }), - terminal.termContainer.drop$.subscribe(event => { + terminal.frontend.drop$.subscribe(event => { for (let file of event.dataTransfer.files as any) { this.injectPath(terminal, file.path) } diff --git a/terminus-terminal/src/services/sessions.service.ts b/terminus-terminal/src/services/sessions.service.ts index 9bd1e4ec..67e5b0b0 100644 --- a/terminus-terminal/src/services/sessions.service.ts +++ b/terminus-terminal/src/services/sessions.service.ts @@ -1,10 +1,10 @@ -const psNode = require('ps-node') +import psNode = require('ps-node') let nodePTY import * as fs from 'mz/fs' import { Observable, Subject } from 'rxjs' import { first } from 'rxjs/operators' 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 { SessionOptions, SessionPersistenceProvider } from '../api' @@ -202,7 +202,6 @@ export class SessionsService { constructor ( @Inject(SessionPersistenceProvider) private persistenceProviders: SessionPersistenceProvider[], private config: ConfigService, - electron: ElectronService, log: LogService, ) { nodePTY = require('node-pty-tmp') diff --git a/terminus-terminal/src/services/terminalContainers.service.ts b/terminus-terminal/src/services/terminalFrontend.service.ts similarity index 50% rename from terminus-terminal/src/services/terminalContainers.service.ts rename to terminus-terminal/src/services/terminalFrontend.service.ts index 1287b5dd..5978c30b 100644 --- a/terminus-terminal/src/services/terminalContainers.service.ts +++ b/terminus-terminal/src/services/terminalFrontend.service.ts @@ -1,23 +1,23 @@ import { Injectable } from '@angular/core' import { ConfigService } from 'terminus-core' -import { TermContainer } from '../terminalContainers/termContainer' -import { HTermContainer } from '../terminalContainers/htermContainer' -import { XTermContainer } from '../terminalContainers/xtermContainer' +import { Frontend } from '../frontends/frontend' +import { HTermFrontend } from '../frontends/htermFrontend' +import { XTermFrontend } from '../frontends/xtermFrontend' import { BaseSession } from '../services/sessions.service' @Injectable() -export class TerminalContainersService { - private containers = new WeakMap() +export class TerminalFrontendService { + private containers = new WeakMap() constructor (private config: ConfigService) { } - getContainer (session: BaseSession): TermContainer { + getFrontend (session: BaseSession): Frontend { if (!this.containers.has(session)) { this.containers.set( session, (this.config.store.terminal.frontend === 'xterm') - ? new XTermContainer() - : new HTermContainer() + ? new XTermFrontend() + : new HTermFrontend() ) } return this.containers.get(session)