API updates

This commit is contained in:
Eugene Pankov
2017-11-04 19:06:58 +01:00
parent 89dff969b1
commit c73d39026b
16 changed files with 75 additions and 46 deletions

View File

@@ -115,7 +115,7 @@ export async function findPlugins (): Promise<IPluginInfo[]> {
try { try {
let info = JSON.parse(await fs.readFile(infoPath, {encoding: 'utf-8'})) let info = JSON.parse(await fs.readFile(infoPath, {encoding: 'utf-8'}))
if (!info.keywords || info.keywords.indexOf('terminus-plugin') === -1) { if (!info.keywords || !(info.keywords.includes('terminus-plugin') || info.keywords.includes('terminus-builtin-plugin'))) {
continue continue
} }
let author = info.author let author = info.author

View File

@@ -58,3 +58,7 @@
color: #842fe0; color: #842fe0;
} }
} }
.modal-dialog {
-webkit-app-region: no-drag;
}

View File

@@ -3,7 +3,7 @@
"version": "1.0.0-alpha.35", "version": "1.0.0-alpha.35",
"description": "Community color schemes for Terminus", "description": "Community color schemes for Terminus",
"keywords": [ "keywords": [
"terminus-plugin" "terminus-builtin-plugin"
], ],
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",

View File

@@ -1,9 +1,9 @@
{ {
"name": "terminus-core", "name": "terminus-core",
"version": "1.0.0-alpha.35", "version": "1.0.0-alpha.35.1",
"description": "Terminus core", "description": "Terminus core",
"keywords": [ "keywords": [
"terminus-plugin" "terminus-builtin-plugin"
], ],
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",

View File

@@ -1,9 +1,9 @@
{ {
"name": "terminus-plugin-manager", "name": "terminus-plugin-manager",
"version": "1.0.0-alpha.35", "version": "1.0.0-alpha.35.1",
"description": "Terminus' plugin manager", "description": "Terminus' plugin manager",
"keywords": [ "keywords": [
"terminus-plugin" "terminus-builtin-plugin"
], ],
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",

View File

@@ -5,6 +5,7 @@ import { PluginsSettingsTabComponent } from './components/pluginsSettingsTab.com
@Injectable() @Injectable()
export class PluginsSettingsTabProvider extends SettingsTabProvider { export class PluginsSettingsTabProvider extends SettingsTabProvider {
id = 'plugins'
title = 'Plugins' title = 'Plugins'
getComponentType (): ComponentType { getComponentType (): ComponentType {

View File

@@ -1,9 +1,9 @@
{ {
"name": "terminus-settings", "name": "terminus-settings",
"version": "1.0.0-alpha.35", "version": "1.0.0-alpha.35.3",
"description": "Terminus terminal settings page", "description": "Terminus terminal settings page",
"keywords": [ "keywords": [
"terminus-plugin" "terminus-builtin-plugin"
], ],
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",

View File

@@ -3,6 +3,7 @@ import { Component } from '@angular/core'
export declare type ComponentType = new (...args: any[]) => Component export declare type ComponentType = new (...args: any[]) => Component
export abstract class SettingsTabProvider { export abstract class SettingsTabProvider {
id: string
title: string title: string
getComponentType (): ComponentType { getComponentType (): ComponentType {

View File

@@ -1,7 +1,7 @@
button.btn.btn-outline-warning.btn-block(*ngIf='config.restartRequested', '(click)'='restartApp()') Restart the app to apply changes button.btn.btn-outline-warning.btn-block(*ngIf='config.restartRequested', '(click)'='restartApp()') Restart the app to apply changes
ngb-tabset.vertical(type='tabs') ngb-tabset.vertical(type='tabs', [activeId]='activeTab')
ngb-tab ngb-tab(id='application')
ng-template(ngbTabTitle) ng-template(ngbTabTitle)
| Application | Application
ng-template(ngbTabContent) ng-template(ngbTabContent)
@@ -164,7 +164,7 @@ ngb-tabset.vertical(type='tabs')
'(ngModelChange)'='config.save()', '(ngModelChange)'='config.save()',
) )
ngb-tab ngb-tab(id='hotkeys')
ng-template(ngbTabTitle) ng-template(ngbTabTitle)
| Hotkeys | Hotkeys
ng-template(ngbTabContent) ng-template(ngbTabContent)
@@ -184,7 +184,7 @@ ngb-tabset.vertical(type='tabs')
'(modelChange)'='config.save(); docking.dock()' '(modelChange)'='config.save(); docking.dock()'
) )
ngb-tab(*ngFor='let provider of settingsProviders') ngb-tab(*ngFor='let provider of settingsProviders', [id]='provider.id')
ng-template(ngbTabTitle) ng-template(ngbTabTitle)
| {{provider.title}} | {{provider.title}}
ng-template(ngbTabContent) ng-template(ngbTabContent)

View File

@@ -1,4 +1,4 @@
import { Component, Inject } from '@angular/core' import { Component, Inject, Input } from '@angular/core'
import { ElectronService, DockingService, ConfigService, IHotkeyDescription, HotkeyProvider, BaseTabComponent, Theme, HostAppService } from 'terminus-core' import { ElectronService, DockingService, ConfigService, IHotkeyDescription, HotkeyProvider, BaseTabComponent, Theme, HostAppService } from 'terminus-core'
import { SettingsTabProvider } from '../api' import { SettingsTabProvider } from '../api'
@@ -12,6 +12,7 @@ import { SettingsTabProvider } from '../api'
], ],
}) })
export class SettingsTabComponent extends BaseTabComponent { export class SettingsTabComponent extends BaseTabComponent {
@Input() activeTab: string
hotkeyFilter = '' hotkeyFilter = ''
private hotkeyDescriptions: IHotkeyDescription[] private hotkeyDescriptions: IHotkeyDescription[]
private screens private screens

View File

@@ -40,3 +40,4 @@ export default class SettingsModule {
} }
export * from './api' export * from './api'
export { SettingsTabComponent }

View File

@@ -1,9 +1,9 @@
{ {
"name": "terminus-terminal", "name": "terminus-terminal",
"version": "1.0.0-alpha.35", "version": "1.0.0-alpha.35.1",
"description": "Terminus' terminal emulation core", "description": "Terminus' terminal emulation core",
"keywords": [ "keywords": [
"terminus-plugin" "terminus-builtin-plugin"
], ],
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",

View File

@@ -60,23 +60,28 @@ export class TerminalTabComponent extends BaseTabComponent {
this.decorators = this.decorators || [] this.decorators = this.decorators || []
this.title = 'Terminal' this.title = 'Terminal'
this.resize$.first().subscribe(async (resizeEvent) => { this.resize$.first().subscribe(async (resizeEvent) => {
this.session = this.sessions.addSession( if (!this.session) {
Object.assign({}, this.sessionOptions, resizeEvent) this.session = this.sessions.addSession(
) Object.assign({}, this.sessionOptions, resizeEvent)
)
}
setTimeout(() => { setTimeout(() => {
this.session.resize(resizeEvent.width, resizeEvent.height) this.session.resize(resizeEvent.width, resizeEvent.height)
}, 1000) }, 1000)
// this.session.output$.bufferTime(10).subscribe((datas) => { // this.session.output$.bufferTime(10).subscribe((datas) => {
this.session.output$.subscribe(data => { this.session.output$.subscribe(data => {
// let data = datas.join('')
this.zone.run(() => { this.zone.run(() => {
this.output$.next(data) this.output$.next(data)
this.write(data)
}) })
this.write(data)
}) })
this.sessionCloseSubscription = this.session.closed$.subscribe(() => { this.sessionCloseSubscription = this.session.closed$.subscribe(() => {
this.app.closeTab(this) this.app.closeTab(this)
}) })
this.session.releaseInitialDataBuffer() this.session.releaseInitialDataBuffer()
}) })
this.hotkeysSubscription = this.hotkeys.matchedHotkey.subscribe(hotkey => { this.hotkeysSubscription = this.hotkeys.matchedHotkey.subscribe(hotkey => {

View File

@@ -10,7 +10,7 @@ import { TerminalTabComponent } from './components/terminalTab.component'
import { TerminalSettingsTabComponent } from './components/terminalSettingsTab.component' import { TerminalSettingsTabComponent } from './components/terminalSettingsTab.component'
import { ColorPickerComponent } from './components/colorPicker.component' import { ColorPickerComponent } from './components/colorPicker.component'
import { SessionsService } from './services/sessions.service' import { SessionsService, BaseSession } from './services/sessions.service'
import { TerminalService } from './services/terminal.service' import { TerminalService } from './services/terminal.service'
import { ScreenPersistenceProvider } from './persistence/screen' import { ScreenPersistenceProvider } from './persistence/screen'
@@ -117,4 +117,4 @@ export default class TerminalModule {
} }
export * from './api' export * from './api'
export { TerminalService } export { TerminalService, BaseSession, TerminalTabComponent }

View File

@@ -14,7 +14,7 @@ export interface IChildProcess {
command: string command: string
} }
export class Session { export abstract class BaseSession {
open: boolean open: boolean
name: string name: string
output$ = new Subject<string>() output$ = new Subject<string>()
@@ -22,11 +22,46 @@ export class Session {
destroyed$ = new Subject<void>() destroyed$ = new Subject<void>()
recoveryId: string recoveryId: string
truePID: number truePID: number
private pty: any
private initialDataBuffer = '' private initialDataBuffer = ''
private initialDataBufferReleased = false private initialDataBufferReleased = false
emitOutput (data: string) {
if (!this.initialDataBufferReleased) {
this.initialDataBuffer += data
} else {
this.output$.next(data)
}
}
releaseInitialDataBuffer () {
this.initialDataBufferReleased = true
this.output$.next(this.initialDataBuffer)
this.initialDataBuffer = null
}
abstract resize (columns, rows)
abstract write (data)
abstract kill (signal?: string)
abstract async getChildProcesses (): Promise<IChildProcess[]>
abstract async gracefullyKillProcess (): Promise<void>
abstract async getWorkingDirectory (): Promise<string>
async destroy (): Promise<void> {
if (this.open) {
this.open = false
this.closed$.next()
this.destroyed$.next()
this.output$.complete()
await this.gracefullyKillProcess()
}
}
}
export class Session extends BaseSession {
private pty: any
constructor (options: SessionOptions) { constructor (options: SessionOptions) {
super()
this.name = options.name this.name = options.name
this.recoveryId = options.recoveryId this.recoveryId = options.recoveryId
@@ -65,12 +100,8 @@ export class Session {
this.open = true this.open = true
this.pty.on('data', (data) => { this.pty.on('data', data => {
if (!this.initialDataBufferReleased) { this.emitOutput(data)
this.initialDataBuffer += data
} else {
this.output$.next(data)
}
}) })
this.pty.on('exit', () => { this.pty.on('exit', () => {
@@ -86,12 +117,6 @@ export class Session {
}) })
} }
releaseInitialDataBuffer () {
this.initialDataBufferReleased = true
this.output$.next(this.initialDataBuffer)
this.initialDataBuffer = null
}
resize (columns, rows) { resize (columns, rows) {
if (this.pty._writable) { if (this.pty._writable) {
this.pty.resize(columns, rows) this.pty.resize(columns, rows)
@@ -144,16 +169,6 @@ export class Session {
} }
} }
async destroy (): Promise<void> {
if (this.open) {
this.open = false
this.closed$.next()
this.destroyed$.next()
this.output$.complete()
await this.gracefullyKillProcess()
}
}
async getWorkingDirectory (): Promise<string> { async getWorkingDirectory (): Promise<string> {
if (!this.truePID) { if (!this.truePID) {
return null return null

View File

@@ -5,6 +5,7 @@ import { TerminalSettingsTabComponent } from './components/terminalSettingsTab.c
@Injectable() @Injectable()
export class TerminalSettingsTabProvider extends SettingsTabProvider { export class TerminalSettingsTabProvider extends SettingsTabProvider {
id = 'terminal'
title = 'Terminal' title = 'Terminal'
getComponentType (): ComponentType { getComponentType (): ComponentType {