v0.33.0 tui tap for live view and console enhancements

This commit is contained in:
lixen committed 2026-10-10 21:32:08 -04:00
1 parent a1e9d21d06
commit 87f5576ccf
41 files changed
+4606 -449

No files matched your search

+52 -23
View File
@@ -10,49 +10,76 @@ import (
ui "github.com/lixenwraith/terminal/tui"
)
// look is a color tier's styles: the widgets' theme and each column's tint
// look is a color tier's styles: the widgets' theme, each column's tint, and
// the live view's levels by name, any other drawn as text
type look struct {
ui.Theme
Source, Flow, Sink ui.Style
Levels map[string]ui.Style
}
// The site's dark tokens; true color and 256 colors paint its background
// The website's dark tokens; true color and 256 colors paint its background
var (
siteBg = color.RGB{R: 0x14, G: 0x17, B: 0x1d}
sitePanel = color.RGB{R: 0x1c, G: 0x20, B: 0x28}
siteFg = color.RGB{R: 0xe3, G: 0xe7, B: 0xef}
siteMuted = color.RGB{R: 0x9a, G: 0xa3, B: 0xb5}
siteAccent = color.RGB{R: 0x6e, G: 0xa0, B: 0xff}
siteBg = color.RGB{R: 0x11, G: 0x11, B: 0x1b} // --dark-bg
siteFg = color.RGB{R: 0xff, G: 0xff, B: 0xff} // --text-color
)
var siteLook = look{
Theme: ui.Theme{
Text: ui.Style{Fg: siteFg, Bg: siteBg},
Muted: ui.Style{Fg: siteMuted},
Accent: ui.Style{Fg: siteAccent, Attr: terminal.AttrBold},
Selected: ui.Style{Bg: color.RGB{R: 0x26, G: 0x2c, B: 0x38}},
Input: ui.Style{Bg: sitePanel},
Muted: ui.Style{Fg: color.RGB{R: 0x94, G: 0xa3, B: 0xb8}}, // --muted-color
Accent: ui.Style{Fg: color.RGB{R: 0x8e, G: 0xa2, B: 0xff}, Attr: terminal.AttrBold}, // --accent-color
Selected: ui.Style{Bg: color.RGB{R: 0x1d, G: 0x1c, B: 0x3e}}, // --card-background-color
Input: ui.Style{Bg: color.RGB{R: 0x1a, G: 0x1b, B: 0x26}}, // --dark-surface
Cursor: ui.Style{Fg: siteBg, Bg: siteFg},
Error: ui.Style{Fg: color.RGB{R: 0xff, G: 0x6b, B: 0x6b}},
Border: ui.Style{Fg: color.RGB{R: 0x5a, G: 0x63, B: 0x75}},
Error: ui.Style{Fg: color.RGB{R: 0xf8, G: 0x71, B: 0x71}}, // --danger-color
Border: ui.Style{Fg: color.RGB{R: 0x7c, G: 0x7c, B: 0x82}}, // the diagram's --wire
},
Source: ui.Style{Fg: color.RGB{R: 0x56, G: 0xc8, B: 0xd8}},
Flow: ui.Style{Fg: color.RGB{R: 0xb1, G: 0x8c, B: 0xff}},
Sink: ui.Style{Fg: color.RGB{R: 0x6f, G: 0xcf, B: 0x8f}},
Source: ui.Style{Fg: color.RGB{R: 0x22, G: 0xd3, B: 0xee}}, // --hue-cyan
Flow: ui.Style{Fg: color.RGB{R: 0xa7, G: 0x8b, B: 0xfa}}, // --hue-violet
Sink: ui.Style{Fg: color.RGB{R: 0x34, G: 0xd3, B: 0x99}}, // --hue-green
Levels: map[string]ui.Style{
"TRACE": {Fg: color.RGB{R: 0x94, G: 0xa3, B: 0xb8}}, // --hue-slate
"DEBUG": {Fg: color.RGB{R: 0x60, G: 0xa5, B: 0xfa}}, // --hue-blue
"INFO": {Fg: color.RGB{R: 0x34, G: 0xd3, B: 0x99}}, // --ok-color
"WARN": {Fg: color.RGB{R: 0xfb, G: 0xbf, B: 0x24}}, // --warn-color
"ERROR": {Fg: color.RGB{R: 0xf8, G: 0x71, B: 0x71}, Attr: terminal.AttrBold}, // --danger-color
},
}
// console16 is the 16-color look, a text console's, where bold is bright:
// text is palette white rather than bold, which On would spread to every role
// drawn on it; muted the console's own grey; the cursor row a blue bar under
// which every role stays readable
var console16 = ui.Theme{
Text: ui.Style{Fg: color.RGB{R: color.ANSIBrightWhite}, Attr: terminal.AttrFg256 | terminal.AttrBgDefault},
Muted: ui.Style{Attr: terminal.AttrFgDefault},
Accent: ansi(color.ANSIBrightYellow),
Selected: ui.Style{Bg: color.RGB{R: color.ANSIBlue}, Attr: terminal.AttrBg256},
Input: ui.Theme16.Input,
Cursor: ui.Theme16.Cursor,
Error: ui.Theme16.Error,
Border: ui.Style{Attr: terminal.AttrFgDefault},
}
// ansi is a palette index the terminal shows in its own shade
func ansi(i uint8) ui.Style { return ui.Style{Fg: color.RGB{R: i}, Attr: terminal.AttrFg256} }
// looks holds one look per color tier: 16 colors and none keep the
// terminal's background
// terminal's background. Levels in 16 colors are picked by hand, as the
// quantizer turns the site's pastels grey; without color, bold and dim only
// add to the level's name.
var looks = map[terminal.ColorMode]look{
terminal.ColorModeTrueColor: siteLook,
terminal.ColorMode256: siteLook,
terminal.ColorMode16: {Theme: ui.Theme16,
Source: ansi(color.ANSICyan), Flow: ansi(color.ANSIMagenta), Sink: ansi(color.ANSIGreen)},
terminal.ColorMode16: {Theme: console16,
Source: ansi(color.ANSICyan), Flow: ansi(color.ANSIBrightMagenta), Sink: ansi(color.ANSIGreen),
Levels: map[string]ui.Style{"TRACE": console16.Muted, "DEBUG": ansi(color.ANSICyan), "INFO": ansi(color.ANSIGreen),
"WARN": ansi(color.ANSIBrightYellow), "ERROR": ansi(color.ANSIBrightRed)}},
terminal.ColorModeNone: {Theme: ui.MonoTheme,
Source: ui.MonoTheme.Text, Flow: ui.MonoTheme.Text, Sink: ui.MonoTheme.Text},
Source: ui.MonoTheme.Text, Flow: ui.MonoTheme.Text, Sink: ui.MonoTheme.Text,
Levels: map[string]ui.Style{"TRACE": ui.MonoTheme.Muted, "DEBUG": ui.MonoTheme.Muted, "INFO": ui.MonoTheme.Text,
"WARN": ui.MonoTheme.Accent, "ERROR": ui.MonoTheme.Accent}},
}
// font is the marks one character set draws: the widgets' and the canvas's;
@@ -63,6 +90,8 @@ type font struct {
arrow, down rune // into the flow box and a sink; between stacked parts
bar, barOn rune // a node, and the chosen node
dot rune // before a column's title
newline rune // a line break in a row of the live view
odd rune // in the live view, a rune a cell cannot show
valid string
invalid string
enter string
@@ -86,12 +115,12 @@ func (f font) fold(r rune) rune {
// fonts: Unicode, a text console's CP437, and ASCII outside UTF-8
var (
unicodeFont = font{Glyphs: ui.GlyphsUnicode, box: ui.LineDashed,
arrow: '►', down: '▼', bar: '▌', barOn: '█', dot: '●', valid: "✓", invalid: "✗", enter: "⏎", space: "␣"}
arrow: '►', down: '▼', bar: '▌', barOn: '█', dot: '●', newline: '↵', odd: '\uFFFD', valid: "✓", invalid: "✗", enter: "⏎", space: "␣"}
cp437Font = font{Glyphs: ui.GlyphsCP437, box: ui.LineSingle,
arrow: '►', down: '▼', bar: '▌', barOn: '█', dot: '•', valid: "√", invalid: "x", enter: "enter", space: "space",
arrow: '►', down: '▼', bar: '▌', barOn: '█', dot: '•', newline: '¶', odd: '?', valid: "√", invalid: "x", enter: "enter", space: "space",
folds: map[rune]rune{'…': '.'}}
asciiFont = font{Glyphs: ui.GlyphsASCII, box: ui.LineASCII,
arrow: '>', down: 'v', bar: '|', barOn: '#', dot: '*', valid: "ok", invalid: "x", enter: "enter", space: "space",
arrow: '>', down: 'v', bar: '|', barOn: '#', dot: '*', newline: '|', odd: '?', valid: "ok", invalid: "x", enter: "enter", space: "space",
folds: map[rune]rune{'…': '.', '·': '-'}, ascii: true}
)