Add more internal links and precisions on command arguments

This commit is contained in:
Igor Támara 2025-10-31 08:53:12 -05:00 committed by CJ van den Berg
parent 0494574c36
commit b01dfdb992
4 changed files with 53 additions and 30 deletions

View file

@ -140,14 +140,17 @@ logger.print("{} unsaved buffer(s) remaining", .{remaining});
### View key presses ### View key presses
There are situations when you press some keys without the expected There are situations when you press some keys without the expected
behavior happening, to review if flow is getting the keys, or your behavior happening, to review if flow is getting the keys, the
desktop environment or something else are capturing them, you will want [keybindings are associated](/docs/architecture/keybind), and are
to invoke flow with the option `--show-input`. executing the [desired command](/docs/architecture/command), or maybe
your desktop environment or something else is capturing them, you will
want to invoke flow with the option `--show-input`.
[]($section.id("next")) []($section.id("next"))
## Next steps ## Next steps
* [Guidelines for contributions](/docs/contributing)
* [Take a peek on testing](/docs/testing)
* [Configure some keybinds](/docs/architecture/keybind) * [Configure some keybinds](/docs/architecture/keybind)
* [Guidelines for contributions](/docs/contributing)
* [Create your own commands](/docs/architecture/command)
* [Take a peek on testing](/docs/testing)
* [Back to docs](/docs) * [Back to docs](/docs)

View file

@ -69,7 +69,7 @@ in Vim Mode `vim.zig`, `q` corresponds to (quit), the most famous one.
```zig ```zig
pub fn q(_: *void, _: Ctx) Result { pub fn q(_: *void, _: Ctx) Result {
try cmd("quit", .{}); try command.cmd("quit", .{});
} }
pub const q_meta: Meta = .{ .description = "q (quit)" }; pub const q_meta: Meta = .{ .description = "q (quit)" };
``` ```
@ -122,14 +122,14 @@ pub fn select_to_char_left_helix(_: *void, ctx: Ctx) Result {
`goto_line` (in the case of vim and helix mode, you first type the `goto_line` (in the case of vim and helix mode, you first type the
number and then the action, `gg`) is a command that exemplifies number and then the action, `gg`) is a command that exemplifies
receiving an integer parameter as stated in its meta: receiving an integer parameter. As stated in its meta:
```zig ```zig
pub const goto_line_meta: Meta = .{ .arguments = &.{.integer} }; pub const goto_line_meta: Meta = .{ .arguments = &.{.integer} };
``` ```
and to actually receiving the integer parameter, `goto_line` will and to actually receiving the integer parameter, `goto_line` will
extract it like this: extract from the context like this:
```zig ```zig
pub fn goto_line(self: *Self, ctx: Context) Result { pub fn goto_line(self: *Self, ctx: Context) Result {
@ -140,9 +140,17 @@ pub fn goto_line(self: *Self, ctx: Context) Result {
``` ```
To send a parameter to a command, make sure that the type is exactly To send a parameter to a command, make sure that the type is exactly
the same when retrieving it. We will refer as encode and decode. Hence the same when retrieving it. We will refer as encode and decode when
for our terminology to send an integer parameter to a command, we packing parameters in the context. To pack the `command.fmt` we will
will encode it using `command.fmt` like in encode it like this, when invoking `goto_line`.
```zig
var the_line: usize = 43;
try command.cmd("goto_line", command.fmt(.{the_line - 1}));
```
Or calling the command directly, if we have a reference to the object
that holds the command.
```zig ```zig
var the_line: usize = 43; var the_line: usize = 43;
@ -150,10 +158,12 @@ try ed.goto_line(command.fmt(.{the_line - 1}));
``` ```
It's possible to pass multiple parameters to commands, including arrays It's possible to pass multiple parameters to commands, including arrays
and json, they all will be packed in Command.Context. and json, packing all of them in Command.Context.
A deeper explanation of the rules about parameter passing is exposed in A deeper explanation of the rules about parameter passing is exposed in
[inner data exchange](/docs/architecture/inner_data_exchange). [inner data exchange](/docs/architecture/inner_data_exchange), given
that parameters can be sent not only to commands, but other broather
use cases.
[]($section.id('next')) []($section.id('next'))
## Next steps ## Next steps

View file

@ -12,29 +12,38 @@
If you are here, maybe is because you want to make flow behave according If you are here, maybe is because you want to make flow behave according
to your key presses preferences or possibly you already have edited your to your key presses preferences or possibly you already have edited your
own keybinds to suit your needs and are looking for some advanced own keybinds to suit your use cases and make everything easier, faster
topics to cope your use cases and make everything easier, faster and and more fluid when in flow.
fluid when in Flow.
First make sure you are aware of the
[existence of ctrl+f2 palette](/docs#key_controls) which
exposes a list of commands available for you to use, and when you select
a command, it's pasted in your current cursor position.
Using the command palette `Ctrl+Shift+p` and typing **Edit key Using the command palette `Ctrl+Shift+p` and typing **Edit key
bindings**, takes you to a json file to extend Flow, configuring bindings**, takes you to a json file to extend flow, configuring
keybindings to suit your needs. According to the mode you are in, the keybindings to suit your needs. According to the mode you are in, your
corresponding file will be opened. The palette can also be reached left personal mode's file configuration will be opened. Explore the
clicking on the current mode in the status bar. the file to discover how commands are bound to some combos, key presses
and the different [imodes](#hierarchy) present.
Command palette can also be reached left clicking on the current
mode in the status bar.
[]($section.id('tldr')) []($section.id('tldr'))
## ;TLDR; ## ;TLDR;
Once you open the corresponding json file, locate inside the imode Once you open the corresponding json file, locate inside the
(internal mode) that will accept the key or key/combos and add an array, [imode](#hierarchy)(internal mode) that will accept the key or
where the first element is the combination to map to the commands that key/combos and add an array, where the first element is the combination
will be invoked, the array accepts strings like in to map to the commands that will be invoked, the array accepts strings
like in
```js ```js
["ctrl+alt+shift+p", "open_command_palette"] ["ctrl+alt+shift+p", "open_command_palette"]
``` ```
To avoid screwing up the combinations, and putting Flow in an unusable To avoid screwing up the combinations, and putting flow in an unusable
state derived from a wrong mapping of key combinations, read on. state derived from a wrong mapping of key combinations, read on.
[]($section.id('defaults')) []($section.id('defaults'))
@ -154,11 +163,12 @@ consider using more keybindings or running tasks for your projects.
If you realized that there is a handy combination that others can If you realized that there is a handy combination that others can
benefit from or that a mode lacks the combination and it might be benefit from or that a mode lacks the combination and it might be
included in flow, look at the [contribution guidelines](/docs/contributing) included in flow, look at the
to submit your findings and solution. [contribution guidelines](/docs/contributing) to submit your findings
and solutions.
Probably binding commands is good, but maybe there is a feature in other Probably binding commands is good, but maybe there is a feature in other
text editors that you miss and would love to have it at your fingertips. text editors that you miss and would love to have at your fingertips.
Then it's Zig time: [Adding commands](/docs/architecture/command) to Then it's Zig time: [Adding commands](/docs/architecture/command) to
flow. flow.

View file

@ -15,7 +15,7 @@ command. The manual is included here for convenience.
* [Flow Control online help](/docs/help) * [Flow Control online help](/docs/help)
[]($section.id("basic_usage"))
## Basic Usage ## Basic Usage
```bash ```bash
flow file.zig:42 # Open at line 42 flow file.zig:42 # Open at line 42
@ -24,7 +24,7 @@ flow --list-languages # Show all supported languages
flow --help # List of command line options flow --help # List of command line options
``` ```
[]($section.id("key_controls"))
## Key Controls ## Key Controls
| Command | Action | | Command | Action |
|---------------------------|----------------------| |---------------------------|----------------------|