Documentation
¶
Overview ¶
Package history is what a History terminal needs, as mdsh-gui's History pane and mdsh -i have: a terminal where a command typed runs in the document's shell and is added to the end of the document as a block, #history-N, with its output, and a note, lines starting with #, is added as prose.
It asks the shell through an Asker, such as a *run.Session, so what it sees is what blocks left there: the directory, variables and prompts.
Index ¶
- func AddNote(d *doc.Document, text string, carry bool) error
- func Background(input string) (string, bool)
- func Info(lang, id string, background bool) string
- func Lang(shell string) string
- func NextID(d *doc.Document) string
- func Note(input string) (string, bool)
- func RCScript(path string) string
- func Shell(d *doc.Document, override string) string
- func Whole(shell, input string) bool
- type Asker
- type Completion
- type Prompt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddNote ¶
AddNote adds text to the end of d as prose. With carry, it carries on the paragraph that ends d, as a note added just before does; else it starts a paragraph. It fails, leaving d as it was, if text would change d's blocks, as it would inside a fence left open.
func Background ¶
Background reports whether input ends in a lone &, as a command run in the background does, and returns it without the &.
func Info ¶
Info is the info string a command is added with: lang and id, and background if it was typed with a trailing &.
func Lang ¶
Lang is the language commands are added as: zsh if the blocks run in shell zsh, else sh.
func NextID ¶
NextID is the id for the next command in d: one past the highest history-N there. A history block that moved has an id of its own, but its output can still link to a file saved under its old one, so those count too: a new block of that number would write over the file.
func Note ¶
Note returns the text of input if it is a note: every line starts with #, which is taken off along with a space after it.
func RCScript ¶
RCScript reads the file at path, if there is one, in the shell, as an interactive shell reads its rc file. A leading ~/ is the home folder. What it prints is dropped, along with any errors, since an rc file often does things only an interactive shell can.
func Shell ¶
Shell is the shell blocks of d run in: override if set, else what d asks for, else /bin/sh.
Types ¶
type Asker ¶
Asker runs script in the shell blocks run in and returns what it printed. *run.Session is one.
type Completion ¶
Completion is what Tab offers for the word before the cursor: each of Items replaces Word, the end of what was typed.
func Complete ¶
Complete completes the word at the end of before, what is typed up to the cursor, asking the shell, so it sees the directory and variables blocks left there: a $ word is a variable, the first word of a command is a command, and any other word, or one with a /, a file. A directory ends in /. Items are quoted for the shell, as they would be typed. zsh says the shell is zsh.