WerWolv / ImHex

🔍 A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM.
https://imhex.werwolv.net
GNU General Public License v2.0
43.98k stars 1.92k forks source link

impr: Ensure that TextEditor's cursor blink state is never invisible after a keyboard event #1664

Closed SparkyTD closed 4 months ago

SparkyTD commented 4 months ago

Problem description

By default, the cursor's blinking cycle is independent from user actions, which feels unconventional while editing pattern code. This change ensures that the blinking cycle is reset, and the cursor is made visible every time the editor receives a keyboard event like character entry, or arrow navigation.

Implementation description

I moved the hard-coded blink timing numbers to their dedicated static constant fields since now they are referenced from multiple different places.

I added the function void ResetCursorBlinkTime() to TextEditor.cpp that will reset the blink cycle to currentMillis() - sCursorBlinkOnTime, ensuring that the cursor is visible. This function is called for every keyboard and mouse click event.

Screenshots

Before:

https://github.com/WerWolv/ImHex/assets/45818400/668c6802-79a3-450b-80d3-d6abf2ce27be

After:

https://github.com/WerWolv/ImHex/assets/45818400/ee7f60e0-a75f-416d-b86d-8d12b5cdadf2