Documentation
¶
Index ¶
- Variables
- func MustParseHexRGB(hex string) (r, g, b uint8)
- func NewString(f func(Buffer)) string
- func String(s string, mods ...Modifier) string
- func ToHex(color Modifier) string
- type Buffer
- func (b Buffer) Bytes(bs ...byte) Buffer
- func (b Buffer) ChangeScrollingRegion(top, bottom int) Buffer
- func (b Buffer) ClearLine() Buffer
- func (b Buffer) ClearLineLeft() Buffer
- func (b Buffer) ClearLineRight() Buffer
- func (b Buffer) ClearLines(n int) Buffer
- func (b Buffer) ClearScreen() Buffer
- func (b Buffer) Copy(str string) Buffer
- func (b Buffer) CopyPrimary(str string) Buffer
- func (b Buffer) CursorBack(n int) Buffer
- func (b Buffer) CursorDown(n int) Buffer
- func (b Buffer) CursorForward(n int) Buffer
- func (b Buffer) CursorNextLine(n int) Buffer
- func (b Buffer) CursorPrevLine(n int) Buffer
- func (b Buffer) CursorUp(n int) Buffer
- func (b Buffer) DeleteLines(n int) Buffer
- func (b Buffer) Disable(d Device) Buffer
- func (b Buffer) Enable(d Device) Buffer
- func (b Buffer) Hyperlink(link, name string) Buffer
- func (b Buffer) InBytePair(start, end byte, f func(Buffer)) Buffer
- func (b Buffer) InsertLines(n int) Buffer
- func (b Buffer) Iter(seq func(yield func(func(Buffer)) bool) bool) Buffer
- func (b Buffer) MoveCursor(row, column int) Buffer
- func (b Buffer) NL() Buffer
- func (b Buffer) Notify(title, body string) Buffer
- func (b Buffer) Printf(format string, args ...any) Buffer
- func (b Buffer) RepeatByte(c byte, n int) Buffer
- func (b Buffer) RestoreCursorPosition() Buffer
- func (b Buffer) SPC() Buffer
- func (b Buffer) SaveCursorPosition() Buffer
- func (b Buffer) SetBackgroundColor(hex string) Buffer
- func (b Buffer) SetCursorColor(hex string) Buffer
- func (b Buffer) SetForegroundColor(hex string) Buffer
- func (b Buffer) SetWindowTitle(title string) Buffer
- func (b Buffer) String(s string, mods ...Modifier) Buffer
- func (b Buffer) Styled(f func(Buffer), mods ...Modifier) Buffer
- func (b Buffer) TAB() Buffer
- type Device
- type Modifier
Constants ¶
This section is empty.
Variables ¶
var ( // Foreground colors FgBlack = FgANSI(0) FgRed = FgANSI(1) FgGreen = FgANSI(2) FgYellow = FgANSI(3) FgBlue = FgANSI(4) FgMagenta = FgANSI(5) FgCyan = FgANSI(6) FgWhite = FgANSI(7) // Foreground bright colors FgHiBlack = FgANSI(8) FgHiRed = FgANSI(9) FgHiGreen = FgANSI(10) FgHiYellow = FgANSI(11) FgHiBlue = FgANSI(12) FgHiMagenta = FgANSI(13) FgHiCyan = FgANSI(14) FgHiWhite = FgANSI(15) // Background colors BgBlack = BgANSI(0) BgRed = BgANSI(1) BgGreen = BgANSI(2) BgYellow = BgANSI(3) BgBlue = BgANSI(4) BgMagenta = BgANSI(5) BgCyan = BgANSI(6) BgWhite = BgANSI(7) // Background bright colors BgHiBlack = BgANSI(8) BgHiRed = BgANSI(9) BgHiGreen = BgANSI(10) BgHiYellow = BgANSI(11) BgHiBlue = BgANSI(12) BgHiMagenta = BgANSI(13) BgHiCyan = BgANSI(14) BgHiWhite = BgANSI(15) ModReset = Modifier("0") ModBold = Modifier("1") ModFaint = Modifier("2") ModItalic = Modifier("3") ModUnderline = Modifier("4") ModBlink = Modifier("5") ModReverse = Modifier("7") ModCrossout = Modifier("9") ModOverline = Modifier("53") )
Functions ¶
func MustParseHexRGB ¶
MustParseHexRGB parses hex color string, in form "#f0c" or "#ff1034". If color is invalid, returns black (or junk)
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
func (Buffer) ChangeScrollingRegion ¶
ChangeScrollingRegion sets the scrolling region of the terminal
func (Buffer) ClearLineLeft ¶
ClearLineLeft clears the line to the left of the cursor.
func (Buffer) ClearLineRight ¶
ClearLineRight clears the line to the right of the cursor.
func (Buffer) ClearLines ¶
ClearLines clears a given number of lines.
func (Buffer) ClearScreen ¶
ClearScreen clears the visible portion of the terminal.
func (Buffer) CopyPrimary ¶
CopyPrimary text to primary clipboard (X11) using OSC 52 escape sequence
func (Buffer) CursorBack ¶
CursorBack moves the cursor backwards a given number of cells.
func (Buffer) CursorDown ¶
CursorDown moves the cursor down a given number of lines.
func (Buffer) CursorForward ¶
CursorForward moves the cursor up a given number of lines.
func (Buffer) CursorNextLine ¶
CursorNextLine moves the cursor down a given number of lines and places it at the beginning of the line.
func (Buffer) CursorPrevLine ¶
CursorPrevLine moves the cursor up a given number of lines and places it at the beginning of the line.
func (Buffer) DeleteLines ¶
DeleteLines deletes the given number of lines, pulling any lines in the scrollable region below up
func (Buffer) InBytePair ¶
InBytePair writes callback inside given byte pair, e.g. parentheses or quotes
func (Buffer) InsertLines ¶
InsertLines inserts the given number of lines at the top of the scrollable region, pushing lines below down.
func (Buffer) MoveCursor ¶
MoveCursor moves the cursor to a given position.
func (Buffer) RepeatByte ¶
RepeatByte repeats byte n times
func (Buffer) RestoreCursorPosition ¶
RestoreCursorPosition restores a saved cursor position.
func (Buffer) SaveCursorPosition ¶
SaveCursorPosition saves the cursor position.
func (Buffer) SetBackgroundColor ¶
SetBackgroundColor set default background color
func (Buffer) SetCursorColor ¶
SetCursorColor set cursor color
func (Buffer) SetForegroundColor ¶
SetForegroundColor set default foreground color
func (Buffer) SetWindowTitle ¶
SetWindowTitle sets the terminal window title
type Device ¶
type Device int
Device things that can be enabled and disabled e.g. for handling events, changing to alt screen, showing/hiding cursor, etc.
const ( // MousePress enables X10 mouse mode. Button press events are sent only. press only (X10) MousePress Device = 9 // Cursor shows cursor on enable, hides on disable Cursor Device = 25 // SaveScreen saves the screen state on enable, on disable restors previously saved screen state SaveScreen Device = 47 // Mouse enables Mouse Tracking mode. press, release, wheel Mouse Device = 1000 // MouseHilite enables Hilite Mouse Tracking mode. MouseHilite Device = 1001 // MouseCellMotion enables Cell Motion Mouse Tracking mode. press, release, move on pressed, wheel MouseCellMotion Device = 1002 // MouseAllMotion enables All Motion Mouse mode. press, release, move, wheel MouseAllMotion Device = 1003 // MouseExtendedMotion enables Extended Mouse mode (SGR). This should be enabled in conjunction with // MouseCellMotion, and MouseAllMotion. press, release, move, wheel, extended coordinates MouseExtendedMode Device = 1006 // MousePixelsMotion enables Pixel Motion Mouse mode (SGR-Pixels). This should be enabled in conjunction with // MouseCellMotion, and MouseAllMotion. press, release, move, wheel, extended pixel coordinates MousePixelsMode Device = 1016 // AltScreen switches to the alternate screen buffer on enable. On disable former view is restored AltScreen Device = 1049 // BracketedPaste enables bracketed paste BracketedPaste Device = 2004 )