mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-05 03:17:50 +08:00
Comment and cosmetics.
This commit is contained in:
parent
f8231c13d4
commit
cfc473fcfe
36
edit/mode.go
36
edit/mode.go
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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{}
|
||||
|
|
Loading…
Reference in New Issue
Block a user