Author Topic: List and search local symbols macro  (Read 110718 times)

asandler

  • Senior Community Member
  • Posts: 303
  • Hero Points: 27
List and search local symbols macro
« on: October 24, 2007, 02:42:18 PM »
I wrote this macro for Slickedit 6 and using it since then. It opens a nice dialog with list of all symbols in current file and allows you to search throughout the file, for certain symbol name. The search is special.
You often have a symbol named 'do_something_foo_blah_bar', but  don't remember the order in which words in the symbol name appear. Sometimes you even forget some of the words making the symbol name. You only remember that it is 'blah' 'foo' thing. Conventional search method won't be very effective here. It's enough to mistakenly think that in the symbol name 'blah' comes before 'foo' and you'll never find the symbol you are looking for.
However, when you use this macro, it's enough to type "foo blah" in the search box to find all symbols containing 'foo' 'blah', disregarding order in which words appear in the symbol name. You may simply type 'f b' and it will do the job. Specifying search criteria, narrows list of symbols to those matching the criteria. Then, choosing the right one and pressing enter will take you to the symbol.
To load the macro, do Macro->Load Module. Once loaded, you can assign keyboard key combination to it.
Enjoy it.

Alexander.

sdayts

  • Community Member
  • Posts: 42
  • Hero Points: 5
Re: List and search local symbols macro
« Reply #1 on: October 24, 2007, 05:10:04 PM »
Alexander,

This is very useful!
Many thanks for sharing it.

Sergey

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: List and search local symbols macro
« Reply #2 on: October 24, 2007, 10:57:59 PM »
Thanks a lot Alexander and get a big HP !
This is a good replacement for the legacy 'list-tags' I'm heavily using (although an improved version).
Just a hint:
You could use this to shorten your module a bit.
Code: [Select]
// needs to be globally visible
void _ols_on_key ()
{
   key := event2name (last_event(null, true));
   symbol_name.p_caption = symbol_name.p_caption''key;
   update_tree();
}

def  'a'-'z'= _ols_on_key;
def  'A'-'Z'= _ols_on_key;
def  '0'-'9'= _ols_on_key;
def  '_'    = _ols_on_key;
def  '.'    = _ols_on_key;
def  ' '    = _ols_on_key;

Thanks again,
HS2

BTW: I'm going to add that the tree index is set to the current symbol and I'm not longer using edit () to go to the line of selected symbol. I prefer to goto the 'start' of the symbol choosen.
I'll add your copyright and post it when done if its ok for you.

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: List and search local symbols macro
« Reply #3 on: October 24, 2007, 11:30:25 PM »
Here we go...
changes:
- goto start of selected symbol (incl. column) and center it (comment [line 94]: center_line() is not desired)
- curr. symbol is pre-selected in tree
- added 'DEL' key (same as BACKSPACE)
- added 'A-BACKSPACE' which resets the type ahead buffer

HS2

Edit: latest update of attachment (see my follow up posts for details): 26-10-2007
« Last Edit: October 26, 2007, 07:44:30 PM by hs2 »

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: List and search local symbols macro
« Reply #4 on: October 25, 2007, 12:16:50 AM »
Updated attachment:
more changes:
- added def_ols_show_return_type == '1'/'0' to enable/disable display of return type in symbol tree
- fixed problem with scroll position when using type ahead buffer reset (A-BACKSPACE)
- internal: using std. SE built-ins: tag_tree_make_caption_fast() + tag_tree_get_bitmap() setting up the tree node attributes

HS2

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: List and search local symbols macro
« Reply #5 on: October 25, 2007, 12:48:09 AM »
Updated attachment - last time ;)
- using same method as 'Defs TB' to determine the current symbol to be always 'in sync' with it
- (force) select first match if tree is filtered

HS2

PS: Thanks again Alexander - this was one of the things I was looking for or wanted to do but never had the time.
« Last Edit: October 25, 2007, 12:58:57 AM by hs2 »

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: List and search local symbols macro
« Reply #6 on: October 25, 2007, 03:34:33 AM »
Sorry - another update :(
There was a minor problem with the 'select first match' - fixed.
Added: set current symbol active again on type ahead buffer reset

HS2

asandler

  • Senior Community Member
  • Posts: 303
  • Hero Points: 27
Re: List and search local symbols macro
« Reply #7 on: October 25, 2007, 12:10:13 PM »
Wow. That's lots of changes  :) Cewl  ;D Thanks for fixing that. Damn, I was so proud I wrote 500 lines long slick-c script and now you ruined it :D ;D ;) Also, thanks for copyright thing - didn't cross my mind, lol ;D

One more thing worth fixing is dialog font and font-size. Now it's fixed Tahoma, 9pt. The actual values should be taken from configuration. So, if you know how to do this and have time, please fill free to fix the script. Again, thanks a lot for all these fixes.

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: List and search local symbols macro
« Reply #8 on: October 25, 2007, 12:41:06 PM »
Good idea using the default font config ! I'll add that along with resizeabilty of the dialog I'm curr. working on if I've some time.
I'll post the result here if it's done.
HS2

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: List and search local symbols macro
« Reply #9 on: October 26, 2007, 02:23:36 AM »
Ok - finished a version including:
- added a config section at the beginning of the module comprising key bindings, font setup using std. font set config
  (thanks again Ding for the indispensable setEditFont() macro - unfortunately it's not working properly for the tree control ???)
- dialog is resizeable now (had to move filter field to top)
- dialog size/position is restored
- added copy / append curr. symbol to clipboard

Attachment 'open_local_symbol2.e' in prev. post updated.

Have fun,
HS2
« Last Edit: October 26, 2007, 03:24:00 AM by hs2 »

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: List and search local symbols macro
« Reply #10 on: October 26, 2007, 10:06:49 AM »
Added workaround for tree control font setup - attachment updated.
HS2

mikesart

  • Community Member
  • Posts: 56
  • Hero Points: 11
Re: List and search local symbols macro
« Reply #11 on: October 26, 2007, 04:53:45 PM »
Thanks Alexander and HS2, this royally kicks butt. One of the two features I really was missing from Source Insight for the past year and now I've got it and it's even better. Very cool.
 -Mike

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: List and search local symbols macro
« Reply #12 on: October 26, 2007, 07:44:50 PM »
Great that it's also helping others ! I've to admit that I'm also quite happy with it  :)
@Brief users: I can really recommend to bind CTRL-G to 'ols' and maybe set the tree to a fixed font for a visually smooth migration from list-tags as I did ;).

Latest changes:
I've added tag filter support (unfortunately still as config variable in the module code so a reload is needed on changes).
It includes a 'inherit filter from Defs TB' value/mode which could be useful.
But is also possible to hardwire the tag filter to e.g. 'procedures and global vars.' and such. It's commented and there are also a few examples.

I've improved the copy/append to clipboard stuff a bit. It's now poss. to set the clip type to 'LINE' or 'CHAR'. Append does not longer require a 'SHIFT'-<key-combination> and is now independant from the copy binding choosen.

Attachment 'open_local_symbol2.e' updated.

Have (even more) fun,
HS2
« Last Edit: October 26, 2007, 07:53:04 PM by hs2 »

asandler

  • Senior Community Member
  • Posts: 303
  • Hero Points: 27
Re: List and search local symbols macro
« Reply #13 on: October 28, 2007, 01:38:07 PM »
hs2, thanks a lot for fixes and features. It is really much better now.

I was wondering how we distribute it even further. Only 15 people downloaded it so far, me and you included. Not as many as I hoped. I remember there was a script directory on slickedit.com once, but it seems to be gone. Any other ideas?

asandler

  • Senior Community Member
  • Posts: 303
  • Hero Points: 27
Re: List and search local symbols macro
« Reply #14 on: October 28, 2007, 02:19:33 PM »
Oh. Found that script directory I mentioned earlier.

http://www.slickedit.com/content/category/5/77/80/

Most up-to-date script in there written for SE 10. Doubt this is a good distribution channel for the script. Any other ideas for distributing the script?