mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-27 06:49:53 +00:00
expose TerminalService
This commit is contained in:
parent
1c62f3074c
commit
41b6e1d54e
@ -108,8 +108,9 @@ export async function findPlugins (): Promise<IPluginInfo[]> {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if (foundPlugins.some(x => x.name === pluginName)) {
|
if (foundPlugins.some(x => x.name === pluginName.substring('terminus-'.length))) {
|
||||||
console.info(`Plugin ${pluginName} already exists`)
|
console.info(`Plugin ${pluginName} already exists, overriding`)
|
||||||
|
foundPlugins = foundPlugins.filter(x => x.name !== pluginName.substring('terminus-'.length))
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "terminus-community-color-schemes",
|
"name": "terminus-community-color-schemes",
|
||||||
"version": "1.0.0-alpha.16-8-gfc060ac",
|
"version": "1.0.0-alpha.23-6-g1c62f30",
|
||||||
"description": "Community color schemes for Terminus",
|
"description": "Community color schemes for Terminus",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"terminus-plugin"
|
"terminus-plugin"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "terminus-core",
|
"name": "terminus-core",
|
||||||
"version": "1.0.0-alpha.16-8-gfc060ac",
|
"version": "1.0.0-alpha.23-6-g1c62f30",
|
||||||
"description": "Terminus core",
|
"description": "Terminus core",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"terminus-plugin"
|
"terminus-plugin"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "terminus-plugin-manager",
|
"name": "terminus-plugin-manager",
|
||||||
"version": "1.0.0-alpha.16-8-gfc060ac",
|
"version": "1.0.0-alpha.23-6-g1c62f30",
|
||||||
"description": "Terminus' plugin manager",
|
"description": "Terminus' plugin manager",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"terminus-plugin"
|
"terminus-plugin"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "terminus-settings",
|
"name": "terminus-settings",
|
||||||
"version": "1.0.0-alpha.16-8-gfc060ac",
|
"version": "1.0.0-alpha.23-6-g1c62f30",
|
||||||
"description": "Terminus terminal settings page",
|
"description": "Terminus terminal settings page",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"terminus-plugin"
|
"terminus-plugin"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "terminus-terminal",
|
"name": "terminus-terminal",
|
||||||
"version": "1.0.0-alpha.16-8-gfc060ac",
|
"version": "1.0.0-alpha.23-6-g1c62f30",
|
||||||
"description": "Terminus' terminal emulation core",
|
"description": "Terminus' terminal emulation core",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"terminus-plugin"
|
"terminus-plugin"
|
||||||
|
@ -2,6 +2,7 @@ import { Observable } from 'rxjs'
|
|||||||
import { TerminalTabComponent } from './components/terminalTab.component'
|
import { TerminalTabComponent } from './components/terminalTab.component'
|
||||||
export { TerminalTabComponent }
|
export { TerminalTabComponent }
|
||||||
export { IChildProcess } from './services/sessions.service'
|
export { IChildProcess } from './services/sessions.service'
|
||||||
|
export { TerminalService } from './services/terminal.service'
|
||||||
|
|
||||||
export abstract class TerminalDecorator {
|
export abstract class TerminalDecorator {
|
||||||
// tslint:disable-next-line no-empty
|
// tslint:disable-next-line no-empty
|
||||||
|
@ -2,11 +2,10 @@ import { AsyncSubject } from 'rxjs'
|
|||||||
import * as fs from 'mz/fs'
|
import * as fs from 'mz/fs'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import { Injectable, Inject } from '@angular/core'
|
import { Injectable, Inject } from '@angular/core'
|
||||||
import { HotkeysService, ToolbarButtonProvider, IToolbarButton, AppService, ConfigService, HostAppService, ElectronService, Logger, LogService } from 'terminus-core'
|
import { HotkeysService, ToolbarButtonProvider, IToolbarButton, ConfigService, HostAppService, ElectronService, Logger, LogService } from 'terminus-core'
|
||||||
|
|
||||||
import { IShell, ShellProvider } from './api'
|
import { IShell, ShellProvider } from './api'
|
||||||
import { SessionsService } from './services/sessions.service'
|
import { TerminalService } from './services/terminal.service'
|
||||||
import { TerminalTabComponent } from './components/terminalTab.component'
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ButtonProvider extends ToolbarButtonProvider {
|
export class ButtonProvider extends ToolbarButtonProvider {
|
||||||
@ -14,8 +13,7 @@ export class ButtonProvider extends ToolbarButtonProvider {
|
|||||||
private logger: Logger
|
private logger: Logger
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private app: AppService,
|
private terminal: TerminalService,
|
||||||
private sessions: SessionsService,
|
|
||||||
private config: ConfigService,
|
private config: ConfigService,
|
||||||
log: LogService,
|
log: LogService,
|
||||||
hostApp: HostAppService,
|
hostApp: HostAppService,
|
||||||
@ -57,27 +55,9 @@ export class ButtonProvider extends ToolbarButtonProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async openNewTab (cwd?: string): Promise<void> {
|
async openNewTab (cwd?: string): Promise<void> {
|
||||||
if (!cwd && this.app.activeTab instanceof TerminalTabComponent) {
|
|
||||||
cwd = await this.app.activeTab.session.getWorkingDirectory()
|
|
||||||
}
|
|
||||||
let shells = await this.shells$.first().toPromise()
|
let shells = await this.shells$.first().toPromise()
|
||||||
let shell = shells.find(x => x.id === this.config.store.terminal.shell) || shells[0]
|
let shell = shells.find(x => x.id === this.config.store.terminal.shell) || shells[0]
|
||||||
let env: any = Object.assign({}, process.env, shell.env || {})
|
this.terminal.openTab(shell, cwd)
|
||||||
|
|
||||||
this.logger.log(`Starting shell ${shell.name}`, shell)
|
|
||||||
let sessionOptions = await this.sessions.prepareNewSession({
|
|
||||||
command: shell.command,
|
|
||||||
args: shell.args || [],
|
|
||||||
cwd,
|
|
||||||
env,
|
|
||||||
})
|
|
||||||
|
|
||||||
this.logger.log('Using session options:', sessionOptions)
|
|
||||||
|
|
||||||
this.app.openNewTab(
|
|
||||||
TerminalTabComponent,
|
|
||||||
{ sessionOptions }
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
provide (): IToolbarButton[] {
|
provide (): IToolbarButton[] {
|
||||||
|
@ -71,5 +71,7 @@ const _collapseToEnd = Selection.prototype.collapseToEnd
|
|||||||
Selection.prototype.collapseToEnd = function () {
|
Selection.prototype.collapseToEnd = function () {
|
||||||
try {
|
try {
|
||||||
_collapseToEnd.apply(this)
|
_collapseToEnd.apply(this)
|
||||||
} catch (err) { ; }
|
} catch (err) {
|
||||||
|
// tslint-disable-line
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import { TerminalSettingsTabComponent } from './components/terminalSettingsTab.c
|
|||||||
import { ColorPickerComponent } from './components/colorPicker.component'
|
import { ColorPickerComponent } from './components/colorPicker.component'
|
||||||
|
|
||||||
import { SessionsService } from './services/sessions.service'
|
import { SessionsService } from './services/sessions.service'
|
||||||
|
import { TerminalService } from './services/terminal.service'
|
||||||
|
|
||||||
import { ScreenPersistenceProvider } from './persistence/screen'
|
import { ScreenPersistenceProvider } from './persistence/screen'
|
||||||
import { TMuxPersistenceProvider } from './persistence/tmux'
|
import { TMuxPersistenceProvider } from './persistence/tmux'
|
||||||
@ -42,6 +43,8 @@ import { hterm } from './hterm'
|
|||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
SessionsService,
|
SessionsService,
|
||||||
|
TerminalService,
|
||||||
|
|
||||||
{ provide: ToolbarButtonProvider, useClass: ButtonProvider, multi: true },
|
{ provide: ToolbarButtonProvider, useClass: ButtonProvider, multi: true },
|
||||||
{ provide: TabRecoveryProvider, useClass: RecoveryProvider, multi: true },
|
{ provide: TabRecoveryProvider, useClass: RecoveryProvider, multi: true },
|
||||||
{ provide: SettingsTabProvider, useClass: TerminalSettingsTabProvider, multi: true },
|
{ provide: SettingsTabProvider, useClass: TerminalSettingsTabProvider, multi: true },
|
||||||
|
40
terminus-terminal/src/services/terminal.service.ts
Normal file
40
terminus-terminal/src/services/terminal.service.ts
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import { Injectable } from '@angular/core'
|
||||||
|
import { AppService, Logger, LogService } from 'terminus-core'
|
||||||
|
import { IShell } from '../api'
|
||||||
|
import { SessionsService } from './sessions.service'
|
||||||
|
import { TerminalTabComponent } from '../components/terminalTab.component'
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class TerminalService {
|
||||||
|
private logger: Logger
|
||||||
|
|
||||||
|
constructor (
|
||||||
|
private app: AppService,
|
||||||
|
private sessions: SessionsService,
|
||||||
|
log: LogService,
|
||||||
|
) {
|
||||||
|
this.logger = log.create('terminal')
|
||||||
|
}
|
||||||
|
|
||||||
|
async openTab (shell: IShell, cwd?: string): Promise<TerminalTabComponent> {
|
||||||
|
if (!cwd && this.app.activeTab instanceof TerminalTabComponent) {
|
||||||
|
cwd = await this.app.activeTab.session.getWorkingDirectory()
|
||||||
|
}
|
||||||
|
let env: any = Object.assign({}, process.env, shell.env || {})
|
||||||
|
|
||||||
|
this.logger.log(`Starting shell ${shell.name}`, shell)
|
||||||
|
let sessionOptions = await this.sessions.prepareNewSession({
|
||||||
|
command: shell.command,
|
||||||
|
args: shell.args || [],
|
||||||
|
cwd,
|
||||||
|
env,
|
||||||
|
})
|
||||||
|
|
||||||
|
this.logger.log('Using session options:', sessionOptions)
|
||||||
|
|
||||||
|
return this.app.openNewTab(
|
||||||
|
TerminalTabComponent,
|
||||||
|
{ sessionOptions }
|
||||||
|
) as TerminalTabComponent
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user