Documentation
¶
Overview ¶
Package modal provides a group with various "modes", each mode identified by a string key and containing multiple modules. It switches between the modes using a control similar to the workspace switcher.
When adding modules to a mode, certain modules can be marked as "summary" modules, to be displayed when no mode is active. When a mode is active, only the modules associated with it are displayed.
For example, if a modal group is constructed with the following sets, where uppercase letters indicate summary modules:
- "A" => "A0", "a1", "a2", "a3"
- "B" => "b0", "B1", "B2"
- "C" => "c0", "c1", "c2"
Then by default the modules displayed will be ["A0", "B1", "B2"]. Activating "A" will replace that with ["A0", "a1", "a2", "a3"], "B" will show ["b0", "B1", "B2"], and "C" will show ["c0", "c1", "c2"].
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller interface { // Modes returns all the modes in this modal group. Modes() []string // Current returns the currently active mode, or an empty string if no mode // is active. Current() string // Activate activates the given mode. Activate(string) // Toggle toggles between the given mode and no active mode. Toggle(string) // Reset clears the active mode. Reset() // AutoReset automatically resets the active mode after a given duration. AutoReset(time.Duration) // SetOutput sets the output segment for a given mode. The default output // is a plain text segment with the mode name. SetOutput(string, *bar.Segment) }
Controller provides an interface to control a modal group.
type Modal ¶
type Modal struct {
// contains filtered or unexported fields
}
Modal represents a partially constructed modal group. Modes and modules can only be added to a Modal before it is finalised, and can only be added to the bar after it is finalised.
func (*Modal) AutoReset ¶
AutoReset automatically resets the active mode after a given duration.
func (*Modal) Build ¶
func (m *Modal) Build() (bar.Module, Controller)
Build constructs the modal group, and returns a linked controller.
type Mode ¶
type Mode struct {
// contains filtered or unexported fields
}
Mode represents a mode added to an existing modal group. It provides methods to add additional outputs and optionally set the default output.
func (*Mode) Add ¶
Add adds a module in both summary and detail modes. Modules added here are shown both when the current mode is active and when no mode is active. They are only hidden when a different mode is active.
func (*Mode) Detail ¶
Detail adds a detail module to a mode. Modules added here are only shown when this mode is active.
func (*Mode) SetOutput ¶
SetOutput sets the output shown in the mode switcher. The default output is just the name of the mode.