mirror of
https://github.com/Eugeny/tabby.git
synced 2024-12-17 23:21:31 +03:00
report progress from the console commands in tab headers and taskbar
This commit is contained in:
parent
c9dde2e29c
commit
64f670bd86
@ -138,7 +138,16 @@ export class AppRootComponent {
|
|||||||
config.changed$.subscribe(() => this.updateVibrancy())
|
config.changed$.subscribe(() => this.updateVibrancy())
|
||||||
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.app.tabClosed$.subscribe(tab => {
|
||||||
this.unsortedTabs = this.unsortedTabs.filter(x => x !== tab)
|
this.unsortedTabs = this.unsortedTabs.filter(x => x !== tab)
|
||||||
})
|
})
|
||||||
|
@ -12,10 +12,12 @@ export abstract class BaseTabComponent {
|
|||||||
protected titleChange = new Subject<string>()
|
protected titleChange = new Subject<string>()
|
||||||
protected focused = new Subject<void>()
|
protected focused = new Subject<void>()
|
||||||
protected blurred = new Subject<void>()
|
protected blurred = new Subject<void>()
|
||||||
|
protected progress = new Subject<number>()
|
||||||
|
|
||||||
get focused$ (): Observable<void> { return this.focused }
|
get focused$ (): Observable<void> { return this.focused }
|
||||||
get blurred$ (): Observable<void> { return this.blurred }
|
get blurred$ (): Observable<void> { return this.blurred }
|
||||||
get titleChange$ (): Observable<string> { return this.titleChange }
|
get titleChange$ (): Observable<string> { return this.titleChange }
|
||||||
|
get progress$ (): Observable<number> { return this.progress }
|
||||||
|
|
||||||
constructor () {
|
constructor () {
|
||||||
this.id = BaseTabComponent.lastTabID++
|
this.id = BaseTabComponent.lastTabID++
|
||||||
@ -34,6 +36,10 @@ export abstract class BaseTabComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setProgress (progress: number) {
|
||||||
|
this.progress.next(progress)
|
||||||
|
}
|
||||||
|
|
||||||
displayActivity (): void {
|
displayActivity (): void {
|
||||||
this.hasActivity = true
|
this.hasActivity = true
|
||||||
}
|
}
|
||||||
@ -58,5 +64,6 @@ export abstract class BaseTabComponent {
|
|||||||
this.focused.complete()
|
this.focused.complete()
|
||||||
this.blurred.complete()
|
this.blurred.complete()
|
||||||
this.titleChange.complete()
|
this.titleChange.complete()
|
||||||
|
this.progress.complete()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
.progressbar([style.width]='progress + "%"', *ngIf='progress != null')
|
||||||
.index(#handle) {{index + 1}}
|
.index(#handle) {{index + 1}}
|
||||||
.name([title]='tab.customTitle || tab.title') {{tab.customTitle || tab.title}}
|
.name([title]='tab.customTitle || tab.title') {{tab.customTitle || tab.title}}
|
||||||
button((click)='app.closeTab(tab, true)') ×
|
button((click)='app.closeTab(tab, true)') ×
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
$tabs-height: 36px;
|
$tabs-height: 36px;
|
||||||
|
|
||||||
:host {
|
:host {
|
||||||
|
position: relative;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
flex: 1000 1 200px;
|
flex: 1000 1 200px;
|
||||||
@ -73,4 +74,12 @@ $tabs-height: 36px;
|
|||||||
&.fully-draggable {
|
&.fully-draggable {
|
||||||
cursor: -webkit-grab;
|
cursor: -webkit-grab;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.progressbar {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,9 @@ export class TabHeaderComponent {
|
|||||||
@Input() @HostBinding('class.active') active: boolean
|
@Input() @HostBinding('class.active') active: boolean
|
||||||
@Input() @HostBinding('class.has-activity') hasActivity: boolean
|
@Input() @HostBinding('class.has-activity') hasActivity: boolean
|
||||||
@Input() tab: BaseTabComponent
|
@Input() tab: BaseTabComponent
|
||||||
|
@Input() progress: number
|
||||||
@ViewChild('handle') handle: ElementRef
|
@ViewChild('handle') handle: ElementRef
|
||||||
|
|
||||||
private contextMenu: any
|
private contextMenu: any
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
@ -74,6 +76,9 @@ export class TabHeaderComponent {
|
|||||||
if (this.hostApp.platform === Platform.macOS) {
|
if (this.hostApp.platform === Platform.macOS) {
|
||||||
this.parentDraggable.setDragHandle(this.handle.nativeElement)
|
this.parentDraggable.setDragHandle(this.handle.nativeElement)
|
||||||
}
|
}
|
||||||
|
this.tab.progress$.subscribe(progress => {
|
||||||
|
this.progress = progress
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@HostListener('dblclick') onDoubleClick (): void {
|
@HostListener('dblclick') onDoubleClick (): void {
|
||||||
|
@ -144,6 +144,10 @@ app-root {
|
|||||||
&:active { background: $button-active-bg !important; }
|
&:active { background: $button-active-bg !important; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.progressbar {
|
||||||
|
background: $green;
|
||||||
|
}
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
color: white;
|
color: white;
|
||||||
background: $content-bg;
|
background: $content-bg;
|
||||||
|
@ -294,6 +294,14 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
write (data: string) {
|
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)
|
this.termContainer.write(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user