addons/addon-progress/README.md
An xterm.js addon providing an interface for ConEmu's progress sequence. See https://conemu.github.io/en/AnsiEscapeCodes.html#ConEmu_specific_OSC for sequence details.
npm install --save @xterm/addon-progress
import { Terminal } from '@xterm/xterm';
import { ProgressAddon, IProgressState } from '@xterm/addon-progress';
const terminal = new Terminal();
const progressAddon = new ProgressAddon();
terminal.loadAddon(progressAddon);
progressAddon.onChange({state, value}: IProgressState) => {
// state: 0-4 integer (see below for meaning)
// value: 0-100 integer (percent value)
// do your visualisation based on state/value here
...
});
See the full API for more advanced usage.
The sequence to set progress information has the following format:
ESC ] 9 ; 4 ; <state> ; <progress value> BEL
where state is a decimal number in 0 to 4 and progress value is a decimal number in 0 to 100. The states have the following meaning:
The addon resolves most of those semantic nuances and will provide these ready-to-go values:
{state: 0, value: 0}.{state: 1, value: 0}.
If a value was given, it must be decimal digits only, any characters outside will mark the whole sequence
as faulty (no sloppy integer parsing). The value will be clamped to max 100 giving
{state: 1, value: parsedAndClampedValue}.{state: 2|4, value: lastValue}.
If a value was given, it must be decimal digits only, any characters outside will mark the whole sequence
as faulty (no sloppy integer parsing). The value will be clamped to max 100 giving
{state: 2|4, value: parsedAndClampedValue}.{state: 3, value: lastValue}. Keep in mind not use that value while
that state is active, as a task might have entered that state without a proper reset at the beginning.