-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
PR: Add multi-cursor support to the editor #22996
base: master
Are you sure you want to change the base?
Conversation
Required manually tracking overwriteMode and leaving it disabled except for during keyEvent. This might be a fragile solution...
…to new line, and clears extra_cursors on goto_definition
…r. many TODO comments
…bool, and added #TODO notes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Second round of suggestions for you @athompson673. Again, mainly code style improvements except for one important comment.
spyder/plugins/editor/widgets/codeeditor/tests/test_multicursor.py
Outdated
Show resolved
Hide resolved
spyder/plugins/editor/widgets/codeeditor/tests/test_multicursor.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Carlos Cordoba <[email protected]>
missed a few style edits in prior batch Co-authored-by: Carlos Cordoba <[email protected]>
Co-authored-by: Carlos Cordoba <[email protected]>
…Simplify call path to get font in paint event.
I've done some digging to try and find where the selection color is set, and I have found where the colors are defined, but not where they are used. The foreground and background are accessible as Edit.. I found the call to Edit 2.. Edit 3. Getting the colors from the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your continued work on this @athompson673!
The holidays are always a bit slow at work 😅 |
Some suggestions after manually checking your work:
|
Currently Alt+Click is already used to jump within a document. Should the two be swapped? It is also Alt+Click (and drag) in Notepad++, so I agree for the purpose of extra cursors it would be better. It should also be possible to prevent underlining links while Ctrl+Alt is held by changing the
I think this should be an easy enough addition. I did also add the Ctrl+Alt+Shift+Click which adds a column of cursors (one on each row) from the primary cursor to the click location. I was trying to somewhat emulate the Notepad++ function of Alt click and drag to create a box selection. I didn't however want to go through the different drag states including adding extra (possibly temporary) spaces to the end of each line, which is why I chose a second click interaction. |
Just pressing But doing
Ok, since it's kind of standard in other editors, there's more reason to use it.
Good idea, but we should leave it for another PR.
Good point too. You could work later on that if you want.
Unfortunately, That also requires bumping the
It seems you forgot to push that change because I can't see it here. |
That's surprising to me, as currently
If I'm going to edit the mouse click interaction to change it to Alt+Click I kinda want to re-factor anyway (to move the extra cursor creation into
I can put that in, but the config version note specified if simply adding new items, a version bump was not needed. Does the minor version bump apply to changes between un-merged commits too? I'm also a bit unclear based on your wording what you intend for the default to be:
This was a feature I added early-on. It is implemented in Media1.mp4 |
Yep, I saw that. But you can try it yourself: doing
Yeah, it's hard-coded. And I think it should remain hard-coded when you change it to add multicursors.
Ok, if you think it's better, then please do it here.
Since the current shortcuts for
Ok, that's really cool, thanks! |
Alt-Click is absolutely working fine for me, and I've been using it for a long time.. That's why I initially didn't overwrite it, and chose Ctrl-Alt-Click to use for multicursor: Media2.mp4Regarding shortcuts: I didn't realize you meant to change those shortcuts as well, I thought you were referring to changing the shortcuts to add a cursor up and down so it wouldn't conflict. Just to be sure; This is what you had in mind?
|
Description of Changes
Multi-line editing has been a feature I've missed having in spyder for a long time. I frequently have a notepad++ scratchpad alongside spyder simply to copy blocks of text back and forth so that I can use the column cursor. I haven't been able to contribute money to the spyder project despite using it for about a decade now, but I can hopefully at least contribute some time.
I am an engineer, not a programmer so please criticize my work so we can make it better :)
I decided to implement the functionality directly inside the
codeeditor.CodeEditor
class as making it an editor extension would still require a great many edits to CodeEditor anyway. The basic implementation is to hide the original cursor when there are multiples, and manually draw the primary cursor and all extras on a timer. For many editor functions afor_each_cursor
wrapper does a lot of heavy lifting. Other functions need to be slightly tweaked directly. I think it is not particularly productive to try to implement code completion (snippets, call-tips, etc) during multi-cursor sessions, so I attempt to disable those functions appropriately.These are some deep changes to one of the most complicated parts of Spyder, so I will naturally need some help getting this code to a state where it's ready to be integrated. I know it is not yet fully ready, but I wanted to get the PR in so that more people could see it and maybe get interested in testing it.
Media1.mp4
TODO list:
Issue(s) Resolved
Fixes #2112
Affirmation
By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.
I certify the above statement is true and correct: athompson673