Author Topic: Multiple Cursors and Selections  (Read 4019 times)

jporkkahtc

  • Senior Community Member
  • Posts: 1825
  • Hero Points: 177
  • Text
Multiple Cursors and Selections
« on: August 21, 2014, 08:13:07 pm »
#1: There should be a "Highlight all matches" option with find to create multiple selections.
#2: After search&Replace (all), the replaced text should be a multiple selection.
#3: Edit->OTher->Enumerate should work with these selections.
#4: There should be a non-mouse way to create multiple cursors / selections.
#5: All cursors appear the same, but there is still an "Active" cursor that has some meaning.
The active cursor / selection should be rendered differently (different color?)
(The active line can be indicated, but that doesn't help when there are two or more cursors on one line).
#6: Clicking on the "2 cursors" part of the status line does something, but what?
It changes from "2 cursors" to "2: 0 cols", and the active cursor begins selecting text as I move the cursors around.
#7: The rol / col goto commands from the status-bar will change the position of one of the cursors, but not all of them.
Which cursor?
#8: The character-code field in the status bar lets me edit the character at one of the cursors, but not all.


Clark

  • Moderator
  • Senior Community Member
  • *
  • Posts: 4892
  • Hero Points: 397
Re: Multiple Cursors and Selections
« Reply #1 on: August 22, 2014, 02:02:00 am »
1. There should be a "Highlight all matches" option with find to create multiple selections.

The performance of multiple cursors gets bad when you have 1000 or so of them. That makes this a no go. With a lot of work, the performance could be improved but not enough.

#2: After search&Replace (all), the replaced text should be a multiple selection.

Same problem as above.

#3: Edit->OTher->Enumerate should work with these selections.

Good idea. At the moment, I would say there probably won't be time for this.

#4: There should be a non-mouse way to create multiple cursors / selections.

This is very doable and very easy to implement. It would be an alternate column selection command. I don't know what key it would go on though.

#5: All cursors appear the same, but there is still an "Active" cursor that has some meaning.
The active cursor / selection should be rendered differently (different color?)
(The active line can be indicated, but that doesn't help when there are two or more cursors on one line).

The "Active" cursor is the one that is dictates scrolling into view and the line/column position. At the moment, the cursor is drawn as an XOR and not a color.  This avoids issues with choosing a color which isn't easy.  Not sure if we will ever change this.

#6: Clicking on the "2 cursors" part of the status line does something, but what?
It changes from "2 cursors" to "2: 0 cols", and the active cursor begins selecting text as I move the cursors around.

Hmm...We will have to look into this.

#7: The rol / col goto commands from the status-bar will change the position of one of the cursors, but not all of them.
Which cursor?

These commands (especially go to col) would be better if it changed the location for all cursors.

#8: The character-code field in the status bar lets me edit the character at one of the cursors, but not all.

We will have to look into this.

Thanks for you post

jporkkahtc

  • Senior Community Member
  • Posts: 1825
  • Hero Points: 177
  • Text
Re: Multiple Cursors and Selections
« Reply #2 on: August 22, 2014, 03:41:04 am »
It would be a shame to not implement #1 and #2 at all due to a 1,000 cursor limit.


It would be really useful even if there was a hard limit of just 100.


I'd imagine most usage, for me at least, would be for well under 100 matches.


If there are more than X matches, just complain:
     Failed: Too many cursors.






Someone pointed out to me another editor that does this (sub-something :-)
I just tried it out in the demo version - on a really big file.
I selected "2013", then pressed alt+f3 to select/cursor all.
It found 86,000 matches!
moving those 86,000 cursors is pretty quick - after all, only 50 or so are displayed.
Then, I typed a character to insert .... suddenly my CPU is pegged - and has been for several minutes.


They should implement some reasonable limit, not that they shouldn't support select-all.
Ctrl+D (add the next occurance of the current selection to the set of cursors - an incremental approach, also very useful and harder to hit a limit).


hs2

  • Senior Community Member
  • Posts: 2737
  • Hero Points: 288
Re: Multiple Cursors and Selections
« Reply #3 on: August 22, 2014, 07:10:47 am »
Quote
#4: There should be a non-mouse way to create multiple cursors / selections.

This is very doable and very easy to implement. It would be an alternate column selection command. I don't know what key it would go on though.
I agree and also like to ask for keyboard support. What about <SHIFT>-<ALT>-C for Brief ;)
But it's not a big deal as long as there is a command provided.

Also the suggestions from jporkkahtc regarding #1/#2 sound pretty reasonable to me.
Why not having a limit option defaulting to just '100' covering 99% of the daily work use cases ?

HS2
« Last Edit: August 22, 2014, 07:12:42 am by hs2 »

Clark

  • Moderator
  • Senior Community Member
  • *
  • Posts: 4892
  • Hero Points: 397
Re: Multiple Cursors and Selections
« Reply #4 on: August 22, 2014, 01:13:43 pm »
With some sort of limit, this can be done.

SlickEdits search and replace is very fast and supports millions of replacements quickly. We just need to make sure we don't mess that up.

We can look into adding this for v20 but I don't think we will have time to slide this into v19.

bengle

  • Senior Community Member
  • Posts: 132
  • Hero Points: 4
Re: Multiple Cursors and Selections
« Reply #5 on: August 22, 2014, 02:22:24 pm »
Quote
#5: All cursors appear the same, but there is still an "Active" cursor that has some meaning.
The active cursor / selection should be rendered differently (different color?)
(The active line can be indicated, but that doesn't help when there are two or more cursors on one line).

The "Active" cursor is the one that is dictates scrolling into view and the line/column position. At the moment, the cursor is drawn as an XOR and not a color.  This avoids issues with choosing a color which isn't easy.  Not sure if we will ever change this.

How about making the active cursor just a little bit thicker or taller than the others.  I agree that being able to distinguish them would be very useful.

Clark

  • Moderator
  • Senior Community Member
  • *
  • Posts: 4892
  • Hero Points: 397
Re: Multiple Cursors and Selections
« Reply #6 on: August 26, 2014, 02:26:14 am »
Its a bit odd to have a key press that creates a selection and then converts it into multiple cursors/selections. It would have to go into a modal loop to know when you're done. I guess you could press Enter or the same key you started with when your done. Then the selection would be converted to multiple cursors/selections. Escape would cancel. Keep in mind with a mouse press, there is a RButtonDown event and an RButtonUp event so the modal-like loop is implemented in a very normal way.

Another way to implement this is to allow users to use whatever method they want to create a selection (like the select_block command) and then just press another key which executes a new "convert_to_multiple_cursors" command. This method is actually more powerful and really trivial to implement. The Slick-C function _MultiCursorAddFromActiveSelection() does this.

What does everyone think?

hs2

  • Senior Community Member
  • Posts: 2737
  • Hero Points: 288
Re: Multiple Cursors and Selections
« Reply #7 on: August 26, 2014, 09:02:54 am »
I'd vote for the 2nd way. It's more transparent to the user, simpler (to do) and '... more powerful...'.
HS2

Clark

  • Moderator
  • Senior Community Member
  • *
  • Posts: 4892
  • Hero Points: 397
Re: Multiple Cursors and Selections
« Reply #8 on: August 26, 2014, 01:10:28 pm »
Any other votes? Thanks hs2. The modal way is easy to implement too but not one line of code ;D

I added support for multiple cursors to gui_enumerate and enumerate. It was easier than I thought.

hs2

  • Senior Community Member
  • Posts: 2737
  • Hero Points: 288
Re: Multiple Cursors and Selections
« Reply #9 on: August 26, 2014, 01:44:42 pm »
Quote
easier than I thought
You know, sometimes things are too easy and flawed in practice ;)  But I'm sure not in this case :)

Thanks Clark and good luck to the team with the very promising V19 !
HS2

jporkkahtc

  • Senior Community Member
  • Posts: 1825
  • Hero Points: 177
  • Text
Re: Multiple Cursors and Selections
« Reply #10 on: August 26, 2014, 08:44:43 pm »
Clark, when I try to reply to your PM to me, I get:
User 'Clark' has blocked your personal message.

Clark

  • Moderator
  • Senior Community Member
  • *
  • Posts: 4892
  • Hero Points: 397
Re: Multiple Cursors and Selections
« Reply #11 on: August 26, 2014, 09:46:52 pm »
Hmm..I didn't know messages to me were blocked. It won't be able to fix this right away (I don't know how ;D). Can you post your vote/oppinion here? HS2 likes the second method. Which one do you like? Thanks

jporkkahtc

  • Senior Community Member
  • Posts: 1825
  • Hero Points: 177
  • Text
Re: Multiple Cursors and Selections
« Reply #12 on: August 26, 2014, 11:39:07 pm »
So, I'm wasn't quite sure what you mean by:
Quote
Its a bit odd to have a key press that creates a selection and then converts it into multiple cursors/selections.

Is this WRT: #2: After search&Replace (all), the replaced text should be a multiple selection.
Or #4: There should be a non-mouse way to create multiple cursors / selections
?


Currently, in BETA1, I can
Code: [Select]
create 2 cursors.
Shift-Right a few times
create a 3'rd cursor (with ctrl+LMB)
Now, I've got 3 cursors, and 2 selections.
 
Shift-Right a few more times
 
Now, I've got 3 cursors, and 3 selections.
Press Right a couple of time.
Now, I've got 3 cursors, and 0 selections.
Seems to work fine.

I'd like to see:
One or more ways, without touching the mouse, to create an additional cursor.
A crazy idea: Have a "meta" cursor that you can move around with the arrows, then drop regular cursors where you want them.

A more realistic idea: Use FIND. For example:
#1: find and "highlight all matches" (highlights are not selections, are they?) With limits - based on performance. Maybe usable tunable parameter?
#2: incrementally using some modification of "find-next"
Code: [Select]
FIND "abc"
Now "abc" is selected and the cursor is at the "a".
Press <KEY>
Now, a 2nd instance of "abc" is selected and there is a cursor at both "a"'s
Every time I press <KEY>, another selection and cursor is created.
Find "def" with some magic option
Now, i've got a 3rd cursor/selection. Two "abc" and one "def".


 "convert_to_multiple_cursors" sounds really cool.


When I try "_MultiCursorAddFromActiveSelection", I just get "invalid number".



The commands to jump the cursor(s) to the begining / end of the selection - begin_select(), end_select() should work with multiple cursors, but they do not - given multiple cursors these functions are a lot more useful than they used to be.




Clark

  • Moderator
  • Senior Community Member
  • *
  • Posts: 4892
  • Hero Points: 397
Re: Multiple Cursors and Selections
« Reply #13 on: August 27, 2014, 12:05:30 am »
Here's the convert_to_multiple_cursors() code:

Code: [Select]
_command void convert_to_multiple_cursors() name_info(','VSARG2_MARK|VSARG2_READ_ONLY|VSARG2_REQUIRES_EDITORCTL)
{
   if (_MultiCursor()) {
      _MultiCursorClearAll();
   }
   _MultiCursorAddFromActiveSelection();
}

begin_select/end_select with multiple selections seems to be broken. I'll see if we can fix this.

Clark

  • Moderator
  • Senior Community Member
  • *
  • Posts: 4892
  • Hero Points: 397
Re: Multiple Cursors and Selections
« Reply #14 on: August 27, 2014, 02:16:41 am »
begin_select and end_select will work for multiple selections in the next beta