Documentation
¶
Overview ¶
Package noteview fetches one td note and renders it as a reusable read-only card. Hosts size the card and decide when it is focused; the Notes plugin remains the editor.
Index ¶
- func CopyID(d *Data) tea.Cmd
- func CopyMarkdown(d *Data) tea.Cmd
- func Fetch(workDir, noteID string) tea.Cmd
- func FormatMarkdown(d *Data) string
- func Heading(d *Data) string
- func LayoutTabStrip(group Tabs, width int, focused bool) tabs.Strip
- func NormalizeID(id string) string
- func StoreTargets(workDir string) []livewatch.Target
- type Data
- type FetchedMsg
- type LoadedMsg
- type Model
- func (m *Model) Arm(modelID int, noteID string, epoch uint64)
- func (m *Model) Data() *Data
- func (m *Model) Err() error
- func (m *Model) Focused() bool
- func (m *Model) HandleKey(k tea.KeyMsg) (bool, tea.Cmd)
- func (m *Model) HasScrollbar() bool
- func (m *Model) Load(modelID int, workDir, noteID string, epoch uint64) tea.Cmd
- func (m *Model) Loading() bool
- func (m *Model) ModelID() int
- func (m *Model) NeedsLoad() bool
- func (m *Model) NoteID() string
- func (m *Model) Observe()
- func (m *Model) OffsetAtTrackRow(row int) int
- func (m *Model) Refresh(suppressed bool) tea.Cmd
- func (m *Model) RefreshPending() bool
- func (m *Model) ResultMatches(msg LoadedMsg) bool
- func (m *Model) Scroll(delta int)
- func (m *Model) ScrollAtBoundary(delta int) bool
- func (m *Model) ScrollOffset() int
- func (m *Model) ScrollToOffset(offset int) bool
- func (m *Model) ScrollbarParams() ui.ScrollbarParams
- func (m *Model) SetFocused(focused bool)
- func (m *Model) SetLoader(loader NoteLoader)
- func (m *Model) SetPendingScroll(offset int)
- func (m *Model) SetResult(msg LoadedMsg) bool
- func (m *Model) SetSize(width, height int)
- func (m *Model) Title() string
- func (m *Model) View() string
- type NotModified
- type NoteLoader
- type TabHit
- type TabStrip
- type Tabs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatMarkdown ¶
FormatMarkdown renders one note as a heading plus its body.
func LayoutTabStrip ¶
LayoutTabStrip is the note header: an end-truncated title strip so the note ID stays visible. Hosts draw this row and register hit regions from the same Tabs so a click cannot land on a tab that was never rendered.
func NormalizeID ¶
NormalizeID is the tab key. Invalid values are empty.
func StoreTargets ¶
StoreTargets returns what to watch for changes to the td store backing workDir, or nil when no store can be resolved. Notes live in the same SQLite directory as issues; watching the directory catches WAL writes.
Types ¶
type Data ¶
type Data struct {
ID string `json:"id"`
Title string `json:"title"`
Content string `json:"content"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Pinned bool `json:"pinned"`
Archived bool `json:"archived"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
}
Data is one td note as `td note show --json` returns it.
type FetchedMsg ¶
FetchedMsg carries one td note fetch result.
type LoadedMsg ¶
type LoadedMsg struct {
ModelID int
RequestGeneration uint64
Epoch uint64
NoteID string
Data *Data
Error error
Refresh bool
// NotModified completes an in-flight refresh without replacing content.
NotModified bool
// Revision is the last adopted source revision, for a later conditional read.
Revision string
}
LoadedMsg is the result of a Model load. Identity fields ensure a result can only be applied to the model, request, and plugin epoch that issued it.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is one td note in one content box.
func New ¶
New creates an empty note viewer.
The card owns its wrap contract: it insets each side by horizontalContentPadding itself and reserves a scrollbar column in contentWidth, so its markdown must render without Glamour's document margin — the same pairing Notes uses. A nil renderer, or one built without markdown.CompactDocument, is replaced by the card's own compact renderer rather than mutated: an injected instance may be shared with viewers (docview, resourceview) whose inset is Glamour's margin. This is what keeps every surface that shows a note — workspace leaf, overview preview, app content deck — wrapping identically no matter what it injects; without it, body text wraps several columns before the frame's right edge (td-65095b).
func (*Model) HasScrollbar ¶ added in v1.4.0
HasScrollbar reports whether the card currently draws a bar (content overflows the viewport). When false, hosts must register no regions: the reserved column is an anti-jitter spacer, not a control.
func (*Model) Observe ¶
func (m *Model) Observe()
Observe records that the td store moved. It is cheap and idempotent.
func (*Model) OffsetAtTrackRow ¶ added in v1.4.0
OffsetAtTrackRow maps a track row (pointer Y minus the bar's top) to the scroll offset whose thumb top anchors there — the shared core every other interactive scrollbar uses for track clicks and drags.
func (*Model) Refresh ¶
Refresh re-reads the note in place, preserving scroll. Nil when nothing is owed, a re-read is already running, a Load is in flight, or suppressed.
func (*Model) RefreshPending ¶
RefreshPending reports whether a re-read is owed but has not started.
func (*Model) ResultMatches ¶ added in v1.12.0
ResultMatches reports whether msg belongs to this model's current load.
func (*Model) ScrollAtBoundary ¶
ScrollAtBoundary reports whether delta would leave this viewport unchanged.
func (*Model) ScrollOffset ¶
ScrollOffset is the current (or still-pending restore) viewport offset.
func (*Model) ScrollToOffset ¶ added in v1.4.0
ScrollToOffset pins the viewport at offset, clamped into range by the same bounds the renderer maps onto thumb travel. Reports whether it moved.
func (*Model) ScrollbarParams ¶ added in v1.4.0
func (m *Model) ScrollbarParams() ui.ScrollbarParams
ScrollbarParams reports the renderer inputs the card draws its bar with: one row per rendered line, a viewport of height rows. Hosts that want to make the bar interactive feed these to ui.RenderScrollbarWithGeometry for region registration and ui.OffsetAtRow/RowForOffset for press and drag mapping — no scrollbar math lives outside internal/ui.
func (*Model) SetFocused ¶
SetFocused marks the card as the current tab stop.
func (*Model) SetLoader ¶ added in v1.12.0
func (m *Model) SetLoader(loader NoteLoader)
SetLoader replaces the default td fetch. Nil restores it.
func (*Model) SetPendingScroll ¶
SetPendingScroll remembers an offset for the current load generation.
type NotModified ¶ added in v1.12.0
NotModified is returned by an injected loader when a refresh found no change.
type NoteLoader ¶ added in v1.12.0
NoteLoader produces a note load command. IfRevision is the last adopted source revision and may be empty. The command should return FetchedMsg, NotModified, or LoadedMsg.