Documentation
¶
Overview ¶
Package ui is the notebook the frontend in web drives: tabs, windows and the calls their pages make, apart from the program that shows the windows.
Index ¶
- func NewConsoleHandler(next slog.Handler, c *Console) slog.Handler
- func TabCalls(next http.Handler) http.Handler
- func WithTab(ctx context.Context, id int) context.Context
- type About
- type App
- func (a *App) About() About
- func (a *App) Answer(ctx context.Context, reply string) error
- func (a *App) AnswerOutside(ctx context.Context, answer string) error
- func (a *App) BlockAt(ctx context.Context, line int) (int, error)
- func (a *App) BlockAttrs() []doc.AttrSpec
- func (a *App) CLIState() CLI
- func (a *App) Cells(ctx context.Context) ([]notebook.Cell, error)
- func (a *App) Changelog() (string, error)
- func (a *App) Cheatsheet() (string, error)
- func (a *App) CheckInfos(infos []string) [][]notebook.Problem
- func (a *App) ChooseFile(ctx context.Context, title, dir string) (string, error)
- func (a *App) ChooseFolder(ctx context.Context, title, dir string) (string, error)
- func (a *App) ChooseReport(ctx context.Context, format report.Format, dest string) (string, error)
- func (a *App) ClearConsole()
- func (a *App) ClearEarlierRuns(ctx context.Context, i int) error
- func (a *App) ClearOutput(ctx context.Context, i int) error
- func (a *App) ClearOutputs(ctx context.Context) error
- func (a *App) CloseTab(id int) error
- func (a *App) Console() []ConsoleEntry
- func (a *App) CopyCastGIF(cast string) error
- func (a *App) CopySecret(text string) error
- func (a *App) CreateReport(ctx context.Context, r notebook.Report) error
- func (a *App) Curl(ctx context.Context, i int) (string, error)
- func (a *App) DeleteBlock(ctx context.Context, i int) (notebook.Deleted, error)
- func (a *App) DeleteEarlierRun(ctx context.Context, i, k int) error
- func (a *App) DependsAt(ctx context.Context) (Depends, error)
- func (a *App) DescribeFix(ctx context.Context, warning string) (notebook.Fix, error)
- func (a *App) DetachTab(x, y int) error
- func (a *App) Doc(ctx context.Context) (Doc, error)
- func (a *App) DragTab(id int) error
- func (a *App) DropTab(ctx context.Context, i int) error
- func (a *App) Edit(ctx context.Context, v notebook.Version, edits []notebook.LineEdit) (notebook.EditReply, error)
- func (a *App) EndDrag(id int, outside bool, x, y int) error
- func (a *App) Events(ctx context.Context) ([]notebook.AuditEvent, error)
- func (a *App) FixWarning(ctx context.Context, warning string) error
- func (a *App) FolderSettings(rel string) (FolderForm, error)
- func (a *App) Fonts() fonts.Fonts
- func (a *App) FrontMatter(ctx context.Context) (notebook.FrontMatter, error)
- func (a *App) HasOutput(ctx context.Context) (bool, error)
- func (a *App) HistoryComplete(ctx context.Context, input string) bool
- func (a *App) HistoryCompletions(ctx context.Context, before string) (notebook.Completion, error)
- func (a *App) HistoryEnter(ctx context.Context, input string, record bool) error
- func (a *App) HistoryPrompt(ctx context.Context, cols, rows int) (notebook.Prompt, error)
- func (a *App) IncludeFile(ctx context.Context, i int) (notebook.IncludeFile, error)
- func (a *App) InstallCLI() (CLI, error)
- func (a *App) KillProcess(ctx context.Context, pid int) bool
- func (a *App) KillShell(ctx context.Context) bool
- func (a *App) LastSession(ctx context.Context) error
- func (a *App) LinesSince(ctx context.Context, v notebook.Version) (notebook.Lines, error)
- func (a *App) Live(ctx context.Context) ([]liveEvent, error)
- func (a *App) MoveBlock(ctx context.Context, i, dir int, byBlock bool) (notebook.Move, error)
- func (a *App) MoveTo(ctx context.Context, from, at int) (notebook.Move, error)
- func (a *App) Names(ctx context.Context) (notebook.Names, error)
- func (a *App) Neovim() NeovimInfo
- func (a *App) NewFile(ctx context.Context, template string) error
- func (a *App) NewSession(ctx context.Context) error
- func (a *App) NewTab(ctx context.Context) error
- func (a *App) NewWindow()
- func (a *App) NvimApply(ctx context.Context, seq int, edits []nvim.LineEdit) (bool, error)
- func (a *App) NvimCall(ctx context.Context, fn, args string) (string, error)
- func (a *App) NvimInput(ctx context.Context, keys string) error
- func (a *App) NvimMouse(ctx context.Context, button, action, mod string, row, col int) error
- func (a *App) NvimPaste(ctx context.Context, text string) error
- func (a *App) NvimResize(ctx context.Context, cols, rows int) error
- func (a *App) NvimSaved(ctx context.Context) error
- func (a *App) NvimStart(ctx context.Context, cols, rows int, background string) (NvimText, error)
- func (a *App) NvimStop(ctx context.Context)
- func (a *App) Open(ctx context.Context) error
- func (a *App) OpenLink(ctx context.Context, href string) (string, error)
- func (a *App) OpenPath(ctx context.Context, file string) error
- func (a *App) OpenURL(u string) error
- func (a *App) Outside(ctx context.Context) (OutsideFiles, error)
- func (a *App) Pin(file string, pin bool) error
- func (a *App) PlanMove(ctx context.Context, i, dir int, byBlock bool) (notebook.Move, error)
- func (a *App) Processes(ctx context.Context) []env.ShellProcs
- func (a *App) Redo(ctx context.Context) (string, error)
- func (a *App) Reload(ctx context.Context) error
- func (a *App) RememberView(file, view string, history bool) error
- func (a *App) RemoteImage(ctx context.Context, src string, load bool) (string, error)
- func (a *App) ReplaceCast(ctx context.Context, i int, as string, frame int) error
- func (a *App) ReportCommand(ctx context.Context, r notebook.Report) (string, error)
- func (a *App) ReportStart(ctx context.Context) (ReportStart, error)
- func (a *App) RestartShells(ctx context.Context) error
- func (a *App) Reveal(file string) error
- func (a *App) RunBlock(ctx context.Context, i int) error
- func (a *App) RunFrom(ctx context.Context, i int) error
- func (a *App) RunSection(ctx context.Context, from, to int) error
- func (a *App) Save(ctx context.Context) error
- func (a *App) SaveAs(ctx context.Context) (bool, error)
- func (a *App) SelectTab(id int) error
- func (a *App) SetCastFrame(ctx context.Context, i int, body string, frame int) error
- func (a *App) SetChoice(ctx context.Context, i int, checked []bool) error
- func (a *App) SetDepends(ctx context.Context, i int, deps []int) error
- func (a *App) SetFolderSettings(rel string, s collection.Settings) error
- func (a *App) SetFolds(ctx context.Context, folds []notebook.Fold) error
- func (a *App) SetFrontMatter(ctx context.Context, f notebook.FrontMatter) error
- func (a *App) SetHistory(ctx context.Context, on, restart bool) (bool, error)
- func (a *App) SetIncludeRange(ctx context.Context, i, from, to int) error
- func (a *App) SetRunOptions(ctx context.Context, args, only string, step, stopOnError bool) error
- func (a *App) SetSettings(s settings.Settings) error
- func (a *App) SetTask(ctx context.Context, task int, done bool) error
- func (a *App) SetTerminalSize(ctx context.Context, cols, rows int)
- func (a *App) SetText(ctx context.Context, base, text string) (bool, error)
- func (a *App) SetTextbox(ctx context.Context, i int, text string) error
- func (a *App) SetView(ctx context.Context, v View)
- func (a *App) SetZshWrapper(on bool) (ZshWrapper, error)
- func (a *App) Settings() settings.Settings
- func (a *App) ShowChangelog()
- func (a *App) ShowCheatsheet()
- func (a *App) SourceBlocks(text string) []notebook.SourceBlock
- func (a *App) SourceBlocksAt(ctx context.Context) (SourceBlocks, error)
- func (a *App) StartScreen() (Start, error)
- func (a *App) Stop(ctx context.Context)
- func (a *App) StopBackground(ctx context.Context, block int) bool
- func (a *App) Tabs(ctx context.Context) (Tabs, error)
- func (a *App) Templates() ([]library.File, error)
- func (a *App) Text(ctx context.Context) (string, error)
- func (a *App) TextAt(ctx context.Context) (SourceText, error)
- func (a *App) Type(ctx context.Context, keys string)
- func (a *App) Undo(ctx context.Context) (string, error)
- func (a *App) UninstallCLI() (CLI, error)
- func (a *App) ZshWrapperState() (ZshWrapper, error)
- type Build
- type Button
- type CLI
- type Console
- type ConsoleEntry
- type Control
- func (c Control) Assets(frontend http.Handler) http.Handler
- func (c Control) ClearRecent()
- func (c Control) CloseTab()
- func (c Control) CloseWindow()
- func (c Control) Closing(id uint) bool
- func (c Control) Console() *Console
- func (c Control) CycleTab(by int)
- func (c Control) Dropped(id uint, files []string)
- func (c Control) File(id uint) string
- func (c Control) Focused(id uint)
- func (c Control) FollowLink(href string) error
- func (c Control) LinkTarget(href string) string
- func (c Control) NewFile()
- func (c Control) NewTab()
- func (c Control) NewWindow() Window
- func (c Control) NvimEdit(op string, get func() (string, bool), set func(string) bool)
- func (c Control) Open()
- func (c Control) OpenFile(file string)
- func (c Control) OpenFromSystem(file string)
- func (c Control) OpenSettings(tab string)
- func (c Control) Quitting()
- func (c Control) Send(action string)
- func (c Control) SendTo(id uint, action string) bool
- func (c Control) SetBuild(b Build)
- func (c Control) SetImages(s *trust.Store)
- func (c Control) SetLSP(cmd func(file string) []string)
- func (c Control) SetOutside(s *trust.Store)
- func (c Control) SetTrust(s *trust.Store)
- func (c Control) Settings() *settings.Store
- func (c Control) ShouldQuit() bool
- func (c Control) ShowChangelog()
- func (c Control) ShowCheatsheet()
- func (c Control) ShowError(err error)
- func (c Control) Start(file string, run notebook.RunOptions) error
- func (c Control) SystemOpensReady()
- type Depends
- type Doc
- type FolderForm
- type Host
- type Link
- type NeovimInfo
- type NvimEvent
- type NvimText
- type OutsideFiles
- type Question
- type ReportStart
- type SaveFile
- type SourceBlocks
- type SourceText
- type Start
- type Tab
- type Tabs
- type Tool
- type View
- type Window
- type ZshWrapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewConsoleHandler ¶
NewConsoleHandler is a handler that adds what is logged at info or above to c and passes everything on to next.
Types ¶
type About ¶
type About struct {
Version string `json:"version"`
Commit string `json:"commit"`
BuildTime string `json:"buildTime"`
Modified bool `json:"modified"`
GoVersion string `json:"goVersion"`
OS string `json:"os"`
Arch string `json:"arch"`
// Home is for showing paths as ~/….
Home string `json:"home"`
// SettingsFile is the JSON file the settings live in.
SettingsFile string `json:"settingsFile"`
// Zshrc is the .zshrc the zsh wrapper setting edits.
Zshrc string `json:"zshrc"`
Tools []Tool `json:"tools"`
Links []Link `json:"links"`
}
About is what Settings' About tab shows.
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is the service the frontend calls. A call from a tab's page acts on that tab; one from a window's tab bar, on that window. Its exported methods are all calls the frontend makes; the Host drives it through its Control.
func New ¶
New makes an App showing its windows with host and keeping its settings in store. cwd is the folder the program started in and dir the folder named on the command line, if any. source is what the files given to --source hold, for every shell to source.
func (*App) AnswerOutside ¶
AnswerOutside remembers whether the file may reach the files Outside lists now, and starts its shells again so the answer holds for its runs. "allow" and "deny" are remembered; "" forgets the answer, so the page asks the next time the file opens.
func (*App) BlockAttrs ¶
BlockAttrs describes the block attributes, for completion, hover help and the attribute form.
func (*App) Cheatsheet ¶
Cheatsheet is the app's cheat sheet, rendered, for its tab.
func (*App) CheckInfos ¶
CheckInfos checks the attributes in fences' info strings. The source pane asks about every new one in one call: a long document has thousands, and asking about each in turn took seconds.
func (*App) ChooseFile ¶
ChooseFile asks for a markdown file, with title, starting in dir or the start folder, and returns it, or "" if none was picked.
func (*App) ChooseFolder ¶
ChooseFolder asks for a folder, with title, starting in dir or the start folder, and returns it, or "" if none was picked.
func (*App) ChooseReport ¶
ChooseReport asks where to save a report in format, starting at dest, and returns the file, or "" if none was picked.
func (*App) ClearConsole ¶
func (a *App) ClearConsole()
ClearConsole empties the console, in every window.
func (*App) ClearEarlierRuns ¶
ClearEarlierRuns takes block i's earlier runs, kept by history=N, out of the file, and keeps its current output. Undo puts them back.
func (*App) ClearOutput ¶
ClearOutput takes block i's output out of the file and forgets its run. Undo puts it back.
func (*App) ClearOutputs ¶
ClearOutputs takes every block's output out of the document and starts its shells again.
func (*App) Console ¶
func (a *App) Console() []ConsoleEntry
Console returns what the console holds, oldest first. New entries come as "console" events, a "console-stale" event names by Seq the entries that no longer apply, and a "console-cleared" event says it was cleared.
func (*App) CopyCastGIF ¶
CopyCastGIF puts an animated GIF of cast, an asciicast v2 recording, on the clipboard.
func (*App) CopySecret ¶
CopySecret puts text, which may hold a secret, on the clipboard, kept out of clipboard history where the system allows, and takes it off again after the settings' SecretShow unless something else was copied.
func (*App) CreateReport ¶
CreateReport writes the report r describes.
func (*App) Curl ¶
Curl is http block i's request as a curl command line, with the placeholders filled in as running it now would, for Copy as curl.
func (*App) DeleteBlock ¶
DeleteBlock takes top-level block i, with its output and tape, out of the file. Undo puts it back.
func (*App) DeleteEarlierRun ¶
DeleteEarlierRun takes block i's earlier run k out of the file, and numbers the rest again. Undo puts it back.
func (*App) DependsAt ¶
DependsAt is the names in the file's depends= that aren't a block that runs, for the source pane to underline, and the version of the text whose lines they name.
func (*App) DescribeFix ¶
DescribeFix says what FixWarning would do for warning, a console entry's message, in the file this window shows.
func (*App) DetachTab ¶
DetachTab gives the tab being dragged a window of its own, at x, y on the screen, if it shares its window. It does nothing if no tab is being dragged.
func (*App) DragTab ¶
DragTab notes that tab id is being dragged, so the window it is dropped on can take it.
func (*App) DropTab ¶
DropTab puts the tab being dragged in the calling window, at index i of its tab bar. It does nothing if no tab is being dragged.
func (*App) Edit ¶
func (a *App) Edit(ctx context.Context, v notebook.Version, edits []notebook.LineEdit) (notebook.EditReply, error)
Edit makes line edits typed in the source pane against version v of the file, if it is still at v. When it isn't, it changes nothing and says how the file changed since, so the pane can fold that in around what was typed and try again. A key costs the lines it changed, not the whole file twice, as SetText does.
func (*App) EndDrag ¶
EndDrag ends dragging tab id. If no window took it and it was let go outside its window, at x, y on the screen, it gets a window of its own there.
func (*App) Events ¶
Events is the event log of the file this window shows: its shells starting and ending, and why, blocks running, the file changing on disk and mdsh ctl calls, oldest first. New events come as "audit" events.
func (*App) FixWarning ¶
FixWarning makes the fix a console entry offers for warning, its message, in the file this window shows. Undo takes it back.
func (*App) FolderSettings ¶
func (a *App) FolderSettings(rel string) (FolderForm, error)
FolderSettings reads the .mdsh.yaml of rel, a folder the start screen lists, for the folder settings dialog.
func (*App) Fonts ¶
Fonts lists the font families installed on this computer, for the Look tab's font menus.
func (*App) FrontMatter ¶
FrontMatter reads the file's front matter for the rendered view's front matter form.
func (*App) HasOutput ¶
HasOutput reports whether the file has output for ClearOutputs to take out, so Clear All Outputs is only offered when it would do something.
func (*App) HistoryComplete ¶
HistoryComplete reports whether input is a whole command, so enter runs it, rather than starting another line.
func (*App) HistoryCompletions ¶
HistoryCompletions completes the word at the end of before, what is typed in the History pane up to the cursor, for Tab.
func (*App) HistoryEnter ¶
HistoryEnter takes what was typed in the History pane: a note is added to the file as prose, and a command is added as a block and run. With record false, as the pane's Record switch sets, a command runs without being added.
func (*App) HistoryPrompt ¶
HistoryPrompt is the shell's PS1 and PS2, expanded, for the History pane's prompt, at the pane's size, cols by rows.
func (*App) IncludeFile ¶
IncludeFile reads the whole of include block i's file, for showing it and for dragging the include's range over it.
func (*App) InstallCLI ¶
InstallCLI puts the command line tool on PATH, and returns where it stands after.
func (*App) KillProcess ¶
KillProcess kills process pid and what it started, if it runs under one of the tab's shells, and reports whether it did.
func (*App) KillShell ¶
KillShell ends the shell the running block runs in, at once, for a block that Stop didn't stop, once the user has said to. What blocks set in that shell is gone. It reports whether a block was running.
func (*App) LastSession ¶
LastSession opens the file in the sessions folder changed last, as NewSession opens a session.
func (*App) LinesSince ¶
LinesSince is how the file changed after version v, as line events, for a source pane catching up with what Go wrote, such as a run's output, without reading the whole file again.
func (*App) Live ¶
Live is what the run going on in the tab has sent so far, for a page that starts partway through it.
func (*App) MoveBlock ¶
MoveBlock moves top-level block i up (dir < 0) or down past the next cell, or with byBlock past the next block. Undo takes it back.
func (*App) MoveTo ¶
MoveTo moves the block or heading's section that starts at from to at, a cell's From or -1 for the end, as dragging does.
func (*App) Neovim ¶
func (a *App) Neovim() NeovimInfo
Neovim says which nvim the source pane would run.
func (*App) NewFile ¶
NewFile asks where to make a new markdown file and opens it: in this tab if it shows the start screen, else in a new tab. The file is a copy of template, or a heading if template is "".
func (*App) NewSession ¶
NewSession opens the day's session, from the start screen: a file named for the date in the sessions folder, made from the session template if it isn't there yet, or else set to run in your login shell. It opens with the History pane open and focused.
func (*App) NewTab ¶
NewTab opens a tab with the start screen in the calling window, after the tab in front.
func (*App) NvimApply ¶
NvimApply makes edits on Neovim's text, as the page merged Go's changes with what was typed, made against its text as of seq, the count of the nvim-lines events the page has had and its own NvimApply calls. It reports false, changing nothing, if Neovim has typing the page hasn't had: that comes as nvim-lines, and the page tries again.
func (*App) NvimCall ¶
NvimCall calls fn in mdsh.lua with args, a JSON array, and returns its result as JSON: the cursor, setting the run buttons or folds, and so on.
func (*App) NvimResize ¶
NvimResize resizes the grid. Before Neovim runs there is nothing to resize: NvimStart takes the size.
func (*App) NvimStart ¶
NvimStart starts the tab's Neovim with a grid of cols by rows, editing the file's text, with 'background' set to "light" or "dark" to match the page. A running one is left as it is.
func (*App) Open ¶
Open asks for markdown files and opens them: the first in this tab if it shows the start screen, the rest in new tabs.
func (*App) OpenLink ¶
OpenLink follows href, a link in the tab's document: a web address opens in the browser, a markdown file in a new tab beside this one, and an image beside the document is shown full size in the window: OpenLink returns the address the window loads it from. Any other file is shown in the file manager, unless Settings › Files lists its type to open with the system's app. Opening it would run a .command, .app or script beside the document on one click, past every question a block asks (finding 6 of the v1.4.0 security review).
func (*App) Outside ¶
func (a *App) Outside(ctx context.Context) (OutsideFiles, error)
Outside lists what the file reaches outside its root, for the page to ask about once per file, and again when the list changes, as mdsh --allow-outside allows it on the command line.
func (*App) PlanMove ¶
PlanMove works out MoveBlock's move without making it, for the source view to make as its own edit.
func (*App) Processes ¶
func (a *App) Processes(ctx context.Context) []env.ShellProcs
Processes lists the tab's shells, each with the processes under it, for the Console's Processes tab. It is empty when no shell runs.
func (*App) Reload ¶
Reload reads the file from disk again, dropping output not saved. The shells keep what blocks set in them, unless the front matter changed the shell, env.share or env.source.
func (*App) RememberView ¶
RememberView notes how file is shown, for the next time it opens: view is "rendered", "source" or "both", and history is whether the History pane is open.
func (*App) RemoteImage ¶
RemoteImage returns the image at src, an image in this window's document that the window doesn't load by itself, as a data: URI for it to show: an http: or https: address on another site, or a file outside the document's folder (or hidden in it), which the window's /doc route doesn't serve. With load false, it only does so for an image the user loaded in this document before, and returns "" for any other, without going to the network. With load true, from the note's Load button, it fetches the image, and remembers that this document may load it, so it loads by itself from then on. Anything that isn't a PNG, JPEG, GIF, WebP, BMP or icon, or is over 20 MB, is refused.
func (*App) ReplaceCast ¶
ReplaceCast swaps tty block i's recording, in its output, for the text of frame n (as "text") or an animated GIF of it (as "gif"). Undo puts the recording back.
func (*App) ReportCommand ¶
ReportCommand is the mdsh command that makes the report r describes.
func (*App) ReportStart ¶
func (a *App) ReportStart(ctx context.Context) (ReportStart, error)
ReportStart reads what the Report dialog shows when it opens.
func (*App) RestartShells ¶
RestartShells starts the file's shells again, as if nothing had run, without changing the file. The page asks the user first: it is the one way the app ends shells that blocks set things up in.
func (*App) RunSection ¶
RunSection runs blocks from up to but not including to, a heading's section, as Run all runs them.
func (*App) SaveAs ¶
SaveAs asks where to save the file with its output, and from then on the tab shows the new file. It returns false if the user cancels.
func (*App) SetCastFrame ¶
SetCastFrame writes frame=n, where a recording's player was left, on tty block i, or with i < 0 on the cast fence holding body. Undo takes it back.
func (*App) SetDepends ¶
SetDepends sets block i's depends= to the blocks deps names, by index, or takes it out when deps is empty. Undo takes it back.
func (*App) SetFolderSettings ¶
func (a *App) SetFolderSettings(rel string, s collection.Settings) error
SetFolderSettings saves s as the .mdsh.yaml of rel, a folder the start screen lists. See collection.Write.
func (*App) SetFolds ¶
SetFolds writes folds made by hand in the rendered view to the file, as collapse attributes and mdsh:collapse lines, so it opens with them.
func (*App) SetFrontMatter ¶
SetFrontMatter writes the front matter form's fields to the file, changing only the keys whose field changed. Undo takes it back.
func (*App) SetHistory ¶
SetHistory turns the History pane on or off for the file. Turning it on needs shells on a terminal: if theirs have none and blocks have run in them, it starts them again only with restart, the user having said so, and otherwise fails with notebook.ErrRestartNeeded. It reports whether they started again. The shells read the rc file Settings names as it is now.
func (*App) SetIncludeRange ¶
SetIncludeRange writes from= and to= on include block i, as its grips were dragged to. Undo takes it back.
func (*App) SetRunOptions ¶
SetRunOptions sets the arguments (one line, split as a shell would), --only, --step and --stop-on-error for this file.
func (*App) SetSettings ¶
SetSettings saves the settings edited in Settings (see edited). Open windows hear of it with a "settings" event.
func (*App) SetTask ¶
SetTask checks or unchecks task list item task, as numbered by the cells' tasks, in the file.
func (*App) SetTerminalSize ¶
SetTerminalSize sets the terminal pane's size in cells, which the window works out from its width.
func (*App) SetText ¶
SetText replaces the whole file, as typed in the source pane, if it is still base, and reports whether it did. When it isn't, the pane reads the file again, keeps what was typed and tries again.
func (*App) SetTextbox ¶
SetTextbox replaces the text of textbox block i, as typed in it.
func (*App) SetZshWrapper ¶
func (a *App) SetZshWrapper(on bool) (ZshWrapper, error)
SetZshWrapper adds the mdsh function to the user's .zshrc, and to their .bashrc if they have one, or takes it out of both, and returns the new state. It doesn't make a .bashrc for someone who doesn't use bash.
func (*App) ShowChangelog ¶
func (a *App) ShowChangelog()
ShowChangelog brings the changelog's tab forward, opening one if there is none (see showPage).
func (*App) ShowCheatsheet ¶
func (a *App) ShowCheatsheet()
ShowCheatsheet brings the cheat sheet's tab forward, opening one as ShowChangelog does.
func (*App) SourceBlocks ¶
func (a *App) SourceBlocks(text string) []notebook.SourceBlock
SourceBlocks lists the blocks in the source pane's text, for completing and checking depends=.
func (*App) SourceBlocksAt ¶
func (a *App) SourceBlocksAt(ctx context.Context) (SourceBlocks, error)
SourceBlocksAt is the file's blocks, for completing depends= in the source pane, and the version of the text whose lines they name.
func (*App) StartScreen ¶
StartScreen lists the markdown files under the start folder, and the recent files that still exist.
func (*App) Stop ¶
Stop stops the running block, answering stop if a block is waiting to be confirmed. The block is interrupted, as ctrl+c would, and its shell lives on.
func (*App) StopBackground ¶
StopBackground kills block, which runs in the background, as Stop can't once the run that started it is over. It reports whether the block was still running.
func (*App) Templates ¶
Templates lists the markdown files in the templates folder, for New File… to start from. With no templates folder set it lists none.
func (*App) TextAt ¶
func (a *App) TextAt(ctx context.Context) (SourceText, error)
TextAt is the whole file and its version.
func (*App) Undo ¶
Undo takes back the rendered view's last edit, such as checking a task, and says what it was: "" when there is none.
func (*App) UninstallCLI ¶
UninstallCLI takes the command line tool off PATH, when it's this app's, and returns where it stands after.
func (*App) ZshWrapperState ¶
func (a *App) ZshWrapperState() (ZshWrapper, error)
ZshWrapperState reads the user's .zshrc and .bashrc for the mdsh function, bringing a block from an older mdsh-gui up to date so it loads completion too.
type Build ¶
type Build struct {
Version string // the release version, module version or "dev"
Commit string // the vcs revision, shortened
Time string // when the commit was made, as the vcs recorded it
Modified bool // the tree had uncommitted changes
}
Build is what the binary knows about itself, for the About tab.
type Button ¶
type Button struct {
Label string
Default bool // picked by return
Cancel bool // picked by escape
Do func()
}
Button is one of a Question's answers.
type CLI ¶
type CLI struct {
// Bundled is the mdsh this app carries, or "" when this build
// carries none (go run, go install, a .deb, Windows, a browser).
Bundled string `json:"bundled"`
// Link is where Install puts it.
Link string `json:"link"`
// Copy is whether Install copies Bundled to Link (an AppImage)
// rather than linking to it (macOS).
Copy bool `json:"copy"`
// Installed is whether Link is this app's: a symlink to Bundled, or
// a copy with the marker beside it.
Installed bool `json:"installed"`
// Broken is where Link points when it's a symlink into an mdsh.app
// that isn't this one, such as after the app moved.
Broken string `json:"broken"`
// OtherApp is whether Broken is still there: another mdsh.app, such
// as an older release's, rather than where this one used to be.
OtherApp bool `json:"otherApp"`
// Linked is another mdsh on PATH that is this app's, such as the
// Homebrew cask's link, which comes first on PATH.
Linked string `json:"linked"`
// Other is an mdsh on PATH that isn't this app's, such as the
// formula's. Install won't put a second one beside it.
Other string `json:"other"`
// InPath is whether Link's folder is on PATH.
InPath bool `json:"inPath"`
// Home is for showing paths as ~/….
Home string `json:"home"`
}
CLI is where the command line tool stands, for Settings › Shell. The desktop app carries mdsh and can put it on PATH; see docs/design/cli-in-app.md.
type Console ¶
type Console struct {
// contains filtered or unexported fields
}
Console is the log the Console pane shows.
func NewConsole ¶
func NewConsole() *Console
NewConsole makes an empty console. Log to it through a handler from NewConsoleHandler, and have Send take what it gets to the windows.
type ConsoleEntry ¶
type ConsoleEntry struct {
Seq int `json:"seq"` // counts up from 1, so a page can tell it missed one
Time time.Time `json:"time"`
Level string `json:"level"`
Message string `json:"message"` // the message, then its attributes as key=value
File string `json:"file,omitempty"` // the file the entry is about, from a "file" attribute
Line int `json:"line,omitempty"` // the line in File, from a "line" attribute; 0 if none
Fix string `json:"fix,omitempty"` // names the fix for it, from a "fix" attribute
// Stale says it no longer applies: an edit fixed what it warned of.
Stale bool `json:"stale,omitempty"`
}
ConsoleEntry is one line of the console.
type Control ¶
type Control struct {
// contains filtered or unexported fields
}
Control is how a Host drives its App: what its windows tell it, and its menu commands. It is apart from App so the frontend can't call it.
func (Control) Assets ¶
Assets serves frontend, and at notebook.DocPrefix the files beside the open documents, such as the images their blocks write.
func (Control) CloseTab ¶
func (c Control) CloseTab()
CloseTab closes the tab in front, asking first if it has unsaved output.
func (Control) Closing ¶
Closing is told window id is closing, and says whether it may: its tabs close first, asking about unsaved output in each, and the window closes again once none are left.
func (Control) Console ¶
Console is the App's console, for the host to log to with a handler from NewConsoleHandler and to send on to the windows with its Send.
func (Control) FollowLink ¶
FollowLink follows href, a link in the document of the tab in front, as OpenLink does; an image beside the document is shown full size in the tab's window.
func (Control) LinkTarget ¶
LinkTarget is where href, a link in the document of the tab in front, goes: a web address or a file's path, or href itself if it can't tell.
func (Control) NewFile ¶
func (c Control) NewFile()
NewFile runs File › New File…: the tab in front asks which template to start from. With no window open there is no page to ask in, so it makes a blank file.
func (Control) NewTab ¶
func (c Control) NewTab()
NewTab opens a tab with the start screen in the window in front, or in a new window if there is none.
func (Control) NvimEdit ¶
NvimEdit does the Neovim pane's right-click Cut, Copy or Paste in the current tab, with the clipboard's get and set. They act on Neovim's selection: the page, which only draws Neovim's grid, has none for the usual edit commands. Paste in visual mode replaces the selection, as Neovim's own paste does.
func (Control) Open ¶
func (c Control) Open()
Open asks for markdown files and opens them in the window in front.
func (Control) OpenFromSystem ¶
OpenFromSystem opens a file the system asked the app to open, such as from Finder's Open With. Before SystemOpensReady it is held.
func (Control) OpenSettings ¶
OpenSettings brings the Settings tab forward, opening one if there is none, at one of its own tabs, such as "about", or at the one it was on for "".
func (Control) Quitting ¶
func (c Control) Quitting()
Quitting lets every window close without asking about unsaved output, as the program is ending.
func (Control) Send ¶
Send sends action to the tab in front as a "menu" event, so its page runs it the way its own buttons and keys do.
func (Control) SendTo ¶
SendTo sends action to the tab in front in window id as a "menu" event, and reports whether id is one of the App's windows.
func (Control) SetImages ¶
SetImages sets where the App remembers the images from other sites the user loaded in each file. Nil remembers nothing.
func (Control) SetLSP ¶
SetLSP says how to run the language server for a file, for the Neovim source pane: cmd(file) is the command and its arguments.
func (Control) SetOutside ¶
SetOutside sets where the App remembers which files may reach outside their folder, or hidden in it. Nil remembers nothing.
func (Control) SetTrust ¶
SetTrust sets where the answers to whether a file's env.source files may be read into its shells are remembered; nil remembers none.
func (Control) ShouldQuit ¶
ShouldQuit asks before quitting with unsaved output in any window.
func (Control) ShowChangelog ¶
func (c Control) ShowChangelog()
ShowChangelog brings the changelog's tab forward, for a Help menu.
func (Control) ShowCheatsheet ¶
func (c Control) ShowCheatsheet()
ShowCheatsheet brings the cheat sheet's tab forward, for a Help menu.
func (Control) Start ¶
func (c Control) Start(file string, run notebook.RunOptions) error
Start opens the first window, with file open in it, run with args, or with the start screen if file is "".
func (Control) SystemOpensReady ¶
func (c Control) SystemOpensReady()
SystemOpensReady opens the files the system asked for before the app started; later ones open at once.
type Depends ¶
type Depends struct {
Problems []notebook.DependsProblem `json:"problems"`
Version notebook.Version `json:"version"`
}
Depends are DependsAt's problems at a version of the file.
type Doc ¶
type Doc struct {
File string `json:"file"`
Dirty bool `json:"dirty"`
Changed bool `json:"changed"`
Running bool `json:"running"` // a run is going on
// Fresh is set the first time Doc is asked for after a file opens
// in the tab, but not after it is reloaded, so the page can show
// the view the settings open files in.
Fresh bool `json:"fresh"`
// OpenHistory is set the first time Doc is asked for after a
// session opens in the tab, so the page opens the History pane and
// focuses it.
OpenHistory bool `json:"openHistory"`
Run notebook.RunOptions `json:"run"`
// Args is Run.Args as one line, quoted as a shell would need.
Args string `json:"args"`
// History is set while the History pane is on for the file.
History bool `json:"history"`
// TermCols and TermRows are the terminal size the front matter asks
// for, 0 where it doesn't.
TermCols int `json:"termCols"`
TermRows int `json:"termRows"`
// EnvBanner, if set, says that the front matter brings in more than
// the base set from the environment the app started in (env.share
// with ..., or naming variables).
EnvBanner string `json:"envBanner"`
// FrontMatterError, if set, is why the front matter doesn't parse:
// the page shows it and runs nothing until it does. FrontMatterFix
// is the fix FixWarning makes for it, with that as the warning, if
// there is one; its Label is "" if not.
FrontMatterError string `json:"frontMatterError"`
FrontMatterFix notebook.Fix `json:"frontMatterFix"`
// LastView is how the file was last shown, "rendered", "source" or
// "both", or "" if that isn't remembered. LastHistory is whether
// its History pane was open then.
LastView string `json:"lastView"`
LastHistory bool `json:"lastHistory"`
}
Doc is what the frontend shows about the open file.
type FolderForm ¶
type FolderForm struct {
// Path is the folder's absolute path.
Path string `json:"path"`
Settings collection.Settings `json:"settings"`
// Images are image files in the folder, for the icon and background.
Images []string `json:"images"`
}
FolderForm is what the folder settings dialog edits.
type Host ¶
type Host interface {
// NewWindow opens a window showing the tab bar, for file if it
// isn't "": where file's window was last, say. The host tells the
// App's Control when it is closing, gets files dropped on it or
// comes to the front.
NewWindow(file string) Window
// WindowOf is the window a frontend call came from.
WindowOf(ctx context.Context) (id uint, ok bool)
// Current is the window in front, if the host knows.
Current() (id uint, ok bool)
// EmitAll sends an event to every window.
EmitAll(name string, data any)
// OnMain runs fn where the host may close windows.
OnMain(fn func())
// ShowError tells the user about err, over win if it isn't nil.
ShowError(win Window, err error)
// Ask asks a question over win with buttons and returns at once;
// the button picked runs its Do, if it has one.
Ask(win Window, q Question)
// OpenFiles asks for markdown files, starting in dir.
OpenFiles(win Window, dir string) ([]string, error)
// SaveFile asks where to save a file, and returns "" if none was
// picked.
SaveFile(win Window, s SaveFile) (string, error)
// ChooseFolder asks for a folder, with title, starting in dir, over
// the window the call ctx is for came from, and returns "" if none
// was picked.
ChooseFolder(ctx context.Context, title, dir string) (string, error)
// ChooseFile asks for a markdown file, with title, starting in dir,
// over the window the call ctx is for came from, and returns "" if
// none was picked.
ChooseFile(ctx context.Context, title, dir string) (string, error)
// Reveal shows file in the file manager.
Reveal(file string) error
// OpenURL opens a web address, as a link in a document gives it.
OpenURL(url string) error
// OpenFile opens a file that isn't markdown, as the system would.
OpenFile(file string) error
// CopySecret puts text, which may hold a secret, on the clipboard,
// kept out of clipboard history where the system allows, and takes
// it off again after clear unless something else was copied.
CopySecret(text string, clear time.Duration) error
// CopyGIF puts data, an animated GIF, on the clipboard. Where it
// can't, its error says it "needs macOS", and the page copies the
// recording's text instead.
CopyGIF(data []byte) error
// CLIState says where the command line tool the app carries stands;
// the zero CLI when it carries none.
CLIState() CLI
// InstallCLI puts the command line tool on PATH, and returns where
// it stands after.
InstallCLI() (CLI, error)
// UninstallCLI takes the command line tool off PATH, when it's the
// app's, and returns where it stands after.
UninstallCLI() (CLI, error)
// ShowView says what the tab in front shows, for a View menu.
ShowView(v View)
// RecentChanged says the recent files changed, for an Open Recent
// menu.
RecentChanged()
// Quit quits, after ShouldQuit has said yes.
Quit()
}
Host is what an App needs from the program that shows its windows: mdsh-gui's Wails windows, say. Each window's page is web's window.html.
type NeovimInfo ¶
type NeovimInfo struct {
Path string `json:"path"`
Version string `json:"version"`
// Error is why Neovim can't be used, or "".
Error string `json:"error"`
}
NeovimInfo is what Settings shows about Neovim.
type NvimEvent ¶
NvimEvent is something the Neovim buffer reports: its name, such as "cursor" or "run", and its data as JSON.
type NvimText ¶
type NvimText struct {
Text string `json:"text"`
Version notebook.Version `json:"version"`
Buffer string `json:"buffer"`
Seq int `json:"seq"`
}
NvimText is what NvimStart answers: the file's text and its version, for Edit, and Neovim's text and seq, the count of its changes it sent and edits it took. A Neovim that just started has the file's text, at seq 0; one already running has its own, typing the file doesn't have yet included.
type OutsideFiles ¶
type OutsideFiles struct {
// Paths are the files, as the document writes them.
Paths []string `json:"paths"`
// Root is the folder they are outside: the document's folder,
// with the home folder as ~.
Root string `json:"root"`
// Answer is "allow" or "deny", or "" when this list hasn't been
// answered: the page asks.
Answer string `json:"answer"`
}
OutsideFiles are the files a document's includes and out= name outside its folder, or hidden in it, and what the user last said about them.
type ReportStart ¶
type ReportStart struct {
Ran int `json:"ran"` // runnable blocks that ran in this tab
Total int `json:"total"` // runnable blocks
// Dest is where a report goes unless another file is picked: beside
// the document, named after it, without an extension.
Dest string `json:"dest"`
Home string `json:"home"` // for showing paths as ~/…
}
ReportStart is what the Report dialog starts with.
type SaveFile ¶
type SaveFile struct {
Message string
Button string // the button that saves, if not the usual one
Dir string
Name string
Filter string // the name of the files Pattern matches
Pattern string // such as "*.md;*.markdown"
}
SaveFile is what Host.SaveFile asks.
type SourceBlocks ¶
type SourceBlocks struct {
Blocks []notebook.SourceBlock `json:"blocks"`
Version notebook.Version `json:"version"`
}
SourceBlocks are blocks at a version of the file.
type SourceText ¶
SourceText is the whole file and the version it is at, for a source pane opening on it: later changes come as line events since.
type Start ¶
type Start struct {
Dir string `json:"dir"`
Home string `json:"home"` // for showing paths as ~/…
Files []library.File `json:"files"`
Collections []library.Collection `json:"collections"`
Full bool `json:"full"` // more files than listed
Recent []string `json:"recent"`
// Pinned are the pinned files that still exist, shown above Recent.
Pinned []string `json:"pinned"`
// LastSession is the file Last Session opens, or "" if there are no
// sessions yet.
LastSession string `json:"lastSession"`
// Writable are the listed folders, by rel, whose .mdsh.yaml the
// folder settings can save.
Writable []string `json:"writable"`
// Outside are the files, by absolute path, allowed to reach outside
// their folder or repository, which the list tags.
Outside []string `json:"outside"`
}
Start is what the start screen lists.
type Tab ¶
type Tab struct {
ID int `json:"id"`
Title string `json:"title"`
File string `json:"file"`
// URL is the address of a document the app carries inside it, such
// as the changelog, for a tab that shows one and has no File. A tab
// dragged out to another app gives it File, or else URL.
URL string `json:"url,omitempty"`
Dirty bool `json:"dirty"`
// Page is the page the tab shows, if not a document's.
Page string `json:"page,omitempty"`
// ReadOnly is set for a page that can't be edited, such as the
// changelog.
ReadOnly bool `json:"readOnly,omitempty"`
}
Tab is a tab as the tab bar draws it.
type Tool ¶
type Tool struct {
Name string `json:"name"`
Note string `json:"note"` // what it's for
Path string `json:"path"` // where it was found, or ""
Version string `json:"version"` // what --version said, or ""
// Bundled is set when Path is the mdsh inside the app, which isn't
// on PATH.
Bundled bool `json:"bundled"`
}
Tool is a program the notebook uses, and whether it was found on PATH.
type View ¶
type View struct {
Split bool `json:"split"` // the source pane
Rendered bool `json:"rendered"` // the rendered view
Outline bool `json:"outline"`
Code bool `json:"code"`
Output bool `json:"output"`
History bool `json:"history"` // the History pane
Console bool `json:"console"` // the Console pane
}
View is what a tab shows, for the View menu's check marks.
type Window ¶
type Window interface {
ID() uint
// Emit sends an event to the window's page.
Emit(name string, data any)
SetTitle(title string)
Close()
Focus()
// MoveTo puts the window's top left corner at x, y on the screen.
MoveTo(x, y int)
// Fit gives the window, which has just opened file in place of the
// start screen, the size file's window had last, if the host
// remembers it.
Fit(file string)
}
Window is one of a Host's windows.
type ZshWrapper ¶
type ZshWrapper struct {
Path string `json:"path"` // the .zshrc
BashPath string `json:"bashPath"` // the .bashrc, or "" when there is none
Home string `json:"home"` // for showing Path as ~/…
On bool `json:"on"`
}
ZshWrapper is whether the user's .zshrc, and .bashrc if they have one, has the mdsh function that gives blocks the calling shell's aliases and functions, and loads mdsh's completion.