mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-13 01:47:51 +08:00
a3f4384495
The elvdocs still use the old format (#elvdoc:fn or #elvdoc:var) for now, but will be changed to "fn" and "var" forms soon. Also remove the accidentally committed cmd/mvelvdoc. It has been used to perform the conversion automatically but is not supposed to be committed.
27 lines
895 B
Go
27 lines
895 B
Go
package edit
|
|
|
|
// This file encapsulates functionality related to a complete REPL cycle. Such as capturing
|
|
// information about the most recently executed interactive command.
|
|
|
|
import (
|
|
"src.elv.sh/pkg/eval"
|
|
"src.elv.sh/pkg/eval/vals"
|
|
"src.elv.sh/pkg/eval/vars"
|
|
"src.elv.sh/pkg/parse"
|
|
)
|
|
|
|
func initRepl(ed *Editor, ev *eval.Evaler, nb eval.NsBuilder) {
|
|
var commandDuration float64
|
|
// TODO: Ensure that this variable can only be written from the Elvish code
|
|
// in elv_init.go.
|
|
nb.AddVar("command-duration", vars.FromPtr(&commandDuration))
|
|
|
|
afterCommandHook := newListVar(vals.EmptyList)
|
|
nb.AddVar("after-command", afterCommandHook)
|
|
ed.AfterCommand = append(ed.AfterCommand,
|
|
func(src parse.Source, duration float64, err error) {
|
|
m := vals.MakeMap("src", src, "duration", duration, "error", err)
|
|
callHooks(ev, "$<edit>:after-command", afterCommandHook.Get().(vals.List), m)
|
|
})
|
|
}
|