Documentation
¶
Index ¶
- Constants
- func CursorBackward(columns int) string
- func CursorDown(lines int) string
- func CursorForward(columns int) string
- func CursorHorizontalAbsolute(column int) string
- func CursorNextLine(lines int) string
- func CursorPosition(row, column int) string
- func CursorPreviousLine(lines int) string
- func CursorUp(lines int) string
- func DeleteCharacters(n int) string
- func DeleteLines(n int) string
- func DesignateCharacterSet(g int, charset byte) string
- func EraseInDisplayMode(n int) string
- func EraseInLineMode(n int) string
- func InsertCharacters(n int) string
- func InsertLines(n int) string
- func ReportCursorPosition(row, col int) string
- func RequestCursorPosition() string
- func RequestTerminalParameters() string
- func ResetMode(mode int) string
- func ScrollDownLines(lines int) string
- func ScrollUpLines(lines int) string
- func SetBackgroundColor(color int) string
- func SetCharacterSet(g int, charset byte) string
- func SetConformanceLevel(level int) string
- func SetGraphicsRendition(params ...int) string
- func SetMode(mode int) string
- func SetRGBBackgroundColor(r, g, b int) string
- func SetRGBTextColor(r, g, b int) string
- func SetScrollingRegion(top, bottom int) string
- func SetTextColor(color int) string
- func SoftTerminalReset() string
- func WindowManipulation(ps int, args ...int) string
Examples ¶
Constants ¶
const ( // ReverseIndex performs the reverse operation of \n, moves cursor up one line, maintains horizontal position, scrolls buffer if necessary ReverseIndex = "\033M" // SaveCursorPointerInMemory saves the cursor position in memory SaveCursorPointerInMemory = "\0337" // RestoreCursorPointerFromMemory restores the cursor position from memory RestoreCursorPointerFromMemory = "\0338" // CursorBlinking enables cursor blinking CursorBlinking = "\033[?12h" // CursorBlinkingDisable disables cursor blinking CursorBlinkingDisable = "\033[?12l" // ShowCursor shows the cursor ShowCursor = "\033[?25h" // HideCursor hides the cursor HideCursor = "\033[?25l" // EnterAltScreen switches to the alternate screen buffer EnterAltScreen = "\033[?1049h" // ExitAltScreen switches back to the main screen buffer ExitAltScreen = "\033[?1049l" // EnableLineWrap enables line wrapping EnableLineWrap = "\033[?7h" // DisableLineWrap disables line wrapping DisableLineWrap = "\033[?7l" // EraseInDisplay clears the screen and moves cursor to home position EraseInDisplay = "\033[2J" // EraseInLine clears from cursor to the end of line EraseInLine = "\033[K" // ScrollUp scrolls display up one line ScrollUp = "\033[S" // ScrollDown scrolls display down one line ScrollDown = "\033[T" // SaveCursorPosition saves current cursor position SaveCursorPosition = "\033[s" // RestoreCursorPosition restores cursor to last saved position RestoreCursorPosition = "\033[u" // EnableVirtualTerminalProcessing enables VT processing EnableVirtualTerminalProcessing = "\033[?1h" // ResetAllAttributes resets all character attributes ResetAllAttributes = "\033[0m" // BoldBright sets bold/bright mode BoldBright = "\033[1m" // NormalIntensity sets normal intensity NormalIntensity = "\033[22m" // Underline enables underline Underline = "\033[4m" // UnderlineDisable disables underline UnderlineDisable = "\033[24m" // Negative sets negative image Negative = "\033[7m" // Positive sets positive image Positive = "\033[27m" // TabSet sets a tab stop at current position TabSet = "\033H" // TabClear clears tab stop at current position TabClear = "\033[0g" // TabClearAll clears all tab stops TabClearAll = "\033[3g" // DoubleHeightTop makes current line the top half of double height characters DoubleHeightTop = "\033#3" // DoubleHeightBottom makes current line the bottom half of double height characters DoubleHeightBottom = "\033#4" // SingleWidthLine makes current line single-width single-height SingleWidthLine = "\033#5" // DoubleWidthLine makes current line double-width single-height DoubleWidthLine = "\033#6" // DeviceStatusReport requests cursor position report DeviceStatusReport = "\033[6n" // ApplicationKeypad enables application keypad mode ApplicationKeypad = "\033=" // NormalKeypad enables numeric keypad mode NormalKeypad = "\033>" // AutoWrap enables auto-wrap mode AutoWrap = "\033[?7h" // AutoWrapOff disables auto-wrap mode AutoWrapOff = "\033[?7l" // ClearAndResetScrollback clears screen and scrollback buffer ClearAndResetScrollback = "\033[3J" )
Variables ¶
This section is empty.
Functions ¶
func CursorBackward ¶
CursorBackward moves cursor backward by specified number of columns
Example ¶
ExampleCursorBackward demonstrates moving cursor backward
fmt.Print("12345") fmt.Print(CursorBackward(2)) // Moves cursor 2 positions left fmt.Println("X") // Overwrites character
func CursorDown ¶
CursorDown moves cursor down by specified number of lines
func CursorForward ¶
CursorForward moves cursor forward by specified number of columns
Example ¶
ExampleCursorForward demonstrates moving cursor forward
fmt.Print(CursorForward(5)) // Moves cursor 5 positions right fmt.Println("Text after 5 spaces")
func CursorHorizontalAbsolute ¶
CursorHorizontalAbsolute moves cursor to specified column
func CursorNextLine ¶
CursorNextLine moves cursor to beginning of line n lines down
func CursorPosition ¶
CursorPosition sets the cursor position where subsequent text will begin
Example ¶
ExampleCursorPosition demonstrates moving cursor to specific location
fmt.Print(CursorPosition(5, 10)) // Moves cursor to row 5, column 10 fmt.Println("Text at position 5,10")
func CursorPreviousLine ¶
CursorPreviousLine moves cursor to beginning of line n lines up
func CursorUp ¶
CursorUp moves cursor up by specified number of lines
Example ¶
ExampleCursorUp demonstrates moving cursor up
fmt.Println("Line 1") fmt.Println("Line 2") fmt.Print(CursorUp(1)) // Moves cursor up one line fmt.Println("Override") // Overwrites Line 2
func DeleteCharacters ¶
DeleteCharacters deletes n characters at cursor
func DeleteLines ¶
DeleteLines deletes n lines at cursor
Example ¶
ExampleDeleteLines demonstrates deleting lines
fmt.Println("Line 1") fmt.Println("Line 2") fmt.Print(CursorUp(1)) fmt.Print(DeleteLines(1)) // Deletes current line
func DesignateCharacterSet ¶
DesignateCharacterSet designates character set g can be 0-3 for G0-G3 charset can be B for US ASCII, 0 for DEC Special Graphics
func EraseInDisplayMode ¶
EraseInDisplayMode erases display with specified mode n=0: erase from cursor to end of display n=1: erase from start of display to cursor n=2: erase complete display n=3: erase scrollback buffer
Example ¶
ExampleEraseInDisplayMode demonstrates clearing screen
fmt.Print(EraseInDisplayMode(2)) // Clears entire screen fmt.Println("Fresh start")
func EraseInLineMode ¶
EraseInLineMode erases line with specified mode n=0: erase from cursor to end of line n=1: erase from start of line to cursor n=2: erase complete line
func InsertCharacters ¶
InsertCharacters inserts n spaces at cursor
func ReportCursorPosition ¶
ReportCursorPosition formats cursor position report response
func RequestCursorPosition ¶
func RequestCursorPosition() string
RequestCursorPosition requests cursor position and returns response sequence
Example ¶
ExampleRequestCursorPosition demonstrates requesting cursor position
fmt.Print(RequestCursorPosition()) // Note: The actual response needs to be read from stdin
func RequestTerminalParameters ¶
func RequestTerminalParameters() string
RequestTerminalParameters requests terminal parameters
func ScrollDownLines ¶
ScrollDownLines scrolls screen down by n lines
func ScrollUpLines ¶
ScrollUpLines scrolls screen up by n lines
Example ¶
ExampleScrollUpLines demonstrates scrolling content up
fmt.Println("Line 1") fmt.Println("Line 2") fmt.Print(ScrollUpLines(1)) // Scrolls content up by one line
func SetBackgroundColor ¶
SetBackgroundColor sets the background color
func SetCharacterSet ¶
SetCharacterSet selects character set g can be 0 or 1 for default/alternate charset can be B for US ASCII, 0 for DEC Special Graphics
Example ¶
ExampleSetCharacterSet demonstrates setting character set
fmt.Print(SetCharacterSet(0, 'B')) // Sets default character set to US ASCII fmt.Println("ASCII text")
func SetConformanceLevel ¶
SetConformanceLevel sets ANSI conformance level level can be 1, 2, or 3
func SetGraphicsRendition ¶
SetGraphicsRendition sets various text attributes Multiple parameters can be combined
Example ¶
ExampleSetGraphicsRendition demonstrates setting multiple text attributes
fmt.Print(SetGraphicsRendition(1, 4)) // Sets bold and underline fmt.Println("Bold and underlined text") fmt.Print(ResetAllAttributes)
func SetMode ¶
SetMode sets various terminal modes
Example ¶
ExampleSetMode demonstrates setting terminal mode
fmt.Print(SetMode(4)) // Enables insert mode fmt.Println("Text in insert mode")
func SetRGBBackgroundColor ¶
SetRGBBackgroundColor sets the background color using RGB values
func SetRGBTextColor ¶
SetRGBTextColor sets the foreground color using RGB values
Example ¶
ExampleSetRGBTextColor demonstrates setting RGB text color
fmt.Print(SetRGBTextColor(255, 0, 0)) // Sets text color to bright red fmt.Println("Bright red text") fmt.Print(ResetAllAttributes)
func SetScrollingRegion ¶
SetScrollingRegion sets top and bottom margins
Example ¶
ExampleSetScrollingRegion demonstrates setting scroll region
fmt.Print(SetScrollingRegion(1, 10)) // Sets scrolling region from line 1 to 10 fmt.Println("Scrolling region set")
func SetTextColor ¶
SetTextColor sets the foreground color
Example ¶
ExampleSetTextColor demonstrates setting text color
fmt.Print(SetTextColor(1)) // Sets text color to red fmt.Println("Red text") fmt.Print(ResetAllAttributes)
func SoftTerminalReset ¶
func SoftTerminalReset() string
SoftTerminalReset performs a soft terminal reset
Example ¶
ExampleSoftTerminalReset demonstrates soft terminal reset
fmt.Print(SoftTerminalReset()) fmt.Println("Terminal reset")
func WindowManipulation ¶
WindowManipulation performs window manipulation ps=1: de-iconify window ps=2: iconify window ps=3: move window to x,y ps=4: resize window to height,width in pixels ps=5: raise window to top of stack ps=6: lower window to bottom of stack ps=7: refresh window ps=8: resize window to rows,cols in characters ps=9: maximize/restore window
Example ¶
ExampleWindowManipulation demonstrates window manipulation
fmt.Print(WindowManipulation(8, 24, 80)) // Resizes window to 24 rows and 80 columns fmt.Println("Window resized")
Types ¶
This section is empty.