mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-16 22:07:09 +09:00
Adding lockbindings option for disallowing lua to modify bindings at all
This commit is contained in:
@@ -262,7 +262,11 @@ func eventsEqual(e1 Event, e2 Event) bool {
|
||||
}
|
||||
|
||||
// TryBindKeyPlug tries to bind a key for the plugin without writing to bindings.json.
|
||||
// This operation can be rejected by lockbindings to prevent unexpected actions by the user.
|
||||
func TryBindKeyPlug(k, v string, overwrite bool) (bool, error) {
|
||||
if l, ok := config.GlobalSettings["lockbindings"]; ok && l.(bool) {
|
||||
return false, errors.New("bindings is locked by the user")
|
||||
}
|
||||
return TryBindKey(k, v, overwrite, false)
|
||||
}
|
||||
|
||||
|
||||
@@ -118,6 +118,7 @@ var DefaultGlobalOnlySettings = map[string]any{
|
||||
"helpsplit": "hsplit",
|
||||
"infobar": true,
|
||||
"keymenu": false,
|
||||
"lockbindings": false,
|
||||
"mouse": true,
|
||||
"multiopen": "tab",
|
||||
"parsecursor": false,
|
||||
|
||||
@@ -231,6 +231,12 @@ Here are the available options:
|
||||
|
||||
default value: `false`
|
||||
|
||||
* `lockbindings`: prevent plugins and lua scripts from binding any keys.
|
||||
Any custom actions must be binded manually either via commands like `bind`
|
||||
or by modifying the `bindings.json` file.
|
||||
|
||||
default value: `false`
|
||||
|
||||
* `matchbrace`: show matching braces for '()', '{}', '[]' when the cursor
|
||||
is on a brace character or (if `matchbraceleft` is enabled) next to it.
|
||||
|
||||
|
||||
@@ -178,6 +178,8 @@ The packages and their contents are listed below (in Go type signatures):
|
||||
bind the key `k` to the string `v`. If `overwrite` is true, this will
|
||||
overwrite any existing binding to key `k`.
|
||||
Returns true if the binding was made, and a possible error.
|
||||
This operation can be rejected by `lockbindings` to prevent undesired
|
||||
actions by the user.
|
||||
|
||||
- `Reload()`: reload configuration files.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user