# SlickEdit Community

## SlickEdit Product Discussion => SlickEdit® => Slick-C® Macro Programming => Topic started by: chrisant on May 14, 2009, 07:53:27 am

Title: Show context in References toolbar
Post by: chrisant on May 14, 2009, 07:53:27 am
When I look up references for "save_pos", the preview control in the References toolbar will show the reference.  But I want to also see at a glance what context the reference occurs in (i.e. without needing to scroll), just like the Current Context toolbar shows for the cursor position in the active editor control.  For example, I want to see something like this:

[22/29 in 10/12 files] c:\slick\macros\tags.e: 5580      _str current_proc(boolean dosticky_message=true)

So I'll need to tweak SetRefInfoCaption() in tagrefs.e to get the current context and append it to the caption.

Question: How can I get the current context in an arbitrary buffer?  I have a patch (see below) that almost does what I'm looking for, but it only works if the file being previewed happens to also be the file in the active mdi editor control.

Here is the patch I've tried so far.  Unless the file being previewed happens to also be the file in the active mdi editor control, it fails to get the current context, thus context_id is 0, thus it can't append the context.
Code: [Select]
`static void SetRefInfoCaption(struct VS_TAG_BROWSE_INFO cm){   _str caption = ctlreferences.RefCountInfoCaption();   caption = caption :+ " " :+              ctlreflabel._ShrinkFilename(cm.file_name,                                         p_active_form.p_width-ctlreflabel.p_x-                                         ctlreflabel._text_width(caption)-                                         ctlreflabel._text_width(' : 'cm.line_no)) :+             ": " :+ cm.line_no;#ifdef CHRISANT   _str cur_tag_name, cur_type_name, cur_class, cur_class_only, cur_package;   int cur_flags=0, cur_type_id=0;   int context_id = ctlrefedit.tag_get_current_context(cur_tag_name, cur_flags, cur_type_name, cur_type_id, cur_class, cur_class_only, cur_package);   say(context_id': 'ctlrefedit.get_text(20)', 'cur_tag_name);   if (context_id > 0) {      caption = caption:+'      ':+tag_tree_make_caption_fast(VS_TAGMATCH_context,context_id);   }#endif   if (caption!=ctlreflabel.p_caption) {      ctlreflabel.p_caption=caption;   }   //ctlreflabel.p_width=ctlreflabel._text_width(ctlreflabel.p_caption);}`
Title: Re: Show context in References toolbar
Post by: Graeme on May 14, 2009, 11:19:00 am
Maybe this, it seems to work (I think).  I noticed most calls to tag_get_current_context were preceded by a call to _UpdateContext.

Code: [Select]
`   ctlrefedit._UpdateContext(true);   int context_id = ctlrefedit.tag_get_current_context(cur_tag_name, cur_flags, cur_type_name, cur_type_id, cur_class, cur_class_only, cur_package);`
Maybe you could also get it from the caption of the current node in the tree.

Graeme
Title: Re: Show context in References toolbar
Post by: chrisant on May 14, 2009, 06:24:25 pm
So it does!  Thanks, Graeme, I must have gotten confused between _UpdateContext and _UpdateContextWindow.