Merge branch 'master' into zig-0.14
This commit is contained in:
commit
00f786e5dd
2 changed files with 25 additions and 1 deletions
18
help.md
18
help.md
|
@ -69,6 +69,24 @@ like this:
|
|||
This allows you to make only minor additions/changes to an existing builtin
|
||||
mode without copying the whole mode and is easier to keep up-to-date.
|
||||
|
||||
Additionally, individual sub-modes may inherit all non-conflicting keybindings
|
||||
from another sub-mode of the same mode by adding an `inherit` option to the
|
||||
sub-mode section like this:
|
||||
|
||||
```
|
||||
"normal": {
|
||||
"inherit": "project",
|
||||
...
|
||||
```
|
||||
|
||||
Multiple inheritance is supported with the `inherits` options like this:
|
||||
|
||||
```
|
||||
"normal": {
|
||||
"inherits": ["project", "tasks"],
|
||||
...
|
||||
```
|
||||
|
||||
## Flow mode
|
||||
|
||||
The default input mode, called just flow, is based on common GUI
|
||||
|
|
|
@ -386,6 +386,7 @@ const BindingSet = struct {
|
|||
line_numbers: LineNumbers = .inherit,
|
||||
cursor: ?CursorShape = null,
|
||||
inherit: ?[]const u8 = null,
|
||||
inherits: ?[][]const u8 = null,
|
||||
selection: ?SelectionStyle = null,
|
||||
};
|
||||
const parsed = try std.json.parseFromValue(JsonConfig, allocator, mode_bindings, .{
|
||||
|
@ -400,7 +401,12 @@ const BindingSet = struct {
|
|||
self.selection_style = parsed.value.selection orelse .normal;
|
||||
try self.load_event(allocator, &self.press, input.event.press, parsed.value.press);
|
||||
try self.load_event(allocator, &self.release, input.event.release, parsed.value.release);
|
||||
if (parsed.value.inherit) |sibling_fallback| {
|
||||
if (parsed.value.inherits) |sibling_fallbacks| {
|
||||
for (sibling_fallbacks) |sibling_fallback| if (namespace.get_mode(sibling_fallback)) |sib| {
|
||||
for (sib.press.items) |binding| try append_if_not_match(allocator, &self.press, binding);
|
||||
for (sib.release.items) |binding| try append_if_not_match(allocator, &self.release, binding);
|
||||
};
|
||||
} else if (parsed.value.inherit) |sibling_fallback| {
|
||||
if (namespace.get_mode(sibling_fallback)) |sib| {
|
||||
for (sib.press.items) |binding| try append_if_not_match(allocator, &self.press, binding);
|
||||
for (sib.release.items) |binding| try append_if_not_match(allocator, &self.release, binding);
|
||||
|
|
Loading…
Add table
Reference in a new issue