Documentation
¶
Overview ¶
Package editor implements the mdit inline-render editor widget: a bubbletea component that shows a markdown document with every block rendered in place, except the block under the cursor, which is shown as raw source so it can be edited. The layout is virtualized (only the visible screen slice is drawn) and rendered blocks are cached by content, so a keystroke re-renders at most the one block it touched.
Index ¶
- type AutocompleteMsg
- type FollowLinkMsg
- type Model
- func (m Model) Cursor() doc.Position
- func (m Model) CursorViewportRowCol() (row, col int)
- func (m Model) Doc() *doc.Document
- func (m Model) HasSelection() bool
- func (m *Model) InsertText(s string)
- func (m Model) Register() string
- func (m Model) Scroll() int
- func (m Model) SelectedText() string
- func (m Model) Selection() (from, to doc.Position, ok bool)
- func (m *Model) SetCursor(p doc.Position)
- func (m *Model) SetDoc(d *doc.Document)
- func (m *Model) SetPlaceholder(s string)
- func (m *Model) SetScroll(s int)
- func (m *Model) SetSize(w, h int)
- func (m *Model) SetZen(on bool)
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m Model) View() string
- func (m Model) Zen() bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AutocompleteMsg ¶
type AutocompleteMsg struct{ Query string }
AutocompleteMsg is emitted (via a tea.Cmd) right after the user types the second '[' of a "[[" so the UI can open the note-completion popup.
type FollowLinkMsg ¶
type FollowLinkMsg struct{ Target string }
FollowLinkMsg is emitted (via a tea.Cmd) when the user presses Ctrl+O (or Ctrl+]) on a [[wikilink]] or [label](dest) under the cursor. The App resolves vault targets and shows external URLs on the status bar.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the editor widget. The zero value is not usable; construct one with New.
func New ¶
New constructs an editor Model over d with the given theme and broken-link predicate (isBroken may be nil). Call SetSize before View.
func (Model) CursorViewportRowCol ¶
CursorViewportRowCol returns the cursor's position relative to the visible viewport: row in [0, height) and cell column. The UI layer uses it to anchor popups (e.g. wikilink autocomplete) next to the cursor.
func (Model) HasSelection ¶ added in v0.3.0
HasSelection reports whether a non-empty selection is active.
func (*Model) InsertText ¶
InsertText inserts s at the cursor (replacing any selection) and rebuilds layout.
func (Model) SelectedText ¶ added in v0.3.0
SelectedText returns the document text covered by the selection, or "".
func (Model) Selection ¶ added in v0.3.0
Selection returns the normalized half-open selection range [from, to). ok is false when there is no active selection (or the range is empty).
func (*Model) SetCursor ¶
SetCursor moves the cursor to p (clamped on next recompute) and rebuilds layout.
func (*Model) SetPlaceholder ¶ added in v0.2.0
SetPlaceholder sets the dim hint drawn when the document is a single empty line. It does not force a re-layout; View reads it directly.
func (Model) Update ¶
Update handles incoming messages (currently key and window-size messages) and returns the updated model plus any command to run.