screen

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2021 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package screen provides building blocks to represent progress bars.

Index

Constants

This section is empty.

Variables

View Source
var SpinnerDefaultStyle = []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}

Functions

func NewProgressLine

func NewProgressLine(table *TableGenerator, initialLabel string) (*ProgressLine, Segment)

Types

type AutoRefreshScreen

type AutoRefreshScreen struct {
	SimpleScreen
	// contains filtered or unexported fields
}

func NewAutoRefreshScreen

func NewAutoRefreshScreen(options RenderingOptions, bars ...Segment) *AutoRefreshScreen

func (*AutoRefreshScreen) Stop

func (s *AutoRefreshScreen) Stop()

type LineSpinnerSegment

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

func NewSpinnerSegment

func NewSpinnerSegment() *LineSpinnerSegment

func (*LineSpinnerSegment) Content

func (l *LineSpinnerSegment) Content(options RenderingOptions) string

type PagePrint

type PagePrint struct {
	Content []Segment
	Footer  []Segment
}

type ProgressBarSegment

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

func (*ProgressBarSegment) Content

func (p *ProgressBarSegment) Content(options RenderingOptions) string

type ProgressLine

type ProgressLine struct {
	SwapSpinner    func(int)
	SetLabel       func(string)
	SetBar         func(uint, uint)
	SetExplanation func(string)
}

type RenderingOptions

type RenderingOptions struct {
	Width int
	Full  bool // Full set to true will clear the whole terminal
}

type Segment

type Segment interface {
	Content(options RenderingOptions) string
}

func NewConstantSegment

func NewConstantSegment(content string) Segment

NewConstantSegment creates a constant segment

func NewGreenTickSegment

func NewGreenTickSegment() Segment

func NewProgressBarSegment

func NewProgressBarSegment() (Segment, func(uint, uint))

func NewSwitchSegment

func NewSwitchSegment(delegates ...Segment) (Segment, func(int))

NewSwitchSegment creates a segment that can switch from one implementation to the other ; returns func to swap that will panic if index out of bound.

func NewUpdatableSegment

func NewUpdatableSegment(content string) (Segment, func(string))

NewUpdatableSegment returns the segment and the function to update it

type SimpleScreen

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

func NewSimpleScreen

func NewSimpleScreen(options RenderingOptions, bars ...Segment) *SimpleScreen

func (*SimpleScreen) Clear

func (s *SimpleScreen) Clear()

Clear goes back to the beginning

func (*SimpleScreen) ContentHeight

func (s *SimpleScreen) ContentHeight() int

ContentHeight returns number of lines used in content (excluding footer)

func (*SimpleScreen) ForceClear

func (s *SimpleScreen) ForceClear()

ForceClear goes back to the beginning after writing white spaces everywhere

func (*SimpleScreen) Print

func (s *SimpleScreen) Print(page PagePrint)

Print writes given segments in the output ; it doesn't keep the segments and doesn't refresh the page.

func (*SimpleScreen) Refresh

func (s *SimpleScreen) Refresh()

func (*SimpleScreen) TermSize

func (s *SimpleScreen) TermSize() (int, int)

TermSize returns the size of the terminal, in chars

type StringSegment

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

func (*StringSegment) Content

func (l *StringSegment) Content(options RenderingOptions) string

type SwitchSegment

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

func (*SwitchSegment) Content

func (s *SwitchSegment) Content(options RenderingOptions) string

type TableGenerator

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

func NewTable

func NewTable(separator string, widths ...int) *TableGenerator

func (*TableGenerator) NewRow

func (t *TableGenerator) NewRow(delegates ...Segment) Segment

Jump to

Keyboard shortcuts

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