Documentation
¶
Overview ¶
Package widget provides reusable TUI components.
Package widget provides reusable composable sub-models for workspace views.
Index ¶
- func Truncate(s string, maxWidth int) string
- type AttachFileRequestMsg
- type AttachStatus
- type Attachment
- type Composer
- func (c *Composer) AddAttachment(path string) tea.Cmd
- func (c *Composer) Attachments() []Attachment
- func (c *Composer) Blur()
- func (c *Composer) Focus() tea.Cmd
- func (c *Composer) HandleEditorReturn(msg EditorReturnMsg) tea.Cmd
- func (c *Composer) HasContent() bool
- func (c *Composer) InputActive() bool
- func (c *Composer) InsertPaste(text string)
- func (c *Composer) Mode() ComposerMode
- func (c *Composer) OpenEditor() tea.Cmd
- func (c *Composer) ProcessPaste(text string) (string, tea.Cmd)
- func (c *Composer) Reset()
- func (c *Composer) SetSize(w, h int)
- func (c *Composer) SetValue(s string)
- func (c *Composer) ShortHelp() []key.Binding
- func (c *Composer) Submit() tea.Cmd
- func (c *Composer) Update(msg tea.Msg) tea.Cmd
- func (c *Composer) Value() string
- func (c *Composer) View() string
- type ComposerContent
- type ComposerMode
- type ComposerOption
- type ComposerSubmitMsg
- type Content
- type EditorReturnMsg
- type Kanban
- func (k *Kanban) FocusColumn(colIdx int)
- func (k *Kanban) FocusedCard() *KanbanCard
- func (k *Kanban) FocusedColumn() int
- func (k *Kanban) MoveDown()
- func (k *Kanban) MoveLeft()
- func (k *Kanban) MoveRight()
- func (k *Kanban) MoveUp()
- func (k *Kanban) SetColumns(cols []KanbanColumn)
- func (k *Kanban) SetFocused(focused bool)
- func (k *Kanban) SetSize(w, h int)
- func (k *Kanban) View() string
- type KanbanCard
- type KanbanColumn
- type List
- func (l *List) Filtering() bool
- func (l *List) Items() []ListItem
- func (l *List) Len() int
- func (l *List) SelectByID(id string) bool
- func (l *List) SelectIndex(idx int)
- func (l *List) Selected() *ListItem
- func (l *List) SelectedIndex() int
- func (l *List) SetEmptyMessage(msg empty.Message)
- func (l *List) SetEmptyText(text string)
- func (l *List) SetFocused(focused bool)
- func (l *List) SetItems(items []ListItem)
- func (l *List) SetLoading(loading bool)
- func (l *List) SetSize(w, h int)
- func (l *List) StartFilter()
- func (l *List) StopFilter()
- func (l *List) Update(msg tea.Msg) tea.Cmd
- func (l *List) View() string
- type ListItem
- type Preview
- func (p *Preview) Fields() []PreviewField
- func (p *Preview) ScrollDown(n int)
- func (p *Preview) ScrollUp(n int)
- func (p *Preview) SetBody(html string)
- func (p *Preview) SetFields(fields []PreviewField)
- func (p *Preview) SetSize(w, h int)
- func (p *Preview) SetTitle(title string)
- func (p *Preview) View() string
- type PreviewField
- type SplitPane
- type UploadFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AttachFileRequestMsg ¶
type AttachFileRequestMsg struct{}
AttachFileRequestMsg is sent when the user presses ctrl+f to attach a file. The containing view should display a hint (e.g. "Paste a file path or drag a file into the terminal").
type AttachStatus ¶
type AttachStatus int
AttachStatus tracks upload progress for a single attachment.
const ( AttachPending AttachStatus = iota // queued, not yet uploading AttachUploading // upload in progress AttachUploaded // upload complete, SGID available AttachFailed // upload failed )
type Attachment ¶
type Attachment struct {
Path string
Filename string
ContentType string
SGID string // populated after upload
Status AttachStatus // current upload state
Err error // set when Status == AttachFailed
}
Attachment represents a file being attached to the composed content.
type Composer ¶
type Composer struct {
// contains filtered or unexported fields
}
Composer is a reusable Markdown editing widget with attachment support.
func NewComposer ¶
func NewComposer(styles *tui.Styles, opts ...ComposerOption) *Composer
NewComposer creates a new Composer widget.
func (*Composer) AddAttachment ¶
AddAttachment queues a file for attachment and triggers upload if an upload function is set.
func (*Composer) Attachments ¶
func (c *Composer) Attachments() []Attachment
Attachments returns the current attachment list.
func (*Composer) HandleEditorReturn ¶
func (c *Composer) HandleEditorReturn(msg EditorReturnMsg) tea.Cmd
HandleEditorReturn populates the composer with the editor's output.
func (*Composer) HasContent ¶
HasContent returns true if there is text or attachments.
func (*Composer) InputActive ¶
InputActive returns true if the composer is capturing text input.
func (*Composer) InsertPaste ¶
InsertPaste appends pasted text at the current cursor position. If the text contains newlines or markdown, the composer auto-expands to rich mode.
func (*Composer) Mode ¶
func (c *Composer) Mode() ComposerMode
Mode returns the current composer mode.
func (*Composer) OpenEditor ¶
OpenEditor launches $EDITOR with the current content. The containing view must handle the returned EditorReturnMsg by calling HandleEditorReturn.
func (*Composer) ProcessPaste ¶
ProcessPaste handles pasted text, detecting file paths and adding them as attachments. Returns remaining text that should be inserted, and any commands to execute.
func (*Composer) Submit ¶
Submit creates a tea.Cmd that uploads any pending attachments and returns ComposerSubmitMsg.
type ComposerContent ¶
type ComposerContent struct {
Markdown string
Attachments []Attachment
IsPlain bool // true when no formatting and no attachments
}
ComposerContent is the structured output from the composer.
type ComposerMode ¶
type ComposerMode int
ComposerMode determines the input style.
const ( // ComposerQuick uses a single-line textinput; Enter sends. ComposerQuick ComposerMode = iota // ComposerRich uses a multi-line textarea; Enter inserts newline, ctrl+enter sends. ComposerRich )
type ComposerOption ¶
type ComposerOption func(*Composer)
ComposerOption configures a Composer.
func WithAutoExpand ¶
func WithAutoExpand(auto bool) ComposerOption
WithAutoExpand enables auto-switching from quick to rich mode.
func WithContext ¶
func WithContext(ctx context.Context) ComposerOption
WithContext sets the cancellable context for upload operations. Uploads started with this context will abort if the context is canceled (e.g., on account switch). Defaults to context.Background().
func WithMode ¶
func WithMode(mode ComposerMode) ComposerOption
WithMode sets the initial composer mode.
func WithPlaceholder ¶
func WithPlaceholder(text string) ComposerOption
WithPlaceholder sets the placeholder text for both input widgets.
func WithUploadFn ¶
func WithUploadFn(fn UploadFunc) ComposerOption
WithUploadFn sets the file upload callback.
type ComposerSubmitMsg ¶
type ComposerSubmitMsg struct {
Content ComposerContent
Err error
}
ComposerSubmitMsg is sent when the composer finishes processing a submission.
type Content ¶
type Content struct {
// contains filtered or unexported fields
}
Content renders HTML or Markdown content as terminal-styled text. It handles the HTML→Markdown→glamour pipeline and provides scrolling.
func NewContent ¶
NewContent creates a new content renderer.
func (*Content) ScrollDown ¶
ScrollDown scrolls the content down by n lines.
func (*Content) SetContent ¶
SetContent sets the raw HTML or Markdown content and renders it. Skips re-render if content is unchanged.
type EditorReturnMsg ¶
EditorReturnMsg is sent when the external editor process exits. Containing views must handle this and call HandleEditorReturn.
type Kanban ¶
type Kanban struct {
// contains filtered or unexported fields
}
Kanban renders a horizontal multi-column kanban board.
func (*Kanban) FocusColumn ¶
FocusColumn sets focus to the given column index and clamps cardIdx.
func (*Kanban) FocusedCard ¶
func (k *Kanban) FocusedCard() *KanbanCard
FocusedCard returns the focused card, or nil.
func (*Kanban) FocusedColumn ¶
FocusedColumn returns the index of the focused column.
func (*Kanban) MoveDown ¶
func (k *Kanban) MoveDown()
MoveDown moves focus to the next card in the current column.
func (*Kanban) MoveLeft ¶
func (k *Kanban) MoveLeft()
MoveLeft moves focus to the previous column, saving/restoring per-column cardIdx.
func (*Kanban) MoveRight ¶
func (k *Kanban) MoveRight()
MoveRight moves focus to the next column, saving/restoring per-column cardIdx.
func (*Kanban) MoveUp ¶
func (k *Kanban) MoveUp()
MoveUp moves focus to the previous card in the current column.
func (*Kanban) SetColumns ¶
func (k *Kanban) SetColumns(cols []KanbanColumn)
SetColumns replaces all columns, preserving cursor by identity.
type KanbanCard ¶
type KanbanCard struct {
ID string
Title string
Assignees string
DueOn string
StepsProgress string // e.g. "3/5"
CommentsCount int
Completed bool
Boosts int // number of boosts (will render as [♥ N])
}
KanbanCard represents a card within a column.
type KanbanColumn ¶
type KanbanColumn struct {
ID string
Title string
Color string // Basecamp color name (red, blue, green, etc.)
Deferred bool // true for Done/NotNow columns (no cards fetched)
Count int // total card count (including deferred)
Items []KanbanCard
}
KanbanColumn represents a column in the kanban board.
type List ¶
type List struct {
// contains filtered or unexported fields
}
List is an async-capable list widget with filtering, scrolling, and selection.
func (*List) SelectByID ¶
SelectByID scans filtered items for a matching ID, sets cursor + adjusts offset. Returns true if found, false if not.
func (*List) SelectIndex ¶
SelectIndex sets the cursor to the given index (clamped to bounds).
func (*List) SelectedIndex ¶
SelectedIndex returns the cursor position.
func (*List) SetEmptyMessage ¶
SetEmptyMessage sets a structured empty state with title, body, and hints.
func (*List) SetEmptyText ¶
SetEmptyText sets the message shown when no items exist.
func (*List) SetLoading ¶
SetLoading puts the list in loading state.
func (*List) StopFilter ¶
func (l *List) StopFilter()
StopFilter exits interactive filter mode and restores all items.
type ListItem ¶
type ListItem struct {
ID string
Title string
Description string
Extra string // right-aligned detail (count, date, etc.)
Boosts int // number of boosts (will render as [♥ N])
Marked bool // visual mark (star, check, etc.)
Header bool // section header (non-selectable, rendered differently)
}
ListItem represents a single item in an async list.
func (ListItem) FilterValue ¶
FilterValue returns the string used for filtering.
type Preview ¶
type Preview struct {
// contains filtered or unexported fields
}
Preview renders a detail pane with key-value fields and an optional body.
func NewPreview ¶
NewPreview creates a new preview pane.
func (*Preview) Fields ¶
func (p *Preview) Fields() []PreviewField
Fields returns the current metadata fields.
func (*Preview) ScrollDown ¶
ScrollDown scrolls the body content down.
func (*Preview) SetFields ¶
func (p *Preview) SetFields(fields []PreviewField)
SetFields sets the key-value metadata fields.
type PreviewField ¶
PreviewField is a key-value pair shown in the preview header.
type SplitPane ¶
type SplitPane struct {
// contains filtered or unexported fields
}
SplitPane renders two panels side by side with a divider.
func NewSplitPane ¶
NewSplitPane creates a new split pane with the given left:right ratio.
func (*SplitPane) IsCollapsed ¶
IsCollapsed returns true if the pane is showing single-panel mode.
func (*SplitPane) RightWidth ¶
RightWidth returns the right panel width (excluding divider).
func (*SplitPane) SetContent ¶
SetContent sets the content for both panels.