Documentation
¶
Overview ¶
Package app is the Kvit Notes window: the sidebar, the note list and the editor pane, over one vault. cmd/kvit-notes opens it.
Index ¶
- Constants
- Variables
- func AcceptDroppedNotes(win *kvitui.Window, open func(path string))
- func AllowQuit() bool
- func ClosesToTray(ui *kvitui.UI, win *kvitui.Window, save func())
- func MathCommands(ui *kvitui.UI) *mathcmd.Model
- func OpenOrRaise(ui *kvitui.UI, root string) error
- func OpenSettings(ui *kvitui.UI, win *kvitui.Window, v *vault.Vault)
- func OpenShortcuts(ui *kvitui.UI, win *kvitui.Window)
- func Quit()
- func Quitting()
- func RaiseAny() bool
- func ShowKvit()
- func StartTray(t *platform.Tray, icon ...image.Image)
- func Tray() *platform.Tray
- type Backlinks
- type ListItem
- type NoteList
- type Outline
- type ResultsList
- type Scope
- type ScopeKind
- type ScopeList
- type ScopeRow
- type TagStrip
- type Toolbar
- func (t *Toolbar) BlockKind() string
- func (t *Toolbar) FocusFirst() bool
- func (t *Toolbar) FocusedChild() bool
- func (t *Toolbar) GroupOn(key string) bool
- func (t *Toolbar) OpenMenu(key unison.KeyCode) bool
- func (t *Toolbar) SetGroup(key string, on bool) bool
- func (t *Toolbar) SetPrefs(p *prefs)
- func (t *Toolbar) Update()
- type ToolbarHooks
- type Window
Constants ¶
const ToolbarHeight = 36
ToolbarHeight is the strip's height in design pixels, as Kvit's toolbar.
const WelcomeNote = `# Welcome to Kvit Notes
The quick **brown** fox has *seven* cubs. Markers such as the stars show only around the caret.
## Things to try
- Type ` + "`# `" + ` at the start of an empty paragraph to make a heading
- Type ` + "`/`" + ` in an empty block for the block menu
- [ ] Drag a block by the handle that appears on hover
- [x] Undo anything with Ctrl+Z
> A quotation keeps its lines
> together.
` + "```" + `
func main() {
fmt.Println("code keeps its indentation")
}
` + "```" + `
---
Bold with Ctrl+B, italic with Ctrl+I, ==highlight==, ~~strike~~, ++underline++ and [links](https://kvit.app).
`
WelcomeNote is the note an empty vault starts with.
Variables ¶
var OpenFile func(ui *kvitui.UI, path string)
OpenFile opens a Markdown file on its own in a window of its own; the command sets it, since that window is the command's.
Functions ¶
func AcceptDroppedNotes ¶
AcceptDroppedNotes makes a window take note files dropped anywhere on it, giving each to open. A part of the window that takes drops of its own comes first, as unison asks the panel under the pointer before its parents, and the window's content is the last of those. The window also registers the text and address types so the editor can take drops from other applications; the content itself only takes note files.
func AllowQuit ¶
func AllowQuit() bool
AllowQuit is unison's AllowQuitCallback: a quit, however it was asked for, closes every window rather than hiding the last one. A window that refuses to close leaves the app running, and the setting applies again.
func ClosesToTray ¶
ClosesToTray makes a window one that closing to the tray applies to: when it is the last one open, the icon is shown and the reader asked for it, closing it runs save and hides it instead. A window closed while another is hidden in the tray closes, and the app goes on running for the hidden one. The vault windows are made so as they open; the command makes its note-file windows so.
func MathCommands ¶
MathCommands is the math command menu's list for ui, to give each editor through SetMathCommands. It is made the first time it is asked for: its recently used commands are read from the settings, and written back each time a command is chosen.
func OpenOrRaise ¶
OpenOrRaise brings forward the window a vault is open in, or opens it in a new window.
func OpenSettings ¶
OpenSettings shows the settings dialog over a window; the This vault section is there when a vault is open in it.
func OpenShortcuts ¶
OpenShortcuts shows the keyboard shortcuts over a window.
func Quit ¶
func Quit()
Quit is the tray's Quit: it asks every window to close, which saves its note, and ends the app when all have.
func Quitting ¶
func Quitting()
Quitting is unison's QuittingCallback: it takes the icon out of the notification area, where Windows would otherwise leave it until the pointer passed over it.
func RaiseAny ¶
func RaiseAny() bool
RaiseAny brings the first vault window forward, and reports whether there was one.
func ShowKvit ¶
func ShowKvit()
ShowKvit brings the app's window forward, showing it if the last close hid it.
Types ¶
type ListItem ¶
type ListItem struct {
Key string // what the row stands for, such as the note's path
Title string
Snippet string // "" shows "Empty note"
Details string // the date and the word count
Pinned bool
Favorite bool
}
ListItem is one row of the note list.
type NoteList ¶
type NoteList struct {
unison.Panel
// Items are the rows, in order.
Items []ListItem
// Current is the index of the row the keyboard is on and whose note is
// open, or -1.
Current int
// OnOpen runs when a row is chosen by a press, the arrows, or a screen
// reader.
OnOpen func(i int)
// OnDrag runs while a row is dragged, and OnDrop when it is let go,
// with the pointer in the window's root coordinates.
OnDrag, OnDrop func(i int, where geom.Point)
// Selected are the rows picked with Ctrl or Shift for acting on
// together; OnSelect runs when they change.
Selected map[int]bool
OnSelect func()
// DropLine is the gap a dragged row would go into, drawn as a line:
// before row DropLine, or -1 for none.
DropLine int
// contains filtered or unexported fields
}
NoteList is the list of notes.
func NewNoteList ¶
NewNoteList returns an empty note list.
func (*NoteList) ClearSelection ¶
func (l *NoteList) ClearSelection()
ClearSelection drops every picked row.
func (*NoteList) PerformAccessibilityAction ¶
func (l *NoteList) PerformAccessibilityAction(req accessibility.ActionRequest) bool
PerformAccessibilityAction opens the note a screen reader selects.
func (*NoteList) ProvideAccessibility ¶
func (l *NoteList) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility describes the rows in view, and the current row, which holds the keyboard focus the list has.
func (*NoteList) SelectedRows ¶
SelectedRows are the picked rows, in order.
type Outline ¶
type Outline struct {
*unison.Panel
// Levels is which heading levels are listed, bit 0 for level 1.
Levels int
// OnLevels runs when the reader changes Levels.
OnLevels func(levels int)
// OnClose hides the pane.
OnClose func()
// OnGo scrolls the note to a block.
OnGo func(index int)
// contains filtered or unexported fields
}
Outline is the outline pane.
func NewOutline ¶
NewOutline returns the outline pane for an editor.
type ResultsList ¶
type ResultsList struct {
unison.Panel
// OnOpen opens a note, at a hit when it is not nil.
OnOpen func(path string, hit *search.Hit)
// Counting is what a note's count counts, for a screen reader.
Counting string
// contains filtered or unexported fields
}
ResultsList draws the results.
func (*ResultsList) PerformAccessibilityAction ¶
func (l *ResultsList) PerformAccessibilityAction(req accessibility.ActionRequest) bool
PerformAccessibilityAction opens a row chosen by a screen reader.
func (*ResultsList) ProvideAccessibility ¶
func (l *ResultsList) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility describes each row: a note with its count, or a line found in it.
type Scope ¶
Scope is what the note list shows: every note, the favourites, one folder (Path is its path in the vault, "" the top), the notes with one tag, or the trash.
type ScopeList ¶
type ScopeList struct {
unison.Panel
// Rows are the rows, top to bottom; the trash is drawn at the foot of
// whatever height the list is given.
Rows []ScopeRow
// Current is the scope the note list shows.
Current Scope
// OnChoose runs when a scope is chosen.
OnChoose func(Scope)
// OnToggle runs when a folder is opened or closed.
OnToggle func(folder string, expanded bool)
// OnDrag runs while a folder row is dragged, and OnDrop when it is let
// go, with the pointer in the window's root coordinates.
OnDrag, OnDrop func(folder string, where geom.Point)
// Target is the row a dragged note or folder would be dropped on, or -1.
Target int
// contains filtered or unexported fields
}
ScopeList is the sidebar's list of scopes.
func (*ScopeList) PerformAccessibilityAction ¶
func (l *ScopeList) PerformAccessibilityAction(req accessibility.ActionRequest) bool
PerformAccessibilityAction chooses, opens or closes a scope for a screen reader.
func (*ScopeList) ProvideAccessibility ¶
func (l *ScopeList) ProvideAccessibility(b *unison.AccessibilityBuilder)
ProvideAccessibility describes each scope as a tree item, the current one holding the focus the list has.
type ScopeRow ¶
type ScopeRow struct {
Scope Scope
Label string
Count int
Depth int // a folder's depth
Expandable bool // a folder with folders in it
Expanded bool
Heading bool // a heading such as "Folders", which is not a scope
Mark palette.Color
HasMark bool // a folder's or tag's colour, drawn before the label
}
ScopeRow is one row of the sidebar's list.
type TagStrip ¶
type TagStrip struct {
*unison.Panel
// OnAdd and OnRemove run when the reader adds or removes a tag.
OnAdd func(tag string)
OnRemove func(tag string)
// contains filtered or unexported fields
}
TagStrip shows a note's tags and adds and removes them.
func (*TagStrip) SetSuggestions ¶
SetSuggestions is every tag the field offers.
type Toolbar ¶
Toolbar is the strip for an editor.
func NewToolbar ¶
NewToolbar returns the strip for an editor.
func (*Toolbar) FocusFirst ¶
FocusFirst puts the keyboard focus on the strip's first button (File, View or Insert), for F6 pane cycling. It reports whether there is one.
func (*Toolbar) FocusedChild ¶
FocusedChild reports whether one of the strip's buttons holds the keyboard focus.
func (*Toolbar) OpenMenu ¶
OpenMenu opens the menu Alt and a key names, File, View or Insert, and reports whether there is one.
func (*Toolbar) SetGroup ¶
SetGroup shows or hides a customization group, keeping the setting, and reports whether there is one.
type ToolbarHooks ¶
type ToolbarHooks struct {
// File and View build the menus of those names when they open.
File, View func() []kvitui.MenuItem
// Back and Forward move through the notes opened.
Back, Forward func()
// Link opens the link dialog, as Ctrl+K does.
Link func()
}
ToolbarHooks are what the strip's window-level buttons do; a nil hook leaves its button out, as a window over a single file has no history.
type Window ¶
type Window struct {
Win *kvitui.Window
Vault *vault.Vault
Editor *editor.Editor
// contains filtered or unexported fields
}
Window is one Kvit Notes window over a vault.
func (*Window) Results ¶
Results are the rows the results list shows, for tests: a note as its title, a hit as its line indented two spaces.
func (*Window) SidesHidden ¶
SidesHidden reports whether Ctrl+\ has hidden the side panes.
Source Files
¶
- actions.go
- backlinks.go
- bulk.go
- capture.go
- clipboard.go
- diagram.go
- drop.go
- egress.go
- embed.go
- exchange.go
- find.go
- fuzzy.go
- images.go
- links.go
- mathcommands.go
- menus.go
- navigate.go
- notelist.go
- outline.go
- pdf.go
- prefs.go
- queries.go
- rename.go
- safety.go
- searchview.go
- settings.go
- shortcuts.go
- sidebar.go
- stats.go
- tagstrip.go
- templates.go
- toolbar.go
- tray.go
- window.go