edit: Don't "import .", this breaks godoc output.

This commit is contained in:
Qi Xiao 2018-02-08 16:43:47 -08:00
parent e534b9b732
commit 2d241485ec
11 changed files with 62 additions and 50 deletions

View File

@ -1,15 +1,15 @@
package edit
import . "github.com/elves/elvish/edit/edtypes"
import "github.com/elves/elvish/edit/edtypes"
func (ed *editor) SetAction(action Action) {
if ed.nextAction == NoAction {
func (ed *editor) SetAction(action edtypes.Action) {
if ed.nextAction == noAction {
ed.nextAction = action
}
}
func (ed *editor) popAction() Action {
func (ed *editor) popAction() edtypes.Action {
action := ed.nextAction
ed.nextAction = NoAction
ed.nextAction = noAction
return action
}

View File

@ -5,8 +5,7 @@ import (
"strconv"
"unicode/utf8"
. "github.com/elves/elvish/edit/edtypes"
"github.com/elves/elvish/edit/edtypes"
"github.com/elves/elvish/edit/ui"
"github.com/elves/elvish/eval"
"github.com/elves/elvish/eval/vartypes"
@ -101,7 +100,7 @@ func makeNs(ed *editor) eval.Ns {
// Functions.
fns := map[string]interface{}{
"binding-table": MakeBindingMap,
"binding-table": edtypes.MakeBindingMap,
"command-history": commandHistory,
"complete-getopt": complGetopt,
"complex-candidate": makeComplexCandidate,

View File

@ -5,7 +5,7 @@ import (
"strings"
"unicode/utf8"
. "github.com/elves/elvish/edit/edtypes"
"github.com/elves/elvish/edit/edtypes"
"github.com/elves/elvish/edit/ui"
"github.com/elves/elvish/eval"
"github.com/elves/elvish/util"
@ -16,7 +16,7 @@ import (
// Interface.
type completion struct {
binding BindingMap
binding edtypes.BindingMap
completionState
}
@ -36,7 +36,7 @@ type completionState struct {
func init() { atEditorInit(initCompletion) }
func initCompletion(ed *editor, ns eval.Ns) {
c := &completion{binding: EmptyBindingMap}
c := &completion{binding: emptyBindingMap}
ed.completion = c
subns := eval.Ns{
@ -116,7 +116,7 @@ func complDefault(ed *editor) {
}
} else {
complAccept(ed)
ed.SetAction(ReprocessKey)
ed.SetAction(reprocessKey)
}
}

View File

@ -12,7 +12,7 @@ import (
"time"
"github.com/elves/elvish/daemon"
. "github.com/elves/elvish/edit/edtypes"
"github.com/elves/elvish/edit/edtypes"
"github.com/elves/elvish/edit/highlight"
"github.com/elves/elvish/edit/prompt"
"github.com/elves/elvish/edit/tty"
@ -64,9 +64,9 @@ type editor struct {
navigation *navigation
listing *listing
histlistBinding BindingMap
lastcmdBinding BindingMap
locationBinding BindingMap
histlistBinding edtypes.BindingMap
lastcmdBinding edtypes.BindingMap
locationBinding edtypes.BindingMap
editorState
}
@ -90,19 +90,19 @@ type editorState struct {
promptContent []*ui.Styled
rpromptContent []*ui.Styled
mode Mode
mode edtypes.Mode
// A cache of external commands, used in stylist.
isExternal map[string]bool
// Used for builtins.
lastKey ui.Key
nextAction Action
nextAction edtypes.Action
}
// NewEditor creates an Editor. When the instance is no longer used, its Close
// method should be called.
func NewEditor(in *os.File, out *os.File, sigs chan os.Signal, ev *eval.Evaler) Editor {
func NewEditor(in *os.File, out *os.File, sigs chan os.Signal, ev *eval.Evaler) edtypes.Editor {
daemon := ev.DaemonClient
ed := &editor{
@ -182,7 +182,7 @@ func (ed *editor) SetBuffer(buffer string, dot int) {
ed.buffer, ed.dot = buffer, dot
}
func (ed *editor) SetMode(m Mode) {
func (ed *editor) SetMode(m edtypes.Mode) {
if ed.mode != nil {
ed.mode.Teardown()
}
@ -193,7 +193,7 @@ func (ed *editor) SetModeInsert() {
ed.SetMode(ed.insert)
}
func (ed *editor) SetModeListing(pb *BindingMap, lp listingProvider) {
func (ed *editor) SetModeListing(pb *edtypes.BindingMap, lp listingProvider) {
ed.listing.listingState = *newListing(pb, lp)
ed.SetMode(ed.listing)
}
@ -498,15 +498,15 @@ MainLoop:
}
switch ed.popAction() {
case ReprocessKey:
case reprocessKey:
err := ed.refresh(false, true)
if err != nil {
return "", err
}
goto lookupKey
case CommitLine:
case commitLine:
return ed.buffer, nil
case CommitEOF:
case commitEOF:
return "", io.EOF
}
}

14
edit/edtypes.go Normal file
View File

@ -0,0 +1,14 @@
package edit
import "github.com/elves/elvish/edit/edtypes"
// Aliases for variables and functions from the edtypes package.
// NOTE: We cannot use type aliases before we drop support for Go 1.8.
var (
noAction = edtypes.NoAction
reprocessKey = edtypes.ReprocessKey
commitLine = edtypes.CommitLine
commitEOF = edtypes.CommitEOF
emptyBindingMap = edtypes.EmptyBindingMap
)

View File

@ -6,7 +6,7 @@ import (
"strings"
"sync"
. "github.com/elves/elvish/edit/edtypes"
"github.com/elves/elvish/edit/edtypes"
"github.com/elves/elvish/edit/history"
"github.com/elves/elvish/edit/ui"
"github.com/elves/elvish/eval"
@ -19,7 +19,7 @@ type hist struct {
ed *editor
mutex sync.RWMutex
fuser *history.Fuser
binding BindingMap
binding edtypes.BindingMap
// Non-persistent state.
walker *history.Walker
@ -30,7 +30,7 @@ func init() {
}
func initHist(ed *editor, ns eval.Ns) {
hist := &hist{ed: ed, binding: EmptyBindingMap}
hist := &hist{ed: ed, binding: emptyBindingMap}
if ed.Daemon() != nil {
fuser, err := history.NewFuser(ed.Daemon())
if err != nil {
@ -124,7 +124,7 @@ func (hist *hist) defaultFn() {
newBuffer := hist.walker.CurrentCmd()
hist.ed.SetBuffer(newBuffer, len(newBuffer))
hist.ed.SetModeInsert()
hist.ed.SetAction(ReprocessKey)
hist.ed.SetAction(reprocessKey)
}
func (hist *hist) appendHistory(line string) {

View File

@ -5,7 +5,7 @@ import (
"unicode"
"unicode/utf8"
. "github.com/elves/elvish/edit/edtypes"
"github.com/elves/elvish/edit/edtypes"
"github.com/elves/elvish/edit/ui"
"github.com/elves/elvish/eval"
"github.com/elves/elvish/util"
@ -53,7 +53,7 @@ func initCoreFns(ed *editor, ns eval.Ns) {
}
type insert struct {
binding BindingMap
binding edtypes.BindingMap
insertState
}
@ -67,7 +67,7 @@ type insertState struct {
}
func initInsert(ed *editor, ns eval.Ns) {
insert := &insert{binding: EmptyBindingMap}
insert := &insert{binding: emptyBindingMap}
ed.insert = insert
insertNs := eval.Ns{
@ -97,11 +97,11 @@ func (ins *insert) Binding(k ui.Key) eval.Callable {
}
type command struct {
binding BindingMap
binding edtypes.BindingMap
}
func initCommand(ed *editor, ns eval.Ns) {
command := &command{binding: EmptyBindingMap}
command := &command{binding: emptyBindingMap}
ed.command = command
commandNs := eval.Ns{
@ -300,7 +300,7 @@ func (ed *editor) insertKey() {
}
func (ed *editor) returnLine() {
ed.SetAction(CommitLine)
ed.SetAction(commitLine)
}
func (ed *editor) smartEnter() {
@ -322,7 +322,7 @@ func findLastIndent(s string) string {
func (ed *editor) returnEOF() {
if len(ed.buffer) == 0 {
ed.SetAction(CommitEOF)
ed.SetAction(commitEOF)
}
}

View File

@ -5,7 +5,6 @@ import (
"strconv"
"strings"
. "github.com/elves/elvish/edit/edtypes"
"github.com/elves/elvish/edit/ui"
"github.com/elves/elvish/eval"
)
@ -118,7 +117,7 @@ func lastcmdAltDefault(ed *editor) {
}
} else {
ed.SetModeInsert()
ed.SetAction(ReprocessKey)
ed.SetAction(reprocessKey)
}
}

View File

@ -6,7 +6,7 @@ import (
"strings"
"unicode/utf8"
. "github.com/elves/elvish/edit/edtypes"
"github.com/elves/elvish/edit/edtypes"
"github.com/elves/elvish/edit/ui"
"github.com/elves/elvish/eval"
"github.com/elves/elvish/util"
@ -15,12 +15,12 @@ import (
// listing implements a listing mode that supports the notion of selecting an
// entry and filtering entries.
type listing struct {
commonBinding BindingMap
commonBinding edtypes.BindingMap
listingState
}
type listingState struct {
binding *BindingMap
binding *edtypes.BindingMap
provider listingProvider
selected int
filter string
@ -31,7 +31,7 @@ type listingState struct {
func init() { atEditorInit(initListing) }
func initListing(ed *editor, ns eval.Ns) {
l := &listing{commonBinding: EmptyBindingMap}
l := &listing{commonBinding: emptyBindingMap}
ed.listing = l
subns := eval.Ns{
@ -67,7 +67,7 @@ type placeholderer interface {
Placeholder() string
}
func newListing(pb *BindingMap, p listingProvider) *listingState {
func newListing(pb *edtypes.BindingMap, p listingProvider) *listingState {
l := &listingState{pb, p, 0, "", 0, 0}
l.refresh()
for i := 0; i < p.Len(); i++ {
@ -339,6 +339,6 @@ func (l *listingState) handleFilterKey(k ui.Key) bool {
func (l *listingState) defaultBinding(ed *editor) {
if !l.handleFilterKey(ed.lastKey) {
ed.SetModeInsert()
ed.SetAction(ReprocessKey)
ed.SetAction(reprocessKey)
}
}

View File

@ -6,7 +6,7 @@ import (
"strings"
"unicode/utf8"
. "github.com/elves/elvish/edit/edtypes"
"github.com/elves/elvish/edit/edtypes"
"github.com/elves/elvish/edit/ui"
"github.com/elves/elvish/eval"
"github.com/elves/elvish/eval/types"
@ -16,14 +16,14 @@ import (
// narrow implements a listing mode that supports the notion of selecting an
// entry and filtering entries.
type narrow struct {
binding BindingMap
binding edtypes.BindingMap
narrowState
}
func init() { atEditorInit(initNarrow) }
func initNarrow(ed *editor, ns eval.Ns) {
n := &narrow{binding: EmptyBindingMap}
n := &narrow{binding: emptyBindingMap}
subns := eval.Ns{
"binding": eval.NewVariableFromPtr(&n.binding),
}
@ -317,7 +317,7 @@ func (l *narrowState) handleFilterKey(ed *editor) bool {
func (l *narrowState) defaultBinding(ed *editor) {
if !l.handleFilterKey(ed) {
ed.SetModeInsert()
ed.SetAction(ReprocessKey)
ed.SetAction(reprocessKey)
}
}

View File

@ -8,7 +8,7 @@ import (
"strings"
"unicode/utf8"
. "github.com/elves/elvish/edit/edtypes"
"github.com/elves/elvish/edit/edtypes"
"github.com/elves/elvish/edit/lscolors"
"github.com/elves/elvish/edit/ui"
"github.com/elves/elvish/eval"
@ -21,7 +21,7 @@ import (
// Interface.
type navigation struct {
binding BindingMap
binding edtypes.BindingMap
chdir func(string) error
navigationState
}
@ -39,7 +39,7 @@ func init() { atEditorInit(initNavigation) }
func initNavigation(ed *editor, ns eval.Ns) {
n := &navigation{
binding: EmptyBindingMap,
binding: emptyBindingMap,
chdir: func(dir string) error { return eval.Chdir(dir, ed.daemon) },
}
ed.navigation = n