1
0
Fork 0
forked from wry/wry

toml-config: add input modes

This commit is contained in:
Julian Orth 2025-07-21 15:50:24 +02:00
parent e160aa3406
commit a57f0036a8
10 changed files with 797 additions and 46 deletions

View file

@ -533,6 +533,40 @@
"src",
"dst"
]
},
{
"description": "Pushes an input mode on top of the input-mode stack. The mode can be popped\nwith the `pop-mode` action.\n\n- Example:\n\n ```toml\n [shortcuts]\n alt-x = { type = \"push-mode\", name = \"navigation\" }\n ```\n",
"type": "object",
"properties": {
"type": {
"const": "push-mode"
},
"name": {
"type": "string",
"description": "The name of the mode."
}
},
"required": [
"type",
"name"
]
},
{
"description": "Temporarily pushes an input mode on top of the input-mode stack. The new mode\nwill automatically be popped when the next shortcut is invoked.\n\n- Example:\n\n ```toml\n [shortcuts]\n alt-x = { type = \"latch-mode\", name = \"navigation\" }\n ```\n",
"type": "object",
"properties": {
"type": {
"const": "latch-mode"
},
"name": {
"type": "string",
"description": "The name of the mode."
}
},
"required": [
"type",
"name"
]
}
]
}
@ -949,6 +983,14 @@
"middle-click-paste": {
"type": "boolean",
"description": "Configures whether middle-click pasting is enabled.\n\nChanging this has no effect on running applications.\n\nThe default is `true`.\n"
},
"modes": {
"description": "Configures the input modes.\n\nModes can be used to define shortcuts that are only active when the mode is\nactive.\n\n- Example\n\n ```toml\n [modes.\"navigation\".shortcuts]\n w = \"focus-up\"\n a = \"focus-left\"\n s = \"focus-down\"\n d = \"focus-right\"\n r = \"focus-above\"\n f = \"focus-below\"\n q = \"focus-prev\"\n e = \"focus-next\"\n ```\n\nModes can be activated with the `push-mode` and `latch-mode` actions.\n",
"type": "object",
"additionalProperties": {
"description": "",
"$ref": "#/$defs/InputMode"
}
}
},
"required": []
@ -1420,6 +1462,33 @@
}
]
},
"InputMode": {
"description": "Defines an input mode.\n\nModes can be used to define shortcuts that are only active when the mode is active.\n\n- Example\n\n ```toml\n [modes.\"navigation\".shortcuts]\n w = \"focus-up\"\n a = \"focus-left\"\n s = \"focus-down\"\n d = \"focus-right\"\n r = \"focus-above\"\n f = \"focus-below\"\n q = \"focus-prev\"\n e = \"focus-next\"\n ```\n",
"type": "object",
"properties": {
"parent": {
"type": "string",
"description": "The parent of this input mode.\n\nThis mode inherits all shortcuts from this parent. If this field is not set, then\nit inherits the shortcuts from the top-level shortcuts.\n\nNote that you can disable a shortcut by explicitly assigning it the action `none`.\n"
},
"shortcuts": {
"description": "The shortcuts of this mode.\n\nSee the same field in the top-level `Config` object for a description.\n",
"type": "object",
"additionalProperties": {
"description": "",
"$ref": "#/$defs/Action"
}
},
"complex-shortcuts": {
"description": "The complex shortcuts of this mode.\n\nSee the same field in the top-level `Config` object for a description.\n",
"type": "object",
"additionalProperties": {
"description": "",
"$ref": "#/$defs/ComplexShortcut"
}
}
},
"required": []
},
"Keymap": {
"description": "A keymap.\n",
"anyOf": [
@ -1692,7 +1761,9 @@
"focus-above",
"focus-tiles",
"create-mark",
"jump-to-mark"
"jump-to-mark",
"clear-modes",
"pop-mode"
]
},
"Status": {

View file

@ -756,6 +756,46 @@ This table is a tagged union. The variant is determined by the `type` field. It
The value of this field should be a [MarkId](#types-MarkId).
- `push-mode`:
Pushes an input mode on top of the input-mode stack. The mode can be popped
with the `pop-mode` action.
- Example:
```toml
[shortcuts]
alt-x = { type = "push-mode", name = "navigation" }
```
The table has the following fields:
- `name` (required):
The name of the mode.
The value of this field should be a string.
- `latch-mode`:
Temporarily pushes an input mode on top of the input-mode stack. The new mode
will automatically be popped when the next shortcut is invoked.
- Example:
```toml
[shortcuts]
alt-x = { type = "latch-mode", name = "navigation" }
```
The table has the following fields:
- `name` (required):
The name of the mode.
The value of this field should be a string.
<a name="types-Brightness"></a>
### `Brightness`
@ -1911,6 +1951,31 @@ The table has the following fields:
The value of this field should be a boolean.
- `modes` (optional):
Configures the input modes.
Modes can be used to define shortcuts that are only active when the mode is
active.
- Example
```toml
[modes."navigation".shortcuts]
w = "focus-up"
a = "focus-left"
s = "focus-down"
d = "focus-right"
r = "focus-above"
f = "focus-below"
q = "focus-prev"
e = "focus-next"
```
Modes can be activated with the `push-mode` and `latch-mode` actions.
The value of this field should be a table whose values are [InputModes](#types-InputMode).
<a name="types-Connector"></a>
### `Connector`
@ -3025,6 +3090,59 @@ The table has the following fields:
The value of this field should be a boolean.
<a name="types-InputMode"></a>
### `InputMode`
Defines an input mode.
Modes can be used to define shortcuts that are only active when the mode is active.
- Example
```toml
[modes."navigation".shortcuts]
w = "focus-up"
a = "focus-left"
s = "focus-down"
d = "focus-right"
r = "focus-above"
f = "focus-below"
q = "focus-prev"
e = "focus-next"
```
Values of this type should be tables.
The table has the following fields:
- `parent` (optional):
The parent of this input mode.
This mode inherits all shortcuts from this parent. If this field is not set, then
it inherits the shortcuts from the top-level shortcuts.
Note that you can disable a shortcut by explicitly assigning it the action `none`.
The value of this field should be a string.
- `shortcuts` (optional):
The shortcuts of this mode.
See the same field in the top-level `Config` object for a description.
The value of this field should be a table whose values are [Actions](#types-Action).
- `complex-shortcuts` (optional):
The complex shortcuts of this mode.
See the same field in the top-level `Config` object for a description.
The value of this field should be a table whose values are [ComplexShortcuts](#types-ComplexShortcut).
<a name="types-Keymap"></a>
### `Keymap`
@ -3830,6 +3948,14 @@ The string should have one of the following values:
The next pressed key identifies the mark to jump to.
- `clear-modes`:
Disables all previously set input modes, clearing the input-mode stack.
- `pop-mode`:
Pops the topmost mode from the input-mode stack.
<a name="types-Status"></a>

View file

@ -675,6 +675,38 @@ Action:
description: The destination id to copy to.
required: true
ref: MarkId
push-mode:
description: |
Pushes an input mode on top of the input-mode stack. The mode can be popped
with the `pop-mode` action.
- Example:
```toml
[shortcuts]
alt-x = { type = "push-mode", name = "navigation" }
```
fields:
name:
description: The name of the mode.
required: true
kind: string
latch-mode:
description: |
Temporarily pushes an input mode on top of the input-mode stack. The new mode
will automatically be popped when the next shortcut is invoked.
- Example:
```toml
[shortcuts]
alt-x = { type = "latch-mode", name = "navigation" }
```
fields:
name:
description: The name of the mode.
required: true
kind: string
Exec:
@ -953,6 +985,10 @@ SimpleActionName:
Interactively jumps to a mark.
The next pressed key identifies the mark to jump to.
- value: clear-modes
description: Disables all previously set input modes, clearing the input-mode stack.
- value: pop-mode
description: Pops the topmost mode from the input-mode stack.
Color:
@ -2742,6 +2778,32 @@ Config:
Changing this has no effect on running applications.
The default is `true`.
modes:
kind: map
values:
ref: InputMode
required: false
description: |
Configures the input modes.
Modes can be used to define shortcuts that are only active when the mode is
active.
- Example
```toml
[modes."navigation".shortcuts]
w = "focus-up"
a = "focus-left"
s = "focus-down"
d = "focus-right"
r = "focus-above"
f = "focus-below"
q = "focus-prev"
e = "focus-next"
```
Modes can be activated with the `push-mode` and `latch-mode` actions.
Idle:
@ -3893,3 +3955,54 @@ MarkId:
Identifies a mark with an arbitrary string.
kind: string
required: false
InputMode:
kind: table
description: |
Defines an input mode.
Modes can be used to define shortcuts that are only active when the mode is active.
- Example
```toml
[modes."navigation".shortcuts]
w = "focus-up"
a = "focus-left"
s = "focus-down"
d = "focus-right"
r = "focus-above"
f = "focus-below"
q = "focus-prev"
e = "focus-next"
```
fields:
parent:
kind: string
required: false
description: |
The parent of this input mode.
This mode inherits all shortcuts from this parent. If this field is not set, then
it inherits the shortcuts from the top-level shortcuts.
Note that you can disable a shortcut by explicitly assigning it the action `none`.
shortcuts:
kind: map
values:
ref: Action
required: false
description: |
The shortcuts of this mode.
See the same field in the top-level `Config` object for a description.
complex-shortcuts:
kind: map
values:
ref: ComplexShortcut
required: false
description: |
The complex shortcuts of this mode.
See the same field in the top-level `Config` object for a description.