Author Topic: Block selection start/continue keyboard only  (Read 4361 times)

sgartner

  • Community Member
  • Posts: 14
  • Hero Points: 2
Block selection start/continue keyboard only
« on: April 30, 2016, 02:25:03 AM »
In SlickEdit you can create a block selection using the right-mouse (which somehow seems too hard for either Visual Studio or N++), but the thing I can't get SlickEdit to do is use the shift-alt-arrow keys to define a block selection.  Instead it selects everything visible on the screen in the direction pointed (which might? be useful).  Those keys are currently bound to cua-select.

So, could someone please tell me to what I could bind those keys to accomplish what I want (essentially the same functionality that both VS and N++ have for alt-shift-arrows).

As an aside, if anyone knows how to get right-mouse block selection in either VS or N++, I'd love to know that as well.

Thanks!

Tim Kemp

  • Senior Community Member
  • Posts: 546
  • Hero Points: 92
Re: Block selection start/continue keyboard only
« Reply #1 on: April 30, 2016, 03:07:23 AM »
You don't say what emulation you are using. For CUA keyboard emulation, you press Ctrl-B to start a block selection and then use the regular cursor movements to move to the diagonally opposite corner. If you aren't using CUA, the command name is select-block. You can use Help->Where Is Command? to find your mapping. You can also find the mapping, and change it, using Tools->Options...->Keyboard and Mouse->Key Bindings. Use Search by command to find the mapping. Then remap it to another key if you like.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6826
  • Hero Points: 526
Re: Block selection start/continue keyboard only
« Reply #2 on: May 01, 2016, 02:54:48 PM »
I added an option used by cua_select to support emulating VS block selections.

The default for this will need to be emulation specific. For example, Mac users expect Alt+Shift+Left/Right to select words and not use a block selection. The VC++ emulations can definitely have this option on.

Right now, Alt+Shift+Up/Down/Left/Right in CUA emulation don't seem that useful to me. Ctl+Shift+Left/Right already takes care of selecting words so Alt+Shift+Left/Right are just redundant. Alt+Shift+Down -->select to bottom_left_of_window  Alt+Shift+Up --> select to top_left_of_window. These seems pretty useless to me. I think CUA emulation should act like VS for these keys.

I've posted a modified cua.e that is compatible with 20.0.2.1. Load it and the cua_select command will do what you want. You will need to bind the cua_select command to Alt+Shift+Home and Alt+Shift+End if you want support for those keys too.

I don't think this will be added as a hot fix because there actually are a bunch of other changes needed to make this emulation specific. We will add this to v21.
« Last Edit: May 02, 2016, 01:09:26 PM by Clark »

davehohl

  • Senior Community Member
  • Posts: 271
  • Hero Points: 27
Re: Block selection start/continue keyboard only
« Reply #3 on: May 02, 2016, 04:08:32 PM »
In VS, Alt+left mouse button does a block selection.

sgartner

  • Community Member
  • Posts: 14
  • Hero Points: 2
Re: Block selection start/continue keyboard only
« Reply #4 on: May 02, 2016, 07:49:21 PM »
I added an option used by cua_select to support emulating VS block selections.

The default for this will need to be emulation specific. For example, Mac users expect Alt+Shift+Left/Right to select words and not use a block selection. The VC++ emulations can definitely have this option on.

Right now, Alt+Shift+Up/Down/Left/Right in CUA emulation don't seem that useful to me. Ctl+Shift+Left/Right already takes care of selecting words so Alt+Shift+Left/Right are just redundant. Alt+Shift+Down -->select to bottom_left_of_window  Alt+Shift+Up --> select to top_left_of_window. These seems pretty useless to me. I think CUA emulation should act like VS for these keys.

I've posted a modified cua.e that is compatible with 20.0.2.1. Load it and the cua_select command will do what you want. You will need to bind the cua_select command to Alt+Shift+Home and Alt+Shift+End if you want support for those keys too.

I don't think this will be added as a hot fix because there actually are a bunch of other changes needed to make this emulation specific. We will add this to v21.

That works perfectly thanks. 

I was a little worried that if cua.e gets updated between now and v21 it will destroy these changes.  I isolated the method you changed (cua_select, renamed to cua_select_updated and attached) and a few variable definitions (scursor_style_block_col, scursor_style_block_col, last_cua_key, gsaa_mark_keys, and gsaa_map_keys), imported the existing cua.e (so that it could access the other cua functions).

This works, but I'm a little confused as to why I had to redefine those variables in my extract (why they didn't work from importing cua.e), but it seems to work fine.  I *only* mapped the alt-shift- keypresses to my cua_select_updated method, will I break something else if I don't map all of the keys that currently point to cua_select? 

Also, I failed to have it load from my own directory, I had to put it in "C:\Program Files\SlickEdit Pro 20.0.2\macros".  Now that I know it all works, I should attempt to pull it out of there again.

I really need to delve deeper into SlickEdit macro programming, the include and builtins.e are a bit confusing.  I used to do a lot with CodeWright (in fact, I think I am the last person to maintain a fairly complete library of CodeWright extension macros on my web site), but haven't done much with SlickEdit.

Thanks again for the code!
« Last Edit: May 02, 2016, 08:13:48 PM by sgartner »

sgartner

  • Community Member
  • Posts: 14
  • Hero Points: 2
Re: Block selection start/continue keyboard only
« Reply #5 on: May 02, 2016, 07:56:42 PM »
You don't say what emulation you are using. For CUA keyboard emulation, you press Ctrl-B to start a block selection and then use the regular cursor movements to move to the diagonally opposite corner. If you aren't using CUA, the command name is select-block. You can use Help->Where Is Command? to find your mapping. You can also find the mapping, and change it, using Tools->Options...->Keyboard and Mouse->Key Bindings. Use Search by command to find the mapping. Then remap it to another key if you like.

Thanks for the reply.  I am currently using the CodeWright emulation, which maps alt-C to the same block selection, but I was specifically wanting to have the Visual Studio shift-alt-<key> method of creating a block (CodeWright emulation uses the cua-select method for selecting). 

The issue for me is that you can't start the same type of block selection in either Visual Studio or Notepad++, you have to use the alt-shift-<key> method (if I'm wrong, please do correct me).  So, I kept trying to use those keys in SE with failure (until the code posted by Clark).

sgartner

  • Community Member
  • Posts: 14
  • Hero Points: 2
Re: Block selection start/continue keyboard only
« Reply #6 on: May 02, 2016, 08:00:00 PM »
In VS, Alt+left mouse button does a block selection.

Thanks for the reply, but I was specifically looking for a keyboard solution something like the alt-B (in CUA emulation) or alt-C (in CodeWright emulation) in SE which starts a block selection and doesn't lose it if you use the arrow keys (Visual Studio removes any block selection if you don't move the cursor with alt-shift-<key> or holding the alt while using the mouse).  So, since I can't seem to do what I want in Visual Studio, I wanted to change CodeWright to support the keyboard method in VS.

It would be really cool if I could get VS to support the right-mouse-drag method of selecting a block as well, but I haven't been able to figure out how to add that functionality (in either VS or N++).
« Last Edit: May 02, 2016, 08:01:34 PM by sgartner »