noteview

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 18 Imported by: 0 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.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyID

func CopyID(d *Data) tea.Cmd

CopyID copies just the note id.

func CopyMarkdown

func CopyMarkdown(d *Data) tea.Cmd

CopyMarkdown copies the note as markdown.

func Fetch

func Fetch(workDir, noteID string) tea.Cmd

Fetch runs `td note show` against workDir's project.

func FormatMarkdown

func FormatMarkdown(d *Data) string

FormatMarkdown renders one note as a heading plus its body.

func Heading

func Heading(d *Data) string

Heading is the note's chrome headline.

func LayoutTabStrip

func LayoutTabStrip(group Tabs, width int, focused bool) tabs.Strip

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

func NormalizeID(id string) string

NormalizeID is the tab key. Invalid values are empty.

func StoreTargets

func StoreTargets(workDir string) []livewatch.Target

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

type FetchedMsg struct {
	NoteID string
	Data   *Data
	Error  error
}

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
}

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.

func (LoadedMsg) GetEpoch

func (m LoadedMsg) GetEpoch() uint64

GetEpoch allows callers to apply the normal plugin epoch checks if desired.

type Model

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

Model is one td note in one content box.

func New

func New(renderer *markdown.Renderer) *Model

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) Arm

func (m *Model) Arm(modelID int, noteID string, epoch uint64)

Arm shows the loading placeholder for a restored tab without issuing a load.

func (*Model) Data

func (m *Model) Data() *Data

Data returns the current note, or nil before a successful fetch.

func (*Model) Err

func (m *Model) Err() error

Err returns the last fetch error, if any.

func (*Model) Focused

func (m *Model) Focused() bool

Focused reports whether the card is the current tab stop.

func (*Model) HandleKey

func (m *Model) HandleKey(k tea.KeyMsg) (bool, tea.Cmd)

HandleKey applies note keys: j/k, arrows, paging, and g/G scroll.

func (*Model) HasScrollbar added in v1.4.0

func (m *Model) HasScrollbar() bool

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) Load

func (m *Model) Load(modelID int, workDir, noteID string, epoch uint64) tea.Cmd

Load retargets the model at noteID and returns a command that fetches it.

func (*Model) Loading

func (m *Model) Loading() bool

Loading reports whether a fetch is outstanding.

func (*Model) ModelID

func (m *Model) ModelID() int

ModelID is the load identity last passed to Load.

func (*Model) NeedsLoad

func (m *Model) NeedsLoad() bool

NeedsLoad reports whether this model has never been asked to Load.

func (*Model) NoteID

func (m *Model) NoteID() string

NoteID returns the note this model is targeting.

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

func (m *Model) OffsetAtTrackRow(row int) int

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

func (m *Model) Refresh(suppressed bool) tea.Cmd

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

func (m *Model) RefreshPending() bool

RefreshPending reports whether a re-read is owed but has not started.

func (*Model) Scroll

func (m *Model) Scroll(delta int)

Scroll moves the viewport by delta rows and clamps it.

func (*Model) ScrollAtBoundary

func (m *Model) ScrollAtBoundary(delta int) bool

ScrollAtBoundary reports whether delta would leave this viewport unchanged.

func (*Model) ScrollOffset

func (m *Model) ScrollOffset() int

ScrollOffset is the current (or still-pending restore) viewport offset.

func (*Model) ScrollToOffset added in v1.4.0

func (m *Model) ScrollToOffset(offset int) bool

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

func (m *Model) SetFocused(focused bool)

SetFocused marks the card as the current tab stop.

func (*Model) SetPendingScroll

func (m *Model) SetPendingScroll(offset int)

SetPendingScroll remembers an offset for the current load generation.

func (*Model) SetResult

func (m *Model) SetResult(msg LoadedMsg) bool

SetResult applies msg if it belongs to the current load.

func (*Model) SetSize

func (m *Model) SetSize(width, height int)

SetSize sets the content box dimensions.

func (*Model) Title

func (m *Model) Title() string

Title returns the note's headline, or its ID before data arrives.

func (*Model) View

func (m *Model) View() string

View returns exactly the configured number of rows, each no wider than the configured width in terminal cells.

type TabHit

type TabHit = tabs.Hit

TabHit is a drawn tab's click target.

type TabStrip

type TabStrip = tabs.Strip

TabStrip is the header row: only tabs, packed left to right.

type Tabs

type Tabs struct {
	tabs.Group[*Model]
}

Tabs is one note pane's open notes. The stable key is a trimmed, validated td note ID.

func (Tabs) ActiveView

func (t Tabs) ActiveView() *Model

ActiveView is the selected note, or nil.

func (Tabs) Find

func (t Tabs) Find(noteID string) int

Find returns the first tab whose key is the normalized note ID, or -1.

func (*Tabs) OpenOrFocus

func (t *Tabs) OpenOrFocus(noteID string, view *Model) (index int, created bool)

OpenOrFocus selects the tab for noteID, or appends view and selects it.

Jump to

Keyboard shortcuts

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