Documentation
¶
Index ¶
- Constants
- Variables
- func EnterMode(w io.Writer, m Mode) (restore func() error, err error)
- func Events(reader iox.ContextReader) (func(ctx context.Context), <-chan any)
- func ExitMode(w io.Writer, m Mode) (restore func() error, err error)
- func FormatSGR[T constraints.Integer](p ...T) string
- func IsCSIFinalByte(b byte) bool
- func IsESCFinalByte(b byte) bool
- func ScanCSI(ctx context.Context, i *InputBuffer) (next ScanFn, seq Sequence, err error)
- func ScanDCS(ctx context.Context, i *InputBuffer) (next ScanFn, seq Sequence, err error)
- func ScanInitial(ctx context.Context, i *InputBuffer) (next ScanFn, seq Sequence, err error)
- func ScanInvalid(ctx context.Context, i *InputBuffer) (next ScanFn, seq Sequence, err error)
- func ScanMeta(ctx context.Context, i *InputBuffer) (next ScanFn, seq Sequence, err error)
- func ScanOSC(ctx context.Context, i *InputBuffer) (next ScanFn, seq Sequence, err error)
- func ScanPaste(ctx context.Context, i *InputBuffer) (next ScanFn, seq Sequence, err error)
- func ScanSS3(ctx context.Context, i *InputBuffer) (next ScanFn, seq Sequence, err error)
- func ScanUtf8(ctx context.Context, i *InputBuffer) (next ScanFn, seq Sequence, err error)
- type Attr
- type BgBrightColor
- type BgColor
- type Color
- type FgBrightColor
- type FgColor
- type InputBuffer
- type Key
- type KeyEvent
- type Mode
- type PasteEvent
- type ScanFn
- type Sequence
- type SequenceScanner
- type SequenceType
Constants ¶
const ( ReverseIndex = ESC + "M" SaveCursor = ESC + "7" RestoreCursor = ESC + "8" )
Simple Cursor Positioning
const ( CursorUpFmt = CSI + "%dA" CursorDownFmt = CSI + "%dB" CursorRightFmt = CSI + "%dC" CursorLeftFmt = CSI + "%dD" CursorNextLineFmt = CSI + "%dE" CursorPrevLineFmt = CSI + "%dF" CursorHorizontalLineFmt = CSI + "%dG" CursorVerticalLineFmt = CSI + "%dd" CursorPositionFmt = CSI + "%d;%dH" CursorHorizontalVerticalPostionFmt = CSI + "%d;%df" SaveCursorAnsi = CSI + "s" RestoreCursorAnsi = CSI + "u" )
Cursor Positioning
const ( CursorBlink = CSI + "?12h" CursorNoBlink = CSI + "?12l" CursorShow = CSI + "?25h" CursorHide = CSI + "?25l" )
Cursor Visibility
const ( CursorShapeDefault = CSI + "0 q" CursorShapeBlockBlink = CSI + "1 q" CursorShapeBlock = CSI + "2 q" CursorShapeUnderlineBlink = CSI + "3 q" CursorShapeUnderline = CSI + "4 q" CursorShapeBarBlink = CSI + "5 q" CursorShapeBar = CSI + "6 q" )
Cursor Shape
const ( KeypadApplicationMode = ESC + "=" KeypadNumericMode = ESC + ">" )
Mode Changes See: https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#mode-changes
const ( PasteBegin = CSI + "200~" PasteEnd = CSI + "201~" )
const ( QueryCursorPosition = CSI + "6n" QueryDeviceAttributes = CSI + "0c" QueryTerminalName = CSI + ">q" QueryOSCFmt = OSC + "%d;?" + BEL QueryFgColor = OSC + "10;?" + BEL QueryBgColor = OSC + "11;?" + BEL QueryCursorColor = OSC + "12;?" + BEL )
Query State See: https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#query-state
const ( SGRFmt = CSI + "%dm" SGRReset = CSI + "0m" )
Text Formatting See: https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#text-formatting
const ( FgColor256Fmt = "38;5;%d" BgColor256Fmt = "48;5;%d" FgColorRGBFmt = "38;2;%d;%d;%d" BgColorRGBFmt = "48;2;%d;%d;%d" )
Extended Colors
const ( InsertCharFmt = CSI + "%d@" DeleteCharFmt = CSI + "%dP" EraseCharFmt = CSI + "%dX" InsertLineFmt = CSI + "%dL" DeleteLineFmt = CSI + "%dM" EraseLineFromCursor = CSI + "0K" EraseLineFromStart = CSI + "1K" EraseEntireLine = CSI + "2K" EraseScreenToBottom = CSI + "0J" EraseEntireScreen = CSI + "2J" )
Text Modification See: https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#text-modification
const ( ESC = "\x1b" CSI = ESC + "[" OSC = ESC + "]" DCS = ESC + "P" SS3 = ESC + "O" ST = ESC + "\\" BEL = "\a" )
See: https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
const (
DefaultEscapeTimeout = 20 * time.Millisecond
)
const (
EscByte byte = 0x1B
)
const (
ModifyScreenColorsFmt = OSC + "4;%d;rgb:%02x/%02x/%02x" + ST
)
Screen Colors
const (
SetWindowTitleFmt = OSC + "2;%s" + ST
)
const (
SoftReset = CSI + "!p"
)
Variables ¶
var ErrInvalidSeq = fmt.Errorf("the sequence is invalid")
var KeyToCanonical = map[Key]Key{ KeyCtrlH: KeyCtrlBackspace, KeyCtrlI: KeyTab, KeyCtrlJ: KeyCtrlEnter, KeyCtrlM: KeyEnter, KeyCtrlZ: KeyPause, }
var SequenceToKey = map[string]Key{}/* 153 elements not displayed */
Functions ¶
func FormatSGR ¶
func FormatSGR[T constraints.Integer](p ...T) string
func IsCSIFinalByte ¶
func IsESCFinalByte ¶
func ScanInitial ¶
func ScanInvalid ¶
Types ¶
type Attr ¶
type Attr uint32
type BgBrightColor ¶
type BgBrightColor uint32
const ( BgBrightBlack BgBrightColor = iota + 100 BgBrightRed BgBrightGreen BgBrightYellow BgBrightBlue BgBrightMagenta BgBrightCyan BgBrightWhite )
Background Colors (Bright/High Intensity)
func (BgBrightColor) String ¶
func (i BgBrightColor) String() string
type BgColor ¶
type BgColor uint32
type FgBrightColor ¶
type FgBrightColor uint32
const ( FgBrightBlack FgBrightColor = iota + 90 FgBrightRed FgBrightGreen FgBrightYellow FgBrightBlue FgBrightMagenta FgBrightCyan FgBrightWhite )
Foreground Colors (Bright/High Intensity)
func (FgBrightColor) String ¶
func (i FgBrightColor) String() string
type FgColor ¶
type FgColor uint32
type InputBuffer ¶
type InputBuffer struct {
*bufiox.ContextReader
BurstTimeout time.Duration
}
type Key ¶
type Key int
const ( KeyUnknown Key = iota KeyTab KeyShiftTab KeyUp KeyDown KeyRight KeyLeft KeyHome KeyEnd KeyCtrlUp KeyCtrlDown KeyCtrlRight KeyCtrlLeft KeyAltUp KeyAltDown KeyAltRight KeyAltLeft KeyShiftUp KeyShiftDown KeyShiftRight KeyShiftLeft KeySpace KeyEnter KeyBackspace KeyPause KeyEsc KeyInsert KeyDelete KeyPageUp KeyPageDown KeyCtrlEnter KeyCtrlBackspace KeyF1 KeyF2 KeyF3 KeyF4 KeyF5 KeyF6 KeyF7 KeyF8 KeyF9 KeyF10 KeyF11 KeyF12 KeyA KeyB KeyC KeyD KeyE KeyF KeyG KeyH KeyI KeyJ KeyK KeyL KeyM KeyN KeyO KeyP KeyQ KeyR KeyS KeyT KeyU KeyV KeyW KeyX KeyY KeyZ KeyCtrlA KeyCtrlB KeyCtrlC KeyCtrlD KeyCtrlE KeyCtrlF KeyCtrlG KeyCtrlH KeyCtrlI KeyCtrlJ KeyCtrlK KeyCtrlL KeyCtrlM KeyCtrlN KeyCtrlO KeyCtrlP KeyCtrlQ KeyCtrlR KeyCtrlS KeyCtrlT KeyCtrlU KeyCtrlV KeyCtrlW KeyCtrlX KeyCtrlY KeyCtrlZ KeyShiftA KeyShiftB KeyShiftC KeyShiftD KeyShiftE KeyShiftF KeyShiftG KeyShiftH KeyShiftI KeyShiftJ KeyShiftK KeyShiftL KeyShiftM KeyShiftN KeyShiftO KeyShiftP KeyShiftQ KeyShiftR KeyShiftS KeyShiftT KeyShiftU KeyShiftV KeyShiftW KeyShiftX KeyShiftY KeyShiftZ KeyAltA KeyAltB KeyAltC KeyAltD KeyAltE KeyAltF KeyAltG KeyAltH KeyAltI KeyAltJ KeyAltK KeyAltL KeyAltM KeyAltN KeyAltO KeyAltP KeyAltQ KeyAltR KeyAltS KeyAltT KeyAltU KeyAltV KeyAltW KeyAltX KeyAltY KeyAltZ KeyAlt0 KeyAlt1 KeyAlt2 KeyAlt3 KeyAlt4 KeyAlt5 KeyAlt6 KeyAlt7 KeyAlt8 KeyAlt9 )
func (Key) Equivalents ¶
type PasteEvent ¶
type PasteEvent struct {
Bytes []byte
}
type Sequence ¶
type Sequence struct {
Data []byte
Type SequenceType
}
func (Sequence) Is ¶
func (s Sequence) Is(types ...SequenceType) bool
type SequenceScanner ¶
type SequenceScanner struct {
// contains filtered or unexported fields
}
func NewSequenceScanner ¶
func NewSequenceScanner(r iox.ContextReader, f ScanFn) *SequenceScanner
func (*SequenceScanner) Err ¶
func (s *SequenceScanner) Err() error
func (*SequenceScanner) ScanContext ¶
func (s *SequenceScanner) ScanContext(ctx context.Context) bool
func (*SequenceScanner) Sequence ¶
func (s *SequenceScanner) Sequence() Sequence
func (*SequenceScanner) SetBurstTimeout ¶
func (s *SequenceScanner) SetBurstTimeout(d time.Duration)
type SequenceType ¶
type SequenceType int
const ( SeqUnknown SequenceType = iota SeqEscape SeqUTF8 SeqCSI SeqOSC SeqDCS SeqSS3 SeqMeta SeqPaste )
func (SequenceType) String ¶
func (i SequenceType) String() string