Skip to main content

Module palette

Module palette 

Source
Expand description

The command palette, as a plugin (PalettePlugin, in DefaultPlugins): every palette command that applies where the palette opened, ranked by a fuzzy match of Category: Title as shown, in the interface’s language (and the command’s id), the commands run lately first. A command declaring arguments (an example object, {"percent": 100}) asks for each in turn, the example’s value as the default; Enter runs it in the context the palette opened in.

A command declaring an icon (CommandSpec::icon) shows it in a column before its title, as JetBrains’ Find Action does; the column is kept on every row while one of the matches has an icon, so the titles align. The icon is decorative: the title is the row’s name.

A quick pick (QuickPick, Palette::pick_in) shows a list of choices instead of the commands, filtered by the same fuzzy match: each choice runs a command with its arguments, as VS Code’s quick picks do. The workbench’s “Open panel…” (workbench.panel.pick) is one: every declared panel, opened where it was.

Keys: Ctrl+Shift+P and F1 open and close it (through modals), the arrows move the selection, Enter runs, Escape closes (or leaves an argument prompt).

Each application window has its own palette (ADR 0025): it opens in the window it is asked in, offers what applies there (that window’s commands, when: "appWindow == 'import'", and the global ones), runs there, and blocks that window only. In the main window’s group it opens in the window the user works in (AppHandle::active_window), a detached panel’s included, as VS Code’s auxiliary windows do, goes to the main window if that one closes, and blocks the main window and its detached panels while it is open.

use egui_pop_api::{App, palette};

let app = App::builder()
    .plugin(palette::PalettePlugin)
    .build(&egui::Context::default())
    .unwrap();
assert!(!palette::is_open(app.handle()));

Structs§

Palette
The palettes’ state, one per window group (AppHandle::window_group): open or not, the query.
PalettePlugin
The plugin.
PickItem
A choice of a quick pick: shown as label, it runs command with args.
QuickPick
A list of choices the palette offers in place of the commands (Palette::pick_in): typed text filters them by a fuzzy match of their labels, Enter runs the selected one’s command, Escape closes.
Ranked
One line of the list.

Constants§

CMD_PALETTE
Opens and closes the palette.
OWNER
The palette’s owner on the bus: its popup is palette@<window>.
PALETTE
The palette’s state, as a service.
POPUP_LISTENER
The palette’s listener on pop.popup.close: closed by anyone (its window closing under it), it closes in its window’s group.
POPUP_PREFIX
The start of the palette’s popup id.
RECENT
How many recent commands come first.

Functions§

is_open
Whether the application’s palette is open in the current window group (the main window’s outside a pass or a command).
is_open_in
Whether the palette is open in a window group (AppHandle::window_group).
rank
The palette’s list for a query: the entries that apply, best first. Without a query, the recent ones first, then by category and title; with one, by fuzzy score (Category: Title, or the id a little behind), a recent command winning ties and close calls.
rank_pick
The choices of a pick matching query, as (index, matched characters) best first; without a query, all of them in their order.
rank_with
As rank, each entry shown and matched as label gives it (the palette passes the label in the interface’s language: shown).
shown
An entry as the palette shows it, Category: Title in the interface’s language (the entry itself stays English).