Inkscape: Command Palette merged!
Tags: cpp, inkscape, opensource
Published: 2021-02-03 07:28:16


### Background
I enrolled in Google Summer of Code this year with Inkscape as my mentor organization. I proposed to implement the Command palette and the Macros (more on that later).

### About
The 'Command Palette' feature is finally merged in [Inkscape's](https://inkscape.org) master branch, it has still a long way to go, but now you can easily contribute and try it out. It is currently available in version 1.1-alpha, and it may even land in version 1.1.
So what even is **command palette**?
## Command Palette
If I had to summarize it in a sentence
> The _Command Palette is an Access Point with a text interface._

Woah! No jargon!
> _You can do things by typing._

What does it do? **Search** and/or **Execute**.

### Why though?
- To Maximize the speed and efficiency of the user and to minimize frustration and boredom.

### Final goals
- Search for actions and execute them.
- Search for recent files and open/import them.
- Remember previous commands and their parameters.
- Execute Python code.
- Execute shell commands.

#### What are actions?
Actions are the backbone of everything you do in Inkscape.
- Rotating an object is an action.
- Zooming in and out are actions.

### Current status
Don't try to be an oracle, tell me what it can do **now**!
- Search for actions and execute them.
- Search for recent files and open/import them.
- Remember previous commands and their parameters.

Well, that's it for now, more features will be added in the future.

## How to use?
NOTE: _only available in Inkscape 1.1-dev or 1.1-alpha_

To open the Command Palette, press <kbd>?</kbd>. You are greeted with a beautiful (_not really_) dialog.
![Command Palette open screenshot](https://dev-to-uploads.s3.amazonaws.com/i/lswo5h3vr1cmfjtqiv72.png)

If you can't stand this beauty (_not really_), you can close it by
1. Clicking on canvas or any object on the canvas.
2. Pressing <kbd>esc</kbd>.
3. Pressing <kbd>?</kbd> again.

### Testing it out
1. Type `snap` and now you can easily find the snapping option you want without hovering over every icon.
![Searched "snap" in command palette](https://dev-to-uploads.s3.amazonaws.com/i/o7p2nqdppuyyq4ygrhck.png)
2. Select an object, type `rotate`, and then press <kbd>enter</kbd>, put in the angle you want to rotate the object by, and press <kbd>enter</kbd> again.
![Rotate using command-palette demo](https://dev-to-uploads.s3.amazonaws.com/i/0iv1840qnlgrzx7sgqk4.gif)
3. Type a **recent filename** you worked on (_before restart_). There will be two options: `open` and `import`.
![Import using command palette demo](https://dev-to-uploads.s3.amazonaws.com/i/ftj63clprhbvplrfjbbf.gif)
`Open` just opens it in a new document in a new window, while `import`, imports the image in the current document.

Scroll through the operations available when you open the command palette.

#### Some operations are missing
- Inkscape is moving from, verbs to actions, and thus not all features of Inkscape are available through the command palette.

### History
The command palette remembers the last commands you performed. To access them press the <kbd>up</kbd> key when Command Palette is in focus.
Press the down key when on the most recent command to go back from history mode to search mode.
![History demo](https://dev-to-uploads.s3.amazonaws.com/i/43970mh9fkaoj34wajzc.gif)

Many actions that you use take input or parameter, for example, `rotate` action takes angle, `transform` action takes distances to move an object by, in `x` and `y` directions.
Parameters of `actions` are also remembered (doesn't work in 1.1-alpha), so when you're asked degrees for `rotate`, you can just press the <kbd>up</kbd> key until you find the previously used value you wanted.
![Action parameter history demo](https://dev-to-uploads.s3.amazonaws.com/i/sob5cyp8epnjxjmiinek.gif)

### TODO
1. Porting more verbs to actions.
2. Favourites.
3. Set shortcuts from the command palette.
4. Display the menu location of an action.
5. Better searching algorithm.
6. Input descriptions
7. Cleanliness: many actions aren't useful for GUI users and hence should not appear in the command palette.

...and many more. It's still a new feature, written by a kid during summer, so there's a lot of room for improvement.

### Contributing
1. Make a feature request or report a bug in the [Inbox](https://gitlab.com/inkscape/inbox/-/issues) bug tracker.
2. Help in making it more intuitive in the [UX discussion channel](https://chat.inkscape.org/channel/team_ux)
3. Want to code? Get in touch on the [Inkscape Chat](https://chat.inkscape.org/channel/team_devel), ping `@rathod-sahaab`, maybe I can help you get up to speed, or reach out on Twitter `@swayambhu_dev`.