mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-13 09:57:51 +08:00
newedit/editutil -> newedit/cliutil.
This commit is contained in:
parent
eef1fd1540
commit
5151b4cbbf
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/elves/elvish/eval"
|
||||
"github.com/elves/elvish/eval/vals"
|
||||
"github.com/elves/elvish/newedit/clitypes"
|
||||
"github.com/elves/elvish/newedit/editutil"
|
||||
"github.com/elves/elvish/newedit/cliutil"
|
||||
)
|
||||
|
||||
// TODO(xiaq): Move the implementation into this package.
|
||||
|
@ -66,7 +66,7 @@ func callBinding(nt notifier, ev *eval.Evaler, f eval.Callable) clitypes.Handler
|
|||
err := frame.Call(f, nil, eval.NoOpts)
|
||||
|
||||
if err != nil {
|
||||
if action, ok := eval.Cause(err).(editutil.ActionError); ok {
|
||||
if action, ok := eval.Cause(err).(cliutil.ActionError); ok {
|
||||
return clitypes.HandlerAction(action)
|
||||
}
|
||||
// TODO(xiaq): Make the stack trace available.
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/elves/elvish/edit/ui"
|
||||
"github.com/elves/elvish/eval"
|
||||
"github.com/elves/elvish/newedit/clitypes"
|
||||
"github.com/elves/elvish/newedit/editutil"
|
||||
"github.com/elves/elvish/newedit/cliutil"
|
||||
)
|
||||
|
||||
func TestKeyHandlerFromBinding_CallsBinding(t *testing.T) {
|
||||
|
@ -150,7 +150,7 @@ func TestCallBinding_CapturesAction(t *testing.T) {
|
|||
nt := &fakeNotifier{}
|
||||
|
||||
action := callBinding(nt, ev, eval.NewGoFn("test", func() error {
|
||||
return editutil.ActionError(clitypes.CommitCode)
|
||||
return cliutil.ActionError(clitypes.CommitCode)
|
||||
}))
|
||||
if action != clitypes.CommitCode {
|
||||
t.Errorf("got ret = %v, want %v", action, clitypes.CommitCode)
|
||||
|
|
|
@ -2,7 +2,7 @@ package newedit
|
|||
|
||||
import (
|
||||
"github.com/elves/elvish/newedit/clitypes"
|
||||
"github.com/elves/elvish/newedit/editutil"
|
||||
"github.com/elves/elvish/newedit/cliutil"
|
||||
)
|
||||
|
||||
//elvdoc:fn exit-binding
|
||||
|
@ -11,7 +11,7 @@ import (
|
|||
// special exception.
|
||||
|
||||
func exitBinding() error {
|
||||
return editutil.ActionError(clitypes.NoAction)
|
||||
return cliutil.ActionError(clitypes.NoAction)
|
||||
}
|
||||
|
||||
//elvdoc:fn commit-code
|
||||
|
@ -20,7 +20,7 @@ func exitBinding() error {
|
|||
// code it just read. Internally, this works by raising a special exception.
|
||||
|
||||
func commitCode() error {
|
||||
return editutil.ActionError(clitypes.CommitCode)
|
||||
return cliutil.ActionError(clitypes.CommitCode)
|
||||
}
|
||||
|
||||
//elvdoc:fn commit-eof
|
||||
|
@ -29,5 +29,5 @@ func commitCode() error {
|
|||
// special exception.
|
||||
|
||||
func commitEOF() error {
|
||||
return editutil.ActionError(clitypes.CommitEOF)
|
||||
return cliutil.ActionError(clitypes.CommitEOF)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package clicore
|
|||
|
||||
import (
|
||||
"github.com/elves/elvish/newedit/clitypes"
|
||||
"github.com/elves/elvish/newedit/editutil"
|
||||
"github.com/elves/elvish/newedit/cliutil"
|
||||
)
|
||||
|
||||
// Returns the first non-nil value. If all are nil, return utils.BasicMode{}
|
||||
|
@ -12,5 +12,5 @@ func getMode(modes ...clitypes.Mode) clitypes.Mode {
|
|||
return mode
|
||||
}
|
||||
}
|
||||
return editutil.BasicMode{}
|
||||
return cliutil.BasicMode{}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package editutil
|
||||
package cliutil
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -1,4 +1,4 @@
|
|||
package editutil
|
||||
package cliutil
|
||||
|
||||
import (
|
||||
"testing"
|
|
@ -1,4 +1,4 @@
|
|||
package editutil
|
||||
package cliutil
|
||||
|
||||
import (
|
||||
"unicode"
|
|
@ -1,4 +1,4 @@
|
|||
package editutil
|
||||
package cliutil
|
||||
|
||||
import (
|
||||
"fmt"
|
2
newedit/cliutil/doc.go
Normal file
2
newedit/cliutil/doc.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
// Package cliutil provides utilities for the editor.
|
||||
package cliutil
|
|
@ -1,2 +0,0 @@
|
|||
// Package editutil provides utilities for the editor.
|
||||
package editutil
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/elves/elvish/edit/tty"
|
||||
"github.com/elves/elvish/edit/ui"
|
||||
"github.com/elves/elvish/newedit/clitypes"
|
||||
"github.com/elves/elvish/newedit/editutil"
|
||||
"github.com/elves/elvish/newedit/cliutil"
|
||||
"github.com/elves/elvish/parse"
|
||||
)
|
||||
|
||||
|
@ -132,7 +132,7 @@ func (m *Mode) handleKey(k ui.Key, st *clitypes.State) clitypes.HandlerAction {
|
|||
if m.KeyHandler != nil {
|
||||
action = m.KeyHandler(k)
|
||||
} else {
|
||||
action = editutil.BasicHandler(tty.KeyEvent(k), st)
|
||||
action = cliutil.BasicHandler(tty.KeyEvent(k), st)
|
||||
}
|
||||
if k.Mod != 0 || k.Rune < 0 {
|
||||
m.inserts = ""
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/elves/elvish/eval/vals"
|
||||
"github.com/elves/elvish/eval/vars"
|
||||
"github.com/elves/elvish/newedit/clitypes"
|
||||
"github.com/elves/elvish/newedit/editutil"
|
||||
"github.com/elves/elvish/newedit/cliutil"
|
||||
"github.com/elves/elvish/newedit/insert"
|
||||
"github.com/xiaq/persistent/hashmap"
|
||||
)
|
||||
|
@ -32,9 +32,9 @@ func initInsert(ed editor, ev *eval.Evaler) (*insert.Mode, eval.Ns) {
|
|||
}.AddGoFns("<edit:insert>:", map[string]interface{}{
|
||||
"start": func() { st.SetMode(m) },
|
||||
"default-handler": func() error {
|
||||
action := editutil.BasicHandler(tty.KeyEvent(st.BindingKey()), st)
|
||||
action := cliutil.BasicHandler(tty.KeyEvent(st.BindingKey()), st)
|
||||
if action != clitypes.NoAction {
|
||||
return editutil.ActionError(action)
|
||||
return cliutil.ActionError(action)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user