From 4e7b4dc55488a5a3cc227c8bd3b8d75ac14ea92d Mon Sep 17 00:00:00 2001 From: myk002 Date: Mon, 28 Nov 2022 15:37:01 -0800 Subject: [PATCH 1/2] show hotkeys bound to number keys, F11, and F12 --- docs/changelog.txt | 2 ++ plugins/hotkeys.cpp | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 75bec1368..6ca4995c9 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -44,6 +44,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - `automaterial`: fix rendering errors with box boundary markers - `autolabor` & `autohauler`: properly handle jobs 241, 242, and 243 - `autofarm`: add missing output flushes +- `hotkeys`: correctly detect hotkeys bound to number keys, F11, or F12 - Core: fix the segmentation fault with the REPORT event in EventManager - Core: fix the new JOB_STARTED event only sending each event once, to the first handler listed - Core: ensure ``foo.init`` always runs before ``foo.*.init`` (e.g. ``dfhack.init`` should always run before ``dfhack.something.init``) @@ -60,6 +61,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - `ls`: indent tag listings and wrap them in the right column for better readability - `ls`: new ``--exclude`` option for hiding matched scripts from the output. this can be especially useful for modders who don't want their mod scripts to be included in ``ls`` output. - `hotkeys`: hotkey screen has been transformed into an interactive `overlay` widget that you can bring up by moving the mouse cursor over the hotspot (in the upper left corner of the screen by default) +- `hotkeys`: now supports printing active hotkeys to the console with ``hotkeys list`` - `digtype`: new ``-z`` option for digtype to restrict designations to the current z-level and down - UX: List widgets now have mouse-interactive scrollbars - UX: You can now hold down the mouse button on a scrollbar to make it scroll multiple times. diff --git a/plugins/hotkeys.cpp b/plugins/hotkeys.cpp index 85c304d82..0e9e0953c 100644 --- a/plugins/hotkeys.cpp +++ b/plugins/hotkeys.cpp @@ -76,11 +76,15 @@ static void find_active_keybindings(df::viewscreen *screen, bool filtermenu) { vector valid_keys; + for (char c = '0'; c <= '9'; c++) { + valid_keys.push_back(string(&c, 1)); + } + for (char c = 'A'; c <= 'Z'; c++) { valid_keys.push_back(string(&c, 1)); } - for (int i = 1; i < 10; i++) { + for (int i = 1; i < 13; i++) { valid_keys.push_back("F" + int_to_string(i)); } From 23e467deaf1dffaf5c82d13707c4af54a764f460 Mon Sep 17 00:00:00 2001 From: myk002 Date: Mon, 28 Nov 2022 15:50:05 -0800 Subject: [PATCH 2/2] use consistent bounds checking style in hotkeys --- plugins/hotkeys.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/hotkeys.cpp b/plugins/hotkeys.cpp index 0e9e0953c..6bb6a1600 100644 --- a/plugins/hotkeys.cpp +++ b/plugins/hotkeys.cpp @@ -84,7 +84,7 @@ static void find_active_keybindings(df::viewscreen *screen, bool filtermenu) { valid_keys.push_back(string(&c, 1)); } - for (int i = 1; i < 13; i++) { + for (int i = 1; i <= 12; i++) { valid_keys.push_back("F" + int_to_string(i)); }