Skip to content

Commit 6188f76

Browse files
authored
Merge pull request #5290 from Tyriar/progress_polish
Progress polish
2 parents 330e91e + dc9084b commit 6188f76

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

addons/addon-progress/src/ProgressAddon.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ export class ProgressAddon implements ITerminalAddon, IProgressApi {
3737
private _seqHandler: IDisposable | undefined;
3838
private _st: ProgressType = ProgressType.REMOVE;
3939
private _pr = 0;
40-
private _onChange: Emitter<IProgressState> | undefined;
41-
public onChange: Event<IProgressState> | undefined;
40+
// HACK: This uses ! to align with the API, this should be fixed when 5283 is resolved
41+
private _onChange!: Emitter<IProgressState>;
42+
public onChange!: Event<IProgressState>;
4243

4344
public dispose(): void {
4445
this._seqHandler?.dispose();

addons/addon-progress/typings/addon-progress.d.ts

+25-11
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@
33
* @license MIT
44
*/
55

6-
import { Terminal, ITerminalAddon, IDisposable } from '@xterm/xterm';
7-
import type { Event } from 'vs/base/common/event';
8-
6+
import { Terminal, ITerminalAddon, IDisposable, IEvent } from '@xterm/xterm';
97

108
declare module '@xterm/addon-progress' {
119
/**
1210
* An xterm.js addon that provides an interface for ConEmu's progress
1311
* sequence.
1412
*/
1513
export class ProgressAddon implements ITerminalAddon, IDisposable {
16-
14+
1715
/**
1816
* Creates a new progress addon
1917
*/
@@ -24,7 +22,7 @@ declare module '@xterm/addon-progress' {
2422
* @param terminal The terminal the addon is being loaded in.
2523
*/
2624
public activate(terminal: Terminal): void;
27-
25+
2826
/**
2927
* Disposes the addon.
3028
*/
@@ -33,22 +31,38 @@ declare module '@xterm/addon-progress' {
3331
/**
3432
* An event that fires when the tracked progress changes.
3533
*/
36-
public readonly onChange: Event<IProgressState> | undefined;
34+
public readonly onChange: IEvent<IProgressState> | undefined;
3735

3836
/**
39-
* Gets or sets the current progress tracked by the addon.
40-
* This can also be used to reset a stuck progress indicator
41-
* back to initial with `{state: 0, value: 0}`
42-
* or to restore an indicator.
37+
* Gets or sets the current progress tracked by the addon. This can be used
38+
* to reset a stuck progress indicator back to initial with
39+
* `{ state: 0, value: 0 }` or to restore an indicator.
4340
*/
4441
public progress: IProgressState;
4542
}
46-
43+
4744
/**
4845
* Progress state tracked by the addon.
4946
*/
5047
export interface IProgressState {
48+
/**
49+
* The progress state.
50+
*
51+
* - `0`: No progress. Setting this will resets progress value to 0
52+
* regardless of the {@link value} used.
53+
* - `1`: Normal percentage-based from 0 to 100.
54+
* - `2`: Error with an optional progress value from 0 to 100.
55+
* - `3`: Indeterminate progress, any progress value will be ignored. This
56+
* is used to indicate work is happening but a percentage value cannot be
57+
* determined.
58+
* - `4`: Pause or warning state with an optional progress value.
59+
*/
5160
state: 0 | 1 | 2 | 3 | 4;
61+
62+
/**
63+
* The percentage value of progress from 0 to 100. See {@link state} for
64+
* whether this is relevant.
65+
*/
5266
value: number;
5367
}
5468
}

0 commit comments

Comments
 (0)