Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hotkey selector panic #110

Merged
merged 5 commits into from
Jul 21, 2024

Conversation

Barafu
Copy link
Contributor

@Barafu Barafu commented Jul 19, 2024

Fixes application panic when trying to set a global hotkey to an unsupported hotkey. Instead of paic, saves hotkey as "Not set", which also allows disabling hotkeys when not needed.

Allows global hotkeys to be set to "not set" by setting to any incompatible value, for example Esc.
@AurevoirXavier AurevoirXavier changed the base branch from main to dev July 20, 2024 09:44
@AurevoirXavier
Copy link
Member

Thanks for your PR!

Personally, I aim to push performance to the limit. I suggest changing ToString to str since the allocation is unnecessary (every matching pattern is a literal static str), and the hotkeys are actually a pretty limited set, making a HashMap somewhat overkill.

Please fix the CI, and I'll merge it into the dev branch. After that, I'll make some improvements later.

@Barafu
Copy link
Contributor Author

Barafu commented Jul 20, 2024

I'll change to &str, and replace HashMap with Vec<tuple>,

@AurevoirXavier AurevoirXavier added T1-Dev The changes will be applied to the dev branch first. T0-Enhancement An enhancement to the existing function. labels Jul 20, 2024
Replace key_to_string()->String with key_to_str()->&str.
@Barafu
Copy link
Contributor Author

Barafu commented Jul 20, 2024

Sorry, with those orange workflows I am not sure if I did everything I needed to do or not.

@AurevoirXavier AurevoirXavier merged commit e7d9716 into hack-ink:dev Jul 21, 2024
AurevoirXavier added a commit that referenced this pull request Jul 21, 2024
* Fix hotkey selector panic (#110)

* Implement to_string() for keyboard::Keys and key

* Allow unsetting global hotkeys

Allows global hotkeys to be set to "not set" by setting to any incompatible value, for example Esc.

* Improve keyboard.rs

Replace key_to_string()->String with key_to_str()->&str.

* Refactor hotkey::Manager

* Allow empty hotkey

---------

Co-authored-by: Barafu Albino Cheetah <[email protected]>
@Barafu Barafu deleted the fix_hotkey_selector_crash branch July 22, 2024 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T0-Enhancement An enhancement to the existing function. T1-Dev The changes will be applied to the dev branch first.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants