termui

package module
v0.0.0-...-20246fa Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

README

Library of tools for building terminal based apps

Documentation

Index

Constants

View Source
const (
	Reset               = "\033[0m"
	Bold                = "\033[1m"
	Italic              = "\033[3m"
	Underscore          = "\033[4m"
	Backslash           = "\u2572"
	Slash               = "\u2571"
	DoubleHorizontal    = "\u2550"
	DoubleVertical      = "\u2551"
	HorizontalSeparator = "\u2500"
	Tee                 = "\u251c"
	Corner              = "\u2514"

	BorderTopLeft        = "\u250F"
	BordertTopLeftAlt    = "\u2554"
	BorderTopRight       = "\u2513"
	BorderTopRightAlt    = "\u2557"
	BorderBottomLeft     = "\u2517"
	BorderBottomLeftAlt  = "\u255A"
	BorderBottomRight    = "\u251B"
	BorderBottomRIghtAlt = "\u255D"
	BorderVertical       = "\u2503"
	BorderVerticalAlt    = "\u2551"
	BorderHorizontal     = "\u2501"
	BorderHorizontalAlt  = "\u2550"

	CursorLeft  = "\033[D"
	CursorRight = "\033[C"
	CursorHide  = "\033[?25l"
	CursorShow  = "\033[?25h"
	CursorTop   = "\033[H"
	Block       = "\u2591"
	Space       = " "
	Line        = "\u2594"

	CarriageReturn = "\r"
	ClearLine      = "\033[2K"

	Segment = Slash + Block + Slash

	Black         = "\033[30m"
	Red           = "\033[31m"
	Green         = "\033[32m"
	Yellow        = "\033[33m"
	Blue          = "\033[34m"
	Magenta       = "\033[35m"
	Cyan          = "\033[36m"
	White         = "\033[37m"
	BrightBlack   = "\033[90m"
	BrightRed     = "\033[91m"
	BrightGreen   = "\033[92m"
	BrightYellow  = "\033[93m"
	BrightBlue    = "\033[94m"
	BrightMagenta = "\033[95m"
	BrightCyan    = "\033[96m"
	BrightWhite   = "\033[97m"

	BgBlack         = "\033[40m"
	BgRed           = "\033[41m"
	BgGreen         = "\033[42m"
	BgYellow        = "\033[43m"
	BgBlue          = "\033[44m"
	BgMagenta       = "\033[45m"
	BgCyan          = "\033[46m"
	BgWhite         = "\033[47m"
	BgBrightBlack   = "\033[100m"
	BgBrightRed     = "\033[101m"
	BgBrightGreen   = "\033[102m"
	BgBrightYellow  = "\033[103m"
	BgBrightBlue    = "\033[104m"
	BgBrightMagenta = "\033[105m"
	BgBrightCyan    = "\033[106m"
	BgBrightWhite   = "\033[107m"
)

Variables

This section is empty.

Functions

func AlignCenter

func AlignCenter(maxWidth int, st, padding string) string

func AlignLeft

func AlignLeft(maxWidth int, st, padding string) string

func AlignRight

func AlignRight(maxWidth int, st, padding string) string

func BuildString

func BuildString(substrings ...string) string

func Cell

func Cell(x, y int)

func ClearRow

func ClearRow(x, y, len int)

func ClearScreen

func ClearScreen()

func HideCursor

func HideCursor()

func NewTerminal

func NewTerminal() *terminal

func ShowCursor

func ShowCursor()

func SplitString

func SplitString(s string) (int, []rune)

func StrLen

func StrLen(st string) int

func TrimEnd

func TrimEnd(input string, maxLen, trimLen, swaps int, swapChar rune) string

Types

type CommandLine

type CommandLine struct {
	// contains filtered or unexported fields
}

func NewCommandLine

func NewCommandLine(x int, offsetY int, promptLine string, promptFmt func(string) string, placeholder string) *CommandLine

func (*CommandLine) Backspace

func (c *CommandLine) Backspace()

func (*CommandLine) DeleteChar

func (c *CommandLine) DeleteChar()

func (*CommandLine) GetOutput

func (c *CommandLine) GetOutput() string

func (*CommandLine) GoToLineEnd

func (c *CommandLine) GoToLineEnd()

func (*CommandLine) GoToLineStart

func (c *CommandLine) GoToLineStart()

func (*CommandLine) InsertChar

func (c *CommandLine) InsertChar(r rune)

func (*CommandLine) NextCol

func (c *CommandLine) NextCol()

func (*CommandLine) PrevCol

func (c *CommandLine) PrevCol()

func (*CommandLine) Print

func (c *CommandLine) Print()

func (*CommandLine) WaitInput

func (cmd *CommandLine) WaitInput() string
type Navigator struct {
	MinOffset int
	MaxOffset int

	PrevIndex    int
	TotalEntries int
	// contains filtered or unexported fields
}
func (c *Navigator) CalculateEndIndex(index, maxIndex int) int
func (c *Navigator) CalculateStartIndex(index int) int
func (c *Navigator) FirstEntry() (res bool)
func (c *Navigator) GetIndexOffset(index int) int
func (c *Navigator) Index() int
func (c *Navigator) IndiceRange(index, lastIndex int) (int, int)
func (c *Navigator) Jump(from, to, maxIndex int) bool
func (c *Navigator) LastEntry() (res bool)
func (c *Navigator) MovePgDown(visibleLines int) bool
func (c *Navigator) MovePgUp() bool
func (c *Navigator) NextEntry() bool
func (c *Navigator) PrevEntry() bool
func (c *Navigator) Reset()
func (c *Navigator) SetIndex(i int)
func (c *Navigator) ShouldUpdateChunk() bool

type Section

type Section struct {
	Content           []string
	Width             int
	Height            int
	Top               int
	Left              int
	PaddingTop        int
	PaddingBottom     int
	PaddingLeft       int
	PaddingRight      int
	BorderTopWidth    int
	BorderLeftWidth   int
	BorderRightWidth  int
	BorderBottomWidth int
	// contains filtered or unexported fields
}

func NewSection

func NewSection() Section

func (*Section) CenterHorizontally

func (s *Section) CenterHorizontally() *Section

func (*Section) CenterVertically

func (s *Section) CenterVertically() *Section

func (*Section) ContentFirstLine

func (s *Section) ContentFirstLine() int

func (*Section) ContentLines

func (s *Section) ContentLines() int

func (*Section) ContentStart

func (s *Section) ContentStart() int

func (*Section) ContentWidth

func (s *Section) ContentWidth() int

func (*Section) OutputFirstLine

func (s *Section) OutputFirstLine() int

func (*Section) OutputLastLine

func (s *Section) OutputLastLine() int

func (*Section) Print

func (s *Section) Print(formatting string)

func (*Section) PrintBorder

func (s *Section) PrintBorder(formatting string)

func (*Section) PrintContent

func (s *Section) PrintContent() (row int)

func (*Section) PrintLine

func (c *Section) PrintLine(row int, line string)

func (*Section) SetBorder

func (s *Section) SetBorder() *Section

func (*Section) SetHeight

func (s *Section) SetHeight(h int) *Section

func (*Section) SetLeft

func (s *Section) SetLeft(left int)

func (*Section) SetPadding

func (s *Section) SetPadding(Top, right, bottom, Left int) *Section

func (*Section) SetTop

func (s *Section) SetTop(top int)

func (*Section) SetWidth

func (s *Section) SetWidth(w int) *Section

Jump to

Keyboard shortcuts

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