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

smarter progress detection (fixes #406)

This commit is contained in:
Eugene Pankov 2018-08-31 12:41:58 +02:00
parent 5b76947d70
commit 0749096d9f
3 changed files with 17 additions and 5 deletions

View File

@ -15,6 +15,8 @@ export abstract class BaseTabComponent {
protected progress = new Subject<number>()
protected activity = new Subject<boolean>()
private progressClearTimeout: number
get focused$ (): Observable<void> { return this.focused }
get blurred$ (): Observable<void> { return this.blurred }
get titleChange$ (): Observable<string> { return this.titleChange }
@ -40,6 +42,14 @@ export abstract class BaseTabComponent {
setProgress (progress: number) {
this.progress.next(progress)
if (progress) {
if (this.progressClearTimeout) {
clearTimeout(this.progressClearTimeout)
}
this.progressClearTimeout = setTimeout(() => {
this.setProgress(null)
}, 5000)
}
}
displayActivity (): void {

View File

@ -79,7 +79,7 @@ $tabs-height: 36px;
position: absolute;
left: 0;
top: 0;
bottom: 0;
height: 5px;
z-index: -1;
}
}

View File

@ -295,11 +295,13 @@ export class TerminalTabComponent extends BaseTabComponent {
}
write (data: string) {
let percentageMatch = /(\d+(\.\d+)?)%/.exec(data)
let percentageMatch = /(^|[^\d])(\d+(\.\d+)?)%([^\d]|$)/.exec(data)
if (percentageMatch) {
let percentage = percentageMatch[2] ? parseFloat(percentageMatch[1]) : parseInt(percentageMatch[1])
this.setProgress(percentage)
console.log('Detected progress:', percentage)
let percentage = percentageMatch[3] ? parseFloat(percentageMatch[2]) : parseInt(percentageMatch[2])
if (percentage > 0 && percentage <= 100) {
this.setProgress(percentage)
console.log('Detected progress:', percentage)
}
} else {
this.setProgress(null)
}