Merge pull request #2253 from myk002/myk_backquote

Support backtick as a keybinding
develop
Myk 2022-07-28 05:48:23 -07:00 committed by GitHub
commit 35a7c577a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 1 deletions

@ -224,7 +224,8 @@ To set keybindings, use the built-in ``keybinding`` command. Like any other
command it can be used at any time from the console, but bindings are not command it can be used at any time from the console, but bindings are not
remembered between runs of the game unless re-created in `dfhack.init`. remembered between runs of the game unless re-created in `dfhack.init`.
Currently, any combinations of Ctrl/Alt/Shift with A-Z, 0-9, or F1-F12 are supported. Currently, any combinations of Ctrl/Alt/Shift with A-Z, 0-9, F1-F12 or \`
are supported.
Possible ways to call the command: Possible ways to call the command:

@ -42,6 +42,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Misc Improvements ## Misc Improvements
- Init scripts: ``dfhack.init`` and other init scripts have moved to ``dfhack-config/init/``. If you have customized your ``dfhack.init`` file and want to keep your changes, please move the part that you have customized to the new location at ``dfhack-config/init/dfhack.init``. If you do not have changes that you want to keep, do not copy anything, and the new defaults will be used automatically. - Init scripts: ``dfhack.init`` and other init scripts have moved to ``dfhack-config/init/``. If you have customized your ``dfhack.init`` file and want to keep your changes, please move the part that you have customized to the new location at ``dfhack-config/init/dfhack.init``. If you do not have changes that you want to keep, do not copy anything, and the new defaults will be used automatically.
- `keybinding`: support backquote (\`) as a hotkey
- `manipulator`: add a library of useful default professions - `manipulator`: add a library of useful default professions
- `manipulator`: move professions configuration from ``professions/`` to ``dfhack-config/professions/`` to keep it together with other dfhack configuration. If you have saved professions that you would like to keep, please manually move them to the new folder. - `manipulator`: move professions configuration from ``professions/`` to ``dfhack-config/professions/`` to keep it together with other dfhack configuration. If you have saved professions that you would like to keep, please manually move them to the new folder.
- ``materials.ItemTraitsDialog``: added a default ``on_select``-handler which toggles the traits. - ``materials.ItemTraitsDialog``: added a default ``on_select``-handler which toggles the traits.

@ -2611,6 +2611,9 @@ static bool parseKeySpec(std::string keyspec, int *psym, int *pmod, std::string
if (keyspec.size() == 1 && keyspec[0] >= 'A' && keyspec[0] <= 'Z') { if (keyspec.size() == 1 && keyspec[0] >= 'A' && keyspec[0] <= 'Z') {
*psym = SDL::K_a + (keyspec[0]-'A'); *psym = SDL::K_a + (keyspec[0]-'A');
return true; return true;
} else if (keyspec.size() == 1 && keyspec[0] == '`') {
*psym = SDL::K_BACKQUOTE;
return true;
} else if (keyspec.size() == 1 && keyspec[0] >= '0' && keyspec[0] <= '9') { } else if (keyspec.size() == 1 && keyspec[0] >= '0' && keyspec[0] <= '9') {
*psym = SDL::K_0 + (keyspec[0]-'0'); *psym = SDL::K_0 + (keyspec[0]-'0');
return true; return true;

@ -44,6 +44,7 @@ static void find_active_keybindings(df::viewscreen *screen)
sorted_keys.clear(); sorted_keys.clear();
vector<string> valid_keys; vector<string> valid_keys;
for (char c = 'A'; c <= 'Z'; c++) for (char c = 'A'; c <= 'Z'; c++)
{ {
valid_keys.push_back(string(&c, 1)); valid_keys.push_back(string(&c, 1));
@ -54,6 +55,8 @@ static void find_active_keybindings(df::viewscreen *screen)
valid_keys.push_back("F" + int_to_string(i)); valid_keys.push_back("F" + int_to_string(i));
} }
valid_keys.push_back("`");
auto current_focus = Gui::getFocusString(screen); auto current_focus = Gui::getFocusString(screen);
for (int shifted = 0; shifted < 2; shifted++) for (int shifted = 0; shifted < 2; shifted++)
{ {