display

package
v0.0.0-...-eb689ba Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: GPL-2.0 Imports: 7 Imported by: 3

Documentation

Index

Constants

View Source
const (
	Red8   = "\033[31m"
	BgRed8 = "\033[41m"
	White8 = "\033[37m"
)

8 Color mode colors.

View Source
const (
	BrightRed   = "\033[31;1m"
	BgBrightRed = "\033[41;1m"
)

16 bit color mode bright colors.

View Source
const (
	Black   = "\033[38;5;0m"
	Red     = "\033[38;5;1m"
	Green   = "\033[38;5;2m"
	Yellow  = "\033[38;5;3m"
	Blue    = "\033[38;5;4m"
	Magenta = "\033[38;5;5m"
	Cyan    = "\033[38;5;6m"
	Grey    = "\033[38;5;7m"
	White   = "\033[38;5;15m"

	BgBlack = "\033[48;5;232m"

	BgRed256  = "\033[48;5;1m"
	BgGrey256 = "\033[48;5;7m"

	Bold          = "\033[1m"
	Underline     = "\033[4m"
	Reverse       = "\033[7m"
	Reset         = "\033[0m"
	NoWrap        = "\033[?7l"
	DoWrap        = "\033[?7h"
	ResetScroll   = "\033[r"
	SaveCursor    = "\033[s"         // TODO: actually this may not be supported
	RestoreCursor = "\033[u"         // by some terminals. Find some other way?
	HideCursor    = "\033[?25l"      // TODO: actually this may not be supported
	ShowCursor    = "\033[?25h"      // by some terminals. Find some other way?
	Suspend       = "\033P=1s\033\\" // https://gitlab.freedesktop.org/terminal-wg/specifications/-/merge_requests/2
	Resume        = "\033P=2s\033\\"

	// Normal is not the same as Reset, because Reset resets Bold/Underline/Reverse.
	Normal = White + BgBlack
)

256 color mode colors.

Variables

This section is empty.

Functions

func Color

func Color(n int) string

Color returns ANSI escape for a given color index.

func Exit

func Exit()

Exit resets the output for exit.

func FixedANSIWidthRight

func FixedANSIWidthRight(s string, w int) string

FixedANSIWidthRight returns a fixed width version of a string, padding on the right. The function will not strip ANSI codes, nor count them as "length".

func FixedWidth

func FixedWidth(s string, w int) string

FixedWidth returns a fixed width version of a string.

func StringWidth

func StringWidth(s string) int

StringWidth returns the render width of a string.

func TermSize

func TermSize() (int, int, error)

TermSize returns the terminal size.

func TerminalTitle

func TerminalTitle(s string) string

TerminalTitle returns ANSI sequence to change the terminal title.

Types

type Screen

type Screen struct {
	Width  int
	Height int
	// contains filtered or unexported fields
}

Screen is a screen.

func NewScreen

func NewScreen() (*Screen, error)

NewScreen creates a new screen.

func NewScreen2

func NewScreen2(w int, h int) *Screen

NewScreen2 creates a new screen with given dimensions.

func (*Screen) Clear

func (s *Screen) Clear()

Clear clears the screen.

func (*Screen) Copy

func (s *Screen) Copy() *Screen

Copy copies a screen.

func (*Screen) Draw

func (s *Screen) Draw()

Draw redraws the screen.

func (*Screen) Printf

func (s *Screen) Printf(y, x int, fmts string, args ...interface{})

Printf prints to a given point on the screen.

func (*Screen) Printlnf

func (s *Screen) Printlnf(y int, fmts string, args ...interface{})

Printlnf sets the content of a line to be a printfed string

func (*Screen) SetCursor

func (s *Screen) SetCursor(y, x int)

SetCursor sets the cursor position.

func (*Screen) UseCache

func (s *Screen) UseCache()

UseCache tells screen to use the cache.

Jump to

Keyboard shortcuts

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