Documentation
¶
Overview ¶
Package tui is mdsh's interactive mode: a terminal UI that shows a document, runs its blocks as they are picked, and saves their output back to the file.
Index ¶
Constants ¶
const MaxRecent = 10
MaxRecent is how many recent files are kept.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶ added in v1.3.0
type Config struct {
Open Opener
// File is the file to open. Without one, the start screen lists the
// markdown files under Dir, and q in a file goes back to it.
File string
Dir string
// State is the file that keeps the files opened most recently, which
// the start screen lists first, and the view the last file was left
// in. Empty keeps neither.
State string
}
Config is what Run shows.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the TUI's state. It is a tea.Model.
type Opener ¶ added in v1.3.0
Opener reads file and returns its document and the options to show it with. The TUI calls it to open a file from the start screen, to reload one and to follow one saved into another folder.
type Options ¶
type Options struct {
// Run are the options every run uses. Run.File must be set. The TUI
// sets Confirm and OnEvent itself.
Run run.Options
// Yes runs confirm blocks, every block in step mode, and the
// blocks depends= names, without
// asking.
Yes bool
// Save writes the document's new contents to file: Run.File, or
// the file picked by save as.
Save func(file string, out []byte) error
// AutoSave saves after every block that runs. Otherwise output is
// saved when w or ctrl+s is pressed.
AutoSave bool
// Writable reports whether a file can be saved, with an error
// wrapping writable.ErrReadOnly if it can't. If nil, writable.Check
// is used.
Writable func(file string) error
// Images turns on image previews, drawn with colored half blocks.
Images bool
// Protocol is how v shows an image at full size. With termimg.None
// it is drawn with half blocks, as large as the terminal allows.
Protocol termimg.Protocol
// Style is the glamour style prose is drawn in, such as "dark",
// "light" or "notty".
Style string
// View is how the file is shown at first.
View View
}
Options configure the TUI.
type RunOptions ¶ added in v1.3.0
RunOptions are the run options the run options form sets.
type View ¶ added in v1.3.0
type View struct {
// Outline shows the headings and blocks down the left.
Outline bool `json:"outline"`
// HideCode and HideOutput leave out the code and the output of
// blocks.
HideCode bool `json:"hideCode"`
HideOutput bool `json:"hideOutput"`
}
View is how a file is shown, as in mdsh-gui's View menu. The TUI keeps the last one used, so the next file opens the same way.