Documentation
¶
Overview ¶
Package control provides control sequence types and builders for VT220 terminals. It defines the escape sequences used for character set designation, invocation (lock shifts and single shifts), and other terminal control functions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DesignateG0 is ESC ( - designate character set to G0 DesignateG0 = Prefix{mnemonic.ESC, codetable.C02R08} // ESC ( // DesignateG1 is ESC ) - designate character set to G1 DesignateG1 = Prefix{mnemonic.ESC, codetable.C02R09} // ESC ) // DesignateG2 is ESC * - designate character set to G2 DesignateG2 = Prefix{mnemonic.ESC, codetable.C02R10} // ESC * // DesignateG3 is ESC + - designate character set to G3 DesignateG3 = Prefix{mnemonic.ESC, codetable.C02R11} // ESC + )
Designation prefixes for Select Character Set (SCS) sequences. These are used to designate a character set into one of the four graphic registers (G0, G1, G2, G3).
Usage: DesignateG0.With(dscs...) where dscs is the DSCS identifier bytes
var ( // LS0 (Locking Shift 0) invokes G0 into GL. Also known as SI. LS0 = Sequence{mnemonic.SI} // LS1 (Locking Shift 1) invokes G1 into GL. Also known as SO. LS1 = Sequence{mnemonic.SO} // LS1R (Locking Shift 1 Right) invokes G1 into GR. LS1R = Sequence{mnemonic.ESC, codetable.C07R14} // ESC ~ // LS2 (Locking Shift 2) invokes G2 into GL. LS2 = Sequence{mnemonic.ESC, codetable.C06R14} // ESC n // LS2R (Locking Shift 2 Right) invokes G2 into GR. LS2R = Sequence{mnemonic.ESC, codetable.C07R13} // ESC } // LS3 (Locking Shift 3) invokes G3 into GL. LS3 = Sequence{mnemonic.ESC, codetable.C06R15} // ESC o // LS3R (Locking Shift 3 Right) invokes G3 into GR. LS3R = Sequence{mnemonic.ESC, codetable.C07R12} // ESC | )
Lock shift sequences invoke a graphic register into GL or GR. Once invoked, all subsequent graphic characters use that register until another shift sequence is issued.
var ( // SS2 (Single Shift 2) temporarily invokes G2 into GL for one character. // Uses the 8-bit C1 control character. SS2 = Sequence{mnemonic.SS2} // SS3 (Single Shift 3) temporarily invokes G3 into GL for one character. // Uses the 8-bit C1 control character. SS3 = Sequence{mnemonic.SS3} // SS2_7bit is the 7-bit representation of SS2 (ESC N). SS2_7bit = Sequence{mnemonic.ESC, codetable.C04R14} // SS3_7bit is the 7-bit representation of SS3 (ESC O). SS3_7bit = Sequence{mnemonic.ESC, codetable.C04R15} )
Single shift sequences temporarily invoke a graphic register into GL for the next graphic character only, then revert to the previous state.
var ( // DECNRCMSet enables NRC mode (CSI ? 4 2 h) DECNRCMSet = Sequence{mnemonic.CSI, codetable.C03R15, codetable.C03R04, codetable.C03R02, codetable.C06R08} // DECNRCMReset disables NRC mode (CSI ? 4 2 l) DECNRCMReset = Sequence{mnemonic.CSI, codetable.C03R15, codetable.C03R04, codetable.C03R02, codetable.C06R12} )
DECNRCM controls the National Replacement Character set mode.
var ( // ED2 (Erase in Display) clears the entire screen (CSI 2 J) ED2 = Sequence{mnemonic.CSI, codetable.C03R02, codetable.C04R10} // CursorHome moves cursor to top-left position (CSI H) CursorHome = Sequence{mnemonic.CSI, codetable.C04R08} )
Screen control sequences.
var ( // RIS (Reset to Initial State) performs a hard reset of the terminal. // This resets the terminal to power-up state. ESC c RIS = Sequence{mnemonic.ESC, codetable.C06R03} // ESC c // DECSTR (Soft Terminal Reset) performs a soft reset. // Resets terminal modes and character sets without clearing screen // or affecting communication settings. CSI ! p DECSTR = Sequence{mnemonic.CSI, codetable.C02R01, codetable.C07R00} // CSI ! p )
Terminal reset sequences.
var ClearScreen = Sequence{ mnemonic.CSI, codetable.C03R02, codetable.C04R10, mnemonic.CSI, codetable.C04R08, }
ClearScreen is a convenience sequence that clears the screen and moves cursor to home position.
Functions ¶
This section is empty.
Types ¶
type Prefix ¶
type Prefix []byte
Prefix represents an incomplete control sequence that requires additional bytes to form a complete sequence. Use With() to append final bytes.
type RegisterIndex ¶
type RegisterIndex int
RegisterIndex identifies one of the four graphic registers.
const ( G0 RegisterIndex = iota G1 G2 G3 )
func (RegisterIndex) DesignationPrefix ¶
func (r RegisterIndex) DesignationPrefix() Prefix
DesignationPrefix returns the SCS designation prefix for this register.
func (RegisterIndex) LockShiftGL ¶
func (r RegisterIndex) LockShiftGL() Sequence
LockShiftGL returns the lock shift sequence to invoke this register into GL.
func (RegisterIndex) LockShiftGR ¶
func (r RegisterIndex) LockShiftGR() Sequence
LockShiftGR returns the lock shift sequence to invoke this register into GR. G0 cannot be invoked into GR, so it returns nil.
func (RegisterIndex) SingleShift ¶
func (r RegisterIndex) SingleShift() Sequence
SingleShift returns the single shift sequence for this register. Only G2 and G3 support single shifts.
type SGRParam ¶
type SGRParam byte
SGRParam represents a Select Graphic Rendition parameter.
const ( SGRReset SGRParam = SGRParam(codetable.C03R00) // 0 - Reset all attributes SGRBold SGRParam = SGRParam(codetable.C03R01) // 1 - Bold SGRUnderline SGRParam = SGRParam(codetable.C03R04) // 4 - Underline SGRBlink SGRParam = SGRParam(codetable.C03R05) // 5 - Blink SGRNegative SGRParam = SGRParam(codetable.C03R07) // 7 - Negative (reverse video) )
SGR parameters for character attributes.
type Sequence ¶
type Sequence []byte
Sequence represents a complete control sequence that can be written to a terminal. It wraps a byte slice containing the escape sequence.
func SGR ¶
SGR builds a Select Graphic Rendition control sequence with the given parameters. Multiple parameters are separated by semicolons.