components

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SlashCommands = []SlashCmd{
	{"/clear", "start a new conversation"},
	{"/compact", "compact the current conversation"},
	{"/exit", "exit Looprig"},
}

SlashCommands is the canonical list (exported so package tui can map Name→action).

Functions

This section is empty.

Types

type FileComplete

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

FileComplete is a filtered file list with a wrapping cursor — the @path completion panel, the disk-backed sibling of SlashComplete. It is display-only: package tui computes the candidate list (the filesystem read) and feeds it here.

func NewFileComplete

func NewFileComplete(items []FileItem) *FileComplete

NewFileComplete returns a completer over items, or nil when empty (nil = hidden).

func (*FileComplete) Cursor

func (f *FileComplete) Cursor() int

Cursor returns the absolute selected index in the filtered list.

func (*FileComplete) Down

func (f *FileComplete) Down()

Down moves the cursor down, wrapping to the top.

func (*FileComplete) SelectWindowRow

func (f *FileComplete) SelectWindowRow(row, maxRows int) bool

SelectWindowRow moves the cursor to a row in the currently rendered maxRows window. It returns whether the selection changed; rows outside the visible window are ignored.

func (*FileComplete) Selected

func (f *FileComplete) Selected() FileItem

Selected returns the item under the cursor.

func (*FileComplete) Up

func (f *FileComplete) Up()

Up moves the cursor up, wrapping to the bottom.

func (*FileComplete) View

func (f *FileComplete) View() string

View renders the filtered list at its natural content width.

func (*FileComplete) ViewWidth

func (f *FileComplete) ViewWidth(width int) string

ViewWidth renders the filtered list as a tray whose rows are padded or clamped ANSI-safely to width display columns.

func (*FileComplete) ViewWindow

func (f *FileComplete) ViewWindow(width, maxRows int) string

ViewWindow renders a full-width tray capped to maxRows and keeps the selected path in the visible window. View and ViewWidth remain the unbounded variants.

func (*FileComplete) ViewWindowBackground

func (f *FileComplete) ViewWindowBackground(width, maxRows int, selectedBg color.Color) string

ViewWindowBackground renders the bounded tray with a caller-provided selected-row fill.

type FileItem

type FileItem struct {
	Path  string
	IsDir bool
}

FileItem is one @path completion candidate. Path is the value to complete to (e.g. "src" or "src/main.go"); IsDir drives the trailing "/" affordance and whether selecting it keeps the panel open to drill in.

type InputBox

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

InputBox wraps a bubbles textarea: an auto-growing editor with the shared "▌" accent bar as its prompt (matching user-message rows), rendered inside a bordered box. No char limit, no line numbers, no "> " prompt. The box height tracks the content between minLines and maxInputLines.

minLines, bg, and padV are per-INSTANCE so a single composer implementation serves both shells: the scrollback Screen keeps the historical 1-line, background-free, unpadded editor (the NewInputBox defaults), and the modern viewport opts into a taller, gray-filled, padded panel via SetMinLines/SetBackground/SetVerticalPadding. Nothing else changes, so the scrollback composer stays byte-identical.

func NewInputBox

func NewInputBox() InputBox

NewInputBox returns a configured, focused prompt editor.

Enter is left unbound on the textarea so screen.go can use it as submit; newline insertion is bound to TWO keys so it works regardless of terminal capability:

  • Shift+Enter (PRIMARY, preferred) — only distinguishable from plain Enter on terminals that implement the Kitty keyboard protocol AND only when the program requests "report all keys as escape codes" (flag 8). screen.go's View() sets KeyboardEnhancements.ReportAllKeysAsEscapeCodes for exactly this reason; without it the Kitty spec keeps Enter as a legacy byte and Shift+Enter arrives as plain Enter (→ submit). Supported on kitty, Ghostty, WezTerm, foot, Alacritty, and recent iTerm2 (with the protocol option enabled).
  • Ctrl+J (UNIVERSAL FALLBACK) — the LF byte (0x0A), delivered by EVERY terminal with no protocol required; v2 decodes it as Code 'j' + ModCtrl (String()=="ctrl+j"). This is the only way to type a literal newline on terminals that cannot deliver a distinct Shift+Enter (Apple Terminal, many VS Code setups). It is purely additive — Shift+Enter stays primary. Ctrl+J does not collide with any global binding in screen.go (which handles only ctrl+c, ctrl+t, and esc).

func (*InputBox) Focus

func (b *InputBox) Focus() tea.Cmd

Focus focuses the editor and returns its Blink command.

func (InputBox) Height

func (b InputBox) Height() int

Height is the editor's visible content height in rows: the textarea's current row count clamped to [minInputLines, maxInputLines]. It excludes the border frame.

It reads ta.Height() rather than ta.LineCount() so it tracks VISUAL rows (a single long logical line that soft-wraps occupies several rows), matching what View() actually renders. DynamicHeight keeps ta.Height() equal to the total visual line count (capped at contentHeightSecurityLimit, far above maxInputLines), so once capHeight has applied the visible cap this returns that capped value, and before capping it returns the true content height — both already within [min, max] after clamp.

func (*InputBox) Reset

func (b *InputBox) Reset()

Reset clears the text.

func (*InputBox) Resize

func (b *InputBox) Resize(width int)

Resize sets the box width; the inner textarea is the box width minus the border's horizontal frame. The height auto-grows with content, so it is not set here.

func (*InputBox) SetBackground

func (b *InputBox) SetBackground(bg color.Color)

SetBackground enables the MODERN gray panel fill of color bg behind every composer row. It derives bg's SGR open/reset pair ONCE (styles.DeriveBackgroundSGR) and View then paints each rendered line to the box width with it — a per-row fill that re-opens the background after the textarea's internal SGR resets, so it never leaves the holes a plain Background() wrap does (and the empty end-of-buffer rows fill too). It does NOT tint the textarea's own Base style: the focused cursor line therefore keeps the empty style NewInputBox already set (no default "black box"), and the uniform post-fill supplies the gray instead. The scrollback Screen never calls this, so its composer stays background-free (styles.BoxStyle). MODERN-safe: the viewport re-renders the whole frame per tick, so the fill never strands into scrollback the way it could in the print-once surface.

func (*InputBox) SetMinLines

func (b *InputBox) SetMinLines(n int)

SetMinLines sets the composer's minimum visible height (default minInputLines). The MODERN viewport uses 2 for a roomier panel; the scrollback Screen never calls this, so it keeps the historical single line. Below-1 values are ignored (fail-safe). It moves BOTH the textarea's own MinHeight and the visible cap in lockstep, then re-caps so the change takes effect immediately.

func (*InputBox) SetValue

func (b *InputBox) SetValue(s string)

SetValue replaces the text.

func (*InputBox) SetVerticalPadding

func (b *InputBox) SetVerticalPadding(n int)

SetVerticalPadding sets the number of padding rows View draws ABOVE and BELOW the text region, so the modern composer reads as a padded box ([pad][text…][pad]) rather than a bare line. It defaults to 0 (the scrollback Screen never calls this, so its composer stays byte-identical); the modern viewport sets 1. Negative values are ignored (fail-safe). Each padding row carries the box's ▌ accent edge (the rail runs unbroken through the padding), gray-filled by the modern panel (SetBackground) so it reads as part of the box. Padding does NOT change the editor's auto-grow — the text region still grows to maxInputLines — it only frames it, so the box's rendered height is the text height plus 2*padV.

func (*InputBox) Update

func (b *InputBox) Update(msg tea.Msg) tea.Cmd

Update forwards the message to the textarea and grows the editor to fit the current content (capped at maxInputLines, past which it scrolls internally).

func (*InputBox) Value

func (b *InputBox) Value() string

Value returns the current text.

func (*InputBox) View

func (b *InputBox) View() string

View renders the editor inside the bordered box. The box grows with the content because the inner textarea height tracks Height(). In MODERN mode (SetBackground called) every rendered row — the ▌ edge, its one-column left pad, the text, and any empty end-of-buffer rows — is filled to the box width with the gray panel color, so the composer reads as one continuous panel; the default (scrollback) box paints nothing.

With vertical padding (SetVerticalPadding, modern sets 1) padV rail rows are added ABOVE and BELOW the text rows so the composer reads as a padded box ([pad][text…][pad]) rather than a bare line. A padding row is the box's ▌ edge alone (so the accent rail runs unbroken through it), gray-filled to the box width when a background is set. The scrollback composer sets neither background nor padding, so it returns the bare box unchanged (byte-identical).

type SessionComplete

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

SessionComplete selects records, while each record renders as two content rows plus one unboxed padding row. The accent rail remains continuous across all three rows.

func NewSessionComplete

func NewSessionComplete(items []SessionItem) *SessionComplete

func (*SessionComplete) Cursor

func (s *SessionComplete) Cursor() int

func (*SessionComplete) Down

func (s *SessionComplete) Down()

func (*SessionComplete) SelectWindowRow

func (s *SessionComplete) SelectWindowRow(row, maxRows int) bool

SelectWindowRow selects by record. The blank third row between records remains inert.

func (*SessionComplete) Selected

func (s *SessionComplete) Selected() SessionItem

func (*SessionComplete) Up

func (s *SessionComplete) Up()

func (*SessionComplete) ViewWindowBackground

func (s *SessionComplete) ViewWindowBackground(width, maxRows int, selectedBg color.Color) string

type SessionItem

type SessionItem struct {
	ID       string
	Title    string
	State    string
	Activity string
	LastUsed string
	ShortID  string
}

SessionItem is the already-formatted, secret-free view data for one session record.

type SlashCmd

type SlashCmd struct {
	Name string // e.g. "/clear"
	Desc string // e.g. "clear the conversation"
}

SlashCmd is one slash command's display metadata. The action is dispatched by package tui keyed on Name; this widget only filters and displays.

type SlashComplete

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

SlashComplete is a filtered command list with a wrapping cursor.

func NewSlashComplete

func NewSlashComplete(prefix string) *SlashComplete

NewSlashComplete returns a case-insensitive, relevance-ranked completer for prefix. The optional leading slash is ignored while matching. Returns nil when nothing matches (nil = panel hidden).

func NewSlashCompleteWithCommands

func NewSlashCompleteWithCommands(prefix string, commands []SlashCmd) *SlashComplete

NewSlashCompleteWithCommands builds a completer from an immutable caller-owned catalog. The slice and aliases are copied so a live tray cannot change underneath keyboard input.

func (*SlashComplete) Cursor

func (s *SlashComplete) Cursor() int

Cursor returns the absolute selected index in the filtered list.

func (*SlashComplete) Down

func (s *SlashComplete) Down()

Down moves the cursor down, wrapping to the top.

func (*SlashComplete) SelectWindowRow

func (s *SlashComplete) SelectWindowRow(row, maxRows int) bool

SelectWindowRow moves the cursor to a row in the currently rendered maxRows window. It returns whether the selection changed; rows outside the visible window are ignored.

func (*SlashComplete) Selected

func (s *SlashComplete) Selected() SlashCmd

Selected returns the item under the cursor.

func (*SlashComplete) Up

func (s *SlashComplete) Up()

Up moves the cursor up, wrapping to the bottom.

func (*SlashComplete) View

func (s *SlashComplete) View() string

View renders the filtered list at its natural content width.

func (*SlashComplete) ViewWidth

func (s *SlashComplete) ViewWidth(width int) string

ViewWidth renders the filtered list as a tray whose rows are padded or clamped ANSI-safely to width display columns.

func (*SlashComplete) ViewWindow

func (s *SlashComplete) ViewWindow(width, maxRows int) string

ViewWindow renders a full-width tray capped to maxRows and keeps the selected command in the visible window. View and ViewWidth remain the unbounded variants.

func (*SlashComplete) ViewWindowBackground

func (s *SlashComplete) ViewWindowBackground(width, maxRows int, selectedBg color.Color) string

ViewWindowBackground renders the bounded tray with a caller-provided selected-row fill.

type ValueComplete

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

ValueComplete is a filtered runtime-choice tray with a record cursor.

func NewValueComplete

func NewValueComplete(items []ValueItem, query string) *ValueComplete

func (*ValueComplete) Cursor

func (v *ValueComplete) Cursor() int

func (*ValueComplete) Down

func (v *ValueComplete) Down()

func (*ValueComplete) Len

func (v *ValueComplete) Len() int

func (*ValueComplete) SelectWindowRow

func (v *ValueComplete) SelectWindowRow(row, maxRows int) bool

func (*ValueComplete) Selected

func (v *ValueComplete) Selected() ValueItem

func (*ValueComplete) Up

func (v *ValueComplete) Up()

func (*ValueComplete) ViewWindow

func (v *ValueComplete) ViewWindow(width, maxRows int) string

func (*ValueComplete) ViewWindowBackground

func (v *ValueComplete) ViewWindowBackground(width, maxRows int, selectedBg color.Color) string

type ValueItem

type ValueItem struct {
	ID          string
	Label       string
	Description string
	Aliases     []string
}

ValueItem is one typed runtime choice. ID is the opaque payload returned on selection.

Jump to

Keyboard shortcuts

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