Documentation ΒΆ
Overview ΒΆ
Package pterm is a modern go module to beautify console output. It can be used without configuration, but if desired, everything can be customized down to the smallest detail.
Official docs are available at: https://docs.pterm.sh
View the animated examples here: https://github.com/pterm/pterm#-examples
Index ΒΆ
- Variables
- func DisableColor()
- func DisableDebugMessages()
- func DisableOutput()
- func DisableStyling()
- func EnableColor()
- func EnableDebugMessages()
- func EnableOutput()
- func EnableStyling()
- func Fprint(term Terminal, a ...interface{})
- func Fprintln(term Terminal, a ...interface{})
- func Fprinto(term Terminal, a ...interface{})
- func Print(term Terminal, a ...interface{})
- func PrintOnError(term Terminal, a ...interface{})
- func PrintOnErrorf(term Terminal, format string, a ...interface{})
- func Printf(term Terminal, format string, a ...interface{})
- func Printfln(term Terminal, format string, a ...interface{})
- func Println(term Terminal, a ...interface{})
- func RemoveColorFromString(a ...interface{}) string
- func Sprint(a ...interface{}) string
- func Sprintf(format string, a ...interface{}) string
- func Sprintfln(format string, a ...interface{}) string
- func Sprintln(a ...interface{}) string
- func Sprinto(a ...interface{}) string
- type Area
- type AreaPrinter
- func (p *AreaPrinter) Clear()
- func (p *AreaPrinter) GenericStart() (*LivePrinter, error)
- func (p *AreaPrinter) GenericStop() (*LivePrinter, error)
- func (p *AreaPrinter) GetContent() string
- func (p *AreaPrinter) Start(text ...interface{}) (*AreaPrinter, error)
- func (p *AreaPrinter) Stop() error
- func (p *AreaPrinter) Update(text ...interface{})
- func (p AreaPrinter) WithCenter(b ...bool) *AreaPrinter
- func (p AreaPrinter) WithFullscreen(b ...bool) *AreaPrinter
- func (p AreaPrinter) WithRemoveWhenDone(b ...bool) *AreaPrinter
- func (p AreaPrinter) WithTerminal(term Terminal) *AreaPrinter
- type Bar
- type BarChartPrinter
- func (p BarChartPrinter) Render(term Terminal) error
- func (p BarChartPrinter) Srender(term Terminal) (string, error)
- func (p BarChartPrinter) WithBars(bars Bars) *BarChartPrinter
- func (p BarChartPrinter) WithHorizontal(b ...bool) *BarChartPrinter
- func (p BarChartPrinter) WithHorizontalBarCharacter(char string) *BarChartPrinter
- func (p BarChartPrinter) WithShowValue(b ...bool) *BarChartPrinter
- func (p BarChartPrinter) WithVerticalBarCharacter(char string) *BarChartPrinter
- type Bars
- type BasicTextPrinter
- func (p *BasicTextPrinter) Print(term Terminal, a ...interface{}) *TextPrinter
- func (p *BasicTextPrinter) PrintOnError(term Terminal, a ...interface{}) *TextPrinter
- func (p *BasicTextPrinter) PrintOnErrorf(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p *BasicTextPrinter) Printf(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p *BasicTextPrinter) Printfln(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p *BasicTextPrinter) Println(term Terminal, a ...interface{}) *TextPrinter
- func (p BasicTextPrinter) Sprint(term Terminal, a ...interface{}) string
- func (p BasicTextPrinter) Sprintf(term Terminal, format string, a ...interface{}) string
- func (p BasicTextPrinter) Sprintfln(term Terminal, format string, a ...interface{}) string
- func (p BasicTextPrinter) Sprintln(term Terminal, a ...interface{}) string
- func (p BasicTextPrinter) WithStyle(style *Style) *BasicTextPrinter
- type BigTextPrinter
- type BoxPrinter
- func (p BoxPrinter) Print(term Terminal, a ...interface{}) *TextPrinter
- func (p BoxPrinter) PrintOnError(term Terminal, a ...interface{}) *TextPrinter
- func (p BoxPrinter) PrintOnErrorf(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p BoxPrinter) Printf(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p BoxPrinter) Printfln(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p BoxPrinter) Println(term Terminal, a ...interface{}) *TextPrinter
- func (p BoxPrinter) Sprint(term Terminal, a ...interface{}) string
- func (p BoxPrinter) Sprintf(term Terminal, format string, a ...interface{}) string
- func (p BoxPrinter) Sprintfln(term Terminal, format string, a ...interface{}) string
- func (p BoxPrinter) Sprintln(term Terminal, a ...interface{}) string
- func (p BoxPrinter) WithBottomLeftCornerString(str string) *BoxPrinter
- func (p BoxPrinter) WithBottomPadding(padding int) *BoxPrinter
- func (p BoxPrinter) WithBottomRightCornerString(str string) *BoxPrinter
- func (p BoxPrinter) WithBoxStyle(style *Style) *BoxPrinter
- func (p BoxPrinter) WithHorizontalString(str string) *BoxPrinter
- func (p BoxPrinter) WithLeftPadding(padding int) *BoxPrinter
- func (p BoxPrinter) WithRightPadding(padding int) *BoxPrinter
- func (p BoxPrinter) WithTextStyle(style *Style) *BoxPrinter
- func (p BoxPrinter) WithTitle(str string) *BoxPrinter
- func (p BoxPrinter) WithTitleBottomCenter(b ...bool) *BoxPrinter
- func (p BoxPrinter) WithTitleBottomLeft(b ...bool) *BoxPrinter
- func (p BoxPrinter) WithTitleBottomRight(b ...bool) *BoxPrinter
- func (p BoxPrinter) WithTitleTopCenter(b ...bool) *BoxPrinter
- func (p BoxPrinter) WithTitleTopLeft(b ...bool) *BoxPrinter
- func (p BoxPrinter) WithTitleTopRight(b ...bool) *BoxPrinter
- func (p BoxPrinter) WithTopLeftCornerString(str string) *BoxPrinter
- func (p BoxPrinter) WithTopPadding(padding int) *BoxPrinter
- func (p BoxPrinter) WithTopRightCornerString(str string) *BoxPrinter
- func (p BoxPrinter) WithVerticalString(str string) *BoxPrinter
- type BulletListItem
- func (p BulletListItem) WithBullet(bullet string) *BulletListItem
- func (p BulletListItem) WithBulletStyle(style *Style) *BulletListItem
- func (p BulletListItem) WithLevel(level int) *BulletListItem
- func (p BulletListItem) WithText(text string) *BulletListItem
- func (p BulletListItem) WithTextStyle(style *Style) *BulletListItem
- type BulletListPrinter
- func (l BulletListPrinter) Render(term Terminal) error
- func (l BulletListPrinter) Srender(term Terminal) (string, error)
- func (l BulletListPrinter) WithBullet(bullet string) *BulletListPrinter
- func (l BulletListPrinter) WithBulletStyle(style *Style) *BulletListPrinter
- func (l BulletListPrinter) WithItems(items []BulletListItem) *BulletListPrinter
- func (l BulletListPrinter) WithTextStyle(style *Style) *BulletListPrinter
- type CenterPrinter
- func (p CenterPrinter) Print(term Terminal, a ...interface{}) *TextPrinter
- func (p CenterPrinter) PrintOnError(term Terminal, a ...interface{}) *TextPrinter
- func (p CenterPrinter) PrintOnErrorf(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p CenterPrinter) Printf(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p CenterPrinter) Printfln(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p CenterPrinter) Println(term Terminal, a ...interface{}) *TextPrinter
- func (p CenterPrinter) Sprint(term Terminal, a ...interface{}) string
- func (p CenterPrinter) Sprintf(term Terminal, format string, a ...interface{}) string
- func (p CenterPrinter) Sprintfln(term Terminal, format string, a ...interface{}) string
- func (p CenterPrinter) Sprintln(term Terminal, a ...interface{}) string
- func (p CenterPrinter) WithCenterEachLineSeparately(b ...bool) *CenterPrinter
- type Color
- func (c Color) Print(term Terminal, a ...interface{}) *TextPrinter
- func (c Color) PrintOnError(term Terminal, a ...interface{}) *TextPrinter
- func (c Color) PrintOnErrorf(term Terminal, format string, a ...interface{}) *TextPrinter
- func (c Color) Printf(term Terminal, format string, a ...interface{}) *TextPrinter
- func (c Color) Printfln(term Terminal, format string, a ...interface{}) *TextPrinter
- func (c Color) Println(term Terminal, a ...interface{}) *TextPrinter
- func (c Color) Sprint(term Terminal, a ...interface{}) string
- func (c Color) Sprintf(term Terminal, format string, a ...interface{}) string
- func (c Color) Sprintfln(term Terminal, format string, a ...interface{}) string
- func (c Color) Sprintln(term Terminal, a ...interface{}) string
- func (c Color) String() string
- type Cursor
- func (c *Cursor) Bottom()
- func (c *Cursor) ClearLine()
- func (c *Cursor) ClearLinesDown(n int)
- func (c *Cursor) ClearLinesUp(n int)
- func (c *Cursor) Down(n int)
- func (c *Cursor) DownAndClear(n int)
- func (c *Cursor) Hide()
- func (c *Cursor) HorizontalAbsolute(n int)
- func (c *Cursor) Left(n int)
- func (c *Cursor) Move(x, y int)
- func (c *Cursor) Right(n int)
- func (c *Cursor) Show()
- func (c *Cursor) StartOfLine()
- func (c *Cursor) StartOfLineDown(n int)
- func (c *Cursor) StartOfLineUp(n int)
- func (c *Cursor) Up(n int)
- func (c *Cursor) UpAndClear(n int)
- type HeaderPrinter
- func (p *HeaderPrinter) Print(term Terminal, a ...interface{}) *TextPrinter
- func (p *HeaderPrinter) PrintOnError(term Terminal, a ...interface{}) *TextPrinter
- func (p *HeaderPrinter) PrintOnErrorf(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p *HeaderPrinter) Printf(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p *HeaderPrinter) Printfln(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p *HeaderPrinter) Println(term Terminal, a ...interface{}) *TextPrinter
- func (p HeaderPrinter) Sprint(term Terminal, a ...interface{}) string
- func (p HeaderPrinter) Sprintf(term Terminal, format string, a ...interface{}) string
- func (p HeaderPrinter) Sprintfln(term Terminal, format string, a ...interface{}) string
- func (p HeaderPrinter) Sprintln(term Terminal, a ...interface{}) string
- func (p HeaderPrinter) WithBackgroundStyle(style *Style) *HeaderPrinter
- func (p HeaderPrinter) WithFullWidth(b ...bool) *HeaderPrinter
- func (p HeaderPrinter) WithMargin(margin int) *HeaderPrinter
- func (p HeaderPrinter) WithTextStyle(style *Style) *HeaderPrinter
- type InteractiveConfirmPrinter
- func (p InteractiveConfirmPrinter) Show(text ...string) (bool, error)
- func (p InteractiveConfirmPrinter) WithConfirmStyle(style *Style) *InteractiveConfirmPrinter
- func (p InteractiveConfirmPrinter) WithConfirmText(text string) *InteractiveConfirmPrinter
- func (p InteractiveConfirmPrinter) WithDefaultText(text string) *InteractiveConfirmPrinter
- func (p InteractiveConfirmPrinter) WithDefaultValue(value bool) *InteractiveConfirmPrinter
- func (p InteractiveConfirmPrinter) WithRejectStyle(style *Style) *InteractiveConfirmPrinter
- func (p InteractiveConfirmPrinter) WithRejectText(text string) *InteractiveConfirmPrinter
- func (p InteractiveConfirmPrinter) WithSuffixStyle(style *Style) *InteractiveConfirmPrinter
- func (p InteractiveConfirmPrinter) WithTerminal(term Terminal) *InteractiveConfirmPrinter
- func (p InteractiveConfirmPrinter) WithTextStyle(style *Style) *InteractiveConfirmPrinter
- type InteractiveMultiselectPrinter
- func (p *InteractiveMultiselectPrinter) Show(text ...string) ([]string, error)
- func (p InteractiveMultiselectPrinter) WithDefaultOptions(options []string) *InteractiveMultiselectPrinter
- func (p InteractiveMultiselectPrinter) WithDefaultText(text string) *InteractiveMultiselectPrinter
- func (p InteractiveMultiselectPrinter) WithMaxHeight(maxHeight int) *InteractiveMultiselectPrinter
- func (p InteractiveMultiselectPrinter) WithOptions(options []string) *InteractiveMultiselectPrinter
- func (p InteractiveMultiselectPrinter) WithTerminal(term Terminal) *InteractiveMultiselectPrinter
- type InteractiveSelectPrinter
- func (p *InteractiveSelectPrinter) Show(text ...string) (string, error)
- func (p InteractiveSelectPrinter) WithDefaultOption(option string) *InteractiveSelectPrinter
- func (p InteractiveSelectPrinter) WithDefaultText(text string) *InteractiveSelectPrinter
- func (p InteractiveSelectPrinter) WithMaxHeight(maxHeight int) *InteractiveSelectPrinter
- func (p InteractiveSelectPrinter) WithOptions(options []string) *InteractiveSelectPrinter
- func (p InteractiveSelectPrinter) WithTerminal(term Terminal) *InteractiveSelectPrinter
- type InteractiveTextInputPrinter
- func (p *InteractiveTextInputPrinter) Show(text ...string) (string, error)
- func (p *InteractiveTextInputPrinter) WithDefaultText(text string) *InteractiveTextInputPrinter
- func (p *InteractiveTextInputPrinter) WithMultiLine(multiLine ...bool) *InteractiveTextInputPrinter
- func (p *InteractiveTextInputPrinter) WithTerminal(term Terminal) *InteractiveTextInputPrinter
- func (p *InteractiveTextInputPrinter) WithTextStyle(style *Style) *InteractiveTextInputPrinter
- type Letter
- type Letters
- type LeveledList
- type LeveledListItem
- type LivePrinter
- type Panel
- type PanelPrinter
- func (p PanelPrinter) Render(term Terminal) error
- func (p PanelPrinter) Srender(term Terminal) (string, error)
- func (p PanelPrinter) WithBottomPadding(bottomPadding int) *PanelPrinter
- func (p PanelPrinter) WithBoxPrinter(boxPrinter BoxPrinter) *PanelPrinter
- func (p PanelPrinter) WithPadding(padding int) *PanelPrinter
- func (p PanelPrinter) WithPanels(panels Panels) *PanelPrinter
- func (p PanelPrinter) WithSameColumnWidth(b ...bool) *PanelPrinter
- type Panels
- type ParagraphPrinter
- func (p *ParagraphPrinter) Print(term Terminal, a ...interface{}) *TextPrinter
- func (p *ParagraphPrinter) PrintOnError(term Terminal, a ...interface{}) *TextPrinter
- func (p *ParagraphPrinter) PrintOnErrorf(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p *ParagraphPrinter) Printf(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p *ParagraphPrinter) Printfln(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p *ParagraphPrinter) Println(term Terminal, a ...interface{}) *TextPrinter
- func (p ParagraphPrinter) Sprint(term Terminal, a ...interface{}) string
- func (p ParagraphPrinter) Sprintf(term Terminal, format string, a ...interface{}) string
- func (p ParagraphPrinter) Sprintfln(term Terminal, format string, a ...interface{}) string
- func (p ParagraphPrinter) Sprintln(term Terminal, a ...interface{}) string
- func (p ParagraphPrinter) WithLimitWidth(width int) *ParagraphPrinter
- type Prefix
- type PrefixPrinter
- func (p PrefixPrinter) GetFormattedPrefix() string
- func (p *PrefixPrinter) Print(term Terminal, a ...interface{}) *TextPrinter
- func (p *PrefixPrinter) PrintOnError(term Terminal, a ...interface{}) *TextPrinter
- func (p *PrefixPrinter) PrintOnErrorf(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p *PrefixPrinter) Printf(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p *PrefixPrinter) Printfln(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p *PrefixPrinter) Println(term Terminal, a ...interface{}) *TextPrinter
- func (p *PrefixPrinter) Sprint(term Terminal, a ...interface{}) string
- func (p PrefixPrinter) Sprintf(term Terminal, format string, a ...interface{}) string
- func (p PrefixPrinter) Sprintfln(term Terminal, format string, a ...interface{}) string
- func (p PrefixPrinter) Sprintln(term Terminal, a ...interface{}) string
- func (p PrefixPrinter) WithDebugger(b ...bool) *PrefixPrinter
- func (p PrefixPrinter) WithFatal(b ...bool) *PrefixPrinter
- func (p PrefixPrinter) WithLineNumberOffset(offset int) *PrefixPrinter
- func (p PrefixPrinter) WithMessageStyle(style *Style) *PrefixPrinter
- func (p PrefixPrinter) WithPrefix(prefix Prefix) *PrefixPrinter
- func (p PrefixPrinter) WithScope(scope Scope) *PrefixPrinter
- func (p PrefixPrinter) WithShowLineNumber(b ...bool) *PrefixPrinter
- type ProgressbarPrinter
- func (p *ProgressbarPrinter) Add(count int) *ProgressbarPrinter
- func (p ProgressbarPrinter) GenericStart() (*LivePrinter, error)
- func (p ProgressbarPrinter) GenericStop() (*LivePrinter, error)
- func (p *ProgressbarPrinter) GetElapsedTime() time.Duration
- func (p *ProgressbarPrinter) Increment() *ProgressbarPrinter
- func (p ProgressbarPrinter) Start() (*ProgressbarPrinter, error)
- func (p *ProgressbarPrinter) Stop() (*ProgressbarPrinter, error)
- func (p *ProgressbarPrinter) UpdateTitle(title string) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithBarCharacter(char string) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithBarFiller(char string) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithBarStyle(style *Style) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithCurrent(current int) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithElapsedTimeRoundingFactor(duration time.Duration) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithLastCharacter(char string) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithMaxWidth(maxWidth int) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithRemoveWhenDone(b ...bool) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithShowCount(b ...bool) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithShowElapsedTime(b ...bool) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithShowPercentage(b ...bool) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithShowTitle(b ...bool) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithTerminal(term Terminal) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithTitle(name string) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithTitleStyle(style *Style) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithTotal(total int) *ProgressbarPrinter
- type RGB
- func (p RGB) Fade(min, max, current float32, end ...RGB) RGB
- func (p RGB) GetValues() (r, g, b uint8)
- func (p RGB) Print(term Terminal, a ...interface{}) *TextPrinter
- func (p RGB) PrintOnError(term Terminal, a ...interface{}) *TextPrinter
- func (p RGB) PrintOnErrorf(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p RGB) Printf(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p RGB) Printfln(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p RGB) Println(term Terminal, a ...interface{}) *TextPrinter
- func (p RGB) Sprint(term Terminal, a ...interface{}) string
- func (p RGB) Sprintf(term Terminal, format string, a ...interface{}) string
- func (p RGB) Sprintfln(term Terminal, format string, a ...interface{}) string
- func (p RGB) Sprintln(term Terminal, a ...interface{}) string
- type RenderPrinter
- type Scope
- type SectionPrinter
- func (p *SectionPrinter) Print(term Terminal, a ...interface{}) *TextPrinter
- func (p *SectionPrinter) PrintOnError(term Terminal, a ...interface{}) *TextPrinter
- func (p *SectionPrinter) PrintOnErrorf(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p *SectionPrinter) Printf(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p *SectionPrinter) Printfln(term Terminal, format string, a ...interface{}) *TextPrinter
- func (p *SectionPrinter) Println(term Terminal, a ...interface{}) *TextPrinter
- func (p SectionPrinter) Sprint(term Terminal, a ...interface{}) string
- func (p SectionPrinter) Sprintf(term Terminal, format string, a ...interface{}) string
- func (p SectionPrinter) Sprintfln(term Terminal, format string, a ...interface{}) string
- func (p SectionPrinter) Sprintln(term Terminal, a ...interface{}) string
- func (p SectionPrinter) WithBottomPadding(padding int) *SectionPrinter
- func (p SectionPrinter) WithIndentCharacter(char string) *SectionPrinter
- func (p SectionPrinter) WithLevel(level int) *SectionPrinter
- func (p SectionPrinter) WithStyle(style *Style) *SectionPrinter
- func (p SectionPrinter) WithTopPadding(padding int) *SectionPrinter
- type SpinnerPrinter
- func (s *SpinnerPrinter) Fail(message ...interface{})
- func (s *SpinnerPrinter) GenericStart() (*LivePrinter, error)
- func (s *SpinnerPrinter) GenericStop() (*LivePrinter, error)
- func (s SpinnerPrinter) Start(text ...interface{}) (*SpinnerPrinter, error)
- func (s *SpinnerPrinter) Stop() error
- func (s *SpinnerPrinter) Success(message ...interface{})
- func (s *SpinnerPrinter) UpdateText(text string)
- func (s *SpinnerPrinter) Warning(message ...interface{})
- func (s SpinnerPrinter) WithDelay(delay time.Duration) *SpinnerPrinter
- func (s SpinnerPrinter) WithMessageStyle(style *Style) *SpinnerPrinter
- func (s SpinnerPrinter) WithRemoveWhenDone(b ...bool) *SpinnerPrinter
- func (s SpinnerPrinter) WithSequence(sequence ...string) *SpinnerPrinter
- func (s SpinnerPrinter) WithShowTimer(b ...bool) *SpinnerPrinter
- func (s SpinnerPrinter) WithStyle(style *Style) *SpinnerPrinter
- func (p SpinnerPrinter) WithTerminal(term Terminal) *SpinnerPrinter
- func (s SpinnerPrinter) WithText(text string) *SpinnerPrinter
- func (s SpinnerPrinter) WithTimerRoundingFactor(factor time.Duration) *SpinnerPrinter
- func (s SpinnerPrinter) WithTimerStyle(style *Style) *SpinnerPrinter
- type StrictTerminal
- func (t *StrictTerminal) GetLineEnding() string
- func (t *StrictTerminal) GetTerminalHeight() int
- func (t *StrictTerminal) GetTerminalSize() (width, height int, err error)
- func (t *StrictTerminal) GetTerminalWidth() int
- func (t *StrictTerminal) GetWriter() io.Writer
- func (t *StrictTerminal) Listen(onKeyPress func(key keys.Key) (stop bool, err error)) error
- func (t *StrictTerminal) WithWriter(writer io.Writer) *StrictTerminal
- type Style
- func (s Style) Add(styles ...Style) Style
- func (s Style) Code() string
- func (s Style) Print(term Terminal, a ...interface{})
- func (s Style) Printf(term Terminal, format string, a ...interface{})
- func (s Style) Printfln(term Terminal, format string, a ...interface{})
- func (s Style) Println(term Terminal, a ...interface{})
- func (s Style) Sprint(a ...interface{}) string
- func (s Style) Sprintf(format string, a ...interface{}) string
- func (s Style) Sprintfln(format string, a ...interface{}) string
- func (s Style) Sprintln(a ...interface{}) string
- func (s Style) String() string
- type TTYTerminal
- func (t *TTYTerminal) GetLineEnding() string
- func (t *TTYTerminal) GetTerminalHeight() int
- func (t *TTYTerminal) GetTerminalSize() (width, height int, err error)
- func (t *TTYTerminal) GetTerminalWidth() int
- func (t *TTYTerminal) GetWriter() io.Writer
- func (t *TTYTerminal) Listen(onKeyPress func(key keys.Key) (stop bool, err error)) error
- func (t *TTYTerminal) SetForcedTerminalSize(width int, height int)
- func (t *TTYTerminal) WithWriter(writer io.Writer) *TTYTerminal
- type TableData
- type TablePrinter
- func (p TablePrinter) Render(term Terminal) error
- func (p TablePrinter) Srender(term Terminal) (string, error)
- func (p TablePrinter) WithBoxed(b ...bool) *TablePrinter
- func (p TablePrinter) WithCSVReader(reader *csv.Reader) *TablePrinter
- func (p TablePrinter) WithData(data [][]string) *TablePrinter
- func (p TablePrinter) WithHasHeader(b ...bool) *TablePrinter
- func (p TablePrinter) WithHeaderRowSeparator(separator string) *TablePrinter
- func (p TablePrinter) WithHeaderRowSeparatorStyle(style *Style) *TablePrinter
- func (p TablePrinter) WithHeaderStyle(style *Style) *TablePrinter
- func (p TablePrinter) WithLeftAlignment(b ...bool) *TablePrinter
- func (p TablePrinter) WithRightAlignment(b ...bool) *TablePrinter
- func (p TablePrinter) WithRowSeparator(separator string) *TablePrinter
- func (p TablePrinter) WithRowSeparatorStyle(style *Style) *TablePrinter
- func (p TablePrinter) WithSeparator(separator string) *TablePrinter
- func (p TablePrinter) WithSeparatorStyle(style *Style) *TablePrinter
- func (p TablePrinter) WithStyle(style *Style) *TablePrinter
- type Terminal
- type TextPrinter
- type Theme
- func (t Theme) WithBarLabelStyle(style Style) Theme
- func (t Theme) WithBarStyle(style Style) Theme
- func (t Theme) WithBoxStyle(style Style) Theme
- func (t Theme) WithBoxTextStyle(style Style) Theme
- func (t Theme) WithBulletListBulletStyle(style Style) Theme
- func (t Theme) WithBulletListTextStyle(style Style) Theme
- func (t Theme) WithDebugMessageStyle(style Style) Theme
- func (t Theme) WithDebugPrefixStyle(style Style) Theme
- func (t Theme) WithDescriptionMessageStyle(style Style) Theme
- func (t Theme) WithDescriptionPrefixStyle(style Style) Theme
- func (t Theme) WithErrorMessageStyle(style Style) Theme
- func (t Theme) WithErrorPrefixStyle(style Style) Theme
- func (t Theme) WithFatalMessageStyle(style Style) Theme
- func (t Theme) WithFatalPrefixStyle(style Style) Theme
- func (t Theme) WithHighlightStyle(style Style) Theme
- func (t Theme) WithInfoMessageStyle(style Style) Theme
- func (t Theme) WithInfoPrefixStyle(style Style) Theme
- func (t Theme) WithLetterStyle(style Style) Theme
- func (t Theme) WithPrimaryStyle(style Style) Theme
- func (t Theme) WithSecondaryStyle(style Style) Theme
- func (t Theme) WithSuccessMessageStyle(style Style) Theme
- func (t Theme) WithSuccessPrefixStyle(style Style) Theme
- func (t Theme) WithTreeStyle(style Style) Theme
- func (t Theme) WithTreeTextStyle(style Style) Theme
- func (t Theme) WithWarningMessageStyle(style Style) Theme
- func (t Theme) WithWarningPrefixStyle(style Style) Theme
- type TreeNode
- type TreePrinter
- func (p TreePrinter) Render(term Terminal) error
- func (p TreePrinter) Srender(term Terminal) (string, error)
- func (p TreePrinter) WithHorizontalString(s string) *TreePrinter
- func (p TreePrinter) WithIndent(indent int) *TreePrinter
- func (p TreePrinter) WithRoot(root TreeNode) *TreePrinter
- func (p TreePrinter) WithTextStyle(style *Style) *TreePrinter
- func (p TreePrinter) WithTopRightCornerString(s string) *TreePrinter
- func (p TreePrinter) WithTopRightDownStringOngoing(s string) *TreePrinter
- func (p TreePrinter) WithTreeStyle(style *Style) *TreePrinter
- func (p TreePrinter) WithVerticalString(s string) *TreePrinter
Constants ΒΆ
This section is empty.
Variables ΒΆ
var ( // Red is an alias for FgRed.Sprint. Red = FgRed.Sprint // Cyan is an alias for FgCyan.Sprint. Cyan = FgCyan.Sprint // Gray is an alias for FgGray.Sprint. Gray = FgGray.Sprint // Blue is an alias for FgBlue.Sprint. Blue = FgBlue.Sprint // Black is an alias for FgBlack.Sprint. Black = FgBlack.Sprint // Green is an alias for FgGreen.Sprint. Green = FgGreen.Sprint // White is an alias for FgWhite.Sprint. White = FgWhite.Sprint // Yellow is an alias for FgYellow.Sprint. Yellow = FgYellow.Sprint // Magenta is an alias for FgMagenta.Sprint. Magenta = FgMagenta.Sprint // Normal is an alias for FgDefault.Sprint. Normal = FgDefault.Sprint // LightRed is a shortcut for FgLightRed.Sprint. LightRed = FgLightRed.Sprint // LightCyan is a shortcut for FgLightCyan.Sprint. LightCyan = FgLightCyan.Sprint // LightBlue is a shortcut for FgLightBlue.Sprint. LightBlue = FgLightBlue.Sprint // LightGreen is a shortcut for FgLightGreen.Sprint. LightGreen = FgLightGreen.Sprint // LightWhite is a shortcut for FgLightWhite.Sprint. LightWhite = FgLightWhite.Sprint // LightYellow is a shortcut for FgLightYellow.Sprint. LightYellow = FgLightYellow.Sprint // LightMagenta is a shortcut for FgLightMagenta.Sprint. LightMagenta = FgLightMagenta.Sprint )
var ( // ErrTerminalSizeNotDetectable - the terminal size can not be detected and the fallback values are used. ErrTerminalSizeNotDetectable = errors.New("terminal size could not be detected - using fallback value") // ErrHexCodeIsInvalid - the given HEX code is invalid. ErrHexCodeIsInvalid = errors.New("hex code is not valid") )
var ( // Info returns a PrefixPrinter, which can be used to print text with an "info" Prefix. Info = PrefixPrinter{ MessageStyle: &ThemeDefault.InfoMessageStyle, Prefix: Prefix{ Style: &ThemeDefault.InfoPrefixStyle, Text: "INFO", }, } // Warning returns a PrefixPrinter, which can be used to print text with a "warning" Prefix. Warning = PrefixPrinter{ MessageStyle: &ThemeDefault.WarningMessageStyle, Prefix: Prefix{ Style: &ThemeDefault.WarningPrefixStyle, Text: "WARNING", }, } // Success returns a PrefixPrinter, which can be used to print text with a "success" Prefix. Success = PrefixPrinter{ MessageStyle: &ThemeDefault.SuccessMessageStyle, Prefix: Prefix{ Style: &ThemeDefault.SuccessPrefixStyle, Text: "SUCCESS", }, } // Error returns a PrefixPrinter, which can be used to print text with an "error" Prefix. Error = PrefixPrinter{ MessageStyle: &ThemeDefault.ErrorMessageStyle, Prefix: Prefix{ Style: &ThemeDefault.ErrorPrefixStyle, Text: " ERROR ", }, } // Fatal returns a PrefixPrinter, which can be used to print text with an "fatal" Prefix. // NOTICE: Fatal terminates the application immediately! Fatal = PrefixPrinter{ MessageStyle: &ThemeDefault.FatalMessageStyle, Prefix: Prefix{ Style: &ThemeDefault.FatalPrefixStyle, Text: " FATAL ", }, Fatal: true, } // Debug Prints debug messages. By default it will only print if PrintDebugMessages is true. // You can change PrintDebugMessages with EnableDebugMessages and DisableDebugMessages, or by setting the variable itself. Debug = PrefixPrinter{ MessageStyle: &ThemeDefault.DebugMessageStyle, Prefix: Prefix{ Text: " DEBUG ", Style: &ThemeDefault.DebugPrefixStyle, }, Debugger: true, } // Description returns a PrefixPrinter, which can be used to print text with a "description" Prefix. Description = PrefixPrinter{ MessageStyle: &ThemeDefault.DescriptionMessageStyle, Prefix: Prefix{ Style: &ThemeDefault.DescriptionPrefixStyle, Text: "Description", }, } )
var ( // Output completely disables output from pterm if set to false. Can be used in CLI application quiet mode. Output = true // PrintDebugMessages sets if messages printed by the DebugPrinter should be printed. PrintDebugMessages = false // RawOutput is set to true if pterm.DisableStyling() was called. // The variable indicates that PTerm will not add additional styling to text. // Use pterm.DisableStyling() or pterm.EnableStyling() to change this variable. // Changing this variable directly, will disable or enable the output of colored text. RawOutput = false )
var ActiveProgressBarPrinters []*ProgressbarPrinter
ActiveProgressBarPrinters contains all running ProgressbarPrinters. Generally, there should only be one active ProgressbarPrinter at a time.
var DefaultArea = AreaPrinter{ Term: DefaultTerminal, }
DefaultArea is the default area printer.
var ( // DefaultBarChart is the default BarChartPrinter. DefaultBarChart = BarChartPrinter{ Horizontal: false, VerticalBarCharacter: "ββ", HorizontalBarCharacter: "β", } )
var ( // DefaultBasicText returns a default BasicTextPrinter, which can be used to print text as is. // No default style is present for BasicTextPrinter. DefaultBasicText = BasicTextPrinter{} )
var DefaultBigText = BigTextPrinter{ BigCharacters: map[string]string{ "a": ` βββββ ββ ββ βββββββ ββ ββ ββ ββ `, "A": ` βββββ ββ ββ βββββββ ββ ββ ββ ββ `, "b": `ββββββ ββ ββ ββββββ ββ ββ ββββββ`, "B": `ββββββ ββ ββ ββββββ ββ ββ ββββββ`, "c": ` ββββββ ββ ββ ββ ββββββ`, "C": ` ββββββ ββ ββ ββ ββββββ`, "d": `ββββββ ββ ββ ββ ββ ββ ββ ββββββ `, "D": `ββββββ ββ ββ ββ ββ ββ ββ ββββββ `, "e": `βββββββ ββ βββββ ββ βββββββ`, "E": `βββββββ ββ βββββ ββ βββββββ`, "f": `βββββββ ββ βββββ ββ ββ `, "F": `βββββββ ββ βββββ ββ ββ `, "g": ` ββββββ ββ ββ βββ ββ ββ ββββββ `, "G": ` ββββββ ββ ββ βββ ββ ββ ββββββ `, "h": `ββ ββ ββ ββ βββββββ ββ ββ ββ ββ `, "H": `ββ ββ ββ ββ βββββββ ββ ββ ββ ββ `, "i": `ββ ββ ββ ββ ββ`, "I": `ββ ββ ββ ββ ββ`, "j": ` ββ ββ ββ ββ ββ βββββ `, "J": ` ββ ββ ββ ββ ββ βββββ `, "k": `ββ ββ ββ ββ βββββ ββ ββ ββ ββ`, "K": `ββ ββ ββ ββ βββββ ββ ββ ββ ββ`, "l": `ββ ββ ββ ββ βββββββ `, "L": `ββ ββ ββ ββ βββββββ `, "m": `βββ βββ ββββ ββββ ββ ββββ ββ ββ ββ ββ ββ ββ`, "M": `βββ βββ ββββ ββββ ββ ββββ ββ ββ ββ ββ ββ ββ`, "n": `βββ ββ ββββ ββ ββ ββ ββ ββ ββ ββ ββ ββββ`, "N": `βββ ββ ββββ ββ ββ ββ ββ ββ ββ ββ ββ ββββ`, "o": ` ββββββ ββ ββ ββ ββ ββ ββ ββββββ `, "O": ` ββββββ ββ ββ ββ ββ ββ ββ ββββββ `, "p": `ββββββ ββ ββ ββββββ ββ ββ `, "P": `ββββββ ββ ββ ββββββ ββ ββ `, "q": ` ββββββ ββ ββ ββ ββ ββ ββ ββ ββββββ ββ `, "Q": ` ββββββ ββ ββ ββ ββ ββ ββ ββ ββββββ ββ `, "r": `ββββββ ββ ββ ββββββ ββ ββ ββ ββ`, "R": `ββββββ ββ ββ ββββββ ββ ββ ββ ββ`, "s": `βββββββ ββ βββββββ ββ βββββββ`, "S": `βββββββ ββ βββββββ ββ βββββββ`, "t": `ββββββββ ββ ββ ββ ββ `, "T": `ββββββββ ββ ββ ββ ββ `, "u": `ββ ββ ββ ββ ββ ββ ββ ββ ββββββ `, "U": `ββ ββ ββ ββ ββ ββ ββ ββ ββββββ `, "v": `ββ ββ ββ ββ ββ ββ ββ ββ ββββ `, "V": `ββ ββ ββ ββ ββ ββ ββ ββ ββββ `, "w": `ββ ββ ββ ββ ββ β ββ ββ βββ ββ βββ βββ `, "W": `ββ ββ ββ ββ ββ β ββ ββ βββ ββ βββ βββ `, "x": `ββ ββ ββ ββ βββ ββ ββ ββ ββ `, "X": `ββ ββ ββ ββ βββ ββ ββ ββ ββ `, "y": `ββ ββ ββ ββ ββββ ββ ββ `, "Y": `ββ ββ ββ ββ ββββ ββ ββ `, "z": `βββββββ βββ βββ βββ βββββββ`, "Z": `βββββββ βββ βββ βββ βββββββ`, "0": ` ββββββ ββ ββββ ββ ββ ββ ββββ ββ ββββββ `, "1": ` ββ βββ ββ ββ ββ `, "2": `ββββββ ββ βββββ ββ βββββββ `, "3": `ββββββ ββ βββββ ββ ββββββ `, "4": `ββ ββ ββ ββ βββββββ ββ ββ `, "5": `βββββββ ββ βββββββ ββ βββββββ`, "6": ` ββββββ ββ βββββββ ββ ββ ββββββ `, "7": `βββββββ ββ ββ ββ ββ`, "8": ` βββββ ββ ββ βββββ ββ ββ βββββ `, "9": ` βββββ ββ ββ ββββββ ββ βββββ `, " ": " ", "!": `ββ ββ ββ ββ `, "$": `βββββββΒ· ββ βββββββ ββ βββββββ βββ `, "%": `ββ ββ ββ ββ ββ ββ ββ`, "/": ` ββ ββ ββ ββ ββ `, "(": ` ββ ββ ββ ββ ββ `, ")": `ββ ββ ββ ββ ββ `, "?": `ββββββ ββ ββββ ββ ββ `, "[": `βββ ββ ββ ββ βββ`, "]": `βββ ββ ββ ββ βββ `, ".": ` ββ`, ",": ` ββ`, "-": ` βββββ `, "<": ` ββ ββ ββ ββ ββ `, ">": `ββ ββ ββ ββ ββ `, "*": ` β ββ β ββββ β ββ β `, "#": ` ββ ββ ββββββββ ββ ββ ββββββββ ββ ββ `, "_": ` βββββββ `, ":": ` ββ ββ `, "Β°": ` ββββ ββ ββ ββββ `, }, }
DefaultBigText contains default values for BigTextPrinter.
var DefaultBox = BoxPrinter{ VerticalString: "|", TopRightCornerString: "β", TopLeftCornerString: "β", BottomLeftCornerString: "β", BottomRightCornerString: "β", HorizontalString: "β", BoxStyle: &ThemeDefault.BoxStyle, TextStyle: &ThemeDefault.BoxTextStyle, RightPadding: 1, LeftPadding: 1, TopPadding: 0, BottomPadding: 0, TitleTopLeft: true, }
DefaultBox is the default BoxPrinter.
var DefaultBulletList = BulletListPrinter{ Bullet: "β’", TextStyle: &ThemeDefault.BulletListTextStyle, BulletStyle: &ThemeDefault.BulletListBulletStyle, }
DefaultBulletList contains standards, which can be used to print a BulletListPrinter.
var DefaultCenter = CenterPrinter{ CenterEachLineSeparately: false, }
DefaultCenter is the default CenterPrinter.
var ( // DefaultHeader returns the printer for a default header text. // Defaults to LightWhite, Bold Text and a Gray DefaultHeader background. DefaultHeader = HeaderPrinter{ TextStyle: &ThemeDefault.HeaderTextStyle, BackgroundStyle: &ThemeDefault.HeaderBackgroundStyle, Margin: 5, } )
var ( // DefaultInteractiveConfirm is the default InteractiveConfirm printer. // Pressing "y" will return true, "n" will return false. // Pressing enter without typing "y" or "n" will return the configured default value (by default set to "no"). DefaultInteractiveConfirm = InteractiveConfirmPrinter{ Term: DefaultTerminal, DefaultValue: false, DefaultText: "Please confirm", TextStyle: &ThemeDefault.PrimaryStyle, ConfirmText: "Yes", ConfirmStyle: &ThemeDefault.SuccessMessageStyle, RejectText: "No", RejectStyle: &ThemeDefault.ErrorMessageStyle, SuffixStyle: &ThemeDefault.SecondaryStyle, Cursor: Cursor{Term: DefaultTerminal}, } )
var ( // DefaultInteractiveMultiselect is the default InteractiveMultiselect printer. DefaultInteractiveMultiselect = InteractiveMultiselectPrinter{ Term: DefaultTerminal, TextStyle: &ThemeDefault.PrimaryStyle, DefaultText: "Please select your options", Options: []string{}, OptionStyle: &ThemeDefault.DefaultText, DefaultOptions: []string{}, MaxHeight: 5, Selector: ">", SelectorStyle: &ThemeDefault.SecondaryStyle, RemoveWhenDone: true, Cursor: Cursor{Term: DefaultTerminal}, } )
var ( // DefaultInteractiveSelect is the default InteractiveSelect printer. DefaultInteractiveSelect = InteractiveSelectPrinter{ Term: DefaultTerminal, TextStyle: &ThemeDefault.PrimaryStyle, DefaultText: "Please select an option", Options: []string{}, OptionStyle: &ThemeDefault.DefaultText, DefaultOption: "", MaxHeight: 5, Selector: ">", SelectorStyle: &ThemeDefault.SecondaryStyle, EnableFuzzySearch: true, RemoveWhenDone: true, Cursor: Cursor{Term: DefaultTerminal}, } )
var ( // DefaultInteractiveTextInput is the default InteractiveTextInput printer. DefaultInteractiveTextInput = InteractiveTextInputPrinter{ Term: DefaultTerminal, DefaultText: "Input text", TextStyle: &ThemeDefault.PrimaryStyle, } )
var DefaultPanel = PanelPrinter{
Padding: 1,
}
DefaultPanel is the default PanelPrinter.
var DefaultParagraph = ParagraphPrinter{ LimitWidth: DefaultTerminal.GetTerminalWidth(), }
DefaultParagraph contains the default values for a ParagraphPrinter.
var ( // DefaultProgressbar is the default ProgressbarPrinter. DefaultProgressbar = ProgressbarPrinter{ Term: DefaultTerminal, Total: 100, BarCharacter: "β", LastCharacter: "β", ElapsedTimeRoundingFactor: time.Second, BarStyle: &ThemeDefault.ProgressbarBarStyle, TitleStyle: &ThemeDefault.ProgressbarTitleStyle, ShowTitle: true, ShowCount: true, ShowPercentage: true, ShowElapsedTime: true, BarFiller: " ", MaxWidth: 80, } )
var DefaultSection = SectionPrinter{ Style: &ThemeDefault.SectionStyle, Level: 1, TopPadding: 1, BottomPadding: 1, IndentCharacter: "#", }
DefaultSection is the default section printer.
var DefaultSpinner = SpinnerPrinter{ Term: DefaultTerminal, Sequence: []string{"β ", " β", " β", "β "}, Style: &ThemeDefault.SpinnerStyle, Delay: time.Millisecond * 200, ShowTimer: true, TimerRoundingFactor: time.Second, TimerStyle: &ThemeDefault.TimerStyle, MessageStyle: &ThemeDefault.SpinnerTextStyle, SuccessPrinter: &Success, FailPrinter: &Error, WarningPrinter: &Warning, }
DefaultSpinner is the default SpinnerPrinter.
var DefaultTable = TablePrinter{ Style: &ThemeDefault.TableStyle, HeaderStyle: &ThemeDefault.TableHeaderStyle, HeaderRowSeparator: "", HeaderRowSeparatorStyle: &ThemeDefault.TableSeparatorStyle, Separator: " | ", SeparatorStyle: &ThemeDefault.TableSeparatorStyle, RowSeparator: "", RowSeparatorStyle: &ThemeDefault.TableSeparatorStyle, LeftAlignment: true, RightAlignment: false, }
DefaultTable contains standards, which can be used to print a TablePrinter.
var DefaultTerminal = &TTYTerminal{ Writer: os.Stdout, Input: keyboard.Listen, }
var DefaultTree = TreePrinter{ TreeStyle: &ThemeDefault.TreeStyle, TextStyle: &ThemeDefault.TreeTextStyle, TopRightCornerString: "β", HorizontalString: "β", TopRightDownString: "β", VerticalString: "β", RightDownLeftString: "β¬", Indent: 2, }
DefaultTree contains standards, which can be used to render a TreePrinter.
var FallbackTerminalHeight = 10
FallbackTerminalHeight is the value used for GetTerminalHeight, if the actual height can not be detected You can override that value if necessary.
var FallbackTerminalWidth = 80
FallbackTerminalWidth is the value used for GetTerminalWidth, if the actual width can not be detected You can override that value if necessary.
var ( // GrayBoxStyle wraps text in a gray box. GrayBoxStyle = NewStyle(BgGray, FgLightWhite) )
var PrintColor = true
PrintColor is false if PTerm should not print colored output.
var ( // ThemeDefault is the default theme used by PTerm. // If this variable is overwritten, the new value is used as default theme. ThemeDefault = Theme{ DefaultText: Style{FgDefault, BgDefault}, PrimaryStyle: Style{FgLightCyan}, SecondaryStyle: Style{FgLightMagenta}, HighlightStyle: Style{Bold, FgYellow}, InfoMessageStyle: Style{FgLightCyan}, InfoPrefixStyle: Style{FgBlack, BgCyan}, SuccessMessageStyle: Style{FgGreen}, SuccessPrefixStyle: Style{FgBlack, BgGreen}, WarningMessageStyle: Style{FgYellow}, WarningPrefixStyle: Style{FgBlack, BgYellow}, ErrorMessageStyle: Style{FgLightRed}, ErrorPrefixStyle: Style{FgBlack, BgLightRed}, FatalMessageStyle: Style{FgLightRed}, FatalPrefixStyle: Style{FgBlack, BgLightRed}, DescriptionMessageStyle: Style{FgDefault}, DescriptionPrefixStyle: Style{FgLightWhite, BgDarkGray}, ScopeStyle: Style{FgGray}, ProgressbarBarStyle: Style{FgCyan}, ProgressbarTitleStyle: Style{FgLightCyan}, HeaderTextStyle: Style{FgLightWhite, Bold}, HeaderBackgroundStyle: Style{BgGray}, SpinnerStyle: Style{FgLightCyan}, SpinnerTextStyle: Style{FgLightWhite}, TableStyle: Style{FgDefault}, TableHeaderStyle: Style{FgLightCyan}, TableSeparatorStyle: Style{FgGray}, SectionStyle: Style{Bold, FgYellow}, BulletListTextStyle: Style{FgDefault}, BulletListBulletStyle: Style{FgGray}, TreeStyle: Style{FgGray}, TreeTextStyle: Style{FgDefault}, LetterStyle: Style{FgDefault}, DebugMessageStyle: Style{FgGray}, DebugPrefixStyle: Style{FgBlack, BgGray}, BoxStyle: Style{FgDefault}, BoxTextStyle: Style{FgDefault}, BarLabelStyle: Style{FgLightCyan}, BarStyle: Style{FgCyan}, TimerStyle: Style{FgGray}, } )
Functions ΒΆ
func DisableDebugMessages ΒΆ
func DisableDebugMessages()
DisableDebugMessages disables the output of debug printers.
func DisableStyling ΒΆ
func DisableStyling()
DisableStyling sets PTerm to RawOutput mode and disables all of PTerms styling. You can use this to print to text files etc. This also calls DisableColor.
func EnableDebugMessages ΒΆ
func EnableDebugMessages()
EnableDebugMessages enables the output of debug printers.
func EnableStyling ΒΆ
func EnableStyling()
EnableStyling enables the default PTerm styling. This also calls EnableColor.
func Fprint ΒΆ
func Fprint(term Terminal, a ...interface{})
Fprint formats using the default formats for its operands and writes to w. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func Fprintln ΒΆ
func Fprintln(term Terminal, a ...interface{})
Fprintln formats using the default formats for its operands and writes to w. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func Fprinto ΒΆ
func Fprinto(term Terminal, a ...interface{})
Fprinto prints Printo to a custom writer.
func Print ΒΆ
func Print(term Terminal, a ...interface{})
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func PrintOnError ΒΆ
func PrintOnError(term Terminal, a ...interface{})
PrintOnError prints every error which is not nil. If every error is nil, nothing will be printed. This can be used for simple error checking.
func PrintOnErrorf ΒΆ
PrintOnErrorf wraps every error which is not nil and prints it. If every error is nil, nothing will be printed. This can be used for simple error checking.
func Printf ΒΆ
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.
func Printfln ΒΆ
Printfln formats according to a format specifier and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func Println ΒΆ
func Println(term Terminal, a ...interface{})
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func RemoveColorFromString ΒΆ
func RemoveColorFromString(a ...interface{}) string
RemoveColorFromString removes color codes from a string.
func Sprint ΒΆ
func Sprint(a ...interface{}) string
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.
func Sprintfln ΒΆ
Sprintfln formats according to a format specifier and returns the resulting string. Spaces are always added between operands and a newline is appended.
Types ΒΆ
type Area ΒΆ added in v0.12.47
Area displays content which can be updated on the fly. You can use this to create live output, charts, dropdowns, etc.
type AreaPrinter ΒΆ
type AreaPrinter struct { Term Terminal RemoveWhenDone bool Fullscreen bool Center bool Area *Area // contains filtered or unexported fields }
AreaPrinter prints an area which can be updated easily. use this printer for live output like charts, algorithm visualizations, simulations and even games.
func (*AreaPrinter) Clear ΒΆ
func (p *AreaPrinter) Clear()
Wrapper function that clears the content of the Area. Moves the cursor to the bottom of the terminal, clears n lines upwards from the current position and moves the cursor again.
func (*AreaPrinter) GenericStart ΒΆ
func (p *AreaPrinter) GenericStart() (*LivePrinter, error)
GenericStart runs Start, but returns a LivePrinter. This is used for the interface LivePrinter. You most likely want to use Start instead of this in your program.
func (*AreaPrinter) GenericStop ΒΆ
func (p *AreaPrinter) GenericStop() (*LivePrinter, error)
GenericStop runs Stop, but returns a LivePrinter. This is used for the interface LivePrinter. You most likely want to use Stop instead of this in your program.
func (*AreaPrinter) GetContent ΒΆ
func (p *AreaPrinter) GetContent() string
GetContent returns the current area content.
func (*AreaPrinter) Start ΒΆ
func (p *AreaPrinter) Start(text ...interface{}) (*AreaPrinter, error)
Start the AreaPrinter.
func (*AreaPrinter) Stop ΒΆ
func (p *AreaPrinter) Stop() error
Stop terminates the AreaPrinter immediately. The AreaPrinter will not resolve into anything.
func (*AreaPrinter) Update ΒΆ
func (p *AreaPrinter) Update(text ...interface{})
Update overwrites the content of the AreaPrinter. Can be used live.
func (AreaPrinter) WithCenter ΒΆ
func (p AreaPrinter) WithCenter(b ...bool) *AreaPrinter
WithCenter centers the AreaPrinter content to the terminal.
func (AreaPrinter) WithFullscreen ΒΆ
func (p AreaPrinter) WithFullscreen(b ...bool) *AreaPrinter
WithFullscreen sets the AreaPrinter height the same height as the terminal, making it fullscreen.
func (AreaPrinter) WithRemoveWhenDone ΒΆ
func (p AreaPrinter) WithRemoveWhenDone(b ...bool) *AreaPrinter
WithRemoveWhenDone removes the AreaPrinter content after it is stopped.
func (AreaPrinter) WithTerminal ΒΆ added in v0.12.47
func (p AreaPrinter) WithTerminal(term Terminal) *AreaPrinter
type Bar ΒΆ
Bar is used in bar charts.
func (Bar) WithLabelStyle ΒΆ
WithLabelStyle returns a new Bar with a specific option.
type BarChartPrinter ΒΆ
type BarChartPrinter struct { Bars Bars Horizontal bool ShowValue bool VerticalBarCharacter string HorizontalBarCharacter string }
BarChartPrinter is used to print bar charts.
func (BarChartPrinter) Render ΒΆ
func (p BarChartPrinter) Render(term Terminal) error
Render prints the Template to the terminal.
func (BarChartPrinter) Srender ΒΆ
func (p BarChartPrinter) Srender(term Terminal) (string, error)
Srender renders the BarChart as a string.
func (BarChartPrinter) WithBars ΒΆ
func (p BarChartPrinter) WithBars(bars Bars) *BarChartPrinter
WithBars returns a new BarChartPrinter with a specific option.
func (BarChartPrinter) WithHorizontal ΒΆ
func (p BarChartPrinter) WithHorizontal(b ...bool) *BarChartPrinter
WithHorizontal returns a new BarChartPrinter with a specific option.
func (BarChartPrinter) WithHorizontalBarCharacter ΒΆ
func (p BarChartPrinter) WithHorizontalBarCharacter(char string) *BarChartPrinter
WithHorizontalBarCharacter returns a new BarChartPrinter with a specific option.
func (BarChartPrinter) WithShowValue ΒΆ
func (p BarChartPrinter) WithShowValue(b ...bool) *BarChartPrinter
WithShowValue returns a new BarChartPrinter with a specific option.
func (BarChartPrinter) WithVerticalBarCharacter ΒΆ
func (p BarChartPrinter) WithVerticalBarCharacter(char string) *BarChartPrinter
WithVerticalBarCharacter returns a new BarChartPrinter with a specific option.
type BasicTextPrinter ΒΆ
type BasicTextPrinter struct {
Style *Style
}
BasicTextPrinter is the printer used to print the input as-is or as specified by user formatting.
func (*BasicTextPrinter) Print ΒΆ
func (p *BasicTextPrinter) Print(term Terminal, a ...interface{}) *TextPrinter
Print formats using the default formats for its operands and writes to provided writer. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func (*BasicTextPrinter) PrintOnError ΒΆ
func (p *BasicTextPrinter) PrintOnError(term Terminal, a ...interface{}) *TextPrinter
PrintOnError prints every error which is not nil. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (*BasicTextPrinter) PrintOnErrorf ΒΆ
func (p *BasicTextPrinter) PrintOnErrorf(term Terminal, format string, a ...interface{}) *TextPrinter
PrintOnErrorf wraps every error which is not nil and prints it. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (*BasicTextPrinter) Printf ΒΆ
func (p *BasicTextPrinter) Printf(term Terminal, format string, a ...interface{}) *TextPrinter
Printf formats according to a format specifier and writes to provided writer. It returns the number of bytes written and any write error encountered.
func (*BasicTextPrinter) Printfln ΒΆ
func (p *BasicTextPrinter) Printfln(term Terminal, format string, a ...interface{}) *TextPrinter
Printfln formats according to a format specifier and writes to provided writer. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (*BasicTextPrinter) Println ΒΆ
func (p *BasicTextPrinter) Println(term Terminal, a ...interface{}) *TextPrinter
Println formats using the default formats for its operands and writes to provided writer. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (BasicTextPrinter) Sprint ΒΆ
func (p BasicTextPrinter) Sprint(term Terminal, a ...interface{}) string
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.
func (BasicTextPrinter) Sprintf ΒΆ
func (p BasicTextPrinter) Sprintf(term Terminal, format string, a ...interface{}) string
Sprintf formats according to a format specifier and returns the resulting string.
func (BasicTextPrinter) Sprintfln ΒΆ
func (p BasicTextPrinter) Sprintfln(term Terminal, format string, a ...interface{}) string
Sprintfln formats according to a format specifier and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (BasicTextPrinter) Sprintln ΒΆ
func (p BasicTextPrinter) Sprintln(term Terminal, a ...interface{}) string
Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (BasicTextPrinter) WithStyle ΒΆ
func (p BasicTextPrinter) WithStyle(style *Style) *BasicTextPrinter
WithStyle adds a style to the printer.
type BigTextPrinter ΒΆ
type BigTextPrinter struct { // BigCharacters holds the map from a normal character to it's big version. BigCharacters map[string]string Letters Letters }
BigTextPrinter renders big text. You can use this as title screen for your application.
func (BigTextPrinter) Render ΒΆ
func (p BigTextPrinter) Render(term Terminal) error
Render prints the BigText to the terminal.
func (BigTextPrinter) Srender ΒΆ
func (p BigTextPrinter) Srender(term Terminal) (string, error)
Srender renders the BigText as a string.
func (BigTextPrinter) WithBigCharacters ΒΆ
func (p BigTextPrinter) WithBigCharacters(chars map[string]string) *BigTextPrinter
WithBigCharacters returns a new BigTextPrinter with specific BigCharacters.
func (BigTextPrinter) WithLetters ΒΆ
func (p BigTextPrinter) WithLetters(letters ...Letters) *BigTextPrinter
WithLetters returns a new BigTextPrinter with specific Letters
type BoxPrinter ΒΆ
type BoxPrinter struct { Title string TitleTopLeft bool TitleTopRight bool TitleTopCenter bool TitleBottomLeft bool TitleBottomRight bool TitleBottomCenter bool TextStyle *Style VerticalString string BoxStyle *Style HorizontalString string TopRightCornerString string TopLeftCornerString string BottomLeftCornerString string BottomRightCornerString string TopPadding int BottomPadding int RightPadding int LeftPadding int }
BoxPrinter is able to render a box around printables.
func (BoxPrinter) Print ΒΆ
func (p BoxPrinter) Print(term Terminal, a ...interface{}) *TextPrinter
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func (BoxPrinter) PrintOnError ΒΆ
func (p BoxPrinter) PrintOnError(term Terminal, a ...interface{}) *TextPrinter
PrintOnError prints every error which is not nil. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (BoxPrinter) PrintOnErrorf ΒΆ
func (p BoxPrinter) PrintOnErrorf(term Terminal, format string, a ...interface{}) *TextPrinter
PrintOnErrorf wraps every error which is not nil and prints it. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (BoxPrinter) Printf ΒΆ
func (p BoxPrinter) Printf(term Terminal, format string, a ...interface{}) *TextPrinter
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.
func (BoxPrinter) Printfln ΒΆ
func (p BoxPrinter) Printfln(term Terminal, format string, a ...interface{}) *TextPrinter
Printfln formats according to a format specifier and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (BoxPrinter) Println ΒΆ
func (p BoxPrinter) Println(term Terminal, a ...interface{}) *TextPrinter
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (BoxPrinter) Sprint ΒΆ
func (p BoxPrinter) Sprint(term Terminal, a ...interface{}) string
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.
func (BoxPrinter) Sprintf ΒΆ
func (p BoxPrinter) Sprintf(term Terminal, format string, a ...interface{}) string
Sprintf formats according to a format specifier and returns the resulting string.
func (BoxPrinter) Sprintfln ΒΆ
func (p BoxPrinter) Sprintfln(term Terminal, format string, a ...interface{}) string
Sprintfln formats according to a format specifier and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (BoxPrinter) Sprintln ΒΆ
func (p BoxPrinter) Sprintln(term Terminal, a ...interface{}) string
Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (BoxPrinter) WithBottomLeftCornerString ΒΆ
func (p BoxPrinter) WithBottomLeftCornerString(str string) *BoxPrinter
WithBottomLeftCornerString returns a new box with a specific BottomLeftCornerString.
func (BoxPrinter) WithBottomPadding ΒΆ
func (p BoxPrinter) WithBottomPadding(padding int) *BoxPrinter
WithBottomPadding returns a new box with a specific BottomPadding.
func (BoxPrinter) WithBottomRightCornerString ΒΆ
func (p BoxPrinter) WithBottomRightCornerString(str string) *BoxPrinter
WithBottomRightCornerString returns a new box with a specific BottomRightCornerString.
func (BoxPrinter) WithBoxStyle ΒΆ
func (p BoxPrinter) WithBoxStyle(style *Style) *BoxPrinter
WithBoxStyle returns a new box with a specific box Style.
func (BoxPrinter) WithHorizontalString ΒΆ
func (p BoxPrinter) WithHorizontalString(str string) *BoxPrinter
WithHorizontalString returns a new box with a specific HorizontalString.
func (BoxPrinter) WithLeftPadding ΒΆ
func (p BoxPrinter) WithLeftPadding(padding int) *BoxPrinter
WithLeftPadding returns a new box with a specific LeftPadding.
func (BoxPrinter) WithRightPadding ΒΆ
func (p BoxPrinter) WithRightPadding(padding int) *BoxPrinter
WithRightPadding returns a new box with a specific RightPadding.
func (BoxPrinter) WithTextStyle ΒΆ
func (p BoxPrinter) WithTextStyle(style *Style) *BoxPrinter
WithTextStyle returns a new box with a specific text Style.
func (BoxPrinter) WithTitle ΒΆ
func (p BoxPrinter) WithTitle(str string) *BoxPrinter
WithTitle returns a new box with a specific Title.
func (BoxPrinter) WithTitleBottomCenter ΒΆ
func (p BoxPrinter) WithTitleBottomCenter(b ...bool) *BoxPrinter
WithTitleBottomCenter returns a new box with a specific Title alignment.
func (BoxPrinter) WithTitleBottomLeft ΒΆ
func (p BoxPrinter) WithTitleBottomLeft(b ...bool) *BoxPrinter
WithTitleBottomLeft returns a new box with a specific Title alignment.
func (BoxPrinter) WithTitleBottomRight ΒΆ
func (p BoxPrinter) WithTitleBottomRight(b ...bool) *BoxPrinter
WithTitleBottomRight returns a new box with a specific Title alignment.
func (BoxPrinter) WithTitleTopCenter ΒΆ
func (p BoxPrinter) WithTitleTopCenter(b ...bool) *BoxPrinter
WithTitleTopCenter returns a new box with a specific Title alignment.
func (BoxPrinter) WithTitleTopLeft ΒΆ
func (p BoxPrinter) WithTitleTopLeft(b ...bool) *BoxPrinter
WithTitleTopLeft returns a new box with a specific Title alignment.
func (BoxPrinter) WithTitleTopRight ΒΆ
func (p BoxPrinter) WithTitleTopRight(b ...bool) *BoxPrinter
WithTitleTopRight returns a new box with a specific Title alignment.
func (BoxPrinter) WithTopLeftCornerString ΒΆ
func (p BoxPrinter) WithTopLeftCornerString(str string) *BoxPrinter
WithTopLeftCornerString returns a new box with a specific TopLeftCornerString.
func (BoxPrinter) WithTopPadding ΒΆ
func (p BoxPrinter) WithTopPadding(padding int) *BoxPrinter
WithTopPadding returns a new box with a specific TopPadding.
func (BoxPrinter) WithTopRightCornerString ΒΆ
func (p BoxPrinter) WithTopRightCornerString(str string) *BoxPrinter
WithTopRightCornerString returns a new box with a specific TopRightCornerString.
func (BoxPrinter) WithVerticalString ΒΆ
func (p BoxPrinter) WithVerticalString(str string) *BoxPrinter
WithVerticalString returns a new box with a specific VerticalString.
type BulletListItem ΒΆ
type BulletListItem struct { Level int Text string TextStyle *Style Bullet string BulletStyle *Style }
BulletListItem is able to render a ListItem.
func NewBulletListItemFromString
deprecated
func NewBulletListItemFromString(text string, padding string) BulletListItem
NewBulletListItemFromString returns a BulletListItem with a Text. The padding is counted in the Text to define the Level of the ListItem.
Deprecated: use putils.BulletListItemFromString instead.
func (BulletListItem) WithBullet ΒΆ
func (p BulletListItem) WithBullet(bullet string) *BulletListItem
WithBullet returns a new BulletListItem with a specific Prefix.
func (BulletListItem) WithBulletStyle ΒΆ
func (p BulletListItem) WithBulletStyle(style *Style) *BulletListItem
WithBulletStyle returns a new BulletListItem with a specific BulletStyle.
func (BulletListItem) WithLevel ΒΆ
func (p BulletListItem) WithLevel(level int) *BulletListItem
WithLevel returns a new BulletListItem with a specific Level.
func (BulletListItem) WithText ΒΆ
func (p BulletListItem) WithText(text string) *BulletListItem
WithText returns a new BulletListItem with a specific Text.
func (BulletListItem) WithTextStyle ΒΆ
func (p BulletListItem) WithTextStyle(style *Style) *BulletListItem
WithTextStyle returns a new BulletListItem with a specific TextStyle.
type BulletListPrinter ΒΆ
type BulletListPrinter struct { Items []BulletListItem TextStyle *Style Bullet string BulletStyle *Style }
BulletListPrinter is able to render a list.
func NewBulletListFromString
deprecated
func NewBulletListFromString(s string, padding string) BulletListPrinter
NewBulletListFromString returns a BulletListPrinter with Text using the NewTreeListItemFromString method, splitting after return (\n).
Deprecated: use putils.BulletListFromString instead.
func NewBulletListFromStrings
deprecated
func NewBulletListFromStrings(s []string, padding string) BulletListPrinter
NewBulletListFromStrings returns a BulletListPrinter with Text using the NewTreeListItemFromString method.
Deprecated: use putils.BulletListFromStrings instead.
func (BulletListPrinter) Render ΒΆ
func (l BulletListPrinter) Render(term Terminal) error
Render prints the list to the terminal.
func (BulletListPrinter) Srender ΒΆ
func (l BulletListPrinter) Srender(term Terminal) (string, error)
Srender renders the list as a string.
func (BulletListPrinter) WithBullet ΒΆ
func (l BulletListPrinter) WithBullet(bullet string) *BulletListPrinter
WithBullet returns a new list with a specific bullet.
func (BulletListPrinter) WithBulletStyle ΒΆ
func (l BulletListPrinter) WithBulletStyle(style *Style) *BulletListPrinter
WithBulletStyle returns a new list with a specific bullet style.
func (BulletListPrinter) WithItems ΒΆ
func (l BulletListPrinter) WithItems(items []BulletListItem) *BulletListPrinter
WithItems returns a new list with specific Items.
func (BulletListPrinter) WithTextStyle ΒΆ
func (l BulletListPrinter) WithTextStyle(style *Style) *BulletListPrinter
WithTextStyle returns a new list with a specific text style.
type CenterPrinter ΒΆ
type CenterPrinter struct {
CenterEachLineSeparately bool
}
CenterPrinter prints centered text.
func (CenterPrinter) Print ΒΆ
func (p CenterPrinter) Print(term Terminal, a ...interface{}) *TextPrinter
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func (CenterPrinter) PrintOnError ΒΆ
func (p CenterPrinter) PrintOnError(term Terminal, a ...interface{}) *TextPrinter
PrintOnError prints every error which is not nil. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (CenterPrinter) PrintOnErrorf ΒΆ
func (p CenterPrinter) PrintOnErrorf(term Terminal, format string, a ...interface{}) *TextPrinter
PrintOnErrorf wraps every error which is not nil and prints it. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (CenterPrinter) Printf ΒΆ
func (p CenterPrinter) Printf(term Terminal, format string, a ...interface{}) *TextPrinter
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.
func (CenterPrinter) Printfln ΒΆ
func (p CenterPrinter) Printfln(term Terminal, format string, a ...interface{}) *TextPrinter
Printfln formats according to a format specifier and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (CenterPrinter) Println ΒΆ
func (p CenterPrinter) Println(term Terminal, a ...interface{}) *TextPrinter
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (CenterPrinter) Sprint ΒΆ
func (p CenterPrinter) Sprint(term Terminal, a ...interface{}) string
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.
func (CenterPrinter) Sprintf ΒΆ
func (p CenterPrinter) Sprintf(term Terminal, format string, a ...interface{}) string
Sprintf formats according to a format specifier and returns the resulting string.
func (CenterPrinter) Sprintfln ΒΆ
func (p CenterPrinter) Sprintfln(term Terminal, format string, a ...interface{}) string
Sprintfln formats according to a format specifier and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (CenterPrinter) Sprintln ΒΆ
func (p CenterPrinter) Sprintln(term Terminal, a ...interface{}) string
Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (CenterPrinter) WithCenterEachLineSeparately ΒΆ
func (p CenterPrinter) WithCenterEachLineSeparately(b ...bool) *CenterPrinter
WithCenterEachLineSeparately centers each line separately.
type Color ΒΆ
type Color uint8
Color is a number which will be used to color strings in the terminal.
const ( FgBlack Color = iota + 30 FgRed FgGreen FgYellow FgBlue FgMagenta FgCyan FgWhite // FgDefault revert default FG. FgDefault Color = 39 )
Foreground colors. basic foreground colors 30 - 37.
const ( FgDarkGray Color = iota + 90 FgLightRed FgLightGreen FgLightYellow FgLightBlue FgLightMagenta FgLightCyan FgLightWhite // FgGray is an alias of FgDarkGray. FgGray Color = 90 )
Extra foreground color 90 - 97.
const ( BgBlack Color = iota + 40 BgRed BgGreen BgYellow // BgBrown like yellow BgBlue BgMagenta BgCyan BgWhite // BgDefault reverts to the default background. BgDefault Color = 49 )
Background colors. basic background colors 40 - 47.
const ( BgDarkGray Color = iota + 100 BgLightRed BgLightGreen BgLightYellow BgLightBlue BgLightMagenta BgLightCyan BgLightWhite // BgGray is an alias of BgDarkGray. BgGray Color = 100 )
Extra background color 100 - 107.
const ( Reset Color = iota Bold Fuzzy Italic Underscore Blink FastBlink Reverse Concealed Strikethrough )
Option settings.
func (Color) Print ΒΆ
func (c Color) Print(term Terminal, a ...interface{}) *TextPrinter
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered. Input will be colored with the parent Color.
func (Color) PrintOnError ΒΆ
func (c Color) PrintOnError(term Terminal, a ...interface{}) *TextPrinter
PrintOnError prints every error which is not nil. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (Color) PrintOnErrorf ΒΆ
func (c Color) PrintOnErrorf(term Terminal, format string, a ...interface{}) *TextPrinter
PrintOnErrorf wraps every error which is not nil and prints it. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (Color) Printf ΒΆ
func (c Color) Printf(term Terminal, format string, a ...interface{}) *TextPrinter
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered. Input will be colored with the parent Color.
func (Color) Printfln ΒΆ
func (c Color) Printfln(term Terminal, format string, a ...interface{}) *TextPrinter
Printfln formats according to a format specifier and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered. Input will be colored with the parent Color.
func (Color) Println ΒΆ
func (c Color) Println(term Terminal, a ...interface{}) *TextPrinter
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered. Input will be colored with the parent Color.
func (Color) Sprint ΒΆ
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string. Input will be colored with the parent Color.
func (Color) Sprintf ΒΆ
Sprintf formats according to a format specifier and returns the resulting string. Input will be colored with the parent Color.
func (Color) Sprintfln ΒΆ
Sprintfln formats according to a format specifier and returns the resulting string. Spaces are always added between operands and a newline is appended. Input will be colored with the parent Color.
type Cursor ΒΆ added in v0.12.47
type Cursor struct { Term Terminal // contains filtered or unexported fields }
func (*Cursor) Bottom ΒΆ added in v0.12.47
func (c *Cursor) Bottom()
Bottom moves the cursor to the bottom of the terminal. This is done by calculating how many lines were moved by Up and Down.
func (*Cursor) ClearLine ΒΆ added in v0.12.47
func (c *Cursor) ClearLine()
ClearLine clears the current line and moves the cursor to it's start position.
func (*Cursor) ClearLinesDown ΒΆ added in v0.12.47
ClearLinesDown clears n lines downwards from the current position and moves the cursor.
func (*Cursor) ClearLinesUp ΒΆ added in v0.12.47
ClearLinesUp clears n lines upwards from the current position and moves the cursor.
func (*Cursor) Down ΒΆ added in v0.12.47
Down moves the cursor n lines down relative to the current position.
func (*Cursor) DownAndClear ΒΆ added in v0.12.47
DownAndClear moves the cursor down by n lines, then clears the line.
func (*Cursor) Hide ΒΆ added in v0.12.47
func (c *Cursor) Hide()
Hide the cursor. Don't forget to show the cursor at least at the end of your application with Show. Otherwise the user might have a terminal with a permanently hidden cursor, until they reopen the terminal.
func (*Cursor) HorizontalAbsolute ΒΆ added in v0.12.47
HorizontalAbsolute moves the cursor to n horizontally. The position n is absolute to the start of the line.
func (*Cursor) Left ΒΆ added in v0.12.47
Left moves the cursor n characters to the left relative to the current position.
func (*Cursor) Right ΒΆ added in v0.12.47
Right moves the cursor n characters to the right relative to the current position.
func (*Cursor) Show ΒΆ added in v0.12.47
func (c *Cursor) Show()
Show the cursor if it was hidden previously. Don't forget to show the cursor at least at the end of your application. Otherwise the user might have a terminal with a permanently hidden cursor, until they reopen the terminal.
func (*Cursor) StartOfLine ΒΆ added in v0.12.47
func (c *Cursor) StartOfLine()
StartOfLine moves the cursor to the start of the current line.
func (*Cursor) StartOfLineDown ΒΆ added in v0.12.47
StartOfLineDown moves the cursor down by n lines, then moves to cursor to the start of the line.
func (*Cursor) StartOfLineUp ΒΆ added in v0.12.47
StartOfLineUp moves the cursor up by n lines, then moves to cursor to the start of the line.
func (*Cursor) Up ΒΆ added in v0.12.47
Up moves the cursor n lines up relative to the current position.
func (*Cursor) UpAndClear ΒΆ added in v0.12.47
UpAndClear moves the cursor up by n lines, then clears the line.
type HeaderPrinter ΒΆ
HeaderPrinter contains the data used to craft a header. A header is printed as a big box with text in it. Can be used as title screens or section separator.
func (*HeaderPrinter) Print ΒΆ
func (p *HeaderPrinter) Print(term Terminal, a ...interface{}) *TextPrinter
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func (*HeaderPrinter) PrintOnError ΒΆ
func (p *HeaderPrinter) PrintOnError(term Terminal, a ...interface{}) *TextPrinter
PrintOnError prints every error which is not nil. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (*HeaderPrinter) PrintOnErrorf ΒΆ
func (p *HeaderPrinter) PrintOnErrorf(term Terminal, format string, a ...interface{}) *TextPrinter
PrintOnErrorf wraps every error which is not nil and prints it. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (*HeaderPrinter) Printf ΒΆ
func (p *HeaderPrinter) Printf(term Terminal, format string, a ...interface{}) *TextPrinter
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.
func (*HeaderPrinter) Printfln ΒΆ
func (p *HeaderPrinter) Printfln(term Terminal, format string, a ...interface{}) *TextPrinter
Printfln formats according to a format specifier and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (*HeaderPrinter) Println ΒΆ
func (p *HeaderPrinter) Println(term Terminal, a ...interface{}) *TextPrinter
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (HeaderPrinter) Sprint ΒΆ
func (p HeaderPrinter) Sprint(term Terminal, a ...interface{}) string
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.
func (HeaderPrinter) Sprintf ΒΆ
func (p HeaderPrinter) Sprintf(term Terminal, format string, a ...interface{}) string
Sprintf formats according to a format specifier and returns the resulting string.
func (HeaderPrinter) Sprintfln ΒΆ
func (p HeaderPrinter) Sprintfln(term Terminal, format string, a ...interface{}) string
Sprintfln formats according to a format specifier and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (HeaderPrinter) Sprintln ΒΆ
func (p HeaderPrinter) Sprintln(term Terminal, a ...interface{}) string
Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (HeaderPrinter) WithBackgroundStyle ΒΆ
func (p HeaderPrinter) WithBackgroundStyle(style *Style) *HeaderPrinter
WithBackgroundStyle changes the background styling of the header.
func (HeaderPrinter) WithFullWidth ΒΆ
func (p HeaderPrinter) WithFullWidth(b ...bool) *HeaderPrinter
WithFullWidth enables full width on a HeaderPrinter.
func (HeaderPrinter) WithMargin ΒΆ
func (p HeaderPrinter) WithMargin(margin int) *HeaderPrinter
WithMargin changes the background styling of the header.
func (HeaderPrinter) WithTextStyle ΒΆ
func (p HeaderPrinter) WithTextStyle(style *Style) *HeaderPrinter
WithTextStyle returns a new HeaderPrinter with changed
type InteractiveConfirmPrinter ΒΆ
type InteractiveConfirmPrinter struct { Term Terminal DefaultValue bool DefaultText string TextStyle *Style ConfirmText string ConfirmStyle *Style RejectText string RejectStyle *Style SuffixStyle *Style Cursor Cursor }
InteractiveConfirmPrinter is a printer for interactive confirm prompts.
func (InteractiveConfirmPrinter) Show ΒΆ
func (p InteractiveConfirmPrinter) Show(text ...string) (bool, error)
Show shows the confirm prompt.
Example:
result, _ := pterm.DefaultInteractiveConfirm.Show("Are you sure?") pterm.Println(result)
func (InteractiveConfirmPrinter) WithConfirmStyle ΒΆ
func (p InteractiveConfirmPrinter) WithConfirmStyle(style *Style) *InteractiveConfirmPrinter
WithConfirmStyle sets the confirm style.
func (InteractiveConfirmPrinter) WithConfirmText ΒΆ
func (p InteractiveConfirmPrinter) WithConfirmText(text string) *InteractiveConfirmPrinter
WithConfirmText sets the confirm text.
func (InteractiveConfirmPrinter) WithDefaultText ΒΆ
func (p InteractiveConfirmPrinter) WithDefaultText(text string) *InteractiveConfirmPrinter
WithDefaultText sets the default text.
func (InteractiveConfirmPrinter) WithDefaultValue ΒΆ
func (p InteractiveConfirmPrinter) WithDefaultValue(value bool) *InteractiveConfirmPrinter
WithDefaultValue sets the default value, which will be returned when the user presses enter without typing "y" or "n".
func (InteractiveConfirmPrinter) WithRejectStyle ΒΆ
func (p InteractiveConfirmPrinter) WithRejectStyle(style *Style) *InteractiveConfirmPrinter
WithRejectStyle sets the reject style.
func (InteractiveConfirmPrinter) WithRejectText ΒΆ
func (p InteractiveConfirmPrinter) WithRejectText(text string) *InteractiveConfirmPrinter
WithRejectText sets the reject text.
func (InteractiveConfirmPrinter) WithSuffixStyle ΒΆ
func (p InteractiveConfirmPrinter) WithSuffixStyle(style *Style) *InteractiveConfirmPrinter
WithSuffixStyle sets the suffix style.
func (InteractiveConfirmPrinter) WithTerminal ΒΆ added in v0.12.47
func (p InteractiveConfirmPrinter) WithTerminal(term Terminal) *InteractiveConfirmPrinter
func (InteractiveConfirmPrinter) WithTextStyle ΒΆ
func (p InteractiveConfirmPrinter) WithTextStyle(style *Style) *InteractiveConfirmPrinter
WithTextStyle sets the text style.
type InteractiveMultiselectPrinter ΒΆ
type InteractiveMultiselectPrinter struct { Term Terminal DefaultText string TextStyle *Style Options []string OptionStyle *Style DefaultOptions []string MaxHeight int Selector string SelectorStyle *Style RemoveWhenDone bool Cursor Cursor // contains filtered or unexported fields }
InteractiveMultiselectPrinter is a printer for interactive multiselect menus.
func (*InteractiveMultiselectPrinter) Show ΒΆ
func (p *InteractiveMultiselectPrinter) Show(text ...string) ([]string, error)
Show shows the interactive multiselect menu and returns the selected entry.
func (InteractiveMultiselectPrinter) WithDefaultOptions ΒΆ
func (p InteractiveMultiselectPrinter) WithDefaultOptions(options []string) *InteractiveMultiselectPrinter
WithDefaultOptions sets the default options.
func (InteractiveMultiselectPrinter) WithDefaultText ΒΆ
func (p InteractiveMultiselectPrinter) WithDefaultText(text string) *InteractiveMultiselectPrinter
WithDefaultText sets the default text.
func (InteractiveMultiselectPrinter) WithMaxHeight ΒΆ
func (p InteractiveMultiselectPrinter) WithMaxHeight(maxHeight int) *InteractiveMultiselectPrinter
WithMaxHeight sets the maximum height of the select menu.
func (InteractiveMultiselectPrinter) WithOptions ΒΆ
func (p InteractiveMultiselectPrinter) WithOptions(options []string) *InteractiveMultiselectPrinter
WithOptions sets the options.
func (InteractiveMultiselectPrinter) WithTerminal ΒΆ added in v0.12.47
func (p InteractiveMultiselectPrinter) WithTerminal(term Terminal) *InteractiveMultiselectPrinter
type InteractiveSelectPrinter ΒΆ
type InteractiveSelectPrinter struct { Term Terminal TextStyle *Style DefaultText string Options []string OptionStyle *Style DefaultOption string MaxHeight int Selector string SelectorStyle *Style EnableFuzzySearch bool RemoveWhenDone bool Cursor Cursor // contains filtered or unexported fields }
InteractiveSelectPrinter is a printer for interactive select menus.
func (*InteractiveSelectPrinter) Show ΒΆ
func (p *InteractiveSelectPrinter) Show(text ...string) (string, error)
Show shows the interactive select menu and returns the selected entry.
func (InteractiveSelectPrinter) WithDefaultOption ΒΆ
func (p InteractiveSelectPrinter) WithDefaultOption(option string) *InteractiveSelectPrinter
WithDefaultOption sets the default options.
func (InteractiveSelectPrinter) WithDefaultText ΒΆ
func (p InteractiveSelectPrinter) WithDefaultText(text string) *InteractiveSelectPrinter
WithDefaultText sets the default text.
func (InteractiveSelectPrinter) WithMaxHeight ΒΆ
func (p InteractiveSelectPrinter) WithMaxHeight(maxHeight int) *InteractiveSelectPrinter
WithMaxHeight sets the maximum height of the select menu.
func (InteractiveSelectPrinter) WithOptions ΒΆ
func (p InteractiveSelectPrinter) WithOptions(options []string) *InteractiveSelectPrinter
WithOptions sets the options.
func (InteractiveSelectPrinter) WithTerminal ΒΆ added in v0.12.47
func (p InteractiveSelectPrinter) WithTerminal(term Terminal) *InteractiveSelectPrinter
type InteractiveTextInputPrinter ΒΆ
type InteractiveTextInputPrinter struct { Term Terminal TextStyle *Style DefaultText string MultiLine bool // contains filtered or unexported fields }
InteractiveTextInputPrinter is a printer for interactive select menus.
func (*InteractiveTextInputPrinter) Show ΒΆ
func (p *InteractiveTextInputPrinter) Show(text ...string) (string, error)
Show shows the interactive select menu and returns the selected entry.
func (*InteractiveTextInputPrinter) WithDefaultText ΒΆ
func (p *InteractiveTextInputPrinter) WithDefaultText(text string) *InteractiveTextInputPrinter
WithDefaultText sets the default text.
func (*InteractiveTextInputPrinter) WithMultiLine ΒΆ
func (p *InteractiveTextInputPrinter) WithMultiLine(multiLine ...bool) *InteractiveTextInputPrinter
WithMultiLine sets the multi line flag.
func (*InteractiveTextInputPrinter) WithTerminal ΒΆ added in v0.12.47
func (p *InteractiveTextInputPrinter) WithTerminal(term Terminal) *InteractiveTextInputPrinter
func (*InteractiveTextInputPrinter) WithTextStyle ΒΆ
func (p *InteractiveTextInputPrinter) WithTextStyle(style *Style) *InteractiveTextInputPrinter
WithTextStyle sets the text style.
type Letter ΒΆ
Letter is an object, which holds a string and a specific Style for it.
func (Letter) WithString ΒΆ
WithString returns a new Letter with a specific String.
type Letters ΒΆ
type Letters []Letter
Letters is a slice of Letter.
func NewLettersFromString
deprecated
func NewLettersFromStringWithRGB
deprecated
func NewLettersFromStringWithStyle
deprecated
type LeveledList ΒΆ
type LeveledList []LeveledListItem
LeveledList is a list, which contains multiple LeveledListItem.
type LeveledListItem ΒΆ
LeveledListItem combines a text with a specific level. The level is the indent, which would normally be seen in a BulletListPrinter.
type LivePrinter ΒΆ
type LivePrinter interface { // GenericStart runs Start, but returns a LivePrinter. // This is used for the interface LivePrinter. // You most likely want to use Start instead of this in your program. GenericStart() (*LivePrinter, error) // GenericStop runs Stop, but returns a LivePrinter. // This is used for the interface LivePrinter. // You most likely want to use Stop instead of this in your program. GenericStop() (*LivePrinter, error) }
LivePrinter is a printer which can update it's output live.
type Panel ΒΆ
type Panel struct {
Data string
}
Panel contains the data, which should be printed inside a PanelPrinter.
type PanelPrinter ΒΆ
type PanelPrinter struct { Panels Panels Padding int BottomPadding int SameColumnWidth bool BoxPrinter BoxPrinter }
PanelPrinter prints content in boxes.
func (PanelPrinter) Render ΒΆ
func (p PanelPrinter) Render(term Terminal) error
Render prints the Template to the terminal.
func (PanelPrinter) Srender ΒΆ
func (p PanelPrinter) Srender(term Terminal) (string, error)
Srender renders the Template as a string.
func (PanelPrinter) WithBottomPadding ΒΆ
func (p PanelPrinter) WithBottomPadding(bottomPadding int) *PanelPrinter
WithBottomPadding returns a new PanelPrinter with specific options.
func (PanelPrinter) WithBoxPrinter ΒΆ
func (p PanelPrinter) WithBoxPrinter(boxPrinter BoxPrinter) *PanelPrinter
WithBoxPrinter returns a new PanelPrinter with specific options.
func (PanelPrinter) WithPadding ΒΆ
func (p PanelPrinter) WithPadding(padding int) *PanelPrinter
WithPadding returns a new PanelPrinter with specific options.
func (PanelPrinter) WithPanels ΒΆ
func (p PanelPrinter) WithPanels(panels Panels) *PanelPrinter
WithPanels returns a new PanelPrinter with specific options.
func (PanelPrinter) WithSameColumnWidth ΒΆ
func (p PanelPrinter) WithSameColumnWidth(b ...bool) *PanelPrinter
WithSameColumnWidth returns a new PanelPrinter with specific options.
type ParagraphPrinter ΒΆ
type ParagraphPrinter struct {
LimitWidth int
}
ParagraphPrinter can print paragraphs to a fixed line width. The text will split between words, so that words will stick together. It's like in a book.
func (*ParagraphPrinter) Print ΒΆ
func (p *ParagraphPrinter) Print(term Terminal, a ...interface{}) *TextPrinter
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func (*ParagraphPrinter) PrintOnError ΒΆ
func (p *ParagraphPrinter) PrintOnError(term Terminal, a ...interface{}) *TextPrinter
PrintOnError prints every error which is not nil. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (*ParagraphPrinter) PrintOnErrorf ΒΆ
func (p *ParagraphPrinter) PrintOnErrorf(term Terminal, format string, a ...interface{}) *TextPrinter
PrintOnErrorf wraps every error which is not nil and prints it. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (*ParagraphPrinter) Printf ΒΆ
func (p *ParagraphPrinter) Printf(term Terminal, format string, a ...interface{}) *TextPrinter
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.
func (*ParagraphPrinter) Printfln ΒΆ
func (p *ParagraphPrinter) Printfln(term Terminal, format string, a ...interface{}) *TextPrinter
Printfln formats according to a format specifier and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (*ParagraphPrinter) Println ΒΆ
func (p *ParagraphPrinter) Println(term Terminal, a ...interface{}) *TextPrinter
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (ParagraphPrinter) Sprint ΒΆ
func (p ParagraphPrinter) Sprint(term Terminal, a ...interface{}) string
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.
func (ParagraphPrinter) Sprintf ΒΆ
func (p ParagraphPrinter) Sprintf(term Terminal, format string, a ...interface{}) string
Sprintf formats according to a format specifier and returns the resulting string.
func (ParagraphPrinter) Sprintfln ΒΆ
func (p ParagraphPrinter) Sprintfln(term Terminal, format string, a ...interface{}) string
Sprintfln formats according to a format specifier and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (ParagraphPrinter) Sprintln ΒΆ
func (p ParagraphPrinter) Sprintln(term Terminal, a ...interface{}) string
Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (ParagraphPrinter) WithLimitWidth ΒΆ added in v0.12.47
func (p ParagraphPrinter) WithLimitWidth(width int) *ParagraphPrinter
WithMaxWidth returns a new ParagraphPrinter with a specific MaxWidth
type Prefix ΒΆ
Prefix contains the data used as the beginning of a printed text via a PrefixPrinter.
type PrefixPrinter ΒΆ
type PrefixPrinter struct { Prefix Prefix Scope Scope MessageStyle *Style Fatal bool ShowLineNumber bool LineNumberOffset int // If Debugger is true, the printer will only print if PrintDebugMessages is set to true. // You can change PrintDebugMessages with EnableDebugMessages and DisableDebugMessages, or by setting the variable itself. Debugger bool }
PrefixPrinter is the printer used to print a Prefix.
func (PrefixPrinter) GetFormattedPrefix ΒΆ
func (p PrefixPrinter) GetFormattedPrefix() string
GetFormattedPrefix returns the Prefix as a styled text string.
func (*PrefixPrinter) Print ΒΆ
func (p *PrefixPrinter) Print(term Terminal, a ...interface{}) *TextPrinter
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func (*PrefixPrinter) PrintOnError ΒΆ
func (p *PrefixPrinter) PrintOnError(term Terminal, a ...interface{}) *TextPrinter
PrintOnError prints every error which is not nil. If every error is nil, nothing will be printed. This can be used for simple error checking.
Note: Use WithFatal(true) or Fatal to panic after first non nil error.
func (*PrefixPrinter) PrintOnErrorf ΒΆ
func (p *PrefixPrinter) PrintOnErrorf(term Terminal, format string, a ...interface{}) *TextPrinter
PrintOnErrorf wraps every error which is not nil and prints it. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (*PrefixPrinter) Printf ΒΆ
func (p *PrefixPrinter) Printf(term Terminal, format string, a ...interface{}) *TextPrinter
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.
func (*PrefixPrinter) Printfln ΒΆ
func (p *PrefixPrinter) Printfln(term Terminal, format string, a ...interface{}) *TextPrinter
Printfln formats according to a format specifier and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (*PrefixPrinter) Println ΒΆ
func (p *PrefixPrinter) Println(term Terminal, a ...interface{}) *TextPrinter
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (*PrefixPrinter) Sprint ΒΆ
func (p *PrefixPrinter) Sprint(term Terminal, a ...interface{}) string
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.
func (PrefixPrinter) Sprintf ΒΆ
func (p PrefixPrinter) Sprintf(term Terminal, format string, a ...interface{}) string
Sprintf formats according to a format specifier and returns the resulting string.
func (PrefixPrinter) Sprintfln ΒΆ
func (p PrefixPrinter) Sprintfln(term Terminal, format string, a ...interface{}) string
Sprintfln formats according to a format specifier and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (PrefixPrinter) Sprintln ΒΆ
func (p PrefixPrinter) Sprintln(term Terminal, a ...interface{}) string
Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (PrefixPrinter) WithDebugger ΒΆ
func (p PrefixPrinter) WithDebugger(b ...bool) *PrefixPrinter
WithDebugger returns a new Printer with specific Debugger value. If Debugger is true, the printer will only print if PrintDebugMessages is set to true. You can change PrintDebugMessages with EnableDebugMessages and DisableDebugMessages, or by setting the variable itself.
func (PrefixPrinter) WithFatal ΒΆ
func (p PrefixPrinter) WithFatal(b ...bool) *PrefixPrinter
WithFatal sets if the printer should panic after printing. NOTE: The printer will only panic if either PrefixPrinter.Println, PrefixPrinter.Print or PrefixPrinter.Printf is called.
func (PrefixPrinter) WithLineNumberOffset ΒΆ
func (p PrefixPrinter) WithLineNumberOffset(offset int) *PrefixPrinter
WithLineNumberOffset can be used to exclude a specific amount of calls in the call stack. If you make a wrapper function for example, you can set this to one. The printed line number will then be the line number where your wrapper function is called.
func (PrefixPrinter) WithMessageStyle ΒΆ
func (p PrefixPrinter) WithMessageStyle(style *Style) *PrefixPrinter
WithMessageStyle adds a custom prefix to the printer.
func (PrefixPrinter) WithPrefix ΒΆ
func (p PrefixPrinter) WithPrefix(prefix Prefix) *PrefixPrinter
WithPrefix adds a custom prefix to the printer.
func (PrefixPrinter) WithScope ΒΆ
func (p PrefixPrinter) WithScope(scope Scope) *PrefixPrinter
WithScope adds a scope to the Prefix.
func (PrefixPrinter) WithShowLineNumber ΒΆ
func (p PrefixPrinter) WithShowLineNumber(b ...bool) *PrefixPrinter
WithShowLineNumber sets if the printer should print the line number from where it's called in a go file.
type ProgressbarPrinter ΒΆ
type ProgressbarPrinter struct { Term Terminal Title string Total int Current int BarCharacter string LastCharacter string ElapsedTimeRoundingFactor time.Duration BarFiller string MaxWidth int ShowElapsedTime bool ShowCount bool ShowTitle bool ShowPercentage bool RemoveWhenDone bool TitleStyle *Style BarStyle *Style IsActive bool // contains filtered or unexported fields }
ProgressbarPrinter shows a progress animation in the terminal.
func (*ProgressbarPrinter) Add ΒΆ
func (p *ProgressbarPrinter) Add(count int) *ProgressbarPrinter
Add to current value.
func (ProgressbarPrinter) GenericStart ΒΆ
func (p ProgressbarPrinter) GenericStart() (*LivePrinter, error)
GenericStart runs Start, but returns a LivePrinter. This is used for the interface LivePrinter. You most likely want to use Start instead of this in your program.
func (ProgressbarPrinter) GenericStop ΒΆ
func (p ProgressbarPrinter) GenericStop() (*LivePrinter, error)
GenericStop runs Stop, but returns a LivePrinter. This is used for the interface LivePrinter. You most likely want to use Stop instead of this in your program.
func (*ProgressbarPrinter) GetElapsedTime ΒΆ
func (p *ProgressbarPrinter) GetElapsedTime() time.Duration
GetElapsedTime returns the elapsed time, since the ProgressbarPrinter was started.
func (*ProgressbarPrinter) Increment ΒΆ
func (p *ProgressbarPrinter) Increment() *ProgressbarPrinter
Increment current value by one.
func (ProgressbarPrinter) Start ΒΆ
func (p ProgressbarPrinter) Start() (*ProgressbarPrinter, error)
Start the ProgressbarPrinter.
func (*ProgressbarPrinter) Stop ΒΆ
func (p *ProgressbarPrinter) Stop() (*ProgressbarPrinter, error)
Stop the ProgressbarPrinter.
func (*ProgressbarPrinter) UpdateTitle ΒΆ
func (p *ProgressbarPrinter) UpdateTitle(title string) *ProgressbarPrinter
This method changed the title and re-renders the progressbar
func (ProgressbarPrinter) WithBarCharacter ΒΆ
func (p ProgressbarPrinter) WithBarCharacter(char string) *ProgressbarPrinter
WithBarCharacter sets the bar character of the ProgressbarPrinter.
func (ProgressbarPrinter) WithBarFiller ΒΆ
func (p ProgressbarPrinter) WithBarFiller(char string) *ProgressbarPrinter
WithBarFiller sets the filler character for the ProgressbarPrinter.
func (ProgressbarPrinter) WithBarStyle ΒΆ
func (p ProgressbarPrinter) WithBarStyle(style *Style) *ProgressbarPrinter
WithBarStyle sets the style of the bar.
func (ProgressbarPrinter) WithCurrent ΒΆ
func (p ProgressbarPrinter) WithCurrent(current int) *ProgressbarPrinter
WithCurrent sets the current value of the ProgressbarPrinter.
func (ProgressbarPrinter) WithElapsedTimeRoundingFactor ΒΆ
func (p ProgressbarPrinter) WithElapsedTimeRoundingFactor(duration time.Duration) *ProgressbarPrinter
WithElapsedTimeRoundingFactor sets the rounding factor of the elapsed time.
func (ProgressbarPrinter) WithLastCharacter ΒΆ
func (p ProgressbarPrinter) WithLastCharacter(char string) *ProgressbarPrinter
WithLastCharacter sets the last character of the ProgressbarPrinter.
func (ProgressbarPrinter) WithMaxWidth ΒΆ
func (p ProgressbarPrinter) WithMaxWidth(maxWidth int) *ProgressbarPrinter
WithMaxWidth sets the maximum width of the ProgressbarPrinter. If the terminal is smaller than the given width, the terminal width will be used instead. If the width is set to zero, or below, the terminal width will be used.
func (ProgressbarPrinter) WithRemoveWhenDone ΒΆ
func (p ProgressbarPrinter) WithRemoveWhenDone(b ...bool) *ProgressbarPrinter
WithRemoveWhenDone sets if the ProgressbarPrinter should be removed when it is done.
func (ProgressbarPrinter) WithShowCount ΒΆ
func (p ProgressbarPrinter) WithShowCount(b ...bool) *ProgressbarPrinter
WithShowCount sets if the total and current count should be displayed in the ProgressbarPrinter.
func (ProgressbarPrinter) WithShowElapsedTime ΒΆ
func (p ProgressbarPrinter) WithShowElapsedTime(b ...bool) *ProgressbarPrinter
WithShowElapsedTime sets if the elapsed time should be displayed in the ProgressbarPrinter.
func (ProgressbarPrinter) WithShowPercentage ΒΆ
func (p ProgressbarPrinter) WithShowPercentage(b ...bool) *ProgressbarPrinter
WithShowPercentage sets if the completed percentage should be displayed in the ProgressbarPrinter.
func (ProgressbarPrinter) WithShowTitle ΒΆ
func (p ProgressbarPrinter) WithShowTitle(b ...bool) *ProgressbarPrinter
WithShowTitle sets if the title should be displayed in the ProgressbarPrinter.
func (ProgressbarPrinter) WithTerminal ΒΆ added in v0.12.47
func (p ProgressbarPrinter) WithTerminal(term Terminal) *ProgressbarPrinter
func (ProgressbarPrinter) WithTitle ΒΆ
func (p ProgressbarPrinter) WithTitle(name string) *ProgressbarPrinter
WithTitle sets the name of the ProgressbarPrinter.
func (ProgressbarPrinter) WithTitleStyle ΒΆ
func (p ProgressbarPrinter) WithTitleStyle(style *Style) *ProgressbarPrinter
WithTitleStyle sets the style of the title.
func (ProgressbarPrinter) WithTotal ΒΆ
func (p ProgressbarPrinter) WithTotal(total int) *ProgressbarPrinter
WithTotal sets the total value of the ProgressbarPrinter.
type RGB ΒΆ
RGB color model is an additive color model in which red, green, and blue light are added together in various ways to reproduce a broad array of colors. The name of the model comes from the initials of the three additive primary colors, red, green, and blue. https://en.wikipedia.org/wiki/RGB_color_model
func NewRGBFromHEX
deprecated
func (RGB) Fade ΒΆ
Fade fades one RGB value (over other RGB values) to another RGB value, by giving the function a minimum, maximum and current value.
func (RGB) Print ΒΆ
func (p RGB) Print(term Terminal, a ...interface{}) *TextPrinter
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func (RGB) PrintOnError ΒΆ
func (p RGB) PrintOnError(term Terminal, a ...interface{}) *TextPrinter
PrintOnError prints every error which is not nil. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (RGB) PrintOnErrorf ΒΆ
func (p RGB) PrintOnErrorf(term Terminal, format string, a ...interface{}) *TextPrinter
PrintOnErrorf wraps every error which is not nil and prints it. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (RGB) Printf ΒΆ
func (p RGB) Printf(term Terminal, format string, a ...interface{}) *TextPrinter
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.
func (RGB) Printfln ΒΆ
func (p RGB) Printfln(term Terminal, format string, a ...interface{}) *TextPrinter
Printfln formats according to a format specifier and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (RGB) Println ΒΆ
func (p RGB) Println(term Terminal, a ...interface{}) *TextPrinter
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (RGB) Sprint ΒΆ
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.
func (RGB) Sprintf ΒΆ
Sprintf formats according to a format specifier and returns the resulting string.
type RenderPrinter ΒΆ
type RenderPrinter interface { // Render the XXX to the terminal. Render(term Terminal) error // Srender returns the rendered string of XXX. Srender(term Terminal) (string, error) }
RenderPrinter is used to display renderable content. Example for renderable content is a Table.
type Scope ΒΆ
Scope contains the data of the optional scope of a prefix. If it has a text, it will be printed after the Prefix in brackets.
type SectionPrinter ΒΆ
type SectionPrinter struct { Style *Style Level int IndentCharacter string TopPadding int BottomPadding int }
SectionPrinter prints a new section title. It can be used to structure longer text, or different chapters of your program.
func (*SectionPrinter) Print ΒΆ
func (p *SectionPrinter) Print(term Terminal, a ...interface{}) *TextPrinter
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func (*SectionPrinter) PrintOnError ΒΆ
func (p *SectionPrinter) PrintOnError(term Terminal, a ...interface{}) *TextPrinter
PrintOnError prints every error which is not nil. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (*SectionPrinter) PrintOnErrorf ΒΆ
func (p *SectionPrinter) PrintOnErrorf(term Terminal, format string, a ...interface{}) *TextPrinter
PrintOnErrorf wraps every error which is not nil and prints it. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (*SectionPrinter) Printf ΒΆ
func (p *SectionPrinter) Printf(term Terminal, format string, a ...interface{}) *TextPrinter
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.
func (*SectionPrinter) Printfln ΒΆ
func (p *SectionPrinter) Printfln(term Terminal, format string, a ...interface{}) *TextPrinter
Printfln formats according to a format specifier and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (*SectionPrinter) Println ΒΆ
func (p *SectionPrinter) Println(term Terminal, a ...interface{}) *TextPrinter
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (SectionPrinter) Sprint ΒΆ
func (p SectionPrinter) Sprint(term Terminal, a ...interface{}) string
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.
func (SectionPrinter) Sprintf ΒΆ
func (p SectionPrinter) Sprintf(term Terminal, format string, a ...interface{}) string
Sprintf formats according to a format specifier and returns the resulting string.
func (SectionPrinter) Sprintfln ΒΆ
func (p SectionPrinter) Sprintfln(term Terminal, format string, a ...interface{}) string
Sprintfln formats according to a format specifier and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (SectionPrinter) Sprintln ΒΆ
func (p SectionPrinter) Sprintln(term Terminal, a ...interface{}) string
Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (SectionPrinter) WithBottomPadding ΒΆ
func (p SectionPrinter) WithBottomPadding(padding int) *SectionPrinter
WithBottomPadding returns a new SectionPrinter with a specific top padding.
func (SectionPrinter) WithIndentCharacter ΒΆ
func (p SectionPrinter) WithIndentCharacter(char string) *SectionPrinter
WithIndentCharacter returns a new SectionPrinter with a specific IndentCharacter.
func (SectionPrinter) WithLevel ΒΆ
func (p SectionPrinter) WithLevel(level int) *SectionPrinter
WithLevel returns a new SectionPrinter with a specific level.
func (SectionPrinter) WithStyle ΒΆ
func (p SectionPrinter) WithStyle(style *Style) *SectionPrinter
WithStyle returns a new SectionPrinter with a specific style.
func (SectionPrinter) WithTopPadding ΒΆ
func (p SectionPrinter) WithTopPadding(padding int) *SectionPrinter
WithTopPadding returns a new SectionPrinter with a specific top padding.
type SpinnerPrinter ΒΆ
type SpinnerPrinter struct { Term Terminal Text string Sequence []string Style *Style Delay time.Duration MessageStyle *Style SuccessPrinter TextPrinter FailPrinter TextPrinter WarningPrinter TextPrinter RemoveWhenDone bool ShowTimer bool TimerRoundingFactor time.Duration TimerStyle *Style IsActive bool // contains filtered or unexported fields }
SpinnerPrinter is a loading animation, which can be used if the progress is unknown. It's an animation loop, which can have a text and supports throwing errors or warnings. A TextPrinter is used to display all outputs, after the SpinnerPrinter is done.
func (*SpinnerPrinter) Fail ΒΆ
func (s *SpinnerPrinter) Fail(message ...interface{})
Fail displays the fail printer. If no message is given, the text of the SpinnerPrinter will be reused as the default message.
func (*SpinnerPrinter) GenericStart ΒΆ
func (s *SpinnerPrinter) GenericStart() (*LivePrinter, error)
GenericStart runs Start, but returns a LivePrinter. This is used for the interface LivePrinter. You most likely want to use Start instead of this in your program.
func (*SpinnerPrinter) GenericStop ΒΆ
func (s *SpinnerPrinter) GenericStop() (*LivePrinter, error)
GenericStop runs Stop, but returns a LivePrinter. This is used for the interface LivePrinter. You most likely want to use Stop instead of this in your program.
func (SpinnerPrinter) Start ΒΆ
func (s SpinnerPrinter) Start(text ...interface{}) (*SpinnerPrinter, error)
Start the SpinnerPrinter.
func (*SpinnerPrinter) Stop ΒΆ
func (s *SpinnerPrinter) Stop() error
Stop terminates the SpinnerPrinter immediately. The SpinnerPrinter will not resolve into anything.
func (*SpinnerPrinter) Success ΒΆ
func (s *SpinnerPrinter) Success(message ...interface{})
Success displays the success printer. If no message is given, the text of the SpinnerPrinter will be reused as the default message.
func (*SpinnerPrinter) UpdateText ΒΆ
func (s *SpinnerPrinter) UpdateText(text string)
UpdateText updates the message of the active SpinnerPrinter. Can be used live.
func (*SpinnerPrinter) Warning ΒΆ
func (s *SpinnerPrinter) Warning(message ...interface{})
Warning displays the warning printer. If no message is given, the text of the SpinnerPrinter will be reused as the default message.
func (SpinnerPrinter) WithDelay ΒΆ
func (s SpinnerPrinter) WithDelay(delay time.Duration) *SpinnerPrinter
WithDelay adds a delay to the SpinnerPrinter.
func (SpinnerPrinter) WithMessageStyle ΒΆ
func (s SpinnerPrinter) WithMessageStyle(style *Style) *SpinnerPrinter
WithMessageStyle adds a style to the SpinnerPrinter message.
func (SpinnerPrinter) WithRemoveWhenDone ΒΆ
func (s SpinnerPrinter) WithRemoveWhenDone(b ...bool) *SpinnerPrinter
WithRemoveWhenDone removes the SpinnerPrinter after it is done.
func (SpinnerPrinter) WithSequence ΒΆ
func (s SpinnerPrinter) WithSequence(sequence ...string) *SpinnerPrinter
WithSequence adds a sequence to the SpinnerPrinter.
func (SpinnerPrinter) WithShowTimer ΒΆ
func (s SpinnerPrinter) WithShowTimer(b ...bool) *SpinnerPrinter
WithShowTimer shows how long the spinner is running.
func (SpinnerPrinter) WithStyle ΒΆ
func (s SpinnerPrinter) WithStyle(style *Style) *SpinnerPrinter
WithStyle adds a style to the SpinnerPrinter.
func (SpinnerPrinter) WithTerminal ΒΆ added in v0.12.47
func (p SpinnerPrinter) WithTerminal(term Terminal) *SpinnerPrinter
func (SpinnerPrinter) WithText ΒΆ
func (s SpinnerPrinter) WithText(text string) *SpinnerPrinter
WithText adds a text to the SpinnerPrinter.
func (SpinnerPrinter) WithTimerRoundingFactor ΒΆ
func (s SpinnerPrinter) WithTimerRoundingFactor(factor time.Duration) *SpinnerPrinter
WithTimerRoundingFactor sets the rounding factor for the timer.
func (SpinnerPrinter) WithTimerStyle ΒΆ
func (s SpinnerPrinter) WithTimerStyle(style *Style) *SpinnerPrinter
WithTimerStyle adds a style to the SpinnerPrinter timer.
type StrictTerminal ΒΆ added in v0.12.47
type StrictTerminal struct { Width int Height int LineEnding string Writer io.Writer Input func(onKeyPress func(key keys.Key) (stop bool, err error)) error }
func (*StrictTerminal) GetLineEnding ΒΆ added in v0.12.47
func (t *StrictTerminal) GetLineEnding() string
func (*StrictTerminal) GetTerminalHeight ΒΆ added in v0.12.47
func (t *StrictTerminal) GetTerminalHeight() int
func (*StrictTerminal) GetTerminalSize ΒΆ added in v0.12.47
func (t *StrictTerminal) GetTerminalSize() (width, height int, err error)
func (*StrictTerminal) GetTerminalWidth ΒΆ added in v0.12.47
func (t *StrictTerminal) GetTerminalWidth() int
func (*StrictTerminal) GetWriter ΒΆ added in v0.12.47
func (t *StrictTerminal) GetWriter() io.Writer
func (*StrictTerminal) WithWriter ΒΆ added in v0.12.47
func (t *StrictTerminal) WithWriter(writer io.Writer) *StrictTerminal
type Style ΒΆ
type Style []Color
Style is a collection of colors. Can include foreground, background and styling (eg. Bold, Underscore, etc.) colors.
func (Style) Print ΒΆ
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered. Input will be colored with the parent Style.
func (Style) Printf ΒΆ
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered. Input will be colored with the parent Style.
func (Style) Printfln ΒΆ
Printfln formats according to a format specifier and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered. Input will be colored with the parent Style.
func (Style) Println ΒΆ
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered. Input will be colored with the parent Style.
func (Style) Sprint ΒΆ
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string. Input will be colored with the parent Style.
func (Style) Sprintf ΒΆ
Sprintf formats according to a format specifier and returns the resulting string. Input will be colored with the parent Style.
func (Style) Sprintfln ΒΆ
Sprintfln formats according to a format specifier and returns the resulting string. Spaces are always added between operands and a newline is appended. Input will be colored with the parent Style.
type TTYTerminal ΒΆ added in v0.12.47
type TTYTerminal struct { ForcedTerminalWidth int ForcedTerminalHeight int Writer io.Writer Input func(onKeyPress func(key keys.Key) (stop bool, err error)) error }
func (*TTYTerminal) GetLineEnding ΒΆ added in v0.12.47
func (t *TTYTerminal) GetLineEnding() string
func (*TTYTerminal) GetTerminalHeight ΒΆ added in v0.12.47
func (t *TTYTerminal) GetTerminalHeight() int
GetTerminalHeight returns the terminal height of the active terminal.
func (*TTYTerminal) GetTerminalSize ΒΆ added in v0.12.47
func (t *TTYTerminal) GetTerminalSize() (width, height int, err error)
GetTerminalSize returns the width and the height of the active terminal.
func (*TTYTerminal) GetTerminalWidth ΒΆ added in v0.12.47
func (t *TTYTerminal) GetTerminalWidth() int
GetTerminalWidth returns the terminal width of the active terminal.
func (*TTYTerminal) GetWriter ΒΆ added in v0.12.47
func (t *TTYTerminal) GetWriter() io.Writer
func (*TTYTerminal) SetForcedTerminalSize ΒΆ added in v0.12.47
func (t *TTYTerminal) SetForcedTerminalSize(width int, height int)
setForcedTerminalSize turns off terminal size autodetection. Usuful for unified tests.
func (*TTYTerminal) WithWriter ΒΆ added in v0.12.47
func (t *TTYTerminal) WithWriter(writer io.Writer) *TTYTerminal
type TableData ΒΆ
type TableData [][]string
TableData is the type that contains the data of a TablePrinter.
type TablePrinter ΒΆ
type TablePrinter struct { Style *Style HasHeader bool HeaderStyle *Style HeaderRowSeparator string HeaderRowSeparatorStyle *Style Separator string SeparatorStyle *Style RowSeparator string RowSeparatorStyle *Style Data TableData Boxed bool LeftAlignment bool RightAlignment bool }
TablePrinter is able to render tables.
func (TablePrinter) Render ΒΆ
func (p TablePrinter) Render(term Terminal) error
Render prints the TablePrinter to the terminal.
func (TablePrinter) Srender ΒΆ
func (p TablePrinter) Srender(term Terminal) (string, error)
Srender renders the TablePrinter as a string.
func (TablePrinter) WithBoxed ΒΆ
func (p TablePrinter) WithBoxed(b ...bool) *TablePrinter
WithBoxed returns a new TablePrinter with a box around the table.
func (TablePrinter) WithCSVReader ΒΆ
func (p TablePrinter) WithCSVReader(reader *csv.Reader) *TablePrinter
WithCSVReader return a new TablePrinter with specified Data extracted from CSV.
func (TablePrinter) WithData ΒΆ
func (p TablePrinter) WithData(data [][]string) *TablePrinter
WithData returns a new TablePrinter with specific Data.
func (TablePrinter) WithHasHeader ΒΆ
func (p TablePrinter) WithHasHeader(b ...bool) *TablePrinter
WithHasHeader returns a new TablePrinter, where the first line is marked as a header.
func (TablePrinter) WithHeaderRowSeparator ΒΆ
func (p TablePrinter) WithHeaderRowSeparator(separator string) *TablePrinter
WithHeaderRowSeparator returns a new TablePrinter with a specific header HeaderRowSeparator.
func (TablePrinter) WithHeaderRowSeparatorStyle ΒΆ
func (p TablePrinter) WithHeaderRowSeparatorStyle(style *Style) *TablePrinter
WithHeaderRowSeparatorStyle returns a new TablePrinter with a specific header HeaderRowSeparatorStyle.
func (TablePrinter) WithHeaderStyle ΒΆ
func (p TablePrinter) WithHeaderStyle(style *Style) *TablePrinter
WithHeaderStyle returns a new TablePrinter with a specific HeaderStyle.
func (TablePrinter) WithLeftAlignment ΒΆ
func (p TablePrinter) WithLeftAlignment(b ...bool) *TablePrinter
WithLeftAlignment returns a new TablePrinter with left alignment.
func (TablePrinter) WithRightAlignment ΒΆ
func (p TablePrinter) WithRightAlignment(b ...bool) *TablePrinter
WithRightAlignment returns a new TablePrinter with right alignment.
func (TablePrinter) WithRowSeparator ΒΆ
func (p TablePrinter) WithRowSeparator(separator string) *TablePrinter
WithRowSeparator returns a new TablePrinter with a specific RowSeparator.
func (TablePrinter) WithRowSeparatorStyle ΒΆ
func (p TablePrinter) WithRowSeparatorStyle(style *Style) *TablePrinter
WithRowSeparatorStyle returns a new TablePrinter with a specific RowSeparatorStyle.
func (TablePrinter) WithSeparator ΒΆ
func (p TablePrinter) WithSeparator(separator string) *TablePrinter
WithSeparator returns a new TablePrinter with a specific separator.
func (TablePrinter) WithSeparatorStyle ΒΆ
func (p TablePrinter) WithSeparatorStyle(style *Style) *TablePrinter
WithSeparatorStyle returns a new TablePrinter with a specific SeparatorStyle.
func (TablePrinter) WithStyle ΒΆ
func (p TablePrinter) WithStyle(style *Style) *TablePrinter
WithStyle returns a new TablePrinter with a specific Style.
type TextPrinter ΒΆ
type TextPrinter interface { // Sprint formats using the default formats for its operands and returns the resulting string. // Spaces are added between operands when neither is a string. Sprint(term Terminal, a ...interface{}) string // Sprintln formats using the default formats for its operands and returns the resulting string. // Spaces are always added between operands and a newline is appended. Sprintln(term Terminal, a ...interface{}) string // Sprintf formats according to a format specifier and returns the resulting string. Sprintf(term Terminal, format string, a ...interface{}) string // Sprintfln formats according to a format specifier and returns the resulting string. // Spaces are always added between operands and a newline is appended. Sprintfln(term Terminal, format string, a ...interface{}) string // Print formats using the default formats for its operands and writes to standard output. // Spaces are added between operands when neither is a string. // It returns the number of bytes written and any write error encountered. Print(term Terminal, a ...interface{}) *TextPrinter // Println formats using the default formats for its operands and writes to standard output. // Spaces are always added between operands and a newline is appended. // It returns the number of bytes written and any write error encountered. Println(term Terminal, a ...interface{}) *TextPrinter // Printf formats according to a format specifier and writes to standard output. // It returns the number of bytes written and any write error encountered. Printf(term Terminal, format string, a ...interface{}) *TextPrinter // Printfln formats according to a format specifier and writes to standard output. // Spaces are always added between operands and a newline is appended. // It returns the number of bytes written and any write error encountered. Printfln(term Terminal, format string, a ...interface{}) *TextPrinter // PrintOnError prints every error which is not nil. // If every error is nil, nothing will be printed. // This can be used for simple error checking. PrintOnError(term Terminal, a ...interface{}) *TextPrinter // PrintOnErrorf wraps every error which is not nil and prints it. // If every error is nil, nothing will be printed. // This can be used for simple error checking. PrintOnErrorf(term Terminal, format string, a ...interface{}) *TextPrinter }
TextPrinter contains methods to print formatted text to the console or return it as a string.
type Theme ΒΆ
type Theme struct { DefaultText Style PrimaryStyle Style SecondaryStyle Style HighlightStyle Style InfoMessageStyle Style InfoPrefixStyle Style SuccessMessageStyle Style SuccessPrefixStyle Style WarningMessageStyle Style WarningPrefixStyle Style ErrorMessageStyle Style ErrorPrefixStyle Style FatalMessageStyle Style FatalPrefixStyle Style DescriptionMessageStyle Style DescriptionPrefixStyle Style ScopeStyle Style ProgressbarBarStyle Style ProgressbarTitleStyle Style HeaderTextStyle Style HeaderBackgroundStyle Style SpinnerStyle Style SpinnerTextStyle Style TimerStyle Style TableStyle Style TableHeaderStyle Style TableSeparatorStyle Style SectionStyle Style BulletListTextStyle Style BulletListBulletStyle Style TreeStyle Style TreeTextStyle Style LetterStyle Style DebugMessageStyle Style DebugPrefixStyle Style BoxStyle Style BoxTextStyle Style BarLabelStyle Style BarStyle Style }
Theme for PTerm. Theme contains every Style used in PTerm. You can create own themes for your application or use one of the existing themes.
func (Theme) WithBarLabelStyle ΒΆ
WithBarLabelStyle returns a new theme with overridden value.
func (Theme) WithBarStyle ΒΆ
WithBarStyle returns a new theme with overridden value.
func (Theme) WithBoxStyle ΒΆ
WithBoxStyle returns a new theme with overridden value.
func (Theme) WithBoxTextStyle ΒΆ
WithBoxTextStyle returns a new theme with overridden value.
func (Theme) WithBulletListBulletStyle ΒΆ
WithBulletListBulletStyle returns a new theme with overridden value.
func (Theme) WithBulletListTextStyle ΒΆ
WithBulletListTextStyle returns a new theme with overridden value.
func (Theme) WithDebugMessageStyle ΒΆ
WithDebugMessageStyle returns a new theme with overridden value.
func (Theme) WithDebugPrefixStyle ΒΆ
WithDebugPrefixStyle returns a new theme with overridden value.
func (Theme) WithDescriptionMessageStyle ΒΆ
WithDescriptionMessageStyle returns a new theme with overridden value.
func (Theme) WithDescriptionPrefixStyle ΒΆ
WithDescriptionPrefixStyle returns a new theme with overridden value.
func (Theme) WithErrorMessageStyle ΒΆ
WithErrorMessageStyle returns a new theme with overridden value.
func (Theme) WithErrorPrefixStyle ΒΆ
WithErrorPrefixStyle returns a new theme with overridden value.
func (Theme) WithFatalMessageStyle ΒΆ
WithFatalMessageStyle returns a new theme with overridden value.
func (Theme) WithFatalPrefixStyle ΒΆ
WithFatalPrefixStyle returns a new theme with overridden value.
func (Theme) WithHighlightStyle ΒΆ
WithHighlightStyle returns a new theme with overridden value.
func (Theme) WithInfoMessageStyle ΒΆ
WithInfoMessageStyle returns a new theme with overridden value.
func (Theme) WithInfoPrefixStyle ΒΆ
WithInfoPrefixStyle returns a new theme with overridden value.
func (Theme) WithLetterStyle ΒΆ
WithLetterStyle returns a new theme with overridden value.
func (Theme) WithPrimaryStyle ΒΆ
WithPrimaryStyle returns a new theme with overridden value.
func (Theme) WithSecondaryStyle ΒΆ
WithSecondaryStyle returns a new theme with overridden value.
func (Theme) WithSuccessMessageStyle ΒΆ
WithSuccessMessageStyle returns a new theme with overridden value.
func (Theme) WithSuccessPrefixStyle ΒΆ
WithSuccessPrefixStyle returns a new theme with overridden value.
func (Theme) WithTreeStyle ΒΆ
WithTreeStyle returns a new theme with overridden value.
func (Theme) WithTreeTextStyle ΒΆ
WithTreeTextStyle returns a new theme with overridden value.
func (Theme) WithWarningMessageStyle ΒΆ
WithWarningMessageStyle returns a new theme with overridden value.
func (Theme) WithWarningPrefixStyle ΒΆ
WithWarningPrefixStyle returns a new theme with overridden value.
type TreeNode ΒΆ
TreeNode is used as items in a TreePrinter.
func NewTreeFromLeveledList
deprecated
func NewTreeFromLeveledList(leveledListItems LeveledList) TreeNode
NewTreeFromLeveledList converts a TreeItems list to a TreeNode and returns it.
Deprecated: use putils.TreeFromLeveledList instead.
type TreePrinter ΒΆ
type TreePrinter struct { Root TreeNode TreeStyle *Style TextStyle *Style TopRightCornerString string TopRightDownString string HorizontalString string VerticalString string RightDownLeftString string Indent int }
TreePrinter is able to render a list.
func (TreePrinter) Render ΒΆ
func (p TreePrinter) Render(term Terminal) error
Render prints the list to the terminal.
func (TreePrinter) Srender ΒΆ
func (p TreePrinter) Srender(term Terminal) (string, error)
Srender renders the list as a string.
func (TreePrinter) WithHorizontalString ΒΆ
func (p TreePrinter) WithHorizontalString(s string) *TreePrinter
WithHorizontalString returns a new list with a specific HorizontalString.
func (TreePrinter) WithIndent ΒΆ
func (p TreePrinter) WithIndent(indent int) *TreePrinter
WithIndent returns a new list with a specific amount of spacing between the levels. Indent must be at least 1.
func (TreePrinter) WithRoot ΒΆ
func (p TreePrinter) WithRoot(root TreeNode) *TreePrinter
WithRoot returns a new list with a specific Root.
func (TreePrinter) WithTextStyle ΒΆ
func (p TreePrinter) WithTextStyle(style *Style) *TreePrinter
WithTextStyle returns a new list with a specific text style.
func (TreePrinter) WithTopRightCornerString ΒΆ
func (p TreePrinter) WithTopRightCornerString(s string) *TreePrinter
WithTopRightCornerString returns a new list with a specific TopRightCornerString.
func (TreePrinter) WithTopRightDownStringOngoing ΒΆ
func (p TreePrinter) WithTopRightDownStringOngoing(s string) *TreePrinter
WithTopRightDownStringOngoing returns a new list with a specific TopRightDownString.
func (TreePrinter) WithTreeStyle ΒΆ
func (p TreePrinter) WithTreeStyle(style *Style) *TreePrinter
WithTreeStyle returns a new list with a specific tree style.
func (TreePrinter) WithVerticalString ΒΆ
func (p TreePrinter) WithVerticalString(s string) *TreePrinter
WithVerticalString returns a new list with a specific VerticalString.
Source Files ΒΆ
- area.go
- area_printer.go
- atoms.go
- barchart.go
- basic_text_printer.go
- bigtext_printer.go
- box_printer.go
- bulletlist_printer.go
- center_printer.go
- color.go
- cursor.go
- deprecated.go
- errors.go
- header_printer.go
- interactive_confirm_printer.go
- interactive_multiselect_printer.go
- interactive_select_printer.go
- interactive_textinput_printer.go
- interface_live_printer.go
- interface_renderable_printer.go
- interface_text_printer.go
- panel_printer.go
- paragraph_printer.go
- prefix_printer.go
- print.go
- progressbar_printer.go
- pterm.go
- rgb.go
- section_printer.go
- spinner_printer.go
- table_printer.go
- terminal.go
- theme.go
- tree_printer.go
Directories ΒΆ
Path | Synopsis |
---|---|
_examples
|
|
Package putils contains utility functions for PTerm, to make it's usage even easier! It contains pre-made functions, that utilize PTerm, to print various stuff to the terminal.
|
Package putils contains utility functions for PTerm, to make it's usage even easier! It contains pre-made functions, that utilize PTerm, to print various stuff to the terminal. |