Author Topic: brief_select_block issue (and possibly other mode block selections)  (Read 5965 times)

greggman

  • Senior Community Member
  • Posts: 279
  • Hero Points: 14
I've never understood why the following is true and I'm only now getting around to asking but.

I use brief_select_block a lot. It defaults to Alt-C in brief mode (Ctrl-B) in the default configuration.

As far as I know this only works in brief mode with Cua select keys added in.

I often start selecting some text using Shift and the cursor keys (normal CUA style selecting) and pressing left. In other words I'm starting at the right most character I want, holding shift and pressing the left cursor key to select the text I want. Then, I realize I want a block select, not a normal select. The reason is when I paste, a normal select will end up with the cursor on the right of the inserted text. A block select will end up with the cursor on the left and down one line below what was pasted. This makes it far easier to past "inline<space>" or "static<space>" in front of a bunch of lines.

The issue is this.  Assume the line I'm selecting from is

Code: [Select]
static int myfunc()
and I want to past "static<space>" in front of each of the following lines

Code: [Select]
int myfunc2()
int myfunc3()
int myfunc4()

what often happens in practice is my cursor happens to be between the space after static and "i" in "int". This is because the line sayd "int myfunc()" and I just type "static<space>". Now I want to put it on the next 3 lines as well so I hold shift and press left so I have "static<space>" highlighted. Then I realize I want to grab the text as a block for the reasons stated above. I press Alt-C which is assigned to brief_select_block and the selection is converted to a block style select BUT it ends up extending one character to the right. It's now "static<space>i". The only option at this point is to cancel my selection and start over :-(

I understand the techinical reasons why it does this meaning I can imagine how it's implemented. The problem is it's useless and annoying that way. Why would anyone want one extra character to the right selected after they've already highlighted the text they want?

Is there a simple way to fix it?  Basically if I change selection modes from char to block I don't want the the right edge extended one character.

ps: this doesn't happen in the default mode because select-block (Control-B) is completely cancels the normal CUA selection where as the brief mode just changes the CUA selection into a block select (and sadly extends the selection one character to the right). I'm sure there are reasons the default mode doesn't just convert the selection but off the top of my head it also seems like the less useful way for it to work.

Tim Kemp

  • Senior Community Member
  • Posts: 537
  • Hero Points: 91
Re: brief_select_block issue (and possibly other mode block selections)
« Reply #1 on: March 28, 2007, 07:15:07 pm »
I have a related issue and it sounds like you don't.

When I insert a block, the cursor doesn't go down to the next line.  It just sits at the left end of the newly inserted block.  I wrote to tech support with this issue about a year ago.  They were in the middle of trying to get V11 out and said to get back with them later.  I never did, but it frequently irritates me that I have to hit, Ctrl-V, down, Ctrl-V, down, Ctrl-V, down, Ctrl-V, down when none of the downs should be necessary.

Why does it work correctly for you?  Does anyone know?

Another thing I miss from some editor of the past (maybe Codewright?) was the ability to select a block, do an insert and have the text inserted in front of the block on every selected line.  In SE the selected block just gets deleted and the text gets inserted on the first line (not a very useful behavior.)

hs2

  • Senior Community Member
  • Posts: 2754
  • Hero Points: 291
Re: brief_select_block issue (and possibly other mode block selections)
« Reply #2 on: March 28, 2007, 11:52:18 pm »
@timkemp:
Do you use Brief emulation ?
1.) You have to BLOCK select sth. to copy'n paste (brief_paste) w/ moving the cursor down.
2.) This can be done by invoking block-insert-mode on cmdline / by keybinding / 'Edit->Other->Block insert mode' after a column selection.
You can do a lot more than simply pasting sth. ... until you ESCape.
Edit2: Related to that there is a bug report pending http://community.slickedit.com/index.php?topic=1293.msg5468#msg5468
But as mentioned there just comment the code block and reload. I didn't recognize any problem after doing so.

@greggman:
Not that easy to get the best of both worlds ... but this patch should help a bit ;)

Edit: The briefutl.e - brief_select_block() patch was wrong :(
This should work (better):
briefutl.e - deselect_or_switch():
Code: [Select]
   ...
   // HS2-CHG: apply 'NBLOCK' for seamless conversion of CHAR cua_select'ion to BLOCK
   // _select_type("","T",type);
   _select_type("","T", ( (!_select_type('','I') && type :== 'BLOCK') ? 'NBLOCK' : type ) );
   return(0);
}

As usual you can also copy this macro command to your personal macro collection and (over-)load it if you don't want to patch product files.

Have fun,

HS2
« Last Edit: March 29, 2007, 01:28:19 am by hs2 »

greggman

  • Senior Community Member
  • Posts: 279
  • Hero Points: 14
Re: brief_select_block issue (and possibly other mode block selections)
« Reply #3 on: March 29, 2007, 06:33:20 am »
That seems to work. Thanks!  I'll try it out for a while and see if I run into any issues.

Now the question is, what will it take to make that part of the normal distribution? It seems to me at least that the old way was arguably a bug. Now that you've fixed it it would be nice not to have to manually reapply the patch each time a new version comes out. Here's hoping

hs2

  • Senior Community Member
  • Posts: 2754
  • Hero Points: 291
Re: brief_select_block issue (and possibly other mode block selections)
« Reply #4 on: March 29, 2007, 11:56:02 am »
@SlickTeam: That's your decision of course, but I also think that this could be integrated into the product.

HS2

Rodney

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 777
  • Hero Points: 53
Re: brief_select_block issue (and possibly other mode block selections)
« Reply #5 on: March 30, 2007, 04:37:05 pm »
@hs2:
@greggman:
hs2's change will be incorporated into 12.0.1. Thanks for the code hs2!

@timkemp:
You might try setting:

def_paste_block_cursor_end = 1

You can do this from Macro>Set Macro Variable. No, there is no GUI front-end for this setting.

--rodney
« Last Edit: March 30, 2007, 05:35:09 pm by Rodney »

Tim Kemp

  • Senior Community Member
  • Posts: 537
  • Hero Points: 91
Re: brief_select_block issue (and possibly other mode block selections)
« Reply #6 on: March 30, 2007, 05:20:06 pm »
Rodney, thank you very much.  def_paste_Block_cursor_end is exactly what I was looking for.

Two things:
  • I think you mean, "set-var def_paste_block_cursor_end 1".  Otherwise it gets set to "= 1".
  • Is there documentation for all these macro variables somewhere?  It seems that half the time when I have a problem with how SE is behaving I have to change a macro variable.  It would be great to be able to just look these things up.

- Tim

Lisa

  • Senior Community Member
  • Posts: 238
  • Hero Points: 24
  • User-friendly geek-speak translator extraordinaire
Re: brief_select_block issue (and possibly other mode block selections)
« Reply #7 on: March 30, 2007, 05:25:53 pm »
  • Is there documentation for all these macro variables somewhere?  It seems that half the time when I have a problem with how SE is behaving I have to change a macro variable.  It would be great to be able to just look these things up.

- Tim

Hi Tim. I think most of the macro variables begin with "def_" - you can get to the API help topics for these items by using the Help Index: type def_ and you'll see a list. We try to document the more common variables in the Help also: go to Help > Table of Contents > Appendix > Configuration Variables.

Best wishes,
Lisa

PS - It would be more convenient if some of these were also documented in the appropriate doc sections. That is one of our goals as we write new doc topics and update/revise older topics.
« Last Edit: March 30, 2007, 05:31:25 pm by Lisa »

Tim Kemp

  • Senior Community Member
  • Posts: 537
  • Hero Points: 91
Re: brief_select_block issue (and possibly other mode block selections)
« Reply #8 on: March 30, 2007, 05:43:18 pm »
Thank you Lisa!   ;D  I didn't know those were there.