// NewEditor creates an Editor. func NewEditor(file *os.File, sigs chan os.Signal, ev *eval.Evaler, st *store.Store) *Editor { seq := -1 if st != nil { var err error seq, err = st.NextCmdSeq() if err != nil { // TODO(xiaq): Also report the error seq = -1 } } prompt, rprompt := defaultPrompts() ed := &Editor{ file: file, writer: newWriter(file), reader: NewReader(file), sigs: sigs, store: st, evaler: ev, cmdSeq: seq, ps1: eval.NewPtrVariableWithValidator(prompt, MustBeFn), rps1: eval.NewPtrVariableWithValidator(rprompt, MustBeFn), abbreviations: make(map[string]string), beforeReadLine: eval.NewPtrVariableWithValidator( eval.NewList(), eval.IsListOfFnValue), afterReadLine: eval.NewPtrVariableWithValidator( eval.NewList(), eval.IsListOfFnValue), } ev.Editor = ed ev.Modules["le"] = makeModule(ed) return ed }
// NewEditor creates an Editor. func NewEditor(file *os.File, sigs chan os.Signal, ev *eval.Evaler, st *store.Store) *Editor { seq := -1 if st != nil { var err error seq, err = st.NextCmdSeq() if err != nil { // TODO(xiaq): Also report the error seq = -1 } } ed := &Editor{ file: file, writer: newWriter(file), reader: NewReader(file), sigs: sigs, store: st, evaler: ev, cmdSeq: seq, } ev.Editor = ed return ed }