Fix internal string binding representation
This commit is contained in:
parent
5d230754a8
commit
95fea064b0
7 changed files with 18 additions and 8 deletions
|
@ -83,8 +83,6 @@ func BindKey(k, v string, bind func(e Event, a string)) {
|
|||
return
|
||||
}
|
||||
|
||||
config.Bindings[event.Name()] = v
|
||||
|
||||
bind(event, v)
|
||||
|
||||
// switch e := event.(type) {
|
||||
|
@ -322,9 +320,9 @@ func UnbindKey(k string) error {
|
|||
defaults := DefaultBindings("buffer")
|
||||
if a, ok := defaults[k]; ok {
|
||||
BindKey(k, a, Binder["buffer"])
|
||||
} else if _, ok := config.Bindings[k]; ok {
|
||||
} else if _, ok := config.Bindings["buffer"][k]; ok {
|
||||
BufUnmap(key)
|
||||
delete(config.Bindings, k)
|
||||
delete(config.Bindings["buffer"], k)
|
||||
}
|
||||
|
||||
txt, _ := json.MarshalIndent(parsed, "", " ")
|
||||
|
|
|
@ -62,6 +62,8 @@ func LuaAction(fn string) func(*BufPane) bool {
|
|||
|
||||
// BufMapKey maps an event to an action
|
||||
func BufMapEvent(k Event, action string) {
|
||||
config.Bindings["buffer"][k.Name()] = action
|
||||
|
||||
switch e := k.(type) {
|
||||
case KeyEvent, KeySequenceEvent, RawEvent:
|
||||
bufMapKey(e, action)
|
||||
|
|
|
@ -646,7 +646,7 @@ func (h *BufPane) ShowKeyCmd(args []string) {
|
|||
InfoBar.Error(err)
|
||||
return
|
||||
}
|
||||
if action, ok := config.Bindings[event.Name()]; ok {
|
||||
if action, ok := config.Bindings["buffer"][event.Name()]; ok {
|
||||
InfoBar.Message(action)
|
||||
} else {
|
||||
InfoBar.Message(args[0], " has no binding")
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"bytes"
|
||||
|
||||
"github.com/zyedidia/micro/v2/internal/buffer"
|
||||
"github.com/zyedidia/micro/v2/internal/config"
|
||||
"github.com/zyedidia/micro/v2/internal/display"
|
||||
"github.com/zyedidia/micro/v2/internal/info"
|
||||
"github.com/zyedidia/micro/v2/internal/util"
|
||||
|
@ -21,6 +22,8 @@ func init() {
|
|||
}
|
||||
|
||||
func InfoMapEvent(k Event, action string) {
|
||||
config.Bindings["command"][k.Name()] = action
|
||||
|
||||
switch e := k.(type) {
|
||||
case KeyEvent, KeySequenceEvent, RawEvent:
|
||||
infoMapKey(e, action)
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"runtime"
|
||||
|
||||
"github.com/zyedidia/micro/v2/internal/clipboard"
|
||||
"github.com/zyedidia/micro/v2/internal/config"
|
||||
"github.com/zyedidia/micro/v2/internal/display"
|
||||
"github.com/zyedidia/micro/v2/internal/screen"
|
||||
"github.com/zyedidia/micro/v2/internal/shell"
|
||||
|
@ -28,6 +29,8 @@ func TermKeyActionGeneral(a TermKeyAction) PaneKeyAction {
|
|||
}
|
||||
|
||||
func TermMapEvent(k Event, action string) {
|
||||
config.Bindings["terminal"][k.Name()] = action
|
||||
|
||||
switch e := k.(type) {
|
||||
case KeyEvent, KeySequenceEvent, RawEvent:
|
||||
termMapKey(e, action)
|
||||
|
|
|
@ -4,8 +4,12 @@ const (
|
|||
DoubleClickThreshold = 400 // How many milliseconds to wait before a second click is not a double click
|
||||
)
|
||||
|
||||
var Bindings map[string]string
|
||||
var Bindings map[string]map[string]string
|
||||
|
||||
func init() {
|
||||
Bindings = make(map[string]string)
|
||||
Bindings = map[string]map[string]string{
|
||||
"command": make(map[string]string),
|
||||
"buffer": make(map[string]string),
|
||||
"terminal": make(map[string]string),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ func (s *StatusLine) Display() {
|
|||
return []byte(fmt.Sprint(s.FindOpt(string(option))))
|
||||
} else if bytes.HasPrefix(name, []byte("bind")) {
|
||||
binding := string(name[5:])
|
||||
for k, v := range config.Bindings {
|
||||
for k, v := range config.Bindings["buffer"] {
|
||||
if v == binding {
|
||||
return []byte(k)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue