outputs

package
v0.0.0-...-0a0720d Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package outputs provides helper functions to construct bar.Outputs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(e error) *bar.Segment

Error constructs a bar output that indicates an error.

func Errorf

func Errorf(format string, args ...interface{}) *bar.Segment

Errorf constructs a bar output that indicates an error, using the given format string and arguments.

func Pango

func Pango(things ...interface{}) *bar.Segment

Pango constructs a pango bar segment from a list of pango Nodes and strings.

func Text

func Text(text string) *bar.Segment

Text constructs a simple text output from the given string.

func Textf

func Textf(format string, args ...interface{}) *bar.Segment

Textf constructs simple text output from a format string and arguments.

Types

type AtTimeDelta

type AtTimeDelta func(time.Duration) bar.Output

AtTimeDelta creates a TimedOutput from a function by repeatedly calling it at different times, using a fixed point in time as a reference point.

func (AtTimeDelta) From

func (a AtTimeDelta) From(time time.Time) bar.TimedOutput

From sets the reference point and creates a timed output that repeats the given function. The repeat rate is: - delta < 1 minute: every second - delta < 1 hour: every minute - otherwise: every hour This is useful if the output displays a single time unit (e.g. 3m, or 8h).

func (AtTimeDelta) FromFine

func (a AtTimeDelta) FromFine(time time.Time) bar.TimedOutput

FromFine is From with more rapid updates: - delta < 1 hour: every second - delta < 24 hours: every minute - otherwise: every hour This is useful if the output displays two time units (e.g. 5h3m, or 2d7h).

type Repeat

type Repeat func(time.Time) bar.Output

Repeat creates a TimedOutput from a function by repeatedly calling it at different times.

func (Repeat) At

func (r Repeat) At(times ...time.Time) bar.TimedOutput

At repeats the output at the specified fixed points in time.

func (Repeat) AtNext

func (r Repeat) AtNext(interval time.Duration) bar.TimedOutput

AtNext repeats the output at multiples of the given duration. e.g. AtNext(time.Minute) will repeat the output at 13:00:00, 13:01:00, and so on, regardless of the first output time.

func (Repeat) Every

func (r Repeat) Every(interval time.Duration) bar.TimedOutput

Every repeats the output at a fixed interval.

type SegmentGroup

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

SegmentGroup represents a group of Segments to be displayed together on the bar.

func Group

func Group(outputs ...bar.Output) *SegmentGroup

Group concatenates several outputs into a single SegmentGroup, to facilitate easier manipulation of output properties. For example, setting a colour or urgency for all segments together.

func (*SegmentGroup) Align

func (g *SegmentGroup) Align(align bar.TextAlignment) *SegmentGroup

Align sets the text alignment for all segments in the group.

func (*SegmentGroup) Append

func (g *SegmentGroup) Append(output bar.Output) *SegmentGroup

Append adds an additional output to this group.

func (*SegmentGroup) Background

func (g *SegmentGroup) Background(background color.Color) *SegmentGroup

Background sets the background color for all segments in the group.

func (*SegmentGroup) Border

func (g *SegmentGroup) Border(border color.Color) *SegmentGroup

Border sets the border color for all segments in the group.

func (*SegmentGroup) Color

func (g *SegmentGroup) Color(color color.Color) *SegmentGroup

Color sets the color for all segments in the group.

func (*SegmentGroup) Glue

func (g *SegmentGroup) Glue() *SegmentGroup

Glue is a shortcut to remove the inner separators and padding.

func (*SegmentGroup) InnerPadding

func (g *SegmentGroup) InnerPadding(separatorWidth int) *SegmentGroup

InnerPadding sets the padding between segments of this group.

func (*SegmentGroup) InnerSeparators

func (g *SegmentGroup) InnerSeparators(separator bool) *SegmentGroup

InnerSeparators sets the separator visibility between segments of this group.

func (*SegmentGroup) MinWidth

func (g *SegmentGroup) MinWidth(minWidth int) *SegmentGroup

MinWidth sets the minimum width for the output, by (mostly) equally distributing the given minWidth amongst all segments in the group.

func (*SegmentGroup) NextRefresh

func (g *SegmentGroup) NextRefresh() time.Time

NextRefresh handles the case of one or more TimedOutputs being added to the group. If any timed outputs exist, NextRefresh will return the earliest next refresh time of any of them.

func (*SegmentGroup) OnClick

func (g *SegmentGroup) OnClick(f func(bar.Event)) *SegmentGroup

OnClick sets the default click handler for the group. Any segments that don't already have a click handler will delegate to this one.

func (*SegmentGroup) Padding

func (g *SegmentGroup) Padding(separatorWidth int) *SegmentGroup

Padding sets the padding of the last segment in the group.

func (*SegmentGroup) Segments

func (g *SegmentGroup) Segments() []*bar.Segment

Segments implements bar.Output for SegmentGroup. This method is responsible for computing all attributes so that all segments, even those added after attributes were set on the group correctly reflect those attributes in the final output.

func (*SegmentGroup) Separator

func (g *SegmentGroup) Separator(separator bool) *SegmentGroup

Separator sets the separator visibility of the last segment in the group.

func (*SegmentGroup) Urgent

func (g *SegmentGroup) Urgent(urgent bool) *SegmentGroup

Urgent sets the urgency flag for all segments in the group.

Jump to

Keyboard shortcuts

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