terminal

package
v1.27.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 9 Imported by: 3

Documentation

Index

Constants

View Source
const (
	Black = iota
	Red
	Green
	Yellow
	Blue
	Magenta
	Cyan
	White
	BrightBlack
	BrightRed
	BrightGreen
	BrightYellow
	BrightBlue
	BrightMagenta
	BrightCyan
	BrightWhite
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Out

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

Out manages the cli outputs that is user facing with many functionalities to manage and control the TUI (Terminal User Interface).

func New

func New() *Out

func (*Out) AltScreen

func (o *Out) AltScreen()

AltScreen switches to the alternate screen buffer. The former view can be restored with ExitAltScreen().

func (*Out) ChangeScrollingRegion

func (o *Out) ChangeScrollingRegion(top, bottom int)

ChangeScrollingRegion sets the scrolling region of the terminal.

func (*Out) ClearLine

func (o *Out) ClearLine()

ClearLine clears the current line.

func (*Out) ClearLineLeft

func (o *Out) ClearLineLeft()

ClearLineLeft clears the line to the left of the cursor.

func (*Out) ClearLineRight

func (o *Out) ClearLineRight()

ClearLineRight clears the line to the right of the cursor.

func (*Out) ClearLines

func (o *Out) ClearLines(n int)

ClearLines clears a given number of lines.

func (*Out) ClearScreen

func (o *Out) ClearScreen()

ClearScreen clears the visible portion of the terminal.

func (*Out) CursorBack

func (o *Out) CursorBack(n int)

CursorBack moves the cursor backwards a given number of cells.

func (*Out) CursorDown

func (o *Out) CursorDown(n int)

CursorDown moves the cursor down a given number of lines.

func (*Out) CursorForward

func (o *Out) CursorForward(n int)

CursorForward moves the cursor up a given number of lines.

func (*Out) CursorNextLine

func (o *Out) CursorNextLine(n int)

CursorNextLine moves the cursor down a given number of lines and places it at the beginning of the line.

func (*Out) CursorPrevLine

func (o *Out) CursorPrevLine(n int)

CursorPrevLine moves the cursor up a given number of lines and places it at the beginning of the line.

func (*Out) CursorUp

func (o *Out) CursorUp(n int)

CursorUp moves the cursor up a given number of lines.

func (*Out) DeleteLines

func (o *Out) DeleteLines(n int)

DeleteLines deletes the given number of lines, pulling any lines in the scrollable region below up.

func (*Out) ExitAltScreen

func (o *Out) ExitAltScreen()

ExitAltScreen exits the alternate screen buffer and returns to the former terminal view.

func (*Out) HideCursor

func (o *Out) HideCursor()

HideCursor hides the cursor.

func (*Out) InsertLines

func (o *Out) InsertLines(n int)

InsertLines inserts the given number of lines at the top of the scrollable region, pushing lines below down.

func (*Out) MoveCursor

func (o *Out) MoveCursor(row, column int)

MoveCursor moves the cursor to a given position.

func (*Out) Print

func (o *Out) Print(messages ...interface{})

func (*Out) Printf

func (o *Out) Printf(format string, args ...interface{})

func (*Out) Println

func (o *Out) Println(messages ...interface{})

func (*Out) Reset

func (o *Out) Reset()

Reset the terminal to its default style, removing any active styles.

func (*Out) ResetColor

func (o *Out) ResetColor()

func (*Out) RestoreCursorPosition

func (o *Out) RestoreCursorPosition()

RestoreCursorPosition restores a saved cursor position.

func (*Out) RestoreScreen

func (o *Out) RestoreScreen()

RestoreScreen restores a previously saved screen state.

func (*Out) SaveCursorPosition

func (o *Out) SaveCursorPosition()

SaveCursorPosition saves the cursor position.

func (*Out) SaveScreen

func (o *Out) SaveScreen()

SaveScreen saves the screen state.

func (*Out) SetColor

func (o *Out) SetColor(colorCode int)

func (*Out) SetWindowTitle

func (o *Out) SetWindowTitle(title string)

SetWindowTitle sets the terminal window title.

func (*Out) ShowCursor

func (o *Out) ShowCursor()

ShowCursor shows the cursor.

type Output

type Output interface {
	AltScreen()
	ChangeScrollingRegion(top int, bottom int)
	ClearLine()
	ClearLineLeft()
	ClearLineRight()
	ClearLines(n int)
	ClearScreen()
	CursorBack(n int)
	CursorDown(n int)
	CursorForward(n int)
	CursorNextLine(n int)
	CursorPrevLine(n int)
	CursorUp(n int)
	DeleteLines(n int)
	ExitAltScreen()
	HideCursor()
	InsertLines(n int)
	MoveCursor(row int, column int)
	Print(messages ...any)
	Printf(format string, args ...any)
	Println(messages ...any)
	Reset()
	ResetColor()
	RestoreCursorPosition()
	RestoreScreen()
	SaveCursorPosition()
	SaveScreen()
	SetColor(colorCode int)
	SetWindowTitle(title string)
	ShowCursor()
	// contains filtered or unexported methods
}

type ProgressBar

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

func NewProgressBar

func NewProgressBar(out Output, total int64) (*ProgressBar, error)

func (*ProgressBar) Incr

func (p *ProgressBar) Incr(i int64) bool

type Spinner

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

Spinner is a TUI component that displays a loading spinner which can be used to denote a running background process.

func NewDotSpinner

func NewDotSpinner(o Output) *Spinner

func NewGlobeSpinner

func NewGlobeSpinner(o Output) *Spinner

func NewPulseSpinner

func NewPulseSpinner(o Output) *Spinner

func (*Spinner) Spin

func (s *Spinner) Spin(ctx context.Context) *Spinner

func (*Spinner) Stop

func (s *Spinner) Stop()

type Term

type Term interface {
	IsTerminal(fd int) bool
	GetSize(fd int) (width, height int, err error)
}

Jump to

Keyboard shortcuts

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