Documentation ¶
Overview ¶
Package ansi provides helper functions for writing ANSI terminal escape codes.
Index ¶
Constants ¶
const ( // SaveCursorPosition saves the current cursor position. SaveCursorPosition = "\u001b7" // RestoreCursorPosition restores the cursor position to the saved position. RestoreCursorPosition = "\u001b8" )
Variables ¶
This section is empty.
Functions ¶
func ClearLine ¶
func ClearLine(method ClearLineMethod) string
ClearLine clears the current line according to the given method. The cursor position within the line does not change.
func ClearScreen ¶
func ClearScreen(method ClearScreenMethod) string
ClearScreen clears the screen according to the given method.
func MoveCursorLeft ¶
MoveCursorLeft moves the cursor left n cells. If the cursor is already at the edge of the screen it has no effect. If n is negative it moves to the right instead.
func MoveCursorRight ¶
MoveCursorRight moves the cursor right n cells. If the cursor is already at the edge of the screen it has no effect. If n is negative it moves to the left instead.
func SetCursorPosition ¶
SetCursorPosition returns the ANSI escape code for setting the cursor position. The rows and columns are one-based. If <=0 they default to the first row/column.
Types ¶
type ClearLineMethod ¶
type ClearLineMethod int
const ( CursorToEnd ClearLineMethod = 0 // cursor to end of line CursorToStart ClearLineMethod = 1 // cursor to start of line WholeLine ClearLineMethod = 2 )
type ClearScreenMethod ¶
type ClearScreenMethod int
const ( CursorToBottom ClearScreenMethod = 0 CursorToTop ClearScreenMethod = 1 WholeScreen ClearScreenMethod = 2 WholeScreenAndScrollback ClearScreenMethod = 3 )