Author Topic: Show word under the cursor in find symbol toolbar  (Read 6175 times)

Graeme

  • Senior Community Member
  • Posts: 2289
  • Hero Points: 298
Show word under the cursor in find symbol toolbar
« on: May 06, 2008, 11:58:41 pm »
In case anyone's already done this...  is there any way to show the word under the cursor in the find symbol toolbar, activating the toolbar if it's not already activated.  I still need to be able to activate the toolbar without the search string changing.  If nobody's done this I'll try and figure out how.

Graeme

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2628
  • Hero Points: 405
Re: Show word under the cursor in find symbol toolbar
« Reply #1 on: May 07, 2008, 02:04:07 pm »
Possible, but, why?  If you want to find that symbol, wouldn't you just hit Ctrl+Dot?

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: Show word under the cursor in find symbol toolbar
« Reply #2 on: May 07, 2008, 05:56:14 pm »
I haven't tried this, but...

You could probably make a new command that:
1.  saves the search state (save_search)
2.  does the same as Ctrl+Dot (push_tag)
3.  restore the search state (restore_search)

Graeme

  • Senior Community Member
  • Posts: 2289
  • Hero Points: 298
Re: Show word under the cursor in find symbol toolbar
« Reply #3 on: May 08, 2008, 12:12:59 am »
Possible, but, why?  If you want to find that symbol, wouldn't you just hit Ctrl+Dot?

Yeah, I thought afterwards I should have explained why Ctrl-dot doesn't do what I want.

I'm writing a kind of database conversion program.  I have two different (legacy) projects each with a bunch of global variables that define their database.  I have created a third project which has a struct for each that has member names that are the same as the global variable names in the other two projects.  Now I want to get from the struct member to either of the global variables (both declaration and definition).  Using Ctrl-dot on the structure member goes nowhere because I'm already at both the definition and declaration of that member  - whereas find symbol finds all instances (quickly) of that member name, regardless of context.  My workspace has all three projects in it.

I guess it's the same as wanting to find all definitions of push_back in the C++ library rather than just vector<T>::push_back.

I think I can probably figure out how to do it.

Graeme


Graeme

  • Senior Community Member
  • Posts: 2289
  • Hero Points: 298
Re: Show word under the cursor in find symbol toolbar
« Reply #4 on: May 08, 2008, 10:26:08 am »
It wasn't too hard.  Find symbol also has the advantage of allowing you to select what gets searched in.  With "context tagging" selected, find symbol finds ctl_search_for but push_tag doesn't.

Code: [Select]
_command void find_symbol_word_at_cursor() name_info(','VSARG2_REQUIRES_EDITORCTL|VSARG2_CMDLINE)
{
   int xx;
   _control ctl_search_for;
   _str s = cur_word(xx);
   int wid = activate_toolbar('_tbfind_symbol_form', 'ctl_search_for', true);
   wid.ctl_search_for.p_text = s;
   wid.ctl_search_for._set_sel(1,length(s)+1);
}

Graeme