1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-11-23 21:34:13 +03:00

report progress from the console commands in tab headers and taskbar

This commit is contained in:
Eugene Pankov 2018-08-25 00:22:43 +02:00
parent c9dde2e29c
commit 64f670bd86
7 changed files with 44 additions and 1 deletions

View File

@ -138,7 +138,16 @@ export class AppRootComponent {
config.changed$.subscribe(() => this.updateVibrancy())
this.updateVibrancy()
this.app.tabOpened$.subscribe(tab => this.unsortedTabs.push(tab))
this.app.tabOpened$.subscribe(tab => {
this.unsortedTabs.push(tab)
tab.progress$.subscribe(progress => {
if (progress !== null) {
this.hostApp.getWindow().setProgressBar(progress / 100.0, 'normal')
} else {
this.hostApp.getWindow().setProgressBar(0, 'none')
}
})
})
this.app.tabClosed$.subscribe(tab => {
this.unsortedTabs = this.unsortedTabs.filter(x => x !== tab)
})

View File

@ -12,10 +12,12 @@ export abstract class BaseTabComponent {
protected titleChange = new Subject<string>()
protected focused = new Subject<void>()
protected blurred = new Subject<void>()
protected progress = new Subject<number>()
get focused$ (): Observable<void> { return this.focused }
get blurred$ (): Observable<void> { return this.blurred }
get titleChange$ (): Observable<string> { return this.titleChange }
get progress$ (): Observable<number> { return this.progress }
constructor () {
this.id = BaseTabComponent.lastTabID++
@ -34,6 +36,10 @@ export abstract class BaseTabComponent {
}
}
setProgress (progress: number) {
this.progress.next(progress)
}
displayActivity (): void {
this.hasActivity = true
}
@ -58,5 +64,6 @@ export abstract class BaseTabComponent {
this.focused.complete()
this.blurred.complete()
this.titleChange.complete()
this.progress.complete()
}
}

View File

@ -1,3 +1,4 @@
.progressbar([style.width]='progress + "%"', *ngIf='progress != null')
.index(#handle) {{index + 1}}
.name([title]='tab.customTitle || tab.title') {{tab.customTitle || tab.title}}
button((click)='app.closeTab(tab, true)') &times;

View File

@ -1,6 +1,7 @@
$tabs-height: 36px;
:host {
position: relative;
cursor: pointer;
flex: 1000 1 200px;
@ -73,4 +74,12 @@ $tabs-height: 36px;
&.fully-draggable {
cursor: -webkit-grab;
}
.progressbar {
position: absolute;
left: 0;
top: 0;
bottom: 0;
z-index: -1;
}
}

View File

@ -17,7 +17,9 @@ export class TabHeaderComponent {
@Input() @HostBinding('class.active') active: boolean
@Input() @HostBinding('class.has-activity') hasActivity: boolean
@Input() tab: BaseTabComponent
@Input() progress: number
@ViewChild('handle') handle: ElementRef
private contextMenu: any
constructor (
@ -74,6 +76,9 @@ export class TabHeaderComponent {
if (this.hostApp.platform === Platform.macOS) {
this.parentDraggable.setDragHandle(this.handle.nativeElement)
}
this.tab.progress$.subscribe(progress => {
this.progress = progress
})
}
@HostListener('dblclick') onDoubleClick (): void {

View File

@ -144,6 +144,10 @@ app-root {
&:active { background: $button-active-bg !important; }
}
.progressbar {
background: $green;
}
&.active {
color: white;
background: $content-bg;

View File

@ -294,6 +294,14 @@ export class TerminalTabComponent extends BaseTabComponent {
}
write (data: string) {
let percentageMatch = /(\d+(\.\d+)?)%/.exec(data)
if (percentageMatch) {
let percentage = percentageMatch[2] ? parseFloat(percentageMatch[1]) : parseInt(percentageMatch[1])
this.setProgress(percentage)
console.log('Detected progress:', percentage)
} else {
this.setProgress(null)
}
this.termContainer.write(data)
}