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 { ToasterConfig } from 'angular2-toaster'
import { ElectronService } from 'services/electron' import { ElectronService } from 'services/electron'
@ -47,7 +47,6 @@ export class AppComponent {
lastTabIndex = 0 lastTabIndex = 0
constructor( constructor(
private elementRef: ElementRef,
private sessions: SessionsService, private sessions: SessionsService,
private docking: DockingService, private docking: DockingService,
private electron: ElectronService, private electron: ElectronService,
@ -162,14 +161,10 @@ export class AppComponent {
} }
if (this.activeTab) { if (this.activeTab) {
this.activeTab.hasActivity = false this.activeTab.hasActivity = false
this.activeTab.blurred.emit()
} }
this.activeTab = tab this.activeTab = tab
setImmediate(() => { this.activeTab.focused.emit()
let iframe = this.elementRef.nativeElement.querySelector(':scope .tab.active iframe')
if (iframe) {
iframe.focus()
}
})
} }
toggleLastTab () { toggleLastTab () {

View File

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

View File

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