Inkscape Command Palette: GSoC 2020
Tags: cpp, opensource, design
Published: 2020-07-01 15:21:03

## Command Palette
Command Palette strives to be, in simple terms an **Access Point**. The *interface* it chooses is text.

Some features that we have included(and planned to include) in the command palette are:
- **Actions Search**: Inkscape has a plethora of features and it becomes hard to remember where they are in deeply nested menus. A large number of operations also create difficulty in assigning shortcuts for all of them. This feature helps to search and execute all actions(operations) specifically `Gio::Actions`, search files, preferences, and others.
- **Python execution:** This feature depends(blocking) on [Integrating Python into Inkscape, Merge Request](https://gitlab.com/inkscape/inkscape/-/merge_requests/417/). This useful for the times when you need some programming goodness for technical accuracy in your designs. For example: Plotting 2D density of an equations
- **Shell execution**: This is more of a developer and CLI users oriented feature, to test that commands have the desired effect.

## Progress
##### 30 June 2020
Command Palette is now capable of searching and executing actions. Actions are the future of how Inkscape will do things/operations. There are close to 100 as I write. Though it's still a long way to go converting all verbs to actions we will get there.

Let me give you a tour of how to use Command Palette.

The default key to toggle CP is `?` (question mark). Thanks to Maren Hachmann for the idea.

Once you press `?`. A rectangular box with rounded corners appears on the canvas. (comment below if you like/dislike this design also suggest other locations/design for CP)

![Command Palette Open SS](https://dev-to-uploads.s3.amazonaws.com/i/zvwvjrh9nfe5c39r4jxo.png)

Let's start with anatomy. 

### Anatomy
The most annoying part `` (Ctrl + `) `` is a placeholder for shortcuts of the actions. Placeholder because currently, only `verbs` predecessors to actions have shortcuts.

In the bold fonts are action names. Currently, an action's name is a verb name of that action. They aren't translatable but I am working and soon will be replaced.

Action name is preceded by the group that action belongs to. Example, File, Dialog, Transform, etc.

Below the action name is the description for what action does.

That's not all let's see what invisible.
![CP Preferences](https://dev-to-uploads.s3.amazonaws.com/i/xr7qgbi7lgmeu5ml2m4y.png)
Let's enable the options
![CP Preferences checked](https://dev-to-uploads.s3.amazonaws.com/i/8rtoezwq5hz2ro9ikfnk.png)
After restarting Inkscape this is how Command Palette looks like.
![CP Open all enabled](https://dev-to-uploads.s3.amazonaws.com/i/e2562ueiknm0kxgxf3y0.png)

The name in small size letters will always be in English, this is to enable tutors of different Interface language to help others.

The cryptic name in far-right is the full action name helpful for CLI users.

### Usage
You type to search and click to execute. Press `Esc` key at any time to close CP. Currently, searching relies on a substring search algorithm.
**TODO**: I'm working on a fuzzy search algorithm for this.

![CP Searched](https://dev-to-uploads.s3.amazonaws.com/i/2p19k00ntm2zoo8z1zoh.png)

Alternatively, you can navigate between suggestions with `Tab` and `Shift + Tab` or arrow key and press enter to execute.

The top row is automatically highlighted when searching so when you press enter/return/linefeed. 
**NOTE:** some bug causes this feature to require 2 presses and highlighting only work if the same row is on top for 2 letters pressed during a search.

#### Arguments
We ask action parameters/data as depicted below
![How we ask for data](https://dev-to-uploads.s3.amazonaws.com/i/4x6o1qirunr0slqdxkts.png)

Due to restriction of Gio::Actions we, for now, can only ask for one parameter.

**TODO:**
- Add better(snippet like) support for multiple params
- Better descriptions/context of parameter

**Links:**
[GitLab Merge Request](https://gitlab.com/inkscape/inkscape/-/merge_requests/2072)
[GitLab UX issue](https://gitlab.com/inkscape/ux/-/issues/31)
[GitLab Technical issue](https://gitlab.com/inkscape/inkscape/-/issues/1567)

**Theme:** Flat Remix

Please comment below any Ideas/Questions you can think of. 
Decency level: **Roast me*