core

package
v0.0.0-...-c936f35 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 7 Imported by: 6

Documentation

Overview

Package core provides some of the basic barista functionality, enabling more complex constructs without duplicating code or logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

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

Module represents a bar.Module wrapped with core barista functionality. It is used as a building block for the main bar, modules that manipulate other modules (group, reformat), and for writing tests. It handles restarting the wrapped module on a left/right/middle click, as well as providing an option to "replay" the last output from the module. It also provides timed output functionality.

func NewModule

func NewModule(original bar.Module) *Module

NewModule wraps an existing bar.Module with core barista functionality, such as restarts and the ability to replay the last output.

func (*Module) Replay

func (m *Module) Replay()

Replay sends the last output from the wrapped module to the sink.

func (*Module) Stream

func (m *Module) Stream(sink bar.Sink)

Stream runs the module with the given sink, automatically handling terminations/restarts of the wrapped module.

type ModuleSet

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

ModuleSet is a group of modules. It provides a channel for identifying module updates, and methods to get the last output of the set or a specific module.

func NewModuleSet

func NewModuleSet(modules []bar.Module) *ModuleSet

NewModuleSet creates a ModuleSet with the given modules.

func (*ModuleSet) LastOutput

func (m *ModuleSet) LastOutput(idx int) bar.Segments

LastOutput returns the last output from the module at a specific position. If the module has not yet updated, an empty output will be used.

func (*ModuleSet) LastOutputs

func (m *ModuleSet) LastOutputs() []bar.Segments

LastOutputs returns the last output from all modules in order. The returned slice will have exactly Len() elements, and if a module has not yet updated an empty output will be placed in its position.

func (*ModuleSet) Len

func (m *ModuleSet) Len() int

Len returns the number of modules in this ModuleSet.

func (*ModuleSet) Stream

func (m *ModuleSet) Stream() <-chan int

Stream starts streaming all modules and returns a channel that receives the index of the module any time one updates with new output.

Jump to

Keyboard shortcuts

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