From 9bee253dd05a89566a4a10b233042153f8304d0e Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Mon, 24 Jul 2017 16:04:17 +0200 Subject: [PATCH] reapply screen config on reattach --- .../src/components/terminalTab.component.ts | 1 + terminus-terminal/src/persistenceProviders.ts | 46 +++++++++++-------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/terminus-terminal/src/components/terminalTab.component.ts b/terminus-terminal/src/components/terminalTab.component.ts index d6f1f35f..5a662ad3 100644 --- a/terminus-terminal/src/components/terminalTab.component.ts +++ b/terminus-terminal/src/components/terminalTab.component.ts @@ -51,6 +51,7 @@ export class TerminalTabComponent extends BaseTabComponent { this.session = this.sessions.addSession( Object.assign({}, this.sessionOptions, resizeEvent) ) + this.session.resize(resizeEvent.width, resizeEvent.height) // this.session.output$.bufferTime(10).subscribe((datas) => { this.session.output$.subscribe(data => { // let data = datas.join('') diff --git a/terminus-terminal/src/persistenceProviders.ts b/terminus-terminal/src/persistenceProviders.ts index 1bdb1b16..ef60fb7b 100644 --- a/terminus-terminal/src/persistenceProviders.ts +++ b/terminus-terminal/src/persistenceProviders.ts @@ -64,7 +64,7 @@ export class ScreenPersistenceProvider extends SessionPersistenceProvider { recoveryId, recoveredTruePID$: truePID$.asObservable(), command: 'screen', - args: ['-d', '-r', recoveryId], + args: ['-d', '-r', recoveryId, '-c', await this.prepareConfig()], } } @@ -85,26 +85,8 @@ export class ScreenPersistenceProvider extends SessionPersistenceProvider { } async startSession (options: SessionOptions): Promise { - let configPath = '/tmp/.termScreenConfig' - await fs.writeFile(configPath, ` - escape ^^^ - vbell off - deflogin on - defflow off - term xterm-color - bindkey "^[OH" beginning-of-line - bindkey "^[OF" end-of-line - bindkey "\\027[?1049h" stuff ----alternate enter----- - bindkey "\\027[?1049l" stuff ----alternate leave----- - termcapinfo xterm* 'hs:ts=\\E]0;:fs=\\007:ds=\\E]0;\\007' - defhstatus "^Et" - hardstatus off - altscreen on - defutf8 on - defencoding utf8 - `, 'utf-8') let recoveryId = `term-tab-${Date.now()}` - let args = ['-d', '-m', '-c', configPath, '-U', '-S', recoveryId, '-T', 'xterm-256color', '--', '-' + options.command].concat(options.args || []) + let args = ['-d', '-m', '-c', await this.prepareConfig(), '-U', '-S', recoveryId, '-T', 'xterm-256color', '--', '-' + options.command].concat(options.args || []) this.logger.debug('Spawning screen with', args.join(' ')) await spawn('screen', args, { cwd: options.cwd, @@ -120,4 +102,28 @@ export class ScreenPersistenceProvider extends SessionPersistenceProvider { // screen has already quit } } + + private async prepareConfig (): Promise { + let configPath = '/tmp/.termScreenConfig' + await fs.writeFile(configPath, ` + escape ^^^ + vbell off + deflogin on + defflow off + term xterm-color + bindkey "^[OH" beginning-of-line + bindkey "^[OF" end-of-line + bindkey "^[[H" beginning-of-line + bindkey "^[[F" end-of-line + bindkey "\\027[?1049h" stuff ----alternate enter----- + bindkey "\\027[?1049l" stuff ----alternate leave----- + termcapinfo xterm* 'hs:ts=\\E]0;:fs=\\007:ds=\\E]0;\\007' + defhstatus "^Et" + hardstatus off + altscreen on + defutf8 on + defencoding utf8 + `, 'utf-8') + return configPath + } }