sterm

package module
v0.0.0-...-62ced4a Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: BSD-2-Clause Imports: 8 Imported by: 2

README

sterm

simple lib for work with terminal

Documentation

Index

Constants

View Source
const (
	// styles
	Reset      = Esc + "[1;0m"
	Bold       = Esc + "[1;1m"
	Faint      = Esc + "[1;2m"
	Italic     = Esc + "[1;3m"
	Underlined = Esc + "[1;4m"
	BlinkSlow  = Esc + "[1;5m"
	BlinkRapid = Esc + "[1;6m"
	Reverse    = Esc + "[1;7m"
	Invisible  = Esc + "[1;8m"
	Strike     = Esc + "[1;9m"
	Overline   = Esc + "[1;53m"

	// foreground colors
	FgDefault      = Esc + "[1;39m"
	FgBlack        = Esc + "[1;30m"
	FgRed          = Esc + "[1;31m"
	FgGreen        = Esc + "[1;32m"
	FgYellow       = Esc + "[1;33m"
	FgBlue         = Esc + "[1;34m"
	FgMagenta      = Esc + "[1;35m"
	FgCyan         = Esc + "[1;36m"
	FgLightGray    = Esc + "[1;37m"
	FgDarkGray     = Esc + "[1;90m"
	FgLightRed     = Esc + "[1;91m"
	FgLightGreen   = Esc + "[1;92m"
	FgLightYellow  = Esc + "[1;93m"
	FgLightBlue    = Esc + "[1;94m"
	FgLightMagenta = Esc + "[1;95m"
	FgLightCyan    = Esc + "[1;96m"
	FgWhite        = Esc + "[1;97m"

	// background colors
	BgDefault      = Esc + "[1;49m"
	BgBlack        = Esc + "[1;40m"
	BgRed          = Esc + "[1;41m"
	BgGreen        = Esc + "[1;42m"
	BgYellow       = Esc + "[1;43m"
	BgBlue         = Esc + "[1;44m"
	BgMagenta      = Esc + "[1;45m"
	BgCyan         = Esc + "[1;46m"
	BgLightGray    = Esc + "[1;47m"
	BgDarkGray     = Esc + "[1;100m"
	BgLightRed     = Esc + "[1;101m"
	BgLightGreen   = Esc + "[1;102m"
	BgLightYellow  = Esc + "[1;103m"
	BgLightBlue    = Esc + "[1;104m"
	BgLightMagenta = Esc + "[1;105m"
	BgLightCyan    = Esc + "[1;106m"
	BgWhite        = Esc + "[1;107m"
)
View Source
const Esc = "\x1b"

escape

Variables

View Source
var (
	ErrPositionsEqual        = errors.New("the positions of the points are equal")
	ErrNegative              = errors.New("value is negative")
	ErrLWOfAreaUnderTwo      = errors.New("the length and width of the area must be at least 2")
	ErrTblLineShorterThanTbl = errors.New("the table line is shorter than the table")
)
View Source
var (
	RoundedBorders = Borders{'│', '─', '╭', '╮', '╰', '╯', '├', '┤', '┬', '┴', '┼'}
	SharpBorders   = Borders{'│', '─', '┌', '┐', '└', '┘', '├', '┤', '┬', '┴', '┼'}
	DoubleBorders  = Borders{'║', '═', '╔', '╗', '╚', '╝', '╠', '╣', '╦', '╩', '╬'}
	AsciiBorders   = Borders{'|', '-', '+', '+', '+', '+', '+', '+', '+', '+', '+'}
	DotBorders     = Borders{'.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'}
)

chars for borders

Functions

func CharArea

func CharArea(ch rune, p1x, p1y, p2x, p2y int) (string, error)

print characters between 2 points

func ClearEntireLine

func ClearEntireLine() string

func ClearEntireScreen

func ClearEntireScreen() string

func ClearHome

func ClearHome() string

clear screen and move cursor to 1:1

func ClearLineLeft

func ClearLineLeft() string

func ClearLineRight

func ClearLineRight() string

func ClearScreenDown

func ClearScreenDown() string

func ClearScreenUp

func ClearScreenUp() string

func Color256Bg

func Color256Bg(c int) string

func Color256Fg

func Color256Fg(c int) string

func ColorRGBBg

func ColorRGBBg(r, g, b int) string

func ColorRGBFg

func ColorRGBFg(r, g, b int) string

func CursorDown

func CursorDown(n int) string

func CursorHide

func CursorHide() string

func CursorHome

func CursorHome() string

func CursorLeft

func CursorLeft(n int) string

func CursorNextLine

func CursorNextLine() string

func CursorPos

func CursorPos() (int, int, error)

get cursor position WARNING: has the side affect if program already wait for input from stdin info about cursor position can by broken or incorrect

func CursorRight

func CursorRight(n int) string

func CursorShow

func CursorShow() string

func CursorTo

func CursorTo(x, y int) string

func CursorUp

func CursorUp(n int) string

func DrawTable

func DrawTable(tbl [][]string, sym Borders) ([]string, error)

func FrameArea

func FrameArea(sym Borders, p1x, p1y, p2x, p2y int) (string, error)

frame the area between 2 points

func GetChar

func GetChar() (rune, error)

func ReserveArea

func ReserveArea(n int) string

func Restore

func Restore(s State) (err error)

func RestoreAttrs

func RestoreAttrs() string

func RevPrint

func RevPrint(v string) string

coz normal print prints from left to right RevPrint return string to print from right to left

func SaveAttrs

func SaveAttrs() string

func SetGRA

func SetGRA(gras ...string) string

set graphics rendition attributes for terminal

func Size

func Size() (x, y int, err error)

Types

type Borders

type Borders [11]rune

type State

type State *term.State

func GetState

func GetState() (s State, err error)

Jump to

Keyboard shortcuts

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