termutils

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2024 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const (
	TERM_CLEAR               = "\x1B[2J"
	TERM_CLEAR_END_OF_SCREEN = "\x1B[0J"
	TERM_CLEAR_END_OF_LINE   = "\x1B[0K"
	STYLE_RESET              = "\x1b[0m"
	STYLE_BOLD               = "\x1b[1m"
)

Variables

View Source
var (
	ErrNoMatch = errors.New("no match")
)

Functions

func ClearLineFromCursor

func ClearLineFromCursor()

func ClearTerminal

func ClearTerminal()

ClearTerminal clears the terminal without repositioning the cursor

func ClearTerminalFromCursor

func ClearTerminalFromCursor()

func CreateFgColor

func CreateFgColor(red int, green int, blue int) string

func Crop

func Crop(text string, length int) (string, int)

Crop ensures that the supplied text is cropped to the target length. If it exceeds the target length, the last (max) 3 characters are replaced with ellipsis. Returned are the cropped string, and the final visible length after cropping.

func GetCursorPosition

func GetCursorPosition(value string) (int, int, error)

GetCursorPosition returns row, column or an error

func GetWindowSize

func GetWindowSize() (int, int)

GetWindowSize returns the size of the window (row, col)

func HideCursor

func HideCursor()

func Measure

func Measure(text string) int

Measure returns the number of horizonal space the provided text accounts for. This will filter out escape characters, and treat multi-byte unicode characters as single space tenants.

func PadRight

func PadRight(text string, maxLength int, gutter int) string

PadRight pads text to the right, cropping anything over the supplied maxLength, preserving up to n gutter chars on the right.

func RequestCursorPos

func RequestCursorPos()

func ResetStyle

func ResetStyle()

func SetBgColor

func SetBgColor(red int, green int, blue int)

func SetCursorPos

func SetCursorPos(row int, col int)

SetCursorPos sets the current cursor position. row and col start from 1

func SetFgColor

func SetFgColor(red int, green int, blue int)

func ShowCursor

func ShowCursor()

func StripTerminalEscapeSequences

func StripTerminalEscapeSequences(data []byte) []byte

StripTerminalEscapeSequences removes all terminal escape sequences from the provided string, and returns the remaining string

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL