porticus

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

porticus

The pantheon suite's shared TUI façade — the colonnade every tool presents in common. It holds what is identical across the suite so it lives in one place instead of being copy-pasted into each tool.

The root package (porticus) is the dependency-light chrome — lipgloss only, no bubbletea, no data spine:

  • Palette & styles — the fixed base palette and the lipgloss style set (NewStyles(accent)); the accent colour is the only per-tool input.
  • Identity — Theme{Name, Sigil, Accent, Version} and the canonical Tools table. Version is optional (set it at runtime, e.g. porticus.Tools["album"].WithVersion(version)) and shows in the help header.
  • Layout — TwoPane / Stacked, pane widths, the ║ divider, ══/── pane headers.
  • Footer — the Hints bar (groups joined by ❧, hints by ·, wrapped).
  • Help — the carved-stone HelpPage plaque.
  • Text helpers — SpacedCaps, PadTo, Truncate, WrapRows, ScrollHint.

Sub-packages add the shared interactive layer that the chrome alone can't cover (each opt-in, imported only where needed):

  • porticus/keys — the canonical key grammar (Map, Default()), the view-key helper (View), and the help-group generator (HelpGroups), so navigation, pane switching, and view selection are identical suite-wide and the help screen can't drift from the bindings. Depends on bubbletea, not the spine.
  • porticus/browse — the stateful two-pane tree-browser scaffold a tool embeds: TreePane (the left-pane node tree), Cursor (list selection + windowing), and Status (the auto-clearing status line). Depends on the data spine (pantheon/tree) for the node type, kept here in its own package.
  • porticus/insights — shared charts (Sparkline, Heatmap, CalendarHeatmap, Compute/Trend) and a scrollable InsightsPage, for the graph/stats screens (album demographics, speculum habit stats). Pure render.
  • porticus/pick — the search/suggest overlay: a generic Picker[T] (query input + live-filtered, scrollable, selectable results) the tool drives with Open/Update/View, supplying Filter/Render and what a selection does. One component for both free-text search and ranked suggest (set Limit). Depends on bubbletea + the bubbles text input, not the spine.
  • porticus/input — text-entry chrome: Editor (the soft-wrapping, content-sized add/edit textarea with the hanging-indent prompt), Field (the single-line input for dates/codes/names), and Confirm (the y/n prompt). All share enter-commits / esc-cancels and report an Action/Answer the tool acts on. Spine-free.
  • porticus/calendar — the month calendar: a Grid (selected day + day/week/month navigation + per-day marker callback + selected/today highlight), the shared base for calendarium and any date view. The day-detail list is the tool's (via browse.Cursor). Spine-free.
  • porticus/dates — the relative-date vocabulary: RelativeDate / FarOff / CoarseSpan render an ISO date as today / tmrw / in 3d / in 2mo, so dates read identically suite-wide. Pure.

The root also has Styles.Page — the shared scrollable read-only page chrome (header + windowed body + scroll hint), behind HelpPage/InsightsPage and reusable as a Pager for custom screens (a markdown preview, a stats page) — and the browse/pick cursors take wheel scrolling (HandleMouse) and reordering (Cursor.Reorder).

Layering

              bubbletea + lipgloss
                       │
   pantheon ───────────┤   porticus (root: chrome, presentation only)
   (data spine)        │       ├── keys      (no spine)
        │              │       ├── insights  (no spine)
        │              │       ├── pick      (no spine)
        │              │       ├── input     (no spine)
        │              │       ├── calendar  (no spine)
        │              │       ├── dates     (no spine)
        │              ├───────┴── browse    (uses pantheon/tree)
        └──────────────┴───────────────┐
                                    each tool

The root package is presentation only — no spine import, no tool-specific types. A tool renders its own rows (a todo, a contact, a habit) and hands the strings to porticus's layout helpers, supplying its Theme. The only package that touches the spine is browse, which needs the tree.Node type for the shared tree pane; tools that aren't tree-shaped (e.g. speculum) use the root, keys, and insights without it.

The authoritative design rationale is the suite TUI design guide (aoapp_tui_design.md); this module is its executable form. When the two drift, fix it here once and record the decision in the guide's §9 log.

Use

theme := porticus.Tools["album"]      // or a Theme literal
st := theme.Styles()                  // == porticus.NewStyles(theme.Accent)

body := st.TwoPane(width, height,
    func(w, h int) string { return renderListPane(st, w, h) },
    func(w, h int) string { return renderDetailPane(st, w, h) },
)
footer := st.Hints([][]string{{"j/k:move", "tab:pane"}, {"?:help", "q:quit"}}, width)

Build

GOWORK=off go build ./... && GOWORK=off go test ./...

The suite go.work makes local edits here visible to every tool immediately; on release, tag the module and bump each tool's pin.

Documentation

Overview

Package porticus is the pantheon suite's shared TUI façade: the chrome every tool presents in common — palette, styles, two-pane layout, title bars, the footer hint bar, and the help plaque. It is the colonnade the whole suite shares; only the accent colour, sigil and name vary per tool (see Theme).

porticus is presentation only: it has no dependency on the data spine (github.com/LinusNyman/pantheon) and no tool-specific types. Tools render their own rows (a todo, a contact, a habit) and hand the rendered strings to the layout helpers here. The canonical design rationale lives in the suite TUI design guide (aoapp_tui_design.md); this package is its executable form.

Index

Constants

View Source
const (
	ColCode      = "#4fa6e0" // aegean blue: node codes
	ColName      = "#f2ead0" // marble ivory: primary text, selection fg
	ColOwnCount  = "#3fc79a" // verdigris bronze: own-item counts
	ColDim       = "#9a917b" // weathered stone: dim text, hints, inactive
	ColDue       = "#f5a623" // ochre: due dates, soft urgency
	ColRecur     = "#bd6ad8" // Tyrian purple: recurrence specs
	ColOverdue   = "#e8492c" // Pompeian red: errors, overdue
	ColCompleted = "#aac63f" // laurel green: done marks, success
	ColHeading   = "#ee7f44" // terracotta: section headings
	ColDesc      = "#d4c79e" // aged parchment: descriptions
	ColSelFocus  = "#4a4231" // dark umber: focused selection bg
	ColSelBlur   = "#332d20" // deep umber: blurred selection bg
	ColSelFg     = "#f2ead0" // marble ivory: selection text
	ColDivider   = "#4a4231" // umber: pane divider, rules, plaque border
	ColPaneOff   = "#9a917b" // weathered stone: unfocused pane title
	ColToday     = "#4fa6e0" // aegean blue: the "today" calendar day, distinct from the accent focus
)

Shared base palette (suite standard §5). Fixed across every tool — do not vary these per tool. Only the accent (Theme.Accent) changes. Kept as exported constants so a tool can reach for a raw colour when a Style isn't enough.

View Source
const Author = "Linus Nyman"

Author is the suite's author, shown on the title screen (TitlePage). It is the same across every tool, so it lives here rather than on Theme.

View Source
const NarrowWidth = 80

NarrowWidth is the terminal width below which the two-pane layout stacks vertically instead (suite standard §2).

Variables

View Source
var Tools = map[string]Theme{
	"pantheon":    {Name: "pantheon", Sigil: "✦", Accent: "#c8c0b0"},
	"pensum":      {Name: "pensum", Sigil: "✎", Accent: "#e06474"},
	"tabella":     {Name: "tabella", Sigil: "≡", Accent: "#4fa6e0"},
	"decreta":     {Name: "decreta", Sigil: "⚖", Accent: "#c45f9c"},
	"speculum":    {Name: "speculum", Sigil: "○", Accent: "#3fc79a"},
	"studium":     {Name: "studium", Sigil: "⊙", Accent: "#a78bfa"},
	"atrium":      {Name: "atrium", Sigil: "◈", Accent: "#ee7f44"},
	"album":       {Name: "album", Sigil: "❦", Accent: "#f5a623"},
	"calendarium": {Name: "calendarium", Sigil: "⊕", Accent: "#5b7dc8"},
}

Tools is the canonical per-tool identity table (suite standard §4), kept in one place so a tool can pull its identity by name rather than hard-coding the hex and glyph. A tool may also construct its own Theme literal.

Functions

func BigText added in v0.1.3

func BigText(s string) string

BigText renders s as a bigHeight-row banner in the suite's heavy-block capitals (see bigFont), the "large characters" of a tool's title screen. It upper-cases s, looks up each rune's glyph (a blank space-width glyph for anything unmapped), and joins the glyphs column-by-column so the rows align. The returned string has exactly bigHeight lines, each the same display width. Empty input yields bigHeight empty lines.

func Center

func Center(s string, width int) string

Center pads s with spaces on both sides to center it within width display cells, accounting for ANSI styling. A string already at least width wide is returned unchanged; any odd remainder favours the right side.

func PadTo

func PadTo(s string, width int) string

PadTo right-pads s with spaces to width display cells, accounting for ANSI styling (it measures with lipgloss.Width). It never truncates: a string wider than width is returned unchanged.

func PaneWidths

func PaneWidths(total int) (left, right int)

PaneWidths returns the left (tree/list) and right (working-area) pane widths for a given total terminal width, per the suite layout spec (§2): the left pane is width*2/5 clamped to [28,48]; the right takes the remainder after the 3-column divider, with a floor of 20.

func SpacedCaps

func SpacedCaps(s string) string

SpacedCaps converts a string to uppercase with a space between every letter, e.g. "pensum" → "P E N S U M". Used for tool and pane titles (suite standard §3.1). Works on multi-byte runes (åäö) since it splits on runes.

func Truncate

func Truncate(s string, width int) string

Truncate visually truncates an ANSI-styled string to width cells, appending an ellipsis when it overflows. width<=0 yields "".

func WrapRows

func WrapRows(prefix, body string, width int) []string

WrapRows wraps a list row's styled body so the whole row fits within width, returning one string per visual row. The first row carries the prefix (index, checkbox, columns…); continuation rows are indented by the prefix width so the leading column reads blank and the body lines up as one paragraph. Shared by every tool's list panes so wrapping behaves identically everywhere.

Types

type HelpGroup

type HelpGroup struct {
	Title string
	Rows  [][2]string
}

HelpGroup is one labelled section of the help page: a heading over key/action rows. Rows are {keys, action} pairs, e.g. {"j / k", "move down / up"}.

type Styles

type Styles struct {
	Accent string // raw accent hex (Theme.Accent), for ad-hoc styling

	Title     lipgloss.Style // bold accent — left pane title, footer hederas
	Code      lipgloss.Style
	Name      lipgloss.Style
	Count     lipgloss.Style
	Dim       lipgloss.Style
	Done      lipgloss.Style // dim + strikethrough
	Due       lipgloss.Style
	Recur     lipgloss.Style
	Overdue   lipgloss.Style
	Completed lipgloss.Style
	Heading   lipgloss.Style // bold terracotta
	Desc      lipgloss.Style // parchment italic
	Err       lipgloss.Style // overdue colour — error text
	OK        lipgloss.Style // laurel green — status text

	SelFocus lipgloss.Style // focused selection: umber bg, ivory fg, bold
	SelBlur  lipgloss.Style // blurred selection: deep umber bg, ivory fg

	Divider    lipgloss.Style // ║ divider and ══ / ── rules
	PaneOn     lipgloss.Style // bold accent — focused pane title
	PaneOff    lipgloss.Style // dim — unfocused pane title
	HelpPlaque lipgloss.Style // double border in umber — the help tablet
	Today      lipgloss.Style // aegean blue — the "today" calendar day
}

Styles bundles every shared lipgloss style, built once per tool by NewStyles. The accent colour is the only per-tool input; every other style uses a fixed suite colour so look stays identical across tools. Field names mirror the suite standard §7 variable names so style code reads the same everywhere.

func NewStyles

func NewStyles(accent string) Styles

NewStyles builds the suite style set for one tool. accent is the tool's identity colour (Theme.Accent, suite standard §4); everything else is fixed.

func (Styles) Checkbox

func (s Styles) Checkbox(done bool) string

Checkbox is the list status glyph shared by every tool: a dim empty ☐, or a laurel-green ☑ when done. Both are one cell wide so columns stay aligned.

func (Styles) HRule

func (s Styles) HRule(width int) string

HRule renders a full-width single-rule line of the given width in the divider colour (the stacked-layout separator, U+2500).

func (Styles) HelpPage

func (s Styles) HelpPage(t Theme, groups []HelpGroup, width, height, scroll int) string

HelpPage renders the suite help screen as a page of the app (suite standard §6): the unchanged tool title with "help" where the node name normally sits, over a carved-stone plaque (a double-ruled border echoing the ══ rule) holding the binding groups in one or two columns. scroll is the first body row to show; the page windows the groups to the available height and shows a scroll hint in the header. Returns a block exactly width×height so the footer stays pinned.

func (Styles) Hints

func (s Styles) Hints(groups [][]string, width int) string

Hints renders the footer hint bar from groups of "key:action" hints, wrapped to width so no hint is pushed off-screen (suite standard §6). Hints within a group are separated by " · " (dim); groups by " ❧ " (the accent hedera). A single "key:action" hint is never split across lines. width<=0 falls back to a sane default.

func (Styles) LeftHeader

func (s Styles) LeftHeader(t Theme, nodeName string, width int) string

LeftHeader renders the left pane's two-line header: the identity title (sigil + spaced-caps tool name + ❧ + node name) over a full-width ══ double rule (suite standard §3.1, §3.3). nodeName may be "" for the root.

func (Styles) Page

func (s Styles) Page(t Theme, label, body string, width, height, scroll int) string

Page renders a scrollable read-only page through the standard chrome: the left header (sigil + spaced-caps tool name + ❧ + label) over the ══ rule, then body windowed to the remaining height and scrolled by scroll (the caller owns the offset, as with HelpPage), a scroll hint when it overflows, filled to exactly width×height so the footer stays pinned. Use it for any custom read-only screen — a markdown preview, a stats page; insights.InsightsPage is a thin wrapper over it.

func (Styles) RightHeader

func (s Styles) RightHeader(label string, focused bool, width int) string

RightHeader renders the right pane's two-line header: a spaced-caps label in stone (no sigil) over a single ── rule. When the pane is focused the rule is drawn in the accent colour (suite standard §6).

func (Styles) ScrollHint

func (s Styles) ScrollHint(above, below, width int) string

ScrollHint renders a dim one-line indicator of how many rows are hidden above and/or below the visible window, e.g. "↑3 ↓5". Empty when nothing is hidden.

func (Styles) Stacked

func (s Styles) Stacked(width, height int, top, bottom func(w, h int) string) string

Stacked assembles the narrow-fallback layout (terminal width < NarrowWidth): the top pane, a full-width ─ rule, then the bottom pane. The top pane gets half the height (min 4 rows), the bottom the rest (min 3) — see suite standard §2.

func (Styles) TitlePage added in v0.1.3

func (s Styles) TitlePage(t Theme, width, height int) string

TitlePage renders a tool's cover screen: the sigil, the tool name in large heavy-block capitals (BigText) in the accent, a hedera-and-rule ornament, then the version (when set) and the author — the whole composition centred in a block of exactly width×height so it sits as its own full-screen view (bound to "0", the way the numbered views are bound to 1…9). It carries no left-header bar; unlike Page/HelpPage a cover is a clean full-bleed composition. The name drops to spaced capitals when the banner is wider than the terminal.

The classical reading comes from the frame — the sigil crown, the ❧ over a ══ rule, the spaced-caps author — not from the glyphs, which stay the suite's bold block letters. Version is shown here rather than in the help header.

func (Styles) TwoPane

func (s Styles) TwoPane(width, height int, left, right func(w, h int) string) string

TwoPane assembles the standard two-column body (terminal width ≥ NarrowWidth): a left pane and a right pane joined by the ` ║ ` divider. The caller supplies each pane's content via a render callback that is handed the pane's computed width and the shared body height, so the tool keeps full control of what fills each pane while porticus owns the geometry and the divider.

type Theme

type Theme struct {
	Name    string // tool name, e.g. "pensum"; rendered spaced-caps in titles
	Sigil   string // identity glyph, e.g. "✎"
	Accent  string // accent hex, e.g. "#e06474"
	Version string // optional app version shown in the help header, e.g. "v1.2.3"; "" hides it
}

Theme is a tool's whole visual identity: the three things that vary across the suite (suite standard §4). Everything else — palette, layout, key grammar — is shared. Build a tool's styles with NewStyles(theme.Accent).

func (Theme) Styles

func (t Theme) Styles() Styles

Styles is a convenience for theme.Styles() == NewStyles(theme.Accent).

func (Theme) WithVersion added in v0.1.2

func (t Theme) WithVersion(v string) Theme

WithVersion returns a copy of the theme with Version set, so a tool can stamp its build version onto its identity in one line, e.g. porticus.Tools["album"].WithVersion(version). The Tools table itself carries no version (it's runtime info).

Directories

Path Synopsis
Package browse is the pantheon suite's shared two-pane tree-browser scaffold: the stateful left-pane node tree (TreePane), the list selection cursor (Cursor), and the auto-clearing status line (Status).
Package browse is the pantheon suite's shared two-pane tree-browser scaffold: the stateful left-pane node tree (TreePane), the list selection cursor (Cursor), and the auto-clearing status line (Status).
Package calendar is the suite's shared month calendar: a selected day plus the navigation and rendering of the month it falls in.
Package calendar is the suite's shared month calendar: a selected day plus the navigation and rendering of the month it falls in.
Package dates is the suite's shared relative-date vocabulary: it renders an ISO date (YYYY-MM-DD) the way every tool should show it at a glance — "today", "tmrw", "in 3d", "in 2mo" — so due dates, agendas, calendars, and birthdays read identically across the suite.
Package dates is the suite's shared relative-date vocabulary: it renders an ISO date (YYYY-MM-DD) the way every tool should show it at a glance — "today", "tmrw", "in 3d", "in 2mo" — so due dates, agendas, calendars, and birthdays read identically across the suite.
Package input is the suite's shared text-entry chrome: the free-text add/edit editor (a soft-wrapping, content-sized textarea), the single-line field (for dates, codes, names…), and the y/n confirm prompt.
Package input is the suite's shared text-entry chrome: the free-text add/edit editor (a soft-wrapping, content-sized textarea), the single-line field (for dates, codes, names…), and the y/n confirm prompt.
Package insights renders the suite's shared statistical chrome: compact sparklines, binary heatmaps, trend computation, and a scrollable insights page.
Package insights renders the suite's shared statistical chrome: compact sparklines, binary heatmaps, trend computation, and a scrollable insights page.
Package keys is the pantheon suite's canonical key grammar — the single source of truth for which keys do what across every tool, so navigation, pane switching, and view selection feel identical suite-wide.
Package keys is the pantheon suite's canonical key grammar — the single source of truth for which keys do what across every tool, so navigation, pane switching, and view selection feel identical suite-wide.
Package pick is the suite's shared search/suggest overlay: a generic, type-parameterised picker — a query input over a live-filtered, scrollable, selectable results list — rendered as a page through the porticus chrome.
Package pick is the suite's shared search/suggest overlay: a generic, type-parameterised picker — a query input over a live-filtered, scrollable, selectable results list — rendered as a page through the porticus chrome.

Jump to

Keyboard shortcuts

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