-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Select Word: Rewrite for OS configurability + more
Fixes: #76 This commit is a rewrite of the Select Word feature, thanks to helpful feedback from @Regnareb and @arkanoryn. Improvements: * OS configurability: Select Word can now be configured for Mac vs. Windows/Linux hotkeys in several ways. OS Detection is used if it is enabled. Or if `SELECT_WORD_OS_DYNAMIC` is defined, the OS setting may be indicated through a callback. * Functions: Word and line selection may now be invoked programmatically through function calls, for greater flexibility. This makes it possible to use separate keys for word vs. line selection, if desired. Additionally, the functions support *backwards* (left of the cursor) word selection. * Elaborated ignored keys: previously, only KC_LSFT and KC_RSFT considered as having no effect on the selection state. Now, this logic is elaborated to include most modifier and layer switch keys. NOTE: This commit makes a breaking change in how Select Word is used. Previously, Select Word was handled in `process_record_user()` as bool process_record_user(uint16_t keycode, keyrecord_t* record) { if (!process_select_word(keycode, record, SELWORD)) { return false; } // ... With this commit, update your keymap to uint16_t SELECT_WORD_KEYCODE = SELWORD; bool process_record_user(uint16_t keycode, keyrecord_t* record) { if (!process_select_word(keycode, record)) { return false; } // ... See the documentation page for full details: https://getreuer.info/posts/keyboards/select-word
- Loading branch information
Showing
2 changed files
with
286 additions
and
105 deletions.
There are no files selected for viewing
This file contains 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
Oops, something went wrong.
hi @getreuer !
Full disclaimer: I did not run the script. My keyboard is currently broken and I need to fix it before I can run more QMK. So maybe I'm wrong. But maybe I'm right, so please hear me out.
The goal of "select_line" is to select the whole line, correct? As you mentioned in your feedback, to have a similar behavior as in Vi.
The issue I see is that if the first line you selected is shorter than a following line, by "only" going down, we would not select the line as a whole, but only a part of it. To illustrate:
If I run "select_line" from line 1, and press it again, with the current code I would select
abcd\nabcd
. theefgh
would stay unselected.To counter that, I added another step after the down keypress
send_action(LINE_JUMPR);
orsend_action(LINE_JUMPL);
with:I was going to make a pull request with the problem and proposition. But since you are working with register / unregister, I'm not entirely sure how you would approach it.
my first thoughts were to do something around the following:
But I'm not sure how the computer / keyboard react if we register multiple key-presses without release. Are we going to have the expected outcome?
DISCLAIMER: all this is code done directly in github comment. Not the best for formatting and stuff. So sorry about that. And it has not be tested or anything, I only wrote it for the sake of the discussion.