This is a draft for the GSoc proposal of godot Organisation working on Command palette project.
- user can search a command from the line-edit in thee command palette.
- user can execute a command that he searched.
- user can view shortcut for a command if available.
- user can search file or scene.
- user can view all the aviable commands with a fuzzy-search result.
- user can change workspace.
-
user uses a shortcut for command palette
ctrl + shift + p
orcmd + shift + p
to open a Modal-Dialog, Which has a line-edit to search and list-view that contains fuzzy-search result of the above searched command or file. -
Modal-Dialog mentioned doesn't have any close button and can be closed by either
Esc
button or changing the focus to other view. -
first retrieved search result is selected by default and pressing
return
orenter
key would execute that command or open that scence or file.-
use
?
to get available command filters like :>
for editor commands. (Editor Main Menu Settings)
-
Example:
>op
will search and retrieve all the commands with name containingop
. -
Navigate Workspace (2D, 3D, Script, AssetLib).
Should use available GUI to make something like described in Wiki.
May be I can use popup-menu but should think of something else.
-
1.Commands / Actions : It is a reference of Callable(Function pointer) that calls some specific function when executed.
To Have a Functional Command Palette we need :
-
A Data-Structre to Store Callable and Arguments and Retreive it by some string.
A
EditorActions
Class is made and Store actions with a HashMap where String type as Key and Storing a Pair of Callable and Vector for arguments (HashMap<String, Pair<Callable, Vector<Variant>> callables
). but EditorAction has some other big plans #70. So to make a difference between Command Palette actions and other Editor actions we have aVector<String> palette_action
which keep track of all Command palette actions. and another Hashmap for shortcutsHashMap<String, Shortcut>
. -
Register EditorActions.
So this can be done in
EditorNode
where most of the Editor code lies. where i callEditorAction::add_palette_action("action_name", callable_mp(this, func), varray(arg1,arg2..), [Shortcut]);
. -
We need a way to search and execute for a Command from avaiable commands.
A
CommandPalette
Class is made which contains all the UI like line-edit, List-view. when we start searching something if it's start with>
it will start searching EditorAction commands i.e it will retreive action_names fromEditorActions::palete_actions
otherwise it will just Search for Resource just likeQuick Open Resource
. when Desired action is selected it emitsexecute_command
signal oropen_file
in case of resource. -
Execute the Command once the desired command is selected.
So
execute_command
signal is connected toEditorNode::_execute_command()
which just callsEditorAction::_execute_action(selected_command)
andopen_file
signal connects toEditorNode::_open_file()
which opens file same asQuick Open Resource
.
Incomplete but Working ProtoType:
Complete Picture: