Marked editor as draft

All the docs contained in this group of commits are marked as not draft,
except for editor, which I will be working as I get more experience and
get more precise on the various topics related to the editor and groups
of functions.
This commit is contained in:
Igor Támara 2025-10-30 23:35:53 -05:00 committed by CJ van den Berg
parent e837a66b97
commit 0494574c36
9 changed files with 234 additions and 188 deletions

View file

@ -10,22 +10,24 @@
},
---
Palettes are overlay menus that allow to select an item from the
presented list, applying a command with the selected element, optionally
deleting the selected item; it's possible to close the palette without
selecting anything(a.k.a. cancel), filter the elements, and having
special elements that trigger different actions.
Palettes are overlay menus with auto complete that allow to select an
item from the presented list, applying a command with the selected
element, optionally deleting the selected item; it's possible to
close the palette without selecting anything(a.k.a. cancel), filter
the elements, and having special elements that trigger different
actions, for example, the task palette.
Examples of palettes are command_palette, clipboard_palette, they all
are based on palette.zig that does all the heavy lifting and sets the
framework to create new palettes as simple as possible.
Examples of palettes are `command_palette`, `clipboard_palette`, they
all are based on `src/tui/mode/overlay/palette.zig that does all the
heavy lifting and sets the framework to create new palettes as simple
as possible.
Palettes are an special case of minimode and for instance a mode, they
receive inputs from keyboards and execute the beforehand mentioned
Palettes are an special case of [minimode] and for instance a mode, they
receive inputs from the keyboard and execute the beforehand mentioned
actions in response.
To get the most of this section, it's recommended to have read about
[commands](/docs/architecture/command), and optionally
[commands](/docs/architecture/command), and optionally,
[minimodes](/docs/architecture/minimode).
[]($section.id("anatomy"))
@ -69,8 +71,7 @@ The index will identify the action to be taken.
When populating with each entry, there must be a relation that links the
option chosen with the required action, and this happens in
`add_menu_entry` used when the user writes in the input to filter out
options.
`add_menu_entry`.
```zig
pub fn add_menu_entry(palette: *Type, entry: *Entry, matches: ?[]const usize) !void {
@ -80,14 +81,17 @@ The common line that will be used when registering the event to a
selected item is
```zig
try palette.menu.add_item_with_handler(value.written(), select);
try palette.menu.add_item_with_handler(value, select);
```
Which will apply the `select` function when the value is selected.
[]($section.id("select"))
### Acting on selection
When the selection happens, it is time to invoke the command with the
selection and the palette needs to be closed. Those actions will be
selection making sure to close the palette. Those actions will be
handled inside `select`, whose signature is:
```zig
@ -96,7 +100,7 @@ fn select(menu: **Type.MenuType, button: *Type.ButtonType, pos: Type.Pos) void {
Other common operations in the palettes can be inspected looking at the
source code of the palettes, all of them import `palette.zig`. Once the
are ready, it's time to make the palette available as a command.
palette is ready, it's time to make the palette available as a command.
[]($section.id("register"))
## Registering the palette
@ -113,6 +117,5 @@ To view a complete implementation of a palette, take a look at
## Next steps
* [Minimodes](/docs/architecture/minimode)
* [Editor topics](/docs/architecture/editor)
* [On commands](/docs/architecture/command)
* [Architecture](/docs/architecture)