borderfx

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package borderfx provides animated border effects for Termdash containers.

Tier 1 — Profiles (simplest)

Profiles are fully pre-configured effects: colors, tick rate, and inactive style all baked in. One call wires everything:

fx := borderfx.NewAnimator(cont)
fx.ApplyProfile(borderfx.Profiles.GradientArc, "root", "sidebar", "chart")
go fx.Run(ctx)

Built-in profiles:

GradientArc        – purple→lavender→blue arc sweeping clockwise
LoadingSweepWhite  – white highlight scanning across the border title
FuturisticSweep    – braille interlaced scanner in bright cyan
NeonPulse          – magenta neon-sign flicker
AmberTelemetry     – amber tick telemetry (professional ops look)

Tier 2 — Macro + Palette (intermediate)

For fine-grained color control, combine a Macro with a Palette:

fx.RegisterMacro("sensors", borderfx.Presets.Orbit, borderfx.Palettes.Cyan)

Tier 3 — Raw Effect (advanced)

For maximum flexibility, build and register an Effect directly:

fx.Register("sensors", borderfx.GradientArcN(stops, dim, 0.45))

Index

Constants

This section is empty.

Variables

View Source
var DecryptCharsets = DecryptCharsetGroup{
	WarpCoreFlux:   "01$#*+-",
	LCARSTelemetry: "><=|/-",
	Comms:          "[]{}:;?",
	Controls:       ".,:*~^",
	Default:        "⠿⣾⣶⣤⣀⠒",
	Sensors:        "⠿⣾⣶⣤⣀⠒",
}

DecryptCharsets exposes reusable title-reveal character groups for the borderfx user API. The intended call site is:

borderfx.DecryptingTitle(" Comms ", borderfx.DecryptCharsets.Comms)

so callers can choose a named reveal set without hand-copying character sequences into their own widget setup code.

View Source
var Palettes = struct {
	Cyan      Palette
	Amber     Palette
	Matrix    Palette
	Synthwave Palette
	Ice       Palette
	Silver    Palette
}{
	Cyan:      Colors(cell.ColorNumber(51), cell.ColorNumber(24), cell.ColorNumber(236)),
	Amber:     Colors(cell.ColorNumber(214), cell.ColorNumber(136), cell.ColorNumber(236)),
	Matrix:    Colors(cell.ColorNumber(123), cell.ColorNumber(39), cell.ColorNumber(236)),
	Synthwave: Colors(cell.ColorNumber(201), cell.ColorNumber(90), cell.ColorNumber(236)),
	Ice:       Colors(cell.ColorNumber(220), cell.ColorNumber(178), cell.ColorNumber(236)),
	Silver:    Duo(cell.ColorNumber(250), cell.ColorNumber(239)),
}

Palettes exposes a few ready-made color palettes for common borderfx looks.

View Source
var Presets = struct {
	Scanner     Macro
	Dual        Macro
	Interlace   Macro
	Braided     Macro
	Shard       Macro
	Orbit       Macro
	Focus       Macro
	Rail        Macro
	Decode      Macro
	Power       Macro
	Rain        Macro
	Braille     Macro
	Bracket     Macro
	Ticks       Macro
	Noise       Macro
	SpinPulse   Macro
	Dots6       Macro
	Dots10      Macro
	Ribbon      Macro
	Brace       Macro
	Emoji       Macro
	Pulse       Macro
	Fire        Macro
	Ice         Macro
	Rainbow     Macro
	Neon        Macro
	Matrix      Macro
	Glow        Macro
	Warp        Macro
	TextSweep   Macro
	GradArc     Macro // single gradient arc sweeping clockwise; uses Palette.Bright→Mid, dim background
	DualGradArc Macro // two opposing gradient arcs; uses Palette.Bright vs Palette.Mid
}{
	Scanner: newMacro("scanner", func(p Palette) *Effect {
		return Scanner(p.Bright, p.Dim)
	}),
	Dual: newMacro("dual", func(p Palette) *Effect {
		return DualScanner(p.Bright, p.Mid, p.Dim)
	}),
	Interlace: newMacro("interlace", func(p Palette) *Effect {
		return InterlacedScanner(p.Bright, p.Mid, p.Dim)
	}),
	Braided: newMacro("braided", func(p Palette) *Effect {
		return BraidedScanner(p.Bright, p.Mid, p.Dim)
	}),
	Shard: newMacro("shard", func(p Palette) *Effect {
		return ShardScanner(p.Bright, p.Mid, p.Dim)
	}),
	Orbit: newMacro("orbit", func(p Palette) *Effect {
		return OrbitScanner(p.Bright, p.Mid, p.Dim)
	}),
	Focus: newMacro("focus", func(p Palette) *Effect {
		return FocusPins(p.Bright, p.Mid, p.Dim)
	}),
	Rail: newMacro("rail", func(p Palette) *Effect {
		return FocusPinsRail(p.Bright, p.Mid, p.Dim)
	}),
	Decode: newMacro("decode", func(p Palette) *Effect {
		return FocusPinsMatrix(p.Bright, p.Mid, p.Dim)
	}),
	Power: newMacro("power", func(p Palette) *Effect {
		return FocusPinsPower(p.Bright, p.Mid, p.Dim)
	}),
	Rain: newMacro("rain", func(p Palette) *Effect {
		return RainScanner(p.Bright, p.Mid, p.Dim)
	}),
	Braille: newMacro("braille", func(p Palette) *Effect {
		return BrailleDrift(p.Bright, p.Mid, p.Dim)
	}),
	Bracket: newMacro("bracket", func(p Palette) *Effect {
		return BracketScan(p.Bright, p.Mid, p.Dim)
	}),
	Ticks: newMacro("ticks", func(p Palette) *Effect {
		return DataTicks(p.Bright, p.Mid, p.Dim)
	}),
	Noise: newMacro("noise", func(p Palette) *Effect {
		return StaticNoise(p.Bright, p.Mid, p.Dim)
	}),
	SpinPulse: newMacro("spin_pulse", func(p Palette) *Effect {
		return SpinnerPulse(p.Bright, p.Mid, p.Dim)
	}),
	Dots6: newMacro("dots6", func(p Palette) *Effect {
		return Dots6Spinner(p.Bright, p.Mid, p.Dim)
	}),
	Dots10: newMacro("dots10", func(p Palette) *Effect {
		return Dots10Spinner(p.Bright, p.Mid, p.Dim)
	}),
	Ribbon: newMacro("ribbon", func(p Palette) *Effect {
		return FocusPinsRibbon(p.Bright, p.Mid, p.Dim)
	}),
	Brace: newMacro("brace", func(p Palette) *Effect {
		return FocusPinsBrace(p.Bright, p.Mid, p.Dim)
	}),
	Emoji: newMacro("emoji", func(p Palette) *Effect {
		return FocusPinsEmoji(p.Bright, p.Mid, p.Dim)
	}),
	Pulse: newMacro("pulse", func(p Palette) *Effect {
		return FocusPinsPulse(p.Bright, p.Mid, p.Dim)
	}),
	Fire: newMacro("fire", func(Palette) *Effect {
		return Fire()
	}),
	Ice: newMacro("ice", func(Palette) *Effect {
		return Ice()
	}),
	Rainbow: newMacro("rainbow", func(Palette) *Effect {
		return Rainbow()
	}),
	Neon: newMacro("neon", func(p Palette) *Effect {
		return Neon(p.Bright)
	}),
	Matrix: newMacro("matrix", func(Palette) *Effect {
		return Matrix()
	}),
	Glow: newMacro("glow", func(p Palette) *Effect {
		return Glow(p.Bright)
	}),
	Warp: newMacro("warp", func(Palette) *Effect {
		return Warp()
	}),
	TextSweep: newMacro("text_sweep", func(p Palette) *Effect {
		return TextSweep(cell.ColorWhite, cell.ColorNumber(245))
	}),
	GradArc: newMacro("grad_arc", func(p Palette) *Effect {
		return GradientArc(p.Bright, p.Mid, p.Dim, 0.35)
	}),
	DualGradArc: newMacro("dual_grad_arc", func(p Palette) *Effect {
		return DualGradientArc(p.Bright, p.Mid, p.Dim, 0.35)
	}),
}

Presets exposes the package's high-level reusable animation presets.

View Source
var Profiles = struct {
	// GradientArc sweeps a purple→lavender→blue→purple gradient arc clockwise.
	// The focused panel animates; inactive panels show a warm-gold static border.
	//
	// Origin: extracted from the ops-dashboard timeline demo (timelinedemo.go).
	//
	// Recommended for: general-purpose dashboards, ops panels, any widget where
	// you want a premium animated border with a clear focus indicator.
	GradientArc Profile

	// LoadingSweepWhite sweeps a bright-white highlight across the border title
	// text, leaving non-title cells in near-black.  Creates a clean "loading" or
	// "scanning" feel.
	//
	// Origin: extracted from the ThreeD tab of the tabdemo (tabdemo.go).
	//
	// Recommended for: panels that boot/load data, 3-D / render stages, any
	// widget whose title text deserves a spotlight moment.
	LoadingSweepWhite Profile

	// FuturisticSweep runs a multi-lane braille interlaced scanner in bright cyan.
	// Dense and high-energy — the border looks like live signal telemetry.
	//
	// Origin: extracted from the Spectrum Analyzer pane of the tabdemo.
	//
	// Recommended for: signal visualization, sensor feeds, spectrum analyzers,
	// any high-frequency data panel.
	FuturisticSweep Profile

	// NeonPulse flickers a magenta neon-sign effect around the full border.
	// Occasional dark frames mimic the gas-discharge instability of a real tube.
	//
	// Recommended for: alert panels, critical-status widgets, notification areas,
	// anything that should draw the eye immediately.
	NeonPulse Profile

	// AmberTelemetry sweeps measured block ticks in amber/gold across the border.
	// Clean and readable — a professional ops look inspired by hardware consoles.
	//
	// Recommended for: production dashboards, metrics panels, timeline widgets,
	// anywhere you want animation that doesn't distract from the data.
	AmberTelemetry Profile
}{
	GradientArc: Profile{
		// contains filtered or unexported fields
	},

	LoadingSweepWhite: Profile{
		// contains filtered or unexported fields
	},

	FuturisticSweep: Profile{
		// contains filtered or unexported fields
	},

	NeonPulse: Profile{
		// contains filtered or unexported fields
	},

	AmberTelemetry: Profile{
		// contains filtered or unexported fields
	},
}

Profiles contains named, fully pre-configured border effect profiles. Each profile bundles an effect, color scheme, tick rate, and inactive style into a single value you can apply in one call.

All five built-in profiles are described below. For the full catalogue of lower-level effects and palette primitives see Presets and Palettes.

Profile             Visual character
──────────────────  ─────────────────────────────────────────────────────
GradientArc         Purple→lavender→blue→purple arc sweeping clockwise
LoadingSweepWhite   White highlight scanning across the border title text
FuturisticSweep     Braille-interlaced multi-lane scanner in bright cyan
NeonPulse           Magenta neon-sign flicker with occasional dark frames
AmberTelemetry      Amber measured-tick telemetry sweep (ops-dashboard look)
View Source
var TitleCharsets = DecryptCharsets

TitleCharsets is a compatibility alias for older code that started using the earlier grouped charset name before DecryptCharsets became the preferred public entry point.

Functions

This section is empty.

Types

type Animator

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

Animator drives border animations on containers by ID.

func NewAnimator

func NewAnimator(root *container.Container) *Animator

NewAnimator creates an animator bound to the root container.

func (*Animator) ApplyProfile

func (a *Animator) ApplyProfile(p Profile, ids ...string)

ApplyProfile configures the animator from a pre-baked Profile in one call. It sets the tick rate to the profile's recommended value, registers a fresh Effect instance for each supplied container ID, and wires up the inactive style so unfocused panels show the profile's recommended resting color.

Each ID receives its own independent Effect so animation phases never lock together — a panel's arc position is not shared with its neighbours.

Example:

fx := borderfx.NewAnimator(cont)
fx.ApplyProfile(borderfx.Profiles.GradientArc, "root", "sidebar", "chart")
go fx.Run(ctx)

func (*Animator) Register

func (a *Animator) Register(id string, e *Effect)

Register assigns an effect to a container ID. Replaces any existing effect.

func (*Animator) RegisterMacro

func (a *Animator) RegisterMacro(id string, m Macro, p Palette)

RegisterMacro applies a high-level macro preset to a container ID.

func (*Animator) Run

func (a *Animator) Run(ctx context.Context) error

Run starts the animation loop. Blocks until ctx is done.

A single ticker is created once and reused for the lifetime of the loop. The previous pattern of creating a new ticker on every iteration caused the effective tick interval to be 64ms + tick_duration instead of a steady 64ms, making the animation speed vary with system load (e.g. faster when the mouse was moving because tick() completed sooner). A persistent ticker fires on a wall-clock schedule regardless of how long tick() takes.

func (*Animator) SetAlwaysActive

func (a *Animator) SetAlwaysActive(v bool)

SetAlwaysActive makes every registered effect animate at full brightness on every tick, regardless of which container is focused. When false (default), only the focused container's effect plays; others receive the inactive style or are cleared.

func (*Animator) SetInactiveStyle

func (a *Animator) SetInactiveStyle(styler func(id string, bc container.BorderCell) container.BorderCellStyle)

SetInactiveStyle sets a styler applied to unfocused registered windows.

func (*Animator) SetTickRate

func (a *Animator) SetTickRate(d time.Duration)

SetTickRate sets the animation tick interval. Must be called before Run(); changes made after Run() has started have no effect.

func (*Animator) Unregister

func (a *Animator) Unregister(id string)

Unregister removes animation from a container ID.

type DecryptCharsetGroup

type DecryptCharsetGroup struct {
	WarpCoreFlux   string
	LCARSTelemetry string
	Comms          string
	Controls       string
	Default        string
	Sensors        string
}

DecryptCharsetGroup groups the common scramble/decrypt character sets used by borderfx title reveal effects.

type Effect

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

Effect holds one animated border treatment.

func BracketScan

func BracketScan(bright, mid, dim cell.Color) *Effect

BracketScan runs restrained bracket-like ticks that sweep along the rails.

func BraidedScanner

func BraidedScanner(bright, mid, dim cell.Color) *Effect

BraidedScanner runs two luminous tracers with a softer, more segmented tail.

func BrailleDrift

func BrailleDrift(bright, mid, dim cell.Color) *Effect

BrailleDrift runs a continuous shaded-block spinner around the border.

func ColorScanner

func ColorScanner(bright, dim cell.Color) *Effect

ColorScanner simulates a scanning beam travelling clockwise around the border using only color changes — the original box-drawing rune characters are never replaced. This matches a CSS conic-gradient rotation effect.

func Cycle

func Cycle(colors []cell.Color) *Effect

Cycle steps through any custom color list you provide.

func DataTicks

func DataTicks(bright, mid, dim cell.Color) *Effect

DataTicks runs measured block ticks that move like professional telemetry.

func Dots6Spinner

func Dots6Spinner(bright, mid, dim cell.Color) *Effect

Dots6Spinner runs the spinner2 dots_6 frames across the border.

func Dots10Spinner

func Dots10Spinner(bright, mid, dim cell.Color) *Effect

Dots10Spinner runs the spinner2 dots_10 frames across the border.

func DualColorScanner

func DualColorScanner(bright, mid, dim cell.Color) *Effect

DualColorScanner runs two color beams in opposite directions around the border, preserving all original rune characters. Gives the rotating conic-gradient illusion of the HTML demo preview.

func DualGradientArc

func DualGradientArc(colorA, colorB, dim cell.Color, arcFraction float64) *Effect

DualGradientArc runs two gradient arcs simultaneously: one sweeping clockwise lit with colorA, one counter-clockwise lit with colorB. Where arcs overlap the brighter cell (closest to its head) wins. Cells outside both arcs receive dim. arcFraction is clamped to [0.05, 0.95].

func DualScanner

func DualScanner(bright, mid, dim cell.Color) *Effect

DualScanner runs two beams in opposite directions for a denser sci-fi trace.

func Fire

func Fire() *Effect

Fire flickers reds, oranges, yellows.

func FocusBrace

func FocusBrace(bright, mid, dim cell.Color) *Effect

FocusBrace performs a vertical brace sweep, then parks on the side rails.

func FocusMatrix

func FocusMatrix(bright, mid, dim cell.Color) *Effect

FocusMatrix performs a decode-style sweep, then parks as matrix glyph locks.

func FocusPins

func FocusPins(bright, mid, dim cell.Color) *Effect

FocusPins performs a crisp activation pass, then parks as corner pins.

func FocusPinsBrace

func FocusPinsBrace(bright, mid, dim cell.Color) *Effect

FocusPinsBrace uses brace-like side rails during activation.

func FocusPinsEmoji

func FocusPinsEmoji(bright, mid, dim cell.Color) *Effect

FocusPinsEmoji uses symbol-heavy sweeps and energized corner pins.

func FocusPinsMatrix

func FocusPinsMatrix(bright, mid, dim cell.Color) *Effect

FocusPinsMatrix uses denser decode-like blocks during activation.

func FocusPinsPower

func FocusPinsPower(bright, mid, dim cell.Color) *Effect

FocusPinsPower uses electrical glyphs and a sine-wave sweep before pinning corners.

func FocusPinsPulse

func FocusPinsPulse(bright, mid, dim cell.Color) *Effect

FocusPinsPulse uses softer round markers during activation.

func FocusPinsRail

func FocusPinsRail(bright, mid, dim cell.Color) *Effect

FocusPinsRail uses heavier rail blocks during activation before pinning corners.

func FocusPinsRibbon

func FocusPinsRibbon(bright, mid, dim cell.Color) *Effect

FocusPinsRibbon uses diamond ribbons during activation.

func FocusPinsShard

func FocusPinsShard(bright, mid, dim cell.Color) *Effect

FocusPinsShard uses compact shard markers during activation.

func FocusRail

func FocusRail(bright, mid, dim cell.Color) *Effect

FocusRail performs a brief dual-rail activation sweep, then parks as top-edge markers.

func FocusRibbon

func FocusRibbon(bright, mid, dim cell.Color) *Effect

FocusRibbon performs a braided sweep, then parks as a centered ribbon.

func Glow

func Glow(c cell.Color) *Effect

Glow pulses a single color between bright and nearly-dark.

func GradientArc

func GradientArc(colorA, colorB, dim cell.Color, arcFraction float64) *Effect

GradientArc renders a single arc of arcFraction of the total border length that sweeps clockwise. The leading edge of the arc glows with colorA, the trailing edge fades to colorB, and cells outside the arc receive dim.

For visually smooth gradients choose colorA and colorB that are adjacent in the xterm-256 cube (e.g. the pure-hue column: 21, 57, 93, 129, 165, 201 — each 36 apart). arcFraction is clamped to [0.05, 0.95].

func GradientArcN

func GradientArcN(stops []cell.Color, dim cell.Color, arcFraction float64) *Effect

GradientArcN is like GradientArc but accepts an ordered slice of color stops. stops[0] is the leading-edge color; stops[len-1] is the trailing-edge color. Cells outside the arc receive dim. arcFraction is clamped to [0.05, 0.95].

Example — purple→indigo→blue with stops from the xterm-256 pure-hue column:

GradientArcN([]cell.Color{
    cell.ColorNumber(201), // magenta
    cell.ColorNumber(129), // violet
    cell.ColorNumber(57),  // indigo
    cell.ColorNumber(21),  // blue
}, cell.ColorNumber(17), 0.4)

func Ice

func Ice() *Effect

Ice shimmers blues and cyans.

func InterlacedScanner

func InterlacedScanner(bright, mid, dim cell.Color) *Effect

InterlacedScanner runs a denser multi-lane tracer with a braille shimmer tail.

func Matrix

func Matrix() *Effect

Matrix pulses dark-to-bright green.

func Neon

func Neon(bright cell.Color) *Effect

Neon flickers like a neon sign with occasional dark frames.

func OrbitScanner

func OrbitScanner(bright, mid, dim cell.Color) *Effect

OrbitScanner runs a denser, tri-lane scanner for high-energy panels.

func Pulse

func Pulse(a, b cell.Color) *Effect

Pulse smoothly fades between two colors and back.

func RainScanner

func RainScanner(bright, mid, dim cell.Color) *Effect

RainScanner runs a restrained telemetry shimmer with sparse side markers and a faint bottom accent.

func Rainbow

func Rainbow() *Effect

Rainbow cycles through the full hue spectrum.

func Scanner

func Scanner(bright, dim cell.Color) *Effect

Scanner simulates a scanning beam traveling clockwise around the full border. Top and bottom edges therefore move in opposite visual directions.

func ShardScanner

func ShardScanner(bright, mid, dim cell.Color) *Effect

ShardScanner runs a sharper segmented scanner with longer travel streaks.

func SpinnerPulse

func SpinnerPulse(bright, mid, dim cell.Color) *Effect

SpinnerPulse runs the spinner2 pulse frames across the border.

func StaticNoise

func StaticNoise(bright, mid, dim cell.Color) *Effect

StaticNoise flickers clean border glyphs with a cool noisy signal field, without any moving artifact or traveling tracer.

func Synthwave

func Synthwave() *Effect

Synthwave cycles purple, pink, cyan.

func TextSweep

func TextSweep(sweepColor, restColor cell.Color) *Effect

TextSweep creates a left-to-right sweep effect on the border title text. The title text is held at grey (restColor) and a white (sweepColor) window quickly sweeps across it left to right. Text returns to grey once the window passes. The sweep repeats continuously to signal active focus or loading. The sweep head advances 3 characters per frame for a fast, snappy feel.

func TextSweepWidth

func TextSweepWidth(sweepColor, restColor cell.Color, windowWidth, speed int) *Effect

TextSweepWidth is like TextSweep but lets the caller choose the sweep window width and speed. Speed is how many characters the sweep head advances per frame (higher = faster).

func Warp

func Warp() *Effect

Warp simulates warp core energy: blue-white pulse with afterglow.

func (*Effect) Next

func (e *Effect) Next() cell.Color

Next advances one frame and returns the effect's primary color.

func (*Effect) NextStyler

func (e *Effect) NextStyler() container.BorderCellStyler

NextStyler advances one frame and returns a per-border-cell styler.

func (*Effect) Reset

func (e *Effect) Reset()

Reset restarts from frame 0.

type LoadingBackground

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

LoadingBackground draws a striped loading surface for widgets that are still booting or hydrating content.

func NewLoadingBackground

func NewLoadingBackground(opts ...LoadingBackgroundOption) LoadingBackground

NewLoadingBackground returns a loading background with the supplied options.

func (LoadingBackground) Draw

Draw renders the striped loading background into rect and then draws the provided loading frame on top of it.

func (LoadingBackground) RowCellOpts

func (lb LoadingBackground) RowCellOpts(row int) []cell.Option

RowCellOpts returns the cell options for the supplied row of the loading background.

type LoadingBackgroundOption

type LoadingBackgroundOption interface {
	// contains filtered or unexported methods
}

LoadingBackgroundOption configures a loading background renderer.

func InterlacedLoadingBackground

func InterlacedLoadingBackground(primary, secondary cell.Color) LoadingBackgroundOption

InterlacedLoadingBackground alternates two background colors row-by-row.

func LoadingTextColor

func LoadingTextColor(color cell.Color) LoadingBackgroundOption

LoadingTextColor sets the foreground color used for loading copy rendered on top of the background stripes.

type LoadingOverlay

type LoadingOverlay struct {
	terminalapi.Terminal // all non-overridden calls delegate here
	// contains filtered or unexported fields
}

LoadingOverlay wraps a terminal and paints an interlaced loading background over one or more named panels during the boot or hydration phase of your app.

It implements terminalapi.Terminal — pass it wherever a terminal is expected (container.New, termdash.Run, etc.). All method calls are forwarded to the wrapped terminal; only Flush() is intercepted to paint the overlay.

Quickstart — three steps:

  1. Wrap your terminal:

    lo := borderfx.WrapWithLoading(t, func(size image.Point, id string) image.Rectangle { outer := myLayout.BorderRect(size, id) // the panel's outer border rect return outer.Inset(1) // strip the 1-cell border })

  2. Set loading content and show the overlay:

    lo.SetContent("sensors", " :: carrier lock ::\n\n preparing .......\n") lo.Show()

  3. Hide when boot is done:

    lo.Hide()

func WrapWithLoading

func WrapWithLoading(t terminalapi.Terminal, rectFn PanelRectFunc) *LoadingOverlay

WrapWithLoading wraps t and returns a LoadingOverlay ready to display an interlaced boot screen.

rectFn maps (terminal size, panel ID) to the drawable inner rectangle for that panel. It is called on every Flush so the overlay stays correct after terminal resize. For a bordered panel the inner rect is the outer border rect inset by 1:

func(size image.Point, id string) image.Rectangle {
    return outerBorderRects(size)[id].Inset(1)
}

func (*LoadingOverlay) Flush

func (lo *LoadingOverlay) Flush() error

Flush flushes the wrapped terminal's back buffer, then — when the overlay is visible — paints the interlaced loading background into each registered panel. This method satisfies terminalapi.Terminal and overrides the embedded one.

func (*LoadingOverlay) Hide

func (lo *LoadingOverlay) Hide()

Hide removes the loading overlay, revealing the live widget content beneath. Call this when your application has finished booting or loading.

func (*LoadingOverlay) SetContent

func (lo *LoadingOverlay) SetContent(id, text string)

SetContent sets the loading text displayed inside a named panel. Call before Show() to pre-populate panels, or at any time during the loading phase to update the copy. Use "\n" to separate lines.

func (*LoadingOverlay) Show

func (lo *LoadingOverlay) Show()

Show makes the loading overlay visible.

type Macro

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

Macro is a reusable, high-level border animation preset.

func (Macro) Name

func (m Macro) Name() string

Name returns the stable preset name.

func (Macro) Register

func (m Macro) Register(a *Animator, id string, p Palette)

Register applies the macro to an animator in one call.

func (Macro) With

func (m Macro) With(p Palette) *Effect

With renders the macro with the supplied palette.

type Palette

type Palette struct {
	Bright cell.Color
	Mid    cell.Color
	Dim    cell.Color
}

Palette groups the colors used by the higher-level borderfx presets.

func Colors

func Colors(bright, mid, dim cell.Color) Palette

Colors builds a palette from explicit bright, mid, and dim colors.

func Duo

func Duo(bright, dim cell.Color) Palette

Duo builds a palette from a bright accent and dim resting color. The mid tone is derived automatically.

func (Palette) Apply

func (p Palette) Apply(m Macro) *Effect

Apply renders the supplied macro using this palette.

type PanelRectFunc

type PanelRectFunc func(termSize image.Point, id string) image.Rectangle

PanelRectFunc maps a terminal size and panel ID to the drawable content rectangle for that panel. For a panel with a 1-cell border, shrink the outer border rectangle by 1 on all sides using rect.Inset(1).

type Profile

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

Profile is a fully pre-configured border effect. Colors, animation speed, and the recommended inactive-panel style are all baked in — no palette selection required.

Quickstart:

fx := borderfx.NewAnimator(cont)
fx.ApplyProfile(borderfx.Profiles.GradientArc, "root", "panel1", "panel2")
go fx.Run(ctx)

func (Profile) Description

func (p Profile) Description() string

Description returns a human-readable summary of the visual effect.

func (Profile) InactiveColor

func (p Profile) InactiveColor() cell.Color

InactiveColor returns the color used to style unfocused panels.

func (Profile) Name

func (p Profile) Name() string

Name returns the profile's stable identifier.

func (Profile) New

func (p Profile) New() *Effect

New returns a fresh *Effect instance for this profile. Each panel must get its own instance so animation phases are independent.

func (Profile) TickRate

func (p Profile) TickRate() time.Duration

TickRate returns the recommended animation tick interval.

type TitleSpec

type TitleSpec struct {
	Base             string
	Charset          string
	Spinner          spin.Spinner
	LeftSpin         spin.Spinner
	RightSpin        spin.Spinner
	SpinnerPlacement TitleSpinnerPlacement
}

TitleSpec describes one focus-aware border title.

Base and Charset cover the common reveal effect. Spinner, LeftSpin, and RightSpin are lower-level hooks for title ornamentation so callers can build outward from a single stable title representation rather than choosing between competing title APIs.

func DecryptingTitle

func DecryptingTitle(base, charset string) TitleSpec

DecryptingTitle returns a title spec that reveals itself from the provided charset when the pane becomes focused.

This is the simplest public entry point for the "decrypt on focus" title effect used by the borderfx demo. Callers can keep building on the returned spec with the existing spinner fields or the chainable helpers below.

func (TitleSpec) Decorated

func (s TitleSpec) Decorated(step int) string

Decorated returns the title with its spinner frame, if configured.

func (TitleSpec) HasSpinners

func (s TitleSpec) HasSpinners() bool

HasSpinners reports whether the spec has any spinner configured.

func (TitleSpec) Plain

func (s TitleSpec) Plain() string

Plain returns the resting version of the title.

func (TitleSpec) Scrambled

func (s TitleSpec) Scrambled(reveal int) string

Scrambled returns the decode/reveal version of the title.

func (TitleSpec) WithLeftSpinner

func (s TitleSpec) WithLeftSpinner(spinner spin.Spinner) TitleSpec

WithLeftSpinner returns a copy of the title spec with a left-side spinner.

func (TitleSpec) WithRightSpinner

func (s TitleSpec) WithRightSpinner(spinner spin.Spinner) TitleSpec

WithRightSpinner returns a copy of the title spec with a right-side spinner.

type TitleSpinnerPlacement

type TitleSpinnerPlacement int

TitleSpinnerPlacement controls where a spinner is rendered relative to a title.

const (
	// TitleSpinnerRight appends the spinner to the title.
	TitleSpinnerRight TitleSpinnerPlacement = iota + 1
	// TitleSpinnerLeft prefixes the spinner to the title.
	TitleSpinnerLeft
)

Directories

Path Synopsis
Binary borderfxdemo - animated LCARS-style borders.
Binary borderfxdemo - animated LCARS-style borders.

Jump to

Keyboard shortcuts

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