Author Topic: Tab group toolbar toggle  (Read 5284 times)

Mr68360

  • Community Member
  • Posts: 46
  • Hero Points: 3
Tab group toolbar toggle
« on: April 03, 2007, 05:42:43 pm »
This issue has a predecessor in http://community.slickedit.com/index.php?topic=644.0, but it's an issue dealing with a macro I'd like to enhance.

When working, I don't like to use the auto hide for the tab group toolbar (build/search/preview/references/etc).  I'd rather have a single key to shrink the toolbar and restore it.  There are plenty of toggle functions already:

toggle_symbol();
toggle_refs();

and so forth.

These functions may leave the cursor in the tool window; I always want the cursor in the text window.

Here's a macro to toggle just the preview window, and make sure the cursor is where I want it:

Code: [Select]
_command toggle_lower_window() name_info(','VSARG2_MARK|VSARG2_REQUIRES_EDITORCTL)
{
   cursor_data();
   toggle_symbol();
   cursor_data();
}

What I want to do now is generalize this: I want a macro to toggle the tab that has focus at the time of the toggle.  (The above always toggles the preview tab--even if the reference tab has focus).

Is there a way to determine if a tab has focus?  If so, I could write the following:

Code: [Select]
_command toggle_lower_window() name_info(','VSARG2_MARK|VSARG2_REQUIRES_EDITORCTL)
{
   cursor_data();
   _str focus_form = get_tool_tab_focused_form();

   if (focus_form == "_tbtagwin_form")
      toggle_symbol();
   else if ...
      toggle_...

   cursor_data();
}

I'm sure there's more involved in determining if the tab is part of the toolbar, etc.  But that's why I'm asking  ;D

Thanks,
Chuck


hs2

  • Senior Community Member
  • Posts: 2737
  • Hero Points: 288
Re: Tab group toolbar toggle
« Reply #1 on: April 03, 2007, 07:08:29 pm »
@Mr68360:

You could try this:
Code: [Select]
_command toggle_lower_toolbars() name_info(','VSARG2_MARK|VSARG2_REQUIRES_EDITORCTL)
{
   cursor_data();
   activate_output_toolbar();
   cursor_data();
}
_command toggle_left_toolbars() name_info(','VSARG2_MARK|VSARG2_REQUIRES_EDITORCTL)
{
   cursor_data();
   activate_project_toolbar();
   cursor_data();
}

HS2

Mr68360

  • Community Member
  • Posts: 46
  • Hero Points: 3
Re: Tab group toolbar toggle
« Reply #2 on: April 03, 2007, 07:38:56 pm »
Sorry, H2S.  activate_output_toolbar() does not seem to toggle anything.  (The search window opens and stays open)...

Could this be a function of what tabs I have open?

hs2

  • Senior Community Member
  • Posts: 2737
  • Hero Points: 288
Re: Tab group toolbar toggle
« Reply #3 on: April 03, 2007, 08:18:02 pm »
You are right. It tries to re-activate an already existing but (auto-)hidden toolbar.
This is probably not what you want... sorry.

HS2

Mr68360

  • Community Member
  • Posts: 46
  • Hero Points: 3
Re: Tab group toolbar toggle
« Reply #4 on: April 06, 2007, 06:58:31 pm »
I came up with something that may not be very elegant, but it solves my problem, at least:

First, assume I have a fixed set of tabs I use all the time, and wish to have them either all showing, or all hidden.  Second, assume I do not use autohide (I want to control the tab window).

Here's the code:

Code: [Select]
static _str my_active_tab[];
static _str my_active_ctrl[];
static int my_active_tab_id;
static int my_max_tab;
static int my_search_tab_idx;

_command toggle_lower_window() name_info(','VSARG2_MARK|VSARG2_REQUIRES_EDITORCTL)
{
   cursor_data();

   int w0 = _tbIsVisible(my_active_tab[0]);

   if (w0)
   {
      boolean found = false;
      int j;

      int af = _tbTabGroupWidFromWid(w0)._tabgroupFindActiveForm(-1);
         for (j = 0; j < my_max_tab; ++j)
         {
            wid = _tbIsVisible(my_active_tab[j]);
            if (wid == af)
            {
               my_active_tab_id = j;
               found = true;
               break;
            }
         }

      if (! found)
         my_active_tab_id = 0;

      toggle_refs();
   }
   else
   {
      my_active_ctrl[my_search_tab_idx] = _get_active_grep_view(); // just in case

      toggle_refs();
      activate_toolbar(my_active_tab[my_active_tab_id], my_active_ctrl[my_active_tab_id]);
   }

   cursor_data();
}

//******************************************************************************************

definit()
{
   my_active_tab_id = 0;

   my_active_tab[0] = '_tbtagrefs_form';
   my_active_ctrl[0] = 'ctlrefname';

   my_active_tab[1] = '_tbtagwin_form';
   my_active_ctrl[1] = 'ctltaglist';

   my_active_tab[2] = '_tbsearch_form';
   my_active_ctrl[2] = _get_active_grep_view();
   my_search_tab_idx = 2;

   my_active_tab[3] = '_tbshell_form';
   my_active_ctrl[3] = '_shellEditor';

   my_active_tab[4] = '_tbbookmarks_form';
   my_active_ctrl[4] = 'ctl_bookmarks_tree';

   my_active_tab[5] = '_tboutputwin_form';
   my_active_ctrl[5] = 'ctloutput';

   my_max_tab = 6;
}

If you don't see your favorite tab, go to tbcmds.e in the program Macros directory, and you will be able to find the strings for the tab names/controls you want.  Note that names/tabs are subject to future change by SE.

By binding toggle_lower_window() to a key, I get a "toggle" of the entire tab bar--with the bonus of it "remembering" which tab was last active.  (The refs window is the default if anything goes wrong.)

This obviously needs value checking, etc.  Also, a more elegant solution would be to first enumerate all the tab windows and their controls that are present (instead of assuming them with an array at init time).

It works for me, though.

Chuck