From 9461e609a0a9ea23ecd9b4088c14c7aface63d33 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sat, 1 Apr 2023 22:53:35 -0700 Subject: [PATCH 1/2] adjust text margin in hotkey menu for wide scrollbar --- docs/changelog.txt | 1 + plugins/lua/hotkeys.lua | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index b34e66aaa..6ad97f8fa 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -36,6 +36,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## New Plugins ## Fixes +- `hotkeys`: hotkey hints on menu popup will no longer get their last character cut off by the scrollbar - ``launchdf``: launch Dwarf Fortress via the Steam client so Steam Workshop is functional - `blueprint`: interpret saplings, shrubs, and twigs as floors instead of walls diff --git a/plugins/lua/hotkeys.lua b/plugins/lua/hotkeys.lua index 0eb09d244..e8121fded 100644 --- a/plugins/lua/hotkeys.lua +++ b/plugins/lua/hotkeys.lua @@ -107,7 +107,7 @@ local function get_bindings_to_hotkeys(hotkeys, bindings) end -- number of non-text tiles: icon, space, space between cmd and hk, scrollbar -local LIST_BUFFER = 2 + 1 + 1 +local LIST_BUFFER = 2 + 1 + 1 + 2 local function get_choices(hotkeys, bindings, is_inverted) local choices, max_width, seen = {}, 0, {} @@ -143,7 +143,7 @@ local function get_choices(hotkeys, bindings, is_inverted) -- adjust width of command fields so the hotkey tokens are right justified for _,choice in ipairs(choices) do local command_token = choice.text[1] - command_token.width = max_width - choice.hk_width - 3 + command_token.width = max_width - choice.hk_width - 5 end return choices, max_width From 55f7643381f973ddb19e3be93f08c4bcfb26160a Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sat, 1 Apr 2023 23:50:14 -0700 Subject: [PATCH 2/2] use the defined constant instead of a magic number --- plugins/lua/hotkeys.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/lua/hotkeys.lua b/plugins/lua/hotkeys.lua index e8121fded..8edb70073 100644 --- a/plugins/lua/hotkeys.lua +++ b/plugins/lua/hotkeys.lua @@ -106,8 +106,8 @@ local function get_bindings_to_hotkeys(hotkeys, bindings) return bindings_to_hotkeys end --- number of non-text tiles: icon, space, space between cmd and hk, scrollbar -local LIST_BUFFER = 2 + 1 + 1 + 2 +-- number of non-text tiles: icon, space between cmd and hk, scrollbar+margin +local LIST_BUFFER = 2 + 1 + 3 local function get_choices(hotkeys, bindings, is_inverted) local choices, max_width, seen = {}, 0, {} @@ -143,7 +143,7 @@ local function get_choices(hotkeys, bindings, is_inverted) -- adjust width of command fields so the hotkey tokens are right justified for _,choice in ipairs(choices) do local command_token = choice.text[1] - command_token.width = max_width - choice.hk_width - 5 + command_token.width = max_width - choice.hk_width - (LIST_BUFFER - 1) end return choices, max_width