Documentation ¶
Index ¶
- Constants
- func BlackText(s string) string
- func BlueText(s string) string
- func ColorText(s string, color uint8) string
- func CyanText(s string) string
- func GreenText(s string) string
- func PurpleText(s string) string
- func RedText(s string) string
- func WhiteText(s string) string
- func YellowText(s string) string
- type Bar
- type BarSetting
- type Conf
- type DefaultBar
- type LoadingBar
- type LoadingBarSetting
- type Progress
- type TextBar
- type TextBarSetting
Constants ¶
const ( // HideCursor DisableInput ResizeReactively are flags that inherit from single-line-print // see more detail: https://github.com/lianggaoqiang/single-line-print HideCursor uint8 = 0x01 // if set, the cursor will be hidden during printing or writing DisableInput uint8 = 0x02 // if set, input will be disabled during printing or writing ResizeReactively uint8 = 0x04 // if set, terminal window size will be got before each printing or writing PercentOverflow uint8 = 0x10 // if set, the percent value displayed will be able to exceed 100% AutoStop uint8 = 0x08 // if set, Progress will be set as a stopped state automatically )
define flags
const ( Black uint8 = 30 + iota Red Green Yellow Blue Purple Cyan White )
define colors
Variables ¶
This section is empty.
Functions ¶
func PurpleText ¶
PurpleText generate string that describes purple text
func YellowText ¶
YellowText generate string that describes yellow text
Types ¶
type Bar ¶
type Bar interface { Hide() Show() IsHidden() bool // contains filtered or unexported methods }
type BarSetting ¶
type BarSetting struct { PercentColor uint8 // the color of percent value LeftSpace, RightSpace uint16 // the spacings at left and right Total uint16 // the total count of inner characters of the progress bar Hidden bool // if set to true, the bar will be hidden and not rendered Inline bool // if set to true, there will not be a line break at the end place of the bar HidePercent bool // if set to true, there will be a percent value be displayed at the end place of progress bar UseFloat bool // if set to true, progress bar will have a precision of 0.01% StartText, EndText string // text at start and end place PassedText, NotPassedText string // text passed and not passed FirstPassedText string // the first passed text }
BarSetting describes the setting of Bar
type Conf ¶
type Conf struct { Debug bool // if set to true, the percent value displayed will be able to exceed 100% AutoStop bool // if set to true, this Progress will be set as a stopped state when all Bars' N-property >= 100. Need: Debug=false }
Conf includes all customizable configurations
type DefaultBar ¶
type DefaultBar struct { N float64 Setting BarSetting // contains filtered or unexported fields }
func (*DefaultBar) Add ¶
func (b *DefaultBar) Add(n float64) error
Add can add specified value to Bar.N and then render the progress bar
func (*DefaultBar) Custom ¶
func (b *DefaultBar) Custom(setting BarSetting) *DefaultBar
Custom changes attributes and display form of Bar
func (*DefaultBar) Hide ¶
func (b *DefaultBar) Hide()
func (*DefaultBar) Inc ¶
func (b *DefaultBar) Inc() error
Inc will increase Bar.N by 1 and then render the progress bar
func (*DefaultBar) IsHidden ¶
func (b *DefaultBar) IsHidden() bool
func (*DefaultBar) Percent ¶
func (b *DefaultBar) Percent(n float64) (err error)
Percent sets the percent of Bar
func (*DefaultBar) Show ¶
func (b *DefaultBar) Show()
type LoadingBar ¶
type LoadingBar struct { Setting LoadingBarSetting // contains filtered or unexported fields }
func NewLoadingBar ¶
func NewLoadingBar(milli time.Duration, steps ...string) *LoadingBar
NewLoadingBar returns an instance pointer of a loading bar
func (*LoadingBar) Custom ¶
func (b *LoadingBar) Custom(setting LoadingBarSetting) *LoadingBar
Custom changes the setting of LoadingBar
func (*LoadingBar) Hide ¶
func (b *LoadingBar) Hide()
func (*LoadingBar) IsHidden ¶
func (b *LoadingBar) IsHidden() bool
func (*LoadingBar) SetColor ¶
func (b *LoadingBar) SetColor(color uint8) *LoadingBar
SetColor will change the color of all strings in LoadingBar.loadingText
func (*LoadingBar) Show ¶
func (b *LoadingBar) Show()
type LoadingBarSetting ¶
type LoadingBarSetting struct { Hidden bool Inline bool StartText, EndText string // text at start and end place FixedWidth bool // if set to true, the LoadingBar will use a fixed width (equal to the length of the longest string) }
LoadingBarSetting describes the setting of LoadingBar
type Progress ¶
type Progress struct {
// contains filtered or unexported fields
}
func StartWithFlag ¶
StartWithFlag instantiate an instance of Progress with flags and returns the instance
type TextBar ¶
type TextBar struct { Setting TextBarSetting // contains filtered or unexported fields }
func NewTextBar ¶
NewTextBar returns an instance pointer of a static content bar
func (*TextBar) Custom ¶
func (b *TextBar) Custom(setting TextBarSetting) *TextBar
Custom changes the setting of TextBar
type TextBarSetting ¶
TextBarSetting describes the setting of TextBar