Comment and cosmetics.

This commit is contained in:
Qi Xiao 2017-06-27 01:50:06 +01:00
parent f8231c13d4
commit cfc473fcfe
3 changed files with 22 additions and 18 deletions

View File

@ -5,16 +5,8 @@ import (
"github.com/elves/elvish/eval"
)
// Mode is an editor mode.
type Mode interface {
ModeLine() renderer
Binding(ui.Key) eval.CallableValue
}
type CursorOnModeLiner interface {
CursorOnModeLine() bool
}
// Names of modes, used for subnamespaces of le: and name of binding table in
// $le:binding.
const (
modeInsert = "insert"
modeRawInsert = "raw-insert"
@ -28,14 +20,28 @@ const (
modeListing = "listing" // A "super mode" for histlist, lastcmd, loc
)
// ListRenderer is a mode with a listing.
type ListRenderer interface {
// ListRender renders the listing under the given constraint of width and maximum
// height. It returns a rendered buffer.
ListRender(width, maxHeight int) *buffer
// Mode is an editor mode.
type Mode interface {
ModeLine() renderer
Binding(ui.Key) eval.CallableValue
}
// CursorOnModeLiner is an optional interface that modes can implement. If a
// mode does and the method returns true, the cursor is placed on the modeline
// when that mode is active.
type CursorOnModeLiner interface {
CursorOnModeLine() bool
}
// Lister is a mode with a listing.
type Lister interface {
List(maxHeight int) renderer
}
// ListRenderer is a mode with a listing that handles the rendering itself.
// NOTE(xiaq): This interface is being deprecated in favor of Lister.
type ListRenderer interface {
// ListRender renders the listing under the given constraint of width and
// maximum height. It returns a rendered buffer.
ListRender(width, maxHeight int) *buffer
}

View File

@ -146,7 +146,6 @@ func navDefault(ed *Editor) {
}
// Implementation.
// TODO(xiaq): Support file preview in navigation mode
// TODO(xiaq): Remember which file was selected in each directory.
var (

View File

@ -49,8 +49,7 @@ var keyBindings = map[string]map[ui.Key]eval.CallableValue{}
// subnamespace using information from builtinMaps. It should be called in init
// functions.
func registerBindings(
mt string, defaultMod string,
bindingData map[ui.Key]string) struct{} {
mt string, defaultMod string, bindingData map[ui.Key]string) struct{} {
if _, ok := keyBindings[mt]; !ok {
keyBindings[mt] = map[ui.Key]eval.CallableValue{}