-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Description
While working on #3391, I felt like there was a ton of boilerplate that was needed for each and every keybindings. The thought crossed my mind that we could do better, but I wasn't sure how. In my mind, I imagined a single file that described each of the ShortcutActions and their possible args, and a small script that just automatically generated all the necessary code to parse them, their args, and hook them up to the TerminalApp.
Now that I've thought on it more, here are some of the steps that'll be needed:
- Take code from my command palette branch for
ShortcutActionDispatch. This is a class that just handles the dispatching of actions. In that branch, I needed it because both keybindings and commands needed to be able to dispatchShortcutActions, but onlyAppKeyBindingsneeded to do aKeyChordlookup. This code being encapsulated will be necessary for a future step. - Add more _templated_ JsonUtils #2550 Add more templated json utils. We'll need this to be able to automagically generate the code to parse a given type from a
Json::Value - Move the code around so that anything having to do with the entirety of the list of
ShortcutActions is in single files by themselves:- AppKeybindingSerialization should only deal with parsing keychords. Lets put the
ShortcutActions and their keys in another file - Add a
IShortcutActionHandlerinterface, with_Handle{{SomeShortcutAction}}(auto&& sender, ActionArgs args)methods for eachShortcutAction. It should declare all the event handlers, but not the definitions. - Make
TerminalPageextendIShortcutActionHandler. This will be necessary to make sure TerminalPage implements each of them. - That one method that hooks up the
TerminalPageto theShortcutActionDispatch. Pull that into it's own file as well.
- AppKeybindingSerialization should only deal with parsing keychords. Lets put the
- Write a script that parses
profiles.schema.jsonfor each of the "*ShortcutAction" definitions, and turns them into code in all the necessary files-
ShortcutActionKeys.h -
ActionAndArgs.idl/.h/.cpp -
ShortcutActionDispatch.idl/.h/.cpp -
IShortcutActionHandler.h - For actions that are listed in
ShortcutActions but don't have a properArgstype, then make sure that they're still dispatched correctly - When the number of args changes, write the above files, and display a message that the developer needs to update
AppActionHandlers.cppto add implementations for the new types. - Validate that all "*ShortcutAction"s listed in the schema actually show up in the
onOfschema forKeybinding
-
Each top-level box could be it's own task here.
In the end, the developer should be able to modify the schema for add their new argument or ShortcutAction, and run a script, and the script should automatically write all the modifications necessary.
I'll probably need to do this in powershell. cmd would be impossible, and as much as I love python, I don't think that's really a part of our toolchain at all currently.