Documentation
¶
Overview ¶
Package osc94 provides OSC 9;4 progress reporting helpers.
The OSC 9;4 sequence lets terminals show a progress indicator in tabs or taskbars. This package focuses on safe, opt-in output for CLI apps.
Index ¶
- func Detect(writer io.Writer) bool
- func Escape(state State, percent int) (string, error)
- type Option
- type Progress
- func (progress *Progress) Clear() error
- func (progress *Progress) Error(percent int) error
- func (progress *Progress) Indeterminate() error
- func (progress *Progress) Set(state State, percent int) error
- func (progress *Progress) SetPercent(percent int) error
- func (progress *Progress) Warning(percent int) error
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(*Progress)
Option configures a Progress instance.
func WithAutoEnable ¶
func WithAutoEnable() Option
WithAutoEnable enables output only when Detect reports support.
func WithDetector ¶
WithDetector uses a custom detector to decide enablement.
func WithEnabled ¶
WithEnabled forces progress output on or off.
func WithTerminatorBEL ¶
func WithTerminatorBEL() Option
WithTerminatorBEL uses BEL (\a) to terminate OSC sequences.
func WithTerminatorST ¶
func WithTerminatorST() Option
WithTerminatorST uses ST (ESC \\) to terminate OSC sequences.
type Progress ¶
type Progress struct {
// contains filtered or unexported fields
}
Progress writes OSC 9;4 sequences to an output stream.
func New ¶
New returns a Progress writer bound to the provided output.
The default behavior is enabled output with a BEL terminator.
func (*Progress) Indeterminate ¶
Indeterminate switches to the indeterminate state.
func (*Progress) Set ¶
Set writes a progress update using the provided state and percentage.
Percent must be 0-100 unless state is StateIndeterminate.
func (*Progress) SetPercent ¶
SetPercent updates progress using the normal state.