Select multiple words/lines when double/triple clicking.#5127
Select multiple words/lines when double/triple clicking.#5127RobertP-McDowell wants to merge 3 commits into
Conversation
ossilator
left a comment
There was a problem hiding this comment.
the commit messages lack explanations/justifications of the changes.
also, judging by the commit message, the 2nd commit mixes two unrelated changes.
|
I made each commit message clearer, and I thought changing the click time delay was an important enough change to warrant a third commit after all, so I split up the 2nd commit into two. |
This is an improvement for double clicking in the editor, allowing the user to drag to select multiple words. Previously the user could only select one word at a time by double clicking. Signed-off-by: Robert P. McDowell <teatimewithrobert@gmail.com>
Like the last commit, improves triple clicking to allow the user to drag select multiple lines on double clicking in the editor. Signed-off-by: Robert P. McDowell <teatimewithrobert@gmail.com>
This is to compliment the last two commits. Before if the user dragged their mouse and tried to immediately click, they might unintentionally initiate a double click; with triple click being re-implemented it was a bigger issue, with accidental triple clicks. Signed-off-by: Robert P. McDowell <teatimewithrobert@gmail.com>
| gboolean edit_load_menu_file (WDialog *h); | ||
| gboolean edit_close_cmd (WEdit *edit); | ||
| void edit_mark_cmd (WEdit *edit, gboolean unmark); | ||
| void edit_mark_words_cmd (WEdit *edit, gboolean unmark); |
There was a problem hiding this comment.
This function is not implemented.
| void edit_mark_words_cmd (WEdit *edit, gboolean unmark); | ||
| void edit_mark_current_word_cmd (WEdit *edit); | ||
| void edit_mark_current_line_cmd (WEdit *edit); | ||
| void edit_get_current_word_extents (WEdit *edit, off_t *start, off_t *end); |
There was a problem hiding this comment.
This function is defined and used in edit.c only. It should be static there.
| { | ||
| off_t word_start; | ||
| off_t word_end; | ||
| edit_get_current_word_extents (edit, &word_start, &word_end); |
There was a problem hiding this comment.
Please add an empty line between variable declarations and code.
| edit_get_current_word_extents (WEdit *edit, off_t *start, off_t *end) | ||
| { | ||
| int test_left = edit_buffer_get_byte (&edit->buffer, edit->buffer.curs1 - 1); | ||
| int test_right = edit_buffer_get_byte (&edit->buffer, edit->buffer.curs1); |
There was a problem hiding this comment.
These variables should be constants.
| return; | ||
| } | ||
|
|
||
| long pos; |
There was a problem hiding this comment.
Please move this variable declaration to the begin of block.
| for (pos = edit->buffer.curs1; pos != 0; pos--) | ||
| { | ||
| int c1, c2; | ||
| int c2 = edit_buffer_get_byte (&edit->buffer, pos - 1); |
There was a problem hiding this comment.
This variable should be constant,
| for (; pos < edit->buffer.size; pos++) | ||
| { | ||
| int c1, c2; | ||
| int c2 = edit_buffer_get_byte (&edit->buffer, pos + 1); |
There was a problem hiding this comment.
This variable should be constant,
Proposed changes
Quality of life feature for mouse users. Many text editors have the ability to drag select words and lines, and mcedit already allows you to select one word at a time, this is just an improvement of what's already there!
Also updated how the delay between clicks works to start the timer on mouse down instead of up, this is a lot more common in text editors (you're very browser probably behaves this way); this change affects all other widgets that use double-click functionality.
Checklist
git commit --amend -smake indent && make check)Tested with both gpm and xterm-only mouse support, ncurses, and slang.