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