term

package
v0.0.0-...-1fa5987 Latest Latest
Warning

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

Go to latest
Published: May 14, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const Esc = 27
View Source
const ResetCode = "\u001b[0m"
View Source
const ScrollOff = 4

Minimum number of scrolling terminal lines to display, no matter the requested panel size.

Variables

This section is empty.

Functions

func EditString

func EditString(tempPattern string, oldValue string) (string, error)

func GetEditor

func GetEditor() (string, error)

Returns the preferred command to execute for editing a file.

func GetSize

func GetSize() (w, h int)

func IsColorEnabled

func IsColorEnabled() bool

See <https://bixense.com/clicolors/>.

func IsInteractive

func IsInteractive() bool

func LookEditor

func LookEditor() (string, error)

Try to find an editor command in $PATH.

func PrintTree

func PrintTree(w io.Writer, node *TreeNode)

func TrimToVisualLength

func TrimToVisualLength(message string, length int) string

TrimToVisualLength truncates the given message to the given length (taking into account ansi escape sequences) From <https://github.com/wagoodman/bashful>.

func VisualLength

func VisualLength(str string) int

VisualLength determines the length of a string (taking into account ansi control sequences) From <https://github.com/wagoodman/bashful>.

Types

type BottomPanel

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

Zero value is ready to use. Operations on panel affect Stdout. Must call Close() when done, to restore terminal settings.

func (*BottomPanel) Close

func (p *BottomPanel) Close()

func (*BottomPanel) Content

func (p *BottomPanel) Content() string

func (*BottomPanel) Height

func (p *BottomPanel) Height() int

func (*BottomPanel) SetContent

func (p *BottomPanel) SetContent(value string)

Set the content to appear at the bottom of the scrollback buffer. Will be truncated if it is larger than the panel's height.

func (*BottomPanel) SetHeight

func (p *BottomPanel) SetHeight(value int)

Set the panel height. The rendered height may be smaller than the requested height, if the requested height exceeds the terminal height minus ScrollOff.

type ColorCache

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

Maps a key to a stable, arbitrary color.

func NewColorCache

func NewColorCache() *ColorCache

func (*ColorCache) Color

func (cache *ColorCache) Color(key string) colorful.Color

type RawMode

type RawMode struct {
	// Zero value signals stdin.
	FD uintptr
	// contains filtered or unexported fields
}

func (*RawMode) Enter

func (raw *RawMode) Enter() error

func (*RawMode) Exit

func (raw *RawMode) Exit() error

func (*RawMode) Suspend

func (raw *RawMode) Suspend() error

Based on NetHack: <https://nethackwiki.com/wiki/%5EZ#cite_note-1>.

type TreeBuilder

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

func NewTreeBuilder

func NewTreeBuilder() *TreeBuilder

func (*TreeBuilder) AddNode

func (b *TreeBuilder) AddNode(node *TreeNode)

func (*TreeBuilder) Build

func (b *TreeBuilder) Build() (roots []*TreeNode)

type TreeNode

type TreeNode struct {
	ID           string
	ParentID     string
	Label        string // Left-most column, part of the tree shape.
	Content      string // Second column, aligned after the labels.
	Suffix       string // Right-aligned, third column.
	HideChildren bool

	// Fields set by TreeBuilder.
	Parent     *TreeNode
	ChildIndex int
	Children   []*TreeNode
	LabelWidth int // Max visual width of own and children's label with padding.
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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