gocular

package module
v0.1.0-pre Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: MIT Imports: 4 Imported by: 0

README

gocular

GitHub GitHub go.mod Go version GitHub release (latest by date)

A simple TUI library for Go.

Preview

Under development

gocular is no where near finished and is not ready for use.

Documentation

Index

Constants

View Source
const (
	DEFAULT_PRIMARY   = colour.FgHiCyan
	DEFAULT_SECONDARY = colour.FgHiMagenta
	DEFAULT_SUCCESS   = colour.FgHiGreen
	DEFAULT_ERROR     = colour.FgHiRed
	DEFAULT_BRACKET   = colour.FgHiBlack
)
View Source
const (
	DEFAULT_DELAY           = time.Millisecond * 500
	DEFAULT_ELEMENTS        = "/|\\-"
	DEFAULT_DOT_COUNT       = 3
	DEFAULT_BAR_LENGTH      = 20
	DEFAULT_SHOW_PERCENTAGE = true
)

Variables

This section is empty.

Functions

func ClearLine

func ClearLine()

Clears the previous line from the console.

func ProgressBar

func ProgressBar(runner func(current *int), text string, finished string, max int, bar int, showPercentage bool, delay time.Duration, colours *ColourSet)

Receives progress from the goroutine `runner` through `current`. Current is parsed as a fraction of `max` and displayed in the terminal as a progress bar. The length of the progress bar is determined by the `bar` value. The progress bar will changed to a finished state when `current` is equal to `max`. `delay` is the update frequency.

func ProgressCycle

func ProgressCycle(runner func(done *bool), text string, finished string, cycle string, delay time.Duration, colours *ColourSet)

Prints `text` with a cyclic prefix (e.g. \ -> | -> / -> -). The cycle characters are specified through the `cycle` slice. Changes to the next `cycle` string every `delay` duration. Stops when `done` is `true`.

func ProgressDots

func ProgressDots(runner func(done *bool), text string, finished string, count int, delay time.Duration, colours *ColourSet)

Displays `text` with a series of trailing dots. Adds another dot every `delay` duration. The maximum number of dots is specified by the `count` integer. Changes to finished text when `done` is equal to `true`.

Types

type ColourSet

type ColourSet struct {
	Primary   *colour.Color
	Secondary *colour.Color
	Success   *colour.Color
	Error     *colour.Color
	Bracket   *colour.Color
}

Holds primary, secondary, success, error and bracket colours.

func NewColourSet

func NewColourSet() *ColourSet

Creates and returns a default `ColourSet` object.

type Progress

type Progress struct {
	// general
	Delay time.Duration

	// cycle
	Elements string
	DotCount int

	// bar
	BarLength      int
	ShowPercentage bool

	// colourset
	Colours *ColourSet
}

Holds presets for the progress functions. This is useful if you re-use progress bars or cycles in your project.

func NewProgress

func NewProgress() *Progress

Initialises and returns a default `Progress` instance.

func (*Progress) Bar

func (pp *Progress) Bar(runner func(current *int), text string, finished string, size int)

func (*Progress) Cycle

func (pp *Progress) Cycle(runner func(done *bool), text string, finished string)

func (*Progress) Dots

func (pp *Progress) Dots(runner func(done *bool), text string, finished string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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