This commit is contained in:
Eugene Pankov 2017-07-26 19:29:47 +02:00
parent 5045c4c82a
commit 98a5a95bec
9 changed files with 47 additions and 23 deletions

View file

@ -1,5 +1,5 @@
export { BaseTabComponent } from '../components/baseTab.component'
export { TabRecoveryProvider } from './tabRecovery'
export { TabRecoveryProvider, RecoveredTab } from './tabRecovery'
export { ToolbarButtonProvider, IToolbarButton } from './toolbarButtonProvider'
export { ConfigProvider } from './configProvider'
export { HotkeyProvider, IHotkeyDescription } from './hotkeyProvider'

View file

@ -1,3 +1,10 @@
export abstract class TabRecoveryProvider {
abstract async recover (recoveryToken: any): Promise<void>
import { TabComponentType } from '../services/app.service'
export interface RecoveredTab {
type: TabComponentType,
options?: any,
}
export abstract class TabRecoveryProvider {
abstract async recover (recoveryToken: any): Promise<RecoveredTab|null>
}

View file

@ -1,3 +1,3 @@
.index {{index + 1}}
.name {{tab.customTitle || tab.title}}
.name([title]='tab.customTitle || tab.title') {{tab.customTitle || tab.title}}
button((click)='closeClicked.emit()') &times;

View file

@ -1,5 +1,5 @@
import { Injectable, Inject } from '@angular/core'
import { TabRecoveryProvider } from '../api/tabRecovery'
import { TabRecoveryProvider, RecoveredTab } from '../api/tabRecovery'
import { BaseTabComponent } from '../components/baseTab.component'
import { Logger, LogService } from '../services/log.service'
import { AppService } from '../services/app.service'
@ -10,7 +10,7 @@ export class TabRecoveryService {
constructor (
@Inject(TabRecoveryProvider) private tabRecoveryProviders: TabRecoveryProvider[],
app: AppService,
private app: AppService,
log: LogService
) {
this.logger = log.create('tabRecovery')
@ -29,15 +29,22 @@ export class TabRecoveryService {
async recoverTabs (): Promise<void> {
if (window.localStorage.tabsRecovery) {
let tabs: RecoveredTab[] = []
for (let token of JSON.parse(window.localStorage.tabsRecovery)) {
for (let provider of this.tabRecoveryProviders) {
try {
await provider.recover(token)
let tab = await provider.recover(token)
if (tab) {
tabs.push(tab)
}
} catch (error) {
this.logger.warn('Tab recovery crashed:', token, provider, error)
}
}
}
tabs.forEach(tab => {
this.app.openNewTab(tab.type, tab.options)
})
}
}

View file

@ -1,19 +1,14 @@
import { Injectable } from '@angular/core'
import { TabRecoveryProvider, AppService } from 'terminus-core'
import { TabRecoveryProvider, RecoveredTab } from 'terminus-core'
import { SettingsTabComponent } from './components/settingsTab.component'
@Injectable()
export class RecoveryProvider extends TabRecoveryProvider {
constructor (
private app: AppService
) {
super()
}
async recover (recoveryToken: any): Promise<void> {
async recover (recoveryToken: any): Promise<RecoveredTab> {
if (recoveryToken.type === 'app:settings') {
this.app.openNewTab(SettingsTabComponent)
return { type: SettingsTabComponent }
}
return null
}
}

View file

@ -51,7 +51,9 @@ export class TerminalTabComponent extends BaseTabComponent {
this.session = this.sessions.addSession(
Object.assign({}, this.sessionOptions, resizeEvent)
)
this.session.resize(resizeEvent.width, resizeEvent.height)
setTimeout(() => {
this.session.resize(resizeEvent.width, resizeEvent.height)
}, 1000)
// this.session.output$.bufferTime(10).subscribe((datas) => {
this.session.output$.subscribe(data => {
// let data = datas.join('')

View file

@ -67,8 +67,9 @@ hterm.hterm.VT.CSI[' q'] = function (parseState) {
this.terminal.applyCursorShape()
}
const _collapseToEnd = Selection.prototype.collapseToEnd
Selection.prototype.collapseToEnd = function () {
try {
this.collapseToEnd()
_collapseToEnd.apply(this)
} catch (err) { ; }
}

View file

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'
import { TabRecoveryProvider, AppService } from 'terminus-core'
import { TabRecoveryProvider, RecoveredTab } from 'terminus-core'
import { TerminalTabComponent } from './components/terminalTab.component'
import { SessionsService } from './services/sessions.service'
@ -8,18 +8,21 @@ import { SessionsService } from './services/sessions.service'
export class RecoveryProvider extends TabRecoveryProvider {
constructor (
private sessions: SessionsService,
private app: AppService,
) {
super()
}
async recover (recoveryToken: any): Promise<void> {
async recover (recoveryToken: any): Promise<RecoveredTab> {
if (recoveryToken.type === 'app:terminal') {
let sessionOptions = await this.sessions.recover(recoveryToken.recoveryId)
if (!sessionOptions) {
return
}
this.app.openNewTab(TerminalTabComponent, { sessionOptions })
return {
type: TerminalTabComponent,
options: { sessionOptions },
}
}
return null
}
}

View file

@ -6,6 +6,15 @@ import { SessionOptions, SessionPersistenceProvider } from './api'
const TMUX_CONFIG = `
set -g status off
set -g focus-events on
set -g bell-action any
set -g bell-on-alert on
set -g visual-bell off
set -g set-titles on
set -g set-titles-string "#W"
set -g window-status-format '#I:#(pwd="#{pane_current_path}"; echo \${pwd####*/})#F'
set -g window-status-current-format '#I:#(pwd="#{pane_current_path}"; echo \${pwd####*/})#F'
set-option -g status-interval 1
`
export class TMuxBlock {
@ -44,7 +53,7 @@ export class TMuxCommandProcess {
this.process = childProcess.spawn('tmux', ['-C', '-L', 'terminus', 'new-session', '-A', '-D', '-s', 'control'])
console.log('[tmux] started')
this.process.stdout.on('data', data => {
console.debug('tmux says:', data.toString())
// console.debug('tmux says:', data.toString())
this.rawOutput$.next(data.toString())
})