Clarified DecorateItemsWithHotkeys. - #1121
Merged
Merged
Conversation
MKadaner
force-pushed
the
mzk/menu_item_data
branch
from
August 3, 2026 00:36
25ee6da to
02fd62e
Compare
alabuzhev
reviewed
Aug 9, 2026
MKadaner
force-pushed
the
mzk/menu_item_data
branch
from
August 15, 2026 16:54
02fd62e to
cc13a25
Compare
MKadaner
force-pushed
the
mzk/menu_item_data
branch
from
August 16, 2026 01:03
cc13a25 to
4f11bdc
Compare
1. Do not inherit `menu_item_ex` from `menu_item_data` 2. Unify functions manipulating menu item flags
MKadaner
force-pushed
the
mzk/menu_item_data
branch
from
August 16, 2026 01:13
4f11bdc to
a926fff
Compare
|
Contributor
|
Thank you |
Contributor
Author
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Now getting
DecorateItemsWithHotkeysright... Hopefully.The original implementation would misalign accelerator key of the item
"&1&2&3".References
N/A
Checklist
If not checked, I accept that this work might be rejected in favor of a different great big ineffable plan.
Details
Fullwidth-aware
DecorateItemsWithHotkeysDecorateItemsWithHotkeys(formerAddHotkeys) tried to compensate the visual string length accounted for byfit_to_leftby comparing the results ofHiStrlenandvisual_string_length. If these functions produce different results, then there is an ampersand in the item name which will be removed during rendering, so we compensated for it adding an extra space before the accelerator string. Unfortunately, escaping ampersand removes all (unescaped) ampersands, so the string may occupy even less screen cells than the algorithm assumed.The fix is simple: let's assume that
HiStrlenreturns honest visual length of the properly escaped string. Now, we need to append as many spaces as required to pad the visual length up to the maximum visual length.Refactoring
menu_itemtomenu_item_dataand decoupled it frommenu_item_ex.menu_item_datais a struct holding data required to construct menu items, whilemenu_item_exis the actual non-trivial class representing menu items internally (well, mostly internally).VisualLengthinmenu_item_exenables future optimizations.GetName/SetNamefrommenu_item_data. It is not needed there. I apologize for code churn.SetCheck,SetCustomCheck,SetSelect,SetDisable, andSetGrayedhelpers.menu_item_dataandmenu_item_ex.