SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => Topic started by: Ding Zhaojie on September 25, 2006, 03:44:35 am

Title: A little modification to tags.e (Added tag preview)
Post by: Ding Zhaojie on September 25, 2006, 03:44:35 am
In SourceInsight, when multiple symbol locations found while performing "Jump to Definition". A symbol list with preview field will be shown and it is very convenience to choose the symbol because you can preview them. (See pic 1)

But Slickedit does not have the preview field. When you selecting tags, it is very hard to choose the right one if there are many tags listed without a preview. So I added a callback function to capture the selected item in list and show it in the Symbol Window. (See pic 2)

1. Open tags.e
2. Find the tag_select_match() function
3. Insert this callback function before it:
Code: [Select]
defeventtab _select_tree_form;
/**
 * Callback routine handles the select_tree dialog events.
 * It shows the selected tag preview in the symbol window.
 *
 * @param reason
 * @param user_data
 * @param info
 *
 * @return _str
 *
 * @author Ding Zhaojie
 */
static _str tag_select_callback(int reason, typeless user_data, typeless info=null)
{
   switch (reason) {
   case SL_ONINITFIRST:
   case SL_ONSELECT:
      if (info != null) {
         _nocheck _control ctl_tree;
         struct VS_TAG_BROWSE_INFO cm;
         typeless temp;

         _str caption = ctl_tree._TreeGetCaption(info);
         parse caption with cm.member_name "\t" caption;
         if (cm.member_name != '') {
            parse caption with cm.file_name "\t" caption;
            parse caption with temp "\t" caption;
            cm.flags = 0;
            cm.class_name = '';
            cm.type_name = '';
            cm.line_no = temp;
            cb_refresh_output_tab(cm, 1);
         }
      }
      break;
   }
   return '';
}
4. Register the callback function: In tag_select_match() find the "match_id = select_tree" line, you will see "null, null, null". Change the second "null" to "tag_select_callback".
5. Reload tags.e.

Have fun :)
Title: Re: A little modification to tags.e (Added tag preview)
Post by: stxl on September 25, 2006, 05:50:58 am
Thanks!
Title: Re: A little modification to tags.e (Added tag preview)
Post by: hs2 on September 25, 2006, 10:14:29 am
This is a really good improvement Ding [thumb-up] !
Should be merged into the product.

HS2
Title: Re: A little modification to tags.e (Added tag preview)
Post by: Clark on September 25, 2006, 02:07:58 pm
Nice!  Works for me.  Dennis will be back tomorrow.  I'll have him check this one over.  As long as this code is safe and doesn't conflict with anything new Dennis is working on, I don't see any reason why we can ship this in the next release.
Title: Re: A little modification to tags.e (Added tag preview)
Post by: alex on September 26, 2006, 06:50:31 pm
Very cool.  If this goes in the product, I think it would be nice to have an option to have it toggle the symbol window on and then off again just for use by this rather than require that the symbol window be open already.  I usually have it closed, so I added toggle_symbol() calls before and after the select_tree call.  There's probably a nicer way of doing that, though.
Title: Re: A little modification to tags.e (Added tag preview)
Post by: Dennis on September 26, 2006, 09:47:09 pm
Nice catch.  I had intended to do that, but I must have forgotten.  This functionality will be in 12.0.  Note that the shipping version will use a timer so that you can scroll through items quickly, and will allow the symbol window to peep out for five seconds if it is auto-hidden.  It will not activate the symbol window if it is completely undocked (there are good reasons not to do this, focus issues, etc.).
Title: Re: A little modification to tags.e (Added tag preview)
Post by: alex on September 27, 2006, 01:29:55 pm
By the way, before I try to write one, is there already a function that lets you bring up a symbol in a given source file in the symbol window already?  For instance, I'd like to just have the cursor over a symbol and hit, say, ctrl-S, and have it bring up the symbol window with the current symbol used.
Title: Re: A little modification to tags.e (Added tag preview)
Post by: Dennis on September 27, 2006, 02:15:42 pm
Sure, no problem.

Code: [Select]
_command void preview_tag(VS_TAG_BROWSE_INFO cm=null)
               name_info(TAG_ARG','VSARG2_EDITORCTL|VSARG2_REQUIRES_MDI)
{
   orig_autohide_delay := def_toolbar_autohide_delay;
   def_toolbar_autohide_delay=5000;
   activate_toolbar("_tbtagwin_form","ctltagname",false);
   def_toolbar_autohide_delay=orig_autohide_delay;
   if (cm==null) {
      _UpdateTagWindow(true);
   } else {
      cb_refresh_output_tab(cm,true,true);
   }
}
Title: Re: A little modification to tags.e (Added tag preview)
Post by: RobFreundlich on October 05, 2006, 12:50:14 pm
Very cool.  If this goes in the product, I think it would be nice to have an option to have it toggle the symbol window on and then off again just for use by this rather than require that the symbol window be open already.  I usually have it closed, so I added toggle_symbol() calls before and after the select_tree call.  There's probably a nicer way of doing that, though.

I tried this, and had problems with it if the symbol window used auto-hide.  Specifically, the code that causes the symbol toolbar's window to become visible seems to clear the list of tag matches.  I narrowed it down to this line in _tbAutoShow() from tbautohide.e:

Code: [Select]
   // CHANGE_AUTO_SHOW event to let tool window know it is about to be shown.
   // This gives the tool window a chance to look pretty for the user.
   wid.call_event(CHANGE_AUTO_SHOW,wid,ON_CHANGE,'w');

Right before that line, calling tag_get_match_info() for a specific match_id fills the cm structure with data, but right after it, the same call leaves cm empty.

So what I did instead of a simple toggle_symbol() before and after select_tree is to put this before select_tree:

Code: [Select]
      int wid = _tbIsVisible('_tbtagwin_form');

      if (wid == 0) {
         tag_push_matches();
         toggle_symbol();
         tag_pop_matches();
      }

I originally had this after it:

Code: [Select]
    if (wid == 0) {
         toggle_symbol();
    }

But it doesn't seem necessary since the auto-hide feature will make the symbol toolbar's window hide anyway.
Title: Re: A little modification to tags.e (Added tag preview)
Post by: Wanderer on October 05, 2006, 01:30:09 pm
Sure, no problem.

Code: [Select]
_command void preview_tag(VS_TAG_BROWSE_INFO cm=null)
               name_info(TAG_ARG','VSARG2_EDITORCTL|VSARG2_REQUIRES_MDI)
{
   orig_autohide_delay := def_toolbar_autohide_delay;
   def_toolbar_autohide_delay=5000;
   activate_toolbar("_tbtagwin_form","ctltagname",false);
   def_toolbar_autohide_delay=orig_autohide_delay;
   if (cm==null) {
      _UpdateTagWindow(true);
   } else {
      cb_refresh_output_tab(cm,true,true);
   }
}

When I try to load this (SlickEdit 11.0.2, WinXP), I get an error: "Expecting ')'", with the cursor on the 'cm' param.
(I added #include "slick.sh" to the .e file.)
Title: Re: A little modification to tags.e (Added tag preview)
Post by: Dan on October 05, 2006, 03:38:54 pm
That is actually defined in tagsdb.sh.  Try this one:
Code: [Select]
#include "tagsdb.sh"
#include "slick.sh"
_command void preview_tag(VS_TAG_BROWSE_INFO cm=null) name_info(TAG_ARG','VSARG2_EDITORCTL|VSARG2_REQUIRES_MDI)
{
   int orig_autohide_delay = def_toolbar_autohide_delay;
   def_toolbar_autohide_delay=5000;
   activate_toolbar("_tbtagwin_form","ctltagname",false);
   def_toolbar_autohide_delay=orig_autohide_delay;
   if (cm==null) {
      _UpdateTagWindow(true);
   } else {
      cb_refresh_output_tab(cm,true,true);
   }
}
Title: Re: A little modification to tags.e (Added tag preview)
Post by: at5dapa1 on October 19, 2006, 07:06:50 am
Very cool.  If this goes in the product, I think it would be nice to have an option to have it toggle the symbol window on and then off again just for use by this rather than require that the symbol window be open already.  I usually have it closed, so I added toggle_symbol() calls before and after the select_tree call.  There's probably a nicer way of doing that, though.

Hi,
1. instead of toggle_symbol before and after, maybe is better activate_symbol before only? Because in case the symbol is already open, toggle_symbol will close it.

2. If the symbol window is floating (see attached), it doesn't get updated when I'm clicking in the "Select a tag" dialog! Anybody can help? Thanks.
Title: Re: A little modification to tags.e (Added tag preview)
Post by: at5dapa1 on October 24, 2006, 06:53:20 am
Hi,
I found the problem. I had to modify the cb_refresh_output_tab function from cbroweser.e.
If the parameter of _GetTagwinWID is set to false, then will be also working in my case, when the Symbol tab is not contained by the Output toolbar.
Daniel