mirror of
https://github.com/Eugeny/tabby.git
synced 2024-12-09 06:20:22 +08:00
smarter progress detection (fixes #406)
This commit is contained in:
parent
5b76947d70
commit
0749096d9f
@ -15,6 +15,8 @@ export abstract class BaseTabComponent {
|
|||||||
protected progress = new Subject<number>()
|
protected progress = new Subject<number>()
|
||||||
protected activity = new Subject<boolean>()
|
protected activity = new Subject<boolean>()
|
||||||
|
|
||||||
|
private progressClearTimeout: 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 }
|
||||||
@ -40,6 +42,14 @@ export abstract class BaseTabComponent {
|
|||||||
|
|
||||||
setProgress (progress: number) {
|
setProgress (progress: number) {
|
||||||
this.progress.next(progress)
|
this.progress.next(progress)
|
||||||
|
if (progress) {
|
||||||
|
if (this.progressClearTimeout) {
|
||||||
|
clearTimeout(this.progressClearTimeout)
|
||||||
|
}
|
||||||
|
this.progressClearTimeout = setTimeout(() => {
|
||||||
|
this.setProgress(null)
|
||||||
|
}, 5000)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
displayActivity (): void {
|
displayActivity (): void {
|
||||||
|
@ -79,7 +79,7 @@ $tabs-height: 36px;
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
bottom: 0;
|
height: 5px;
|
||||||
z-index: -1;
|
z-index: -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,11 +295,13 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
write (data: string) {
|
write (data: string) {
|
||||||
let percentageMatch = /(\d+(\.\d+)?)%/.exec(data)
|
let percentageMatch = /(^|[^\d])(\d+(\.\d+)?)%([^\d]|$)/.exec(data)
|
||||||
if (percentageMatch) {
|
if (percentageMatch) {
|
||||||
let percentage = percentageMatch[2] ? parseFloat(percentageMatch[1]) : parseInt(percentageMatch[1])
|
let percentage = percentageMatch[3] ? parseFloat(percentageMatch[2]) : parseInt(percentageMatch[2])
|
||||||
this.setProgress(percentage)
|
if (percentage > 0 && percentage <= 100) {
|
||||||
console.log('Detected progress:', percentage)
|
this.setProgress(percentage)
|
||||||
|
console.log('Detected progress:', percentage)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.setProgress(null)
|
this.setProgress(null)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user