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

new hotkeys #219

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open

new hotkeys #219

wants to merge 3 commits into from

Conversation

tomxp411
Copy link

added Delete Line hotkey (Control+L)
added a second keybind for Search+Replace (Control+H)

These two hotkeys are common in Windows code editors (Visual Studio, Notepad++), and I find myself deleting lines a lot. Same with Search/Replace. ^H is easier to hit than Alt+F3, and it's also the standard binding in all of the editors I use regularly.

added Delete Line hotkey (^L)
added a second keybind for Search+Replace (^H)
@aouwt
Copy link
Contributor

aouwt commented Jan 21, 2022

may i suggest also Ctrl+q to exit? I use this often and was actually trying to fix it myself but i gave up bc im not very good with navigating the QB64 source code.

Copy link
Contributor

@FellippeHeitor FellippeHeitor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • The section that does find/replace is actually a few lines after that, at 1830..1833;
  • For ^L, you might wanna cater for when there's an active selection (what do other IDEs do in that case?)

@tomxp411
Copy link
Author

tomxp411 commented Jan 21, 2022

The section that does find/replace is actually a few lines after that, at 1830..1833;

Hmm... I thought I just added a second key sequence to the existing find/replace code. I'll re-check that.
** My bad. I had to merge in my change from the release version, because you've added a lot in the dev branch. You're right - I changed the "Find" line, rather than the "Find And Replace" line. Fixed.

For ^L, you might wanna cater for when there's an active selection (what do other IDEs do in that case?)

Notepad++ and Visual Studio both delete every line that has selected text, including the line with the cursor (whether or not text on the cursor line is selected.) So that sounds like the approach to take. I haven't dug into QB64's text selection mechanism yet, so I'll take a look at that tonight.

The ^L delete line shortcut now deletes all lines with selected text. If the cursor is on the start of a line and no text is selected on that line, that line is also deleted.

I had previously added the ^H shortcut to the wrong code block in ide_methods.bas. I moved that to the correct code block (the same as Alt-F3) so ^H now opens the Search And Replace dialog, consistent with other code editors on Windows.
@tomxp411
Copy link
Author

I have updated the source file. The ^L shortcut now checks the ideselected flag and counts the number of selected lines. It removes all selected lines and checks on each iteration to ensure the cursor is still on a valid line and that there is at least one line in the buffer. (The IDE crashes if you delete the only line. That's probably worth a future fix.)

I also moved the ^H shortcut to the correct code block (Search/Replace, rather than Search.) I guess I should not be merging two different branches of code at 2 AM.

I saw a request for ^Q by auowt. PM me on the forum or via Discord and I'll show you how to add your own hotkeys.

If you select more than one line and hit ^L to delete the whole block, the cursor ends up in the wrong place. This fix will put the cursor at the top of the selected block, so if you remove 2 or more lines, you're in the right spot afterward.
@tomxp411 tomxp411 closed this Jan 23, 2022
@tomxp411 tomxp411 reopened this Jan 23, 2022
@tomxp411
Copy link
Author

Added another fix. This moves the cursor to the start of the selection. Previously, if you selected lines 11-15 and then deleted them, the cursor would still be on line 15. This change moves the cursor to line 11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants