Documentation
¶
Overview ¶
Package repl includes the types and functions for a Read Eval Print Loop.
Index ¶
- Constants
- Variables
- func FindConfigDir() (dir string)
- func GetScope() *slip.Scope
- func Run()
- func RuneWidth(r rune) int
- func Scope() *slip.Scope
- func SetConfigDir(dir string)
- func SetSizer(hs hasSize)
- func Stop()
- func WordMatch(word string) (words []string, lo, hi int)
- func ZeroMods()
- type Ansi
- type ClearHistory
- type ClearStash
- type Completer
- type Completions
- type EditStash
- type Form
- type Help
- type History
- type LineReader
- type NthHistory
- type NthStash
- type Quit
- type Repl
- type ReplBindKey
- type ReplKeyActions
- type ReplKeyBinding
- type ReplUnbindKey
- type ShowHistory
- type ShowStash
- type Stash
- func (s *Stash) Add(form Form)
- func (s *Stash) Append(b []byte, annotate, tight, raw bool, start, end int) []byte
- func (s *Stash) Clear(start, end int)
- func (s *Stash) Cursor() int
- func (s *Stash) Get() (form Form)
- func (s *Stash) LoadExpanded(filename string)
- func (s *Stash) Nth(n int) (form Form)
- func (s *Stash) SearchBack(target string) Form
- func (s *Stash) SearchForward(target string) (form Form)
- func (s *Stash) SetCursor(pos int)
- func (s *Stash) Size() int
- type Termock
- func (tm *Termock) Append(b []byte) []byte
- func (tm *Termock) Close()
- func (tm *Termock) Equal(other slip.Object) bool
- func (tm *Termock) Eval(s *slip.Scope, depth int) slip.Object
- func (tm *Termock) Hierarchy() []slip.Symbol
- func (tm *Termock) HoldCursorReports(n int)
- func (tm *Termock) Input(keys ...string)
- func (tm *Termock) Output() string
- func (tm *Termock) Read(p []byte) (n int, err error)
- func (tm *Termock) ReleaseCursorReports()
- func (tm *Termock) SendBeforeCursorReport(text string, sameRead bool)
- func (tm *Termock) Simplify() any
- func (tm *Termock) SplitCursorReport(at int)
- func (tm *Termock) String() string
- func (tm *Termock) Write(p []byte) (n int, err error)
- type UseStash
Constants ¶
const (
MAX_DIM = 9999
)
Variables ¶
var ( Pkg = slip.Package{ Name: "repl", Nicknames: []string{}, Doc: "A package for REPL related functions.", PreSet: slip.DefaultPreSet, } // TheHistory is the single global used by readers (editor and // termReader). TheHistory History TheStash Stash )
var ( // Interactive is set to true when the REPL is interactive. Interactive bool // Trace reflects the value of tracing as set on startup. It does no // reflect the current trace state. Trace bool // DebugEditor if set before Run() is called will log keystrokes to // editor.log when using the editor. DebugEditor bool )
Functions ¶
func FindConfigDir ¶ added in v0.9.5
func FindConfigDir() (dir string)
FindConfigDir finds the preferred config directory.
func SetConfigDir ¶
func SetConfigDir(dir string)
SetConfigDir sets the configuration directory for the configuration and history files.
Types ¶
type ClearHistory ¶ added in v0.9.0
ClearHistory represents the clear-history function.
type ClearStash ¶ added in v0.9.0
ClearStash represents the clear-stash function.
type Completer ¶
type Completer struct {
// contains filtered or unexported fields
}
Completer provides completion choices given a partial word. Words are stored in a slice in sorted order to optimize not only the search for a match but for returing a slice of matches.
type Completions ¶ added in v0.9.5
Completions represents the completions function.
type Form ¶
type Form [][]rune
Form is used to represent slip forms as a sequence of lines which are []rune.
type History ¶
type History struct {
Stash
// contains filtered or unexported fields
}
History keeps a history of forms. Previously added Forms are stored in memory and also to a file.
type LineReader ¶
type LineReader struct {
// contains filtered or unexported fields
}
LineReader is an io.Reader that is optimized for reading lines terminated by a newline character.
func NewLineReader ¶
func NewLineReader(r io.Reader, size uint) *LineReader
NewLineReader creates a new LineReader.
func (*LineReader) Read ¶
func (lr *LineReader) Read(p []byte) (n int, err error)
Read into the provided buffer, p.
func (*LineReader) ReadLine ¶
func (lr *LineReader) ReadLine() ([]byte, error)
ReadLine reads a line. The returned line is the internal buffer so should be copied if it needs to be preserved past the next call to the reader.
type NthHistory ¶ added in v0.9.0
NthHistory represents the nth-history function.
type ReplBindKey ¶ added in v1.6.0
ReplBindKey represents the repl-bind-key function.
type ReplKeyActions ¶ added in v1.6.0
ReplKeyActions represents the repl-key-actions function.
type ReplKeyBinding ¶ added in v1.6.0
ReplKeyBinding represents the repl-key-binding function.
type ReplUnbindKey ¶ added in v1.6.0
ReplUnbindKey represents the repl-unbind-key function.
type ShowHistory ¶ added in v0.9.0
ShowHistory represents the show-history function.
type Stash ¶ added in v0.9.0
type Stash struct {
// contains filtered or unexported fields
}
Stash is used for history and general use stashes which are a collection of LISP expressions.
func (*Stash) LoadExpanded ¶ added in v0.9.0
LoadExpanded forms from a file and use that file for updates to history.
func (*Stash) SearchBack ¶ added in v0.9.0
SearchBack for a match to the provided target string starting with the cursor position.
func (*Stash) SearchForward ¶ added in v0.9.0
SearchForward for a match to the provided target string starting with the cursor at the start position.
type Termock ¶
type Termock struct {
// contains filtered or unexported fields
}
Termock is a mock terminal for testing the editor.
func NewTermock ¶
NewTermock creates a new Termock with an initial size described by high and wide.
func (*Termock) Close ¶ added in v1.6.0
func (tm *Termock) Close()
Close the Termock so Output returns an empty string. The output channel is left open since the editor may still write to it. Close can be called more than once.
func (*Termock) HoldCursorReports ¶ added in v1.6.0
HoldCursorReports holds back the next n cursor position reports, as when a terminal is slow to answer, until ReleaseCursorReports is called.
func (*Termock) Output ¶
Output returns the next output or an empty string once the Termock is closed.
func (*Termock) Read ¶
Read the next input. Input longer than p is returned over several reads as a terminal would.
func (*Termock) ReleaseCursorReports ¶ added in v1.6.0
func (tm *Termock) ReleaseCursorReports()
ReleaseCursorReports sends all held cursor position reports in one read.
func (*Termock) SendBeforeCursorReport ¶ added in v1.6.0
SendBeforeCursorReport sends text as input just before the next cursor position report, as when a user types while a slow terminal answers a query. If sameRead is true the text and the report arrive in one read.
func (*Termock) Simplify ¶
Simplify the Object into simple go types of nil, bool, int64, float64, string, []any, map[string]any, or time.Time.
func (*Termock) SplitCursorReport ¶ added in v1.6.0
SplitCursorReport sends the next cursor position report as two reads, the first with at bytes, as when a report arrives across two reads.
Source Files
¶
- actions.go
- ansi.go
- bindings.go
- clear-history.go
- clear-stash.go
- completer.go
- completions.go
- dirty.go
- doc.go
- edit-stash.go
- editor.go
- form.go
- hassize.go
- help.go
- history.go
- keyname.go
- linereader.go
- nth-history.go
- nth-stash.go
- pkg.go
- point.go
- quit.go
- reader.go
- repl-bind-key.go
- repl-key-actions.go
- repl-key-binding.go
- repl-unbind-key.go
- repl.go
- runewidth.go
- show-history.go
- show-stash.go
- stash.go
- termock.go
- termreader.go
- use-stash.go
- userkeys.go