Author Topic: Expand / collapse via keyboard  (Read 9964 times)

PouncingPanda

  • Community Member
  • Posts: 74
  • Hero Points: 2
Expand / collapse via keyboard
« on: July 31, 2008, 11:08:21 AM »
What are the commands for expanding / collapsing the branch your cursor is currently in (e.g.: view->selective display)?  For the life of me I can't find it.  Thanks.

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: Expand / collapse via keyboard
« Reply #1 on: July 31, 2008, 11:33:01 AM »
To create a collapsible/ expandable region  - hide-code-block or hide-selection or show-procs or show-braces or ... see help -> contents -> macro functions by category -> selective display.

To collapse / uncollapse - use plusminus.  (ctrl backslash).

Graeme

Lisa

  • Senior Community Member
  • Posts: 238
  • Hero Points: 24
  • User-friendly geek-speak translator extraordinaire
Re: Expand / collapse via keyboard
« Reply #2 on: July 31, 2008, 01:38:47 PM »
FWIW, in the current version of SlickEdit, you can find info on the plusminus command and more if you type "Selective Display" in the Help > Index.

PouncingPanda

  • Community Member
  • Posts: 74
  • Hero Points: 2
Re: Expand / collapse via keyboard
« Reply #3 on: July 31, 2008, 08:42:20 PM »
Ah yes, the help button.  Now why didn't I think of that ;)  Thanks guys, you're the best.

PouncingPanda

  • Community Member
  • Posts: 74
  • Hero Points: 2
Re: Expand / collapse via keyboard
« Reply #4 on: August 05, 2008, 08:08:22 PM »
Sorry to revive a resolved topic but I'm observing a quirk with expand/collapse that appears to be a problem.  In python (SE 13, winxp):

    def reset (self):

if the cursor is at the beginning of the line or anywhere inside the function expand/collapse reports "Nothing to expand or collapse".  If the cursor is inside the code above (e.g. Move cursor to after the "d" in def) then expand/collapse works.  After it works once it will successfully expand/collapse the function when called anywhere inside the function body.

Is this by design?  I get the "no expansion inside the body of the function until after a successful collapse has occured" logic.  However could somebody please explain why the cursor at the beginning of the line fails to expand/collapse but in the middle of the line it succeeds?  Thanks a lot.

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: Expand / collapse via keyboard
« Reply #5 on: August 06, 2008, 12:23:36 PM »
Hi

I'm unsure of the rationale for why plusminus is picky about where the cursor is when you try to collapse something.  As fas as I can see, if you ask it to collapse something, it should try its hardest to.  You could try the following code  - dunno if it works with python though.

Code: [Select]
_command void my_hide_code_block() name_info(','VSARG2_REQUIRES_EDITORCTL|VSARG2_READ_ONLY)
{
   // Check to see if the very last command executed is the same command:
   int expandBlock = 0;
   _str name = name_name( prev_index( '', 'C' ) );
   if ( name == "hide-code-block" || name == "my-hide-code-block" ) expandBlock = 1;
   //say( '******* name='name );

   //Check if the first non-blank character of this line is a comment
   save_pos(auto p);
   first_non_blank();
   if (_clex_find(0,'g')==CFG_COMMENT) {
      hide_comments();
      return;
   }

   restore_pos(p);
   int status=cs_hide_code_block( expandBlock );
   if (!status && select_active()) {
      hide_selection();
      restore_pos(p);
   } else {
      down();
      down();
      prev_tag('', 'A');
      // try again
      down();
      hide_code_block();
   }
   // Make this command the last command executed:
   last_index( find_index( 'hide_code_block', COMMAND_TYPE ), 'C' );
}


_command void my_plusminus() name_info(','VSARG2_REQUIRES_EDITORCTL|VSARG2_READ_ONLY)
{
   if (plusminus())
      my_hide_code_block();
}

PouncingPanda

  • Community Member
  • Posts: 74
  • Hero Points: 2
Re: Expand / collapse via keyboard
« Reply #6 on: August 07, 2008, 02:52:08 AM »
Thank you, I will try that.