This commit is contained in:
Eugene Pankov 2017-03-23 20:15:32 +01:00
parent 84341fb09a
commit 755d626f3d
3 changed files with 15 additions and 10 deletions

View file

@ -1,4 +1,4 @@
import { Component, ElementRef, Input, trigger, style, animate, transition, state } from '@angular/core'
import { Component, Input, trigger, style, animate, transition, state } from '@angular/core'
import { ToasterConfig } from 'angular2-toaster'
import { ElectronService } from 'services/electron'
@ -47,7 +47,6 @@ export class AppComponent {
lastTabIndex = 0
constructor(
private elementRef: ElementRef,
private sessions: SessionsService,
private docking: DockingService,
private electron: ElectronService,
@ -162,14 +161,10 @@ export class AppComponent {
}
if (this.activeTab) {
this.activeTab.hasActivity = false
this.activeTab.blurred.emit()
}
this.activeTab = tab
setImmediate(() => {
let iframe = this.elementRef.nativeElement.querySelector(':scope .tab.active iframe')
if (iframe) {
iframe.focus()
}
})
this.activeTab.focused.emit()
}
toggleLastTab () {

View file

@ -20,6 +20,7 @@ export class TerminalTabComponent extends BaseTabComponent<TerminalTab> {
@Output() titleChange = new EventEmitter()
terminal: any
configSubscription: Subscription
focusedSubscription: Subscription
startupTime: number
constructor(
@ -36,7 +37,10 @@ export class TerminalTabComponent extends BaseTabComponent<TerminalTab> {
}
initTab () {
let io
this.focusedSubscription = this.model.focused.subscribe(() => {
this.terminal.scrollPort_.focus()
})
this.terminal = new hterm.hterm.Terminal()
this.pluginDispatcher.emit('preTerminalInit', { terminal: this.terminal })
this.terminal.setWindowTitle = (title) => {
@ -47,7 +51,7 @@ export class TerminalTabComponent extends BaseTabComponent<TerminalTab> {
}
this.terminal.onTerminalReady = () => {
this.terminal.installKeyboard()
io = this.terminal.io.push()
let io = this.terminal.io.push()
const dataSubscription = this.model.session.dataAvailable.subscribe((data) => {
if (performance.now() - this.startupTime > 500) {
this.zone.run(() => {
@ -88,6 +92,7 @@ export class TerminalTabComponent extends BaseTabComponent<TerminalTab> {
}
ngOnDestroy () {
this.focusedSubscription.unsubscribe()
this.configSubscription.unsubscribe()
}
}

View file

@ -1,3 +1,4 @@
import { EventEmitter } from '@angular/core'
import { BaseTabComponent } from 'components/baseTab'
import { Session } from 'services/sessions'
@ -8,6 +9,8 @@ export class Tab {
title: string
scrollable: boolean
hasActivity = false
focused = new EventEmitter<any>()
blurred = new EventEmitter<any>()
static lastTabID = 0
constructor () {
@ -51,4 +54,6 @@ export class TerminalTab extends Tab {
getComponentType (): ComponentType<TerminalTab> {
return TerminalTabComponent
}
onFocus (): void { }
}