Documentation
¶
Overview ¶
Package s99term is the terminal render layer for smegg99 command-line programs.
Index ¶
- func Declared() string
- type Console
- func (c *Console) Begin(label string) *Step
- func (c *Console) BeginCounted(label string, total int) *Step
- func (c *Console) Charset() bool
- func (c *Console) Close()
- func (c *Console) Line(st Status, label string, fields ...Field)
- func (c *Console) Print(block string)
- func (c *Console) Profile() colorprofile.Profile
- func (c *Console) Renderer() Renderer
- func (c *Console) Sink() s99logger.Sink
- func (c *Console) Styles() Styles
- func (c *Console) Width() int
- type Field
- type Options
- type Palette
- type Renderer
- type Status
- type Step
- type Styles
- type Words
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Console ¶
type Console struct {
// contains filtered or unexported fields
}
Console owns one output stream: its colour level, its charset, its width, and the one live step that may be animating on it.
func (*Console) BeginCounted ¶
BeginCounted starts a step with a known number of units, shown as a bar.
func (*Console) Close ¶
func (c *Console) Close()
Close ends any live step and restores the cursor. Defer it in every command.
func (*Console) Print ¶
Print writes one already-rendered block, downsampled for the stream. A live step's frame is erased first and redrawn after, so the block is never torn.
func (*Console) Profile ¶
func (c *Console) Profile() colorprofile.Profile
type Field ¶
Field is one key and value appended to a line. The key is an identifier, like an s99logger attr key, so it is never translated.
type Options ¶
type Options struct {
// Out receives every line. Pass os.Stderr to keep stdout for machine output.
Out io.Writer
// Env feeds colour and charset detection. Nil reads os.Environ().
Env []string
// Words names each state. A state left out prints its glyph alone.
Words Words
// Profile overrides colour detection. The zero value detects.
Profile colorprofile.Profile
// Animate overrides animation. Nil animates only on a sized terminal.
Animate *bool
// Charset overrides the charset answer. Nil reads the locale variables.
Charset *bool
// Now supplies step timestamps. Nil uses time.Now.
Now func() time.Time
}
Options configures a Console.
type Palette ¶
type Palette struct {
Accent color.Color
Muted color.Color
Line color.Color
Good color.Color
Bad color.Color
Warn color.Color
}
Palette holds every colour. All but Accent are ANSI indices, so no background query is needed.
type Renderer ¶
Renderer composes the strings. It holds no stream, so every function here is testable without a terminal.
func NewRenderer ¶
NewRenderer pairs a palette with the catalog words for each state.
func (Renderer) Frame ¶
Frame is the live line while a step runs: spinner, label, and whatever the step wants to show on the right, such as a progress bar.
func (Renderer) StatusCell ¶
StatusCell is the glyph and the word, padded to the shared column width.
type Status ¶
type Status int
Status is what a line says happened, independent of how it is coloured.
type Step ¶
type Step struct {
// contains filtered or unexported fields
}
Step is one unit of work the reader waits on. On a terminal it animates one inline line; on any other stream it prints nothing until it ends.
type Styles ¶
type Styles struct {
Palette Palette
Border lipgloss.Border
Unicode bool
Title lipgloss.Style
Ink lipgloss.Style
Muted lipgloss.Style
AccentStyle lipgloss.Style
Line lipgloss.Style
Good lipgloss.Style
Bad lipgloss.Style
Warn lipgloss.Style
Key lipgloss.Style
Field lipgloss.Style
Spinner lipgloss.Style
Panel lipgloss.Style
StatusWidth int
}
Styles owns every colour, border and pad value in the package.