new toolbar design

This commit is contained in:
Eugene Pankov
2021-07-07 20:11:38 +02:00
parent 621536a078
commit 224abcb2c4
12 changed files with 157 additions and 116 deletions

View File

@@ -3,7 +3,7 @@ import { Spinner } from 'cli-spinner'
import colors from 'ansi-colors'
import { NgZone, OnInit, OnDestroy, Injector, ViewChild, HostBinding, Input, ElementRef, InjectFlags } from '@angular/core'
import { trigger, transition, style, animate, AnimationTriggerMetadata } from '@angular/animations'
import { AppService, ConfigService, BaseTabComponent, HostAppService, HotkeysService, NotificationsService, Platform, LogService, Logger, TabContextMenuItemProvider, SplitTabComponent, SubscriptionContainer, MenuItemOptions, PlatformService, HostWindowService } from 'tabby-core'
import { AppService, ConfigService, BaseTabComponent, HostAppService, HotkeysService, NotificationsService, Platform, LogService, Logger, TabContextMenuItemProvider, SplitTabComponent, SubscriptionContainer, MenuItemOptions, PlatformService, HostWindowService, ResettableTimeout } from 'tabby-core'
import { BaseSession } from '../session'
import { TerminalFrontendService } from '../services/terminalFrontend.service'
@@ -75,6 +75,15 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
/** @hidden */
@HostBinding('class.top-padded') topPadded: boolean
/** @hidden */
@HostBinding('class.toolbar-enabled') enableToolbar = false
/** @hidden */
@HostBinding('class.toolbar-pinned') pinToolbar = false
/** @hidden */
@HostBinding('class.toolbar-revealed') revealToolbar = false
frontend?: Frontend
/** @hidden */
@@ -125,6 +134,9 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
},
})
private spinnerActive = false
private toolbarRevealTimeout = new ResettableTimeout(() => {
this.revealToolbar = false
}, 1000)
get input$ (): Observable<Buffer> {
if (!this.frontend) {
@@ -260,6 +272,8 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
this.bellPlayer.src = require('../bell.ogg').default
this.contextMenuProviders.sort((a, b) => a.weight - b.weight)
this.pinToolbar = (window.localStorage.pinTerminalToolbar ?? 'true') === 'true'
}
/** @hidden */
@@ -646,6 +660,20 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
this.sessionChanged.next(session)
}
showToolbar (): void {
this.revealToolbar = true
this.toolbarRevealTimeout.clear()
}
hideToolbar (): void {
this.toolbarRevealTimeout.set()
}
togglePinToolbar (): void {
this.pinToolbar = !this.pinToolbar
window.localStorage.pinTerminalToolbar = this.pinToolbar
}
protected attachSessionHandler <T> (observable: Observable<T>, handler: (v: T) => void): void {
this.sessionHandlers.subscribe(observable, handler)
}