powerline

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2023 License: MIT Imports: 9 Imported by: 0

README

powerline

Go Reference

Demo using go run ./examples/powerline:

Demo

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// StyleDefault - default Style when none provided.
	StyleDefault = Style{
		Color: prompt.Color{
			Foreground: termenv.ForegroundColor(),
			Background: termenv.BackgroundColor(),
		},
		InvertSeparatorColors: false,
		MarginLeft:            " ",
		MarginRight:           " ",
		SeparatorLeft:         "",
		SeparatorRight:        "",
	}

	// StyleNonPatched assumes use of regular non-patched fonts.
	StyleNonPatched = Style{
		Color: prompt.Color{
			Foreground: termenv.ForegroundColor(),
			Background: termenv.BackgroundColor(),
		},
		InvertSeparatorColors: true,
		MarginLeft:            " ",
		MarginRight:           " ",
		SeparatorLeft:         "◢",
		SeparatorRight:        "◣",
	}

	// StylePatched assumes use of patched fonts with the separator characters:
	// https://github.com/powerline/fonts
	StylePatched = Style{
		Color: prompt.Color{
			Foreground: termenv.ForegroundColor(),
			Background: termenv.BackgroundColor(),
		},
		InvertSeparatorColors: false,
		MarginLeft:            " ",
		MarginRight:           " ",
		SeparatorLeft:         "\uE0B0",
		SeparatorRight:        "\uE0B2",
	}
)

Functions

This section is empty.

Types

type Powerline

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

Powerline helps construct a powerline like prompt with segmented contents.

func (*Powerline) Append

func (p *Powerline) Append(s *Segment)

Append appends the given segment to the Left side of the prompt.

func (*Powerline) AppendRight

func (p *Powerline) AppendRight(s *Segment)

AppendRight appends the given segment to the Right side of the prompt.

func (*Powerline) AutoAdjustWidth

func (p *Powerline) AutoAdjustWidth(v bool)

AutoAdjustWidth turns on automatically reducing number of segments to fit the provided width.

func (*Powerline) Render

func (p *Powerline) Render(maxWidth int) string

Render renders the Powerline prompt with all the segments.

func (*Powerline) SetStyle

func (p *Powerline) SetStyle(style Style)

type Segment

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

Segment contains the contents for a "segment" of data in the Powerline prompt.

func (*Segment) Color

func (s *Segment) Color() prompt.Color

Color returns the color that will be used for the segment.

func (*Segment) HasChanges

func (s *Segment) HasChanges() bool

HasChanges returns true if Render is going to return a different result compared to its last invocation.

func (*Segment) Render

func (s *Segment) Render() string

Render returns the segment rendered in appropriate colors.

func (*Segment) ResetColor

func (s *Segment) ResetColor()

ResetColor resets the color of the content to defaults.

func (*Segment) SetColor

func (s *Segment) SetColor(color prompt.Color)

SetColor sets the colors to be used for the segment. If not set, the hash of the content determines the colors.

func (*Segment) SetContent

func (s *Segment) SetContent(content string, tags ...string)

SetContent sets the text of the segment.

Normally, the client can set the color for the content using SetColor. However, in case the client doesn't do it, the color is determined automatically by hashing one of the following:

  • the "tags" values
  • the "content" value if no "tags" provided

func (*Segment) SetIcon

func (s *Segment) SetIcon(icon string)

SetIcon sets the optional Icon/Emoji to be rendered before the text.

func (*Segment) Width

func (s *Segment) Width() int

Width returns the width of the segment when printed on screen.

type Style

type Style struct {
	Color                 prompt.Color
	InvertSeparatorColors bool
	MarginLeft            string
	MarginRight           string
	SeparatorLeft         string
	SeparatorRight        string
}

Style is used to customize the look and feel of the Powerline.

Jump to

Keyboard shortcuts

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