Documentation ¶
Index ¶
- Constants
- func CursorMove(x, y int) string
- func CursorPos(x, y int) string
- func CursorPosX(x int) string
- func CursorPosY(y int) string
- func DisableVirtualTerminal(fd uintptr) error
- func EnableVirtualTerminal(fd uintptr) error
- func Image(img []byte) string
- func ImageWidthHeight(img []byte, height, width int, preserveAspectRatio bool) string
- func Link(url, text string) string
- func Scroll(n int) string
- func SetCwd(dir string) string
- func TextDeleteChars(n int) string
- func TextDeleteLines(n int) string
- func TextEraseChars(n int) string
- func TextInsertChars(n int) string
- func TextInsertLines(n int) string
- type ConsoleDim
Constants ¶
const ( Esc = "\u001B[" Osc = "\u001B]" Bel = "\u0007" )
Common fragments of escape sequences
const ( CursorUp = Esc + "A" CursorDown = Esc + "B" CursorForward = Esc + "C" CursorBackward = Esc + "D" CursorNextLine = Esc + "E" CursorPrevLine = Esc + "F" CursorLeft = Esc + "G" CursorTop = Esc + "d" CursorTopLeft = Esc + "H" CursorBlinkEnable = Esc + "?12h" CursorBlinkDisable = Esc + "?12I" CursorShow = Esc + "?25h" CursorHide = Esc + "?25l" ScrollUp = Esc + "S" ScrollDown = Esc + "T" TextInsertChar = Esc + "@" TextDeleteChar = Esc + "P" TextEraseChar = Esc + "X" TextInsertLine = Esc + "L" TextDeleteLine = Esc + "M" EraseRight = Esc + "K" EraseLeft = Esc + "1K" EraseLine = Esc + "2K" EraseDown = Esc + "J" EraseUp = Esc + "1J" EraseScreen = Esc + "2J" TextColorBlack = Esc + "30m" TextColorRed = Esc + "31m" TextColorGreen = Esc + "32m" TextColorYellow = Esc + "33m" TextColorBlue = Esc + "34m" TextColorMagenta = Esc + "35m" TextColorCyan = Esc + "36m" TextColorWhite = Esc + "37m" TextColorBrightBlack = Esc + "30;1m" TextColorBrightRed = Esc + "31;1m" TextColorBrightGreen = Esc + "32;1m" TextColorBrightYellow = Esc + "33;1m" TextColorBrightBlue = Esc + "34;1m" TextColorBrightMagenta = Esc + "35;1m" TextColorBrightCyan = Esc + "36;1m" TextColorBrightWhite = Esc + "37;1m" BackgroundColorBlack = Esc + "40m" BackgroundColorRed = Esc + "41m" BackgroundColorGreen = Esc + "42m" BackgroundColorYellow = Esc + "43m" BackgroundColorBlue = Esc + "44m" BackgroundColorMagenta = Esc + "45m" BackgroundColorCyan = Esc + "46m" BackgroundColorWhite = Esc + "47m" BackgroundColorBrightBlack = Esc + "40;1m" BackgroundColorBrightRed = Esc + "41;1m" BackgroundColorBrightGreen = Esc + "42;1m" BackgroundColorBrightYellow = Esc + "43;1m" BackgroundColorBrightBlue = Esc + "44;1m" BackgroundColorBrightMagenta = Esc + "45;1m" BackgroundColorBrightCyan = Esc + "46;1m" BackgroundColorBrightWhite = Esc + "47;1m" ColorReset = Esc + "0m" ClearScreen = "\u001Bc" )
Common ANSI escapes sequences. These should be used when the desired action is only needed once; otherwise, use the functions (e.g. moving a cursor several lines/columns). See: https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
const ( CursorSavePosition = Esc + "s" CursorRestorePosition = Esc + "u" )
ANSI escape sequences for saving and restoring the cursor position
Variables ¶
This section is empty.
Functions ¶
func CursorMove ¶
CursorMove returns an escape sequence to move the cursor relative to its current position.
func CursorPos ¶
CursorPos returns an escape sequence to move the cursor to a coordinate pair, where (0, 0) is the origin (top-left corner).
func CursorPosX ¶
CursorPosX returns an escape sequence to move the cursor to an x-coordinate (column) at the current y-coordinate (row), where 0 is the leftmost.
func CursorPosY ¶
CursorPosY returns an escape sequence to move the cursor to an y-coordinate (row) at the current x-coordinate (column), where 0 is the topmost.
func DisableVirtualTerminal ¶
DisableVirtualTerminal disables virtual terminal escapes sequences for a console handle. It is only effective when built for Windows. On other OSes, it will simply return nil.
func EnableVirtualTerminal ¶
EnableVirtualTerminal enables virtual terminal escapes sequences for a console handle. It is only effective when built for Windows. On other OSes, it will simply return nil.
func Image ¶
Image returns an escape sequence to display an image, preserving the original height and width.
func ImageWidthHeight ¶
ImageWidthHeight returns an escape sequence to display an image.
func Scroll ¶
Scroll returns an escape sequence to scroll the current window. A positive number of lines indicates scrolling up, while a negative number of lines indicates scrolling down.
func TextDeleteChars ¶
TextDeleteChars returns an escape sequence to delete characters to the right of, and including, the current cursor position, shifting existing characters to the left.
func TextDeleteLines ¶
TextDeleteLines returns an escape sequence to delete the lines below, and including, the current cursor row.
func TextEraseChars ¶
TextEraseChars returns an escape sequence to insert spaces to the right of, and including, the current cursor position, overwriting existing characters to the right.
func TextInsertChars ¶
TextInsertChars returns an escape sequence to insert spaces to the right of, and including, the current cursor position, shifting existing characters to the right.
func TextInsertLines ¶
TextInsertLines returns an escape sequence to insert blank lines below, and including the current cursor row, shifting existing lines downwards.
Types ¶
type ConsoleDim ¶
ConsoleDim represents the dimensions of a console in rows and columns.
func GetConsoleSize ¶
func GetConsoleSize(fd uintptr) (*ConsoleDim, error)