SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => Slick-C® Macro Programming => Topic started by: asandler on October 24, 2007, 02:42:18 PM

Title: List and search local symbols macro
Post by: asandler 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.
Title: Re: List and search local symbols macro
Post by: sdayts on October 24, 2007, 05:10:04 PM
Alexander,

This is very useful!
Many thanks for sharing it.

Sergey
Title: Re: List and search local symbols macro
Post by: hs2 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.
Title: Re: List and search local symbols macro
Post by: hs2 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
Title: Re: List and search local symbols macro
Post by: hs2 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
Title: Re: List and search local symbols macro
Post by: hs2 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.
Title: Re: List and search local symbols macro
Post by: hs2 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
Title: Re: List and search local symbols macro
Post by: asandler 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.
Title: Re: List and search local symbols macro
Post by: hs2 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
Title: Re: List and search local symbols macro
Post by: hs2 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
Title: Re: List and search local symbols macro
Post by: hs2 on October 26, 2007, 10:06:49 AM
Added workaround for tree control font setup - attachment updated.
HS2
Title: Re: List and search local symbols macro
Post by: mikesart 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
Title: Re: List and search local symbols macro
Post by: hs2 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
Title: Re: List and search local symbols macro
Post by: asandler 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?
Title: Re: List and search local symbols macro
Post by: asandler 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?
Title: Re: List and search local symbols macro
Post by: hs2 on October 28, 2007, 02:43:55 PM
Hmm .. there is a already a place/board prepared for this: http://community.slickedit.com/index.php?board=4.0
I'll write a msg to the Jason (admin) to move this topic.
However, I afraid that using a board is not as clear as a simple list somewhere.
Maybe a sticky topic with such a maintained list (preferably by a moderator @SlickEdit) would be a solution...

HS2
Title: Re: List and search local symbols macro
Post by: sdayts on October 28, 2007, 10:53:42 PM
asandler & hs2,

Many thanks for this macro.  I love way it allows me to rapidly navigate to any symbol in the file.
It has occurred to me that this macro can probably be easily (in the right hands) modified to handle open buffer navigation.  I find existing V11's list-buffers too limiting.  When it displays a large number of files, it is hard to find the one you are looking for.   I started looking into ways to adopt local symbols macro to list buffers.  However, my slick-c skill are rather primitive.  For instance, I have trouble locating a function which would return a list of open buffer names. 

Any help would be greatly appreciated!
Title: Re: List and search local symbols macro
Post by: hs2 on October 28, 2007, 11:52:25 PM
You should consider to upgrade to v12 (or v13 soon) since there is an improved support for buffer/project/workspace files implemented as dockable toolbar. It also works using a filter.

However, maybe this snippet could give you pointers to generate a list of open files.
Code: [Select]
static typeless prj_buflist[];
_command void savebuflist()
{
   int width = 0;
   _str result = '';

   int temp_view_id=0;
   int orig_view_id=_create_temp_view(temp_view_id);
   int cnt = 0;

   sav_buflist = def_buflist;
   // def_buflist|=0x4; // SHOW_SYSTEM_BUFFERS_FLAG;
   _build_buf_list(width,p_buf_id,false,p_buf_id,true);
   def_buflist = sav_buflist;

   prj_buflist._makeempty();
   top();
   for (;;)
   {
      get_line (result);

      // @sdayts: instead of filling the prj_buflist you could add tree items

      prj_buflist [ prj_buflist._length() ] = result;
      cnt++;

      if (down()) break;
   }
   _delete_temp_view(temp_view_id);
   activate_window(orig_view_id);
   message ("saved " cnt " buffer(s) - restore with 'restorebuflist'");
}

Good luck and if you need some further macro examples - don't hesitate to ask. There are a few more ;)
HS2
Title: Re: List and search local symbols macro
Post by: lambertia on October 29, 2007, 12:06:09 AM
Fellas,

You should both wear your underpants on the outside for a day.

Because you're supermen.

Cheers,
--
Greg.
Title: Re: List and search local symbols macro
Post by: sdayts on October 29, 2007, 12:24:18 AM
Thanks hs2!

This gives me a good start.
Title: Re: List and search local symbols macro
Post by: hs2 on October 29, 2007, 01:53:29 AM
@sdayts: Thought it a lot easier for me to quickly strip the tag stuff and add the buffer handling.
You could use the attached ''open_buffer.e' as basis for further improvements if you want.
However, I prefer the 2 column display of v12 'Files TB' with filename/path seperated.
HS2

@lambertia: Thanks ;D
Title: Re: List and search local symbols macro
Post by: hs2 on October 29, 2007, 02:00:41 AM
Wait .. I changed the attachment again using just the filename as _TreeSetUserInfo to omit the path on type ahead filtering in update_tree(). I think that's better.

Edit: Maybe add some more events below defeventtab open_buffers; allowed for filenames.

HS2
Title: Re: List and search local symbols macro
Post by: sdayts on October 29, 2007, 01:49:01 PM
hs2,

Thank you so, so much!
This would probably have taken me a week or more...

I am eternally grateful!
Title: Re: List and search local symbols macro
Post by: hs2 on November 26, 2007, 09:37:21 PM
Hi,
I've finished a new version of 'open_local_symbol2.e' (I just keep this module name).

What's new in v4.0.0:

(1) Hint: A single '~' token matches all destructors and ':' matches all classes/members in a buffer

(2) These chars can be entered at any time b/c they are automatically added to/removed from the right position.
There are some alternative key bindings which might be useful too:
'!' == '^' and '(' or ')' == '$' (and a few more - see event handler definitions)
If 'Strict word order is NOT set '^' (prefix match) affects the last/current word.
Otherwise it's added to/removed from the 1st word.

(3) '_' is not longer handled as separator (by default).
BTW: Don't be surprised that you can't enter successive separators - they are clipped to 1 automatically.

(4) 'Smart' case sensitivity is evaluated per word.
It simply uses this expression to get triggered: if ( word != lowcase(word) ) ...
Example: 'C init' matches all symbols containing a 'C' (case sens.) and 'init'/'Init'/'INIT'/... (not case sens.)
as long as global CaSe sensitivity is OFF. If the latter is ON it takes precedence of course.

Note: The current CaSe sens. setting is visualized in title / status line as follows:
CaSe sens. ON         -> '101 TAGS- in ...' ('TAGS' upcase)
CaSe smart sens. ON   -> '101 Tags~ in ...' ('Tags' capitalized)
CaSe (smart)sens. OFF -> '101 tags~ in ...' ('tags' lowcase)

Also note the appended '~' / '-' char. This flags the current word order setting as follows:
Strict word order ON  -> '101 TAGS- in ...' ('-' appended)
Strict word order OFF -> '101 TAGS~ in ...' ('~' appended)

(5) If enabled it can be skipped by pressing SHIFT/CTRL modifiers with ENTER or vice versa.

(6) The context menu can be activated by shortcut (default 'ALT-M') or by r-clicking the filter box / symbol tree.
Configuration is persistent (stored as 'def_' variables: def_ols_tag_filter, def_ols_flags).
There is still a 'hardwired config definitions' section at the beginning of the module.
It needs to be changed manually to setup e.g. user tag filter, fonts and the pseudo cursor (GUI config would be too much effort).
Don't forget to re-load the module to make the changes take effect.

I've added comments to the configuration and event handler stuff at the beginning of the module.
It could be useful to have look at it.
Also I don't list all keybindings here - please refer to the event handler definitions in the module (@see defeventtab open_local_symbol).
Most often used things as the quick tag filters have 'direct' keybindings corresponding to the accelerators in the context menu.

Although some of the new Slick-C language enhancements (SE >= v12) are used the module could be backported to v11 at least.

I've put 'open_local_symbol2.e' and a patched version of 'tagwin.e' into a hotfix package.
'tagwin.e' contains the patch related to the Preview TB described here: http://community.slickedit.com/index.php?topic=2371.msg9859#msg9859 (http://community.slickedit.com/index.php?topic=2371.msg9859#msg9859)
I'll take care about 'tagwin.e' too in case 'tagwin.e' gets hotfixed.
However, it's not absolutely necessary to install it (although recommended) b/c 'open_local_symbol2.e' is compatible to the original version.
Just unzip it and load it manually in this case.

Feedback, questions and/or change proposals are appreciated ! I'll see what I can do.
But for sure it will be maintained since I'm heavily using it ;)

Have fun,
HS2

Edit: Added a note to (4)
Title: Re: List and search local symbols macro
Post by: asandler on November 27, 2007, 12:29:49 PM
With your permission, I'd like to post it on my website instead of my old macro, with reference to this forum and header inside remaining intact.

It has no conflicts with open_project_file, so from now open_local_symbols3 and open_project_file3 are void. If you want to continue running "2" branch, please do so, but I think it would be better if you just rename it to open_local_symbol. My original branch is dead and there's no point running two branches. It's confusing. Also, from now on it's simply open_project_file.

Few bug reports.
1) From some reason, I have weird font in symbols tree control. It does not use "Dialog" font, but some other font.
2) When changing "Dialog" font to something a little bigger than default font (Tahoma 10 for instance) and then resizing the dialog, tree control becomes too high and its bottom side slides below dialog. I fixed this problem in open_local_symbol3. As far as I understood, this caused by relation between _dx2lx(SM_TWIP,p_active_form.p_client_width) and p_active_form.p_width being non-linear. I.e. There is no number X so that _dx2lx(SM_TWIP,p_active_form.p_client_width) + X == p_active_form.p_width. For more hints, take a look at my implementation of on_resize() in open_local_symbol3.

In general, it's an excellent version. I absolutely adore smart case sensitivity. Way to go mate! Thanks for making it.

Alexander.
Title: Re: List and search local symbols macro
Post by: hs2 on November 27, 2007, 01:47:17 PM
Hi Alexander,
of course you can put it on your website (What's the URL ?). I think it's very good idea since I'm also not really happy with the current way of 'publishing' macros in the forums.
Geez - found a stupid bug in the font setup stuff and fixed it. It didn't occur with my CFG_* setting but e.g. with CFG_DIALOG :(

I agree with you and already renamed the module to 'open_local_symbol.e'.
Concering the resizing maybe I've used the 'wrong' example. I've searched again in the product code and found resizeOutputWin() in 'output.e' which seems to be an appropriate example (and used it).
I've to admit that I'm not very experienced with SE GUI programming. Maybe Graeme should have a look at it.
See attached the updated package.

HS2
Title: Re: List and search local symbols macro
Post by: asandler on November 27, 2007, 01:52:16 PM
Took me some time to figure out whats wrong ;D The file you uploaded is empty. Can you reupload please? Thanks! ;D
Title: Re: List and search local symbols macro
Post by: hs2 on November 27, 2007, 02:06:11 PM
Oops - my bad :-[ .. done. HS2
Title: Re: List and search local symbols macro
Post by: asandler on November 27, 2007, 02:55:29 PM
Thanks!
Hmm. Strange. I no longer can reproduce the problem with resizing, after updating to latest version. Could it be caused by font issue? Note that I had this problem with previous version as well.
Title: Re: List and search local symbols macro
Post by: hs2 on November 27, 2007, 03:04:24 PM
To be honest I don't know ... I'm just happy that it's working ;) At least the 'p_xyscale_mode' is taken into account now.
Er .. one more update. I fixed a minor issue which was on my list but missed to do it before uploading.
It's related to suffix matching with relaxed word order. It was not possible to add another word after the END marker '$' as it's intended for strict word ordering only.
Updated the attachment to v4.0.2.

HS2
Title: Re: List and search local symbols macro
Post by: Graeme on November 28, 2007, 09:45:11 AM
Hi guys

This is a great effort.  I don't think I deserve the comment about the GUI thing ... but thanks.

I don't like to report problems but I guess you'd rather know ... (they're relatively minor).

Using the 4.02 hotfix including the new tagwin.e and slick 12.0.3

The first time I tried enabling "show return type" I got a slick stack (added below)  - seems to be on the call to _TreeSetCaption in the function update_return_type().

After restarting slick, the first use of ols always comes up with "show return type" enabled  - you can turn it off ok but it always comes back when you restart slick.

After restarting slick a couple of times to test this return type thing a couple of glitches happened  - firstly the ols list showed the tags for open_local_symbol but had hotfix.e listed in its title bar and hotfix.e was the file that was actually the current buffer;  then another time the preview toolbar was stepping through the tags for hotfix.e but the ols dialog was showing me the symbols for open_local_symbol.e and had open_local_symbol.e in its title bar.  I seem to be able to reproduce these problems by turning "show return type" on and off  - let me know if you can't reproduce and maybe I could try and debug it sometime.

Anyway, I don't like to complain coz this is a great macro  - thanks for posting it.

Here's that stack dump  - probably if I'd restarted slick after loading the hotfix and before running ols it wouldn't have happened because it was just the very first time that I enabled "show return type" that it crashed.

Graeme

Code: [Select]
Slick-C STACK TRACE ******************************
 Created on 11/28/2007 at 22:5:20 (546 ms)
 SlickEdit Version 12.0.3.0 Copyright 1988-2007 SlickEdit Inc.
 Edit module and type "st -f <offset>" to get the
 run-time error position

 error code=-2073
 This property or method is not allowed on this object

open_local_symbol.ex 1406 static()   p_window_id: 122   p_object: OI_LABEL   p_name: symbol_name
open_local_symbol.ex 3072 _ols_on_key_show_return_type_toggle()
   p_window_id: 122
   p_object: OI_LABEL
   p_name: symbol_name
open_local_symbol.ex 4409 ols_menu_cmd(_ols_on_key_show_return_type_toggle)
   p_window_id: 122
   p_object: OI_LABEL
   p_name: symbol_name
dlgeditv.ex 7360 show(-modal -mdi -xy open_local_symbol)   p_window_id: 12   p_object: OI_FORM   p_name:
open_local_symbol.ex 6372 ols()   p_window_id: 12   p_object: OI_FORM   p_name:
stdcmds.ex 6462 command_execute()   p_window_id: 12   p_object: OI_FORM   p_name:
stdcmds.ex 6687 split_insert_line()   p_window_id: 4   p_object: OI_TEXT_BOX   p_name:
stdprocs.ex 6508 try_calling(1072)   p_window_id: 4   p_object: OI_TEXT_BOX   p_name:
stdprocs.ex 9409 call_root_key("




Title: Re: List and search local symbols macro
Post by: hs2 on November 28, 2007, 10:50:50 AM
Thanks for the valueable feedback Graeme !
Think I found the reason of the stack-dump. In case you want to hotfix the 'hotfix' just add 'symbols.' to '_TreeSetCaption' ;)
Code: [Select]
      symbols._TreeSetCaption( index, name );

The other problems are caused by a 'sync problem' of the current buffer <-> current context.
(Would be very helpful to have a rough idea about how the tagging engine does it's magic work e.g. maintaining the contexts...)
Thought that there is no (more) problem with that but it's obviously not stable/robust enough.
I'll take care about it a bit later today and post a v4.0.3.

BTW: I've also added that the target symbol is auto-expanded in case it's hidden. (This is useful if you use e.g. 'show-current-proc' and goto to another symbol.)

Thanks, HS2



Title: Re: List and search local symbols macro
Post by: hs2 on November 28, 2007, 11:34:21 AM
Ok - I think / hope that I could solve the issues.
I'm not sure about the current buffer <-> current context fix since it didn't occur here even when I tested the ols v4.0.2...
See attached v4.0.3.
Have fun,
HS2
Title: Re: List and search local symbols macro
Post by: hs2 on April 05, 2008, 04:31:43 PM
Hi, I've updated open_local_symbol.e to v4.0.6 which now supports SE v12.0.3 and SE v13.0.0.
When using this module on v12.0.3 I'd recommened to install the hotfix pack due a useful patch to 'tagwin.e' related to the Preview TB.
This is not longer neccessary when using SE >= v13.0.0 because Dennis (HP++) implemented a really nice solution for this type of Preview TB problems.
There were a few minor changes:

- dialog is now non-modal which allows e.g. to scroll/use the Preview TB even when the dialog is shown
+ along with that there is a new option: 'Dismiss on goto tag' [default: ON]
  (I should better convert the dialog to a real tool window...if I find some time)

- using an adaptive timer depending on number of visible tags/symbols for tree update
  This should provide a better user experience even with files containing a HUGE number of symbols as 'slick.sh'...

- I've added a 1 level history: the last filter text and the settings are restored on <TAB>
  If the dialog was cancelled maybe entered filter text or changed settings are not saved to this 'history'.

- minor bugfixes + using the method to retrieve tags of the current buffer recommend by Dennis (could be a bit faster)

Edit:
- goto line support (enter line number as filter text)

ToDo:
- finish 'show references' feature
- implement clipboard support (paste filter text)

Have fun,
HS2
Title: Re: List and search local symbols macro
Post by: hs2 on April 07, 2008, 10:43:04 AM
Hi, I've updated open_local_symbol.e to v4.0.7.

I've seen VERY RARE situations, where the tag context was not updated correctly (empty) on v12.0.3.
(When this happend also the Defs TB didn't show any symbol.)
So it's changed back to the original method which seems to ALWAYS work.

HS2
Title: Re: List and search local symbols macro
Post by: Clark on April 07, 2008, 03:01:34 PM
Just thought I would mention that there is a "gt" command but it searches more than the current file (ex.  gt /main  OR  gt/?*main/r). Also, the Find Symbol tool window searches more than just the current file but you can change it to just search the current file.
Title: Re: List and search local symbols macro
Post by: hs2 on April 07, 2008, 03:17:49 PM
Thanks Clark, but I know... ;)
It's basically a replacement for 'list-tags'. HS2
Title: Re: List and search local symbols macro
Post by: mikesart on April 16, 2008, 08:13:26 PM
Hi hs2.

I'm using your latest ols (v4.0.7 (SE >= v12.0.3)) with SE v13.0.0.0 and every so often something goes horribly wrong and I get a never ending stream of dialog boxes saying:

  Invalidate argument
  file=open_local_symbol2.ex offset=297

The single line on the callstack is:

  open_local_symbol2.ex 297 open_local_symbol2:ReInitTimerCallback(235)   p_window_id: 5   p_object: OI_FORM   p_name:

I managed to sneak a double click in there between all the dialog boxes and I believe it's complaining about the p_window_id = ols_wid line. It also starts right back up when I close and re-open SE. Not sure what the secret sauce is to get it to stop happening once it's started, but a combination of closing all the files, re-loading open_local_symbol2.e seems, and restarting SE seems to eventually work.

I'm also not sure what causes it to start happening. I've stuck a little say() command right before the assignment to see what ols_wid is for the next time this occurs. If you have any other debugging suggestions I'd love to hear em.

Thanks much!
 -Mike

Code: [Select]
static void ReInitTimerCallback ( int ols_wid )
{
   _kill_timer ( _ols_ReInitTimerId ); _ols_ReInitTimerId = -1;
   orig_wid := p_window_id;
   p_window_id = ols_wid;                                       <---------------
   init_tree ( def_ols_tag_filter, OLS_INIT_TREE_INITIAL );
   p_window_id = orig_wid;
}
Title: Re: List and search local symbols macro
Post by: hs2 on April 16, 2008, 09:42:47 PM
Oops - I'll take care about it in a few minutes - stay tuned ;) HS2
Title: Re: List and search local symbols macro
Post by: hs2 on April 16, 2008, 10:37:37 PM
Hi Mike,
part 1: fix to solve the re-occuring stack dump after SE restart:
Could you please apply this patch to the module ?
change:
- moved some init's from defload() to (new) definit() entry

Code: [Select]
////////////////////////////////////////////////////////////////////////////////////////////////
definit()
{
   if (arg(1)!='L')
   {
      // better init all statics on editor invocation
      _ols_cur_buf_name    = '';
      _ols_cur_tree_index  = -1;

      _ols_num_context     = 0;
      _ols_num_tags        = 0;
      _ols_cur_context_id  = 0;

      _ols_PreviewTimerId  = -1;
      _ols_UpdateTimerId   = -1;
      _ols_ReInitTimerId   = -1;

      _ols_window_id       = -1;

      _ols_use_tagwin      = false;

      _ols_last_cfg.flags         = def_ols_flags;
      _ols_last_cfg.tag_filter    = def_ols_tag_filter;
      _ols_last_cfg.filter_text   = OLS_EOS;
      prev_ols_cfg = curr_ols_cfg = _ols_last_cfg;
   }
}

defload()
{
   // try to close dialog on re-load if it's still hanging around (not dismissed)
   // HS2-2DO: Even after closing the dialog I'm getting an 'Invalid Function pointer' stack dump ???
   //          The 'Invalid Function pointer' always occurs if the module was recompiled due to changes.
   formwid := _find_formobj(OLS_FORM_NAME);
   if ( formwid > 0 )   formwid._ols_goto_tag( true );

   // HS2-CHG: (old) proposal to avoid unintended idle update of the 'Preview TB'
   // @see tagwin.e - _UpdateTagWindow()
   #if __VERSION__<13
   // check if 'tagwin.e' patch was applied
   int index = find_index( 'maybe_add_tagwin_noupdate_form', PROC_TYPE );
   if ( index ) call_index( OLS_FORM_NAME, index );
   #endif
}

Sorry, but it'd be nice if you could tell me some more details when the 'ols' goes crazy.
Do you use mult. edit windows ? Which other dialog boxes are open ?
Did you switch/close buffers while the dialog was visible ?
And could you post the value of 'def_ols_flags' ?
Please do a 'set-var def_ols_flags' on commandline and just copy'n post it or better send me a message.

Needless to say that with the way I'm using SE the problem didn't occur until now...
But for sure there is a bug which has to be fixed !

Thanks, HS2
Title: Re: List and search local symbols macro
Post by: mikesart on April 17, 2008, 12:11:44 AM
I really wish I could give you more information about what causes this but it's extremely sporadic. I've been using ols() since it was first posted and even got the original one working with v13 before you submitted your last update. I use it a lot (love it!) and this has only happened three times. I've tried all kinds of things to repro it after it happens but it's not having any. That's the reason I didn't submit this the first two times - not much data. I was kind of hoping you'd just spot the issue :d or there might be some places in the code I could sprinkle some debug squirties to help narrow it down.

In any case, I got your changes in. I'll keep poking around and post with any new data I can come up with. Thanks HS2 - appreciate all your help yet again.
 -Mike
Title: Re: List and search local symbols macro
Post by: hs2 on April 17, 2008, 12:31:44 AM
Ok - I've changed a couple of things which seemed a bit fragile to me and added an improvement in the '_switch_buffer_' callback.
I've made some tests and I didn't notice any problem.
So I hope the attached v4.0.8 solves the problems you've encountered as well.

Thanks again for your help,
HS2
Title: Re: List and search local symbols macro
Post by: chrisant on April 17, 2008, 07:19:55 AM
I upgraded from open_local_symbol.e v4.0.6 to v4.0.8.
4.0.8 seems to have introduced a problem with auto-hide toolbars:

Relevant config settings:

Baseline repro of proper auto-hide with v4.0.6:
1.  Open open_local_symbol.e v4.0.6.
2.  Load Module (F12 in the default config, I think).
3.  Hover mouse over the Preview toolbar's tab.
-->  Preview toolbar unhides.
4.  Move mouse over the main editing window.
-->  Preview toolbar auto-hides.
5.  Invoke the ols command.
-->  OLS dialog pops up and Preview toolbar unhides.
6.  Press Escape to dismiss the OLS dialog.
-->  OLS dialog closes and Preview toolbar auto-hides.
7.  Do steps 3 & 4 again; results are the same as before.

Repro for problem with v4.0.8:
1.  Open open_local_symbol.e v4.0.8.
2.  Load Module.
3.  Hover mouse over the Preview toolbar's tab.
-->  Preview toolbar unhides.
4.  Move mouse over the main editing window.
-->  Preview toolbar auto-hides.
5.  Invoke the ols command.
-->  OLS dialog pops up and Preview toolbar unhides.
6.  Press Escape to dismiss the OLS dialog.
-->  OLS dialog closes but Preview toolbar does not auto-hide.
7.  Do steps 3 & 4 again; do the steps 3 & 4 for the Preview toolbar, and for the Output toolbar.
-->  Pretty quickly the auto-hide toolbars get stuck in the unhidden state, and won't auto-hide.
8.  At the SE command line type "set-var def_toolbar_autohide_delay" and it reports that the value is 2147483647.

Diagnosis:
I inserted some say() lines where orig_autohide_delay gets set/restored, and the problem appears to be because both on_create and on_got_focus set orig_autohide_delay, but both of those get called when the ols window gets created, so the true orig value ends up getting overwritten with the MAXINT value.

A Possible Fix:
1.  If the condition for restoring the orig value were "if ( def_toolbar_autohide_delay != orig_autohide_delay && def_toolbar_autohide_delay == MAXINT )", then the restore wouldn't overwrite an intentional change the user might have made to the setting while the ols dialog is up.
2.  If a boolean is used to guard the orig value (e.g. "is_orig_value_saved"), it can avoid saving the def value multiple times and avoid accidentally overwriting an already-saved value.  Should then also check the boolean when determining whether to restore the saved orig value.

See attached file for possible implementation of the possible fix.
Title: Re: List and search local symbols macro
Post by: hs2 on April 17, 2008, 09:56:56 AM
Argh - I knew that there are still some problems with the new non-modal behaviour...
I think the root cause problem was a missing state check in the on_got_focus handler.
I did some regression testing and it seems to work now. See attached the bug fix release v4.0.8.1

Thanks for your help chrisant !
HS2

Edit: Minor update to v4.0.8.4
Title: Feature proposal
Post by: asandler on April 29, 2010, 07:45:48 AM
Hi all.

I'd like to propose and discuss with you a new feature for the ols. Here's the scenario. Lets say we have C++ file with lots of methods. In it, there are several methods that start with write. For instance:

write()
write_all()
write_tomorrow()
write_before_you_leave()
just_write()
write_damn_you()
write_slowly()
write_faster()

In ols, typing write would leave these functions in search result (and filter out everything else). But lets say I'd like to have a way to refine ols search criteria to match only write(). With all other functions, I can add one more word to match the function exactly, but in case of write() I can't do it.

To tackle this issue, I propose that we add a new special syntax. We mark the word we're looking for with ! (exclamation mark). When ols sees a word with !, instead of searching for the exact word, it will search for [^a-zA-Z0-9_]word[^a-zA-Z0-9_] - i.e. it will search for the exact word and not a word as part of function name.
(in case I made a mistake in the regular expression, the regex should match word that doesn't have a-z A-Z 0-9 and _ before and after itself).

Some notes:
1. This entire thing has meaning only if you are looking for a function those name consists of one word. So, searching for something like "slowly write!" won't produce any result, but it really shouldn't produce any result, so its ok.
2. Searching for .*word.* won't work because this won't match class_name::write().
3. I am not sure about it, but ! may already have some special meaning. In case it does, we may use some other symbol. ! seems the most natural for this purpose though.
Title: Re: List and search local symbols macro
Post by: lambertia on April 29, 2010, 09:18:45 AM
Hi.

In this particular case above, wouldn't it be more natural to type "write("?

Cheers,
--
Greg.
Title: Re: List and search local symbols macro
Post by: asandler on April 29, 2010, 12:33:22 PM
Two problems with this. First it will only filter out all write_...() functions. But ..._write() will remain. Second, from some reason when I press ( in ols window, it shows $ sign.

@hs2, could it (the later) be because of keyboard layouts (i.e. German layout vs American)?
Title: Re: List and search local symbols macro
Post by: hs2 on April 29, 2010, 02:55:33 PM
Hi Alex,
there is a special char '$' (like the regexp. line ending) to postfix-match the given pattern.
The '(' char is also mapped/guessed to this special char temporarily for 'better' C/C++ support until you continue typing.
Accordingly there is also a prefix-match char '^' ('!' is also auto-mapped to '^' when typing it).
So in your case you could e.g. use 'write$' as pattern or even more strict '^write$'.
Hope it helps,
HS2

PS: I'll have a detailed look at your posting later. Thanks !
Title: Re: List and search local symbols macro
Post by: asandler on April 29, 2010, 07:18:16 PM
Hi hs2,

I don't know if ^word$ will do the job - need some time to give it a try. In any case thanks for looking into it.

Alex.
Title: Re: List and search local symbols macro
Post by: hs2 on April 29, 2010, 08:20:17 PM
Yep - please try it and tell me if it's ok or rather confusing...
Just for clarification:
(your sample use case)
'write$' would match:
write()
 just_write()

and '^write$' only write()
The additional regex keys as '!', '(' etc. are listed and commented in open_local_symbol.e [line 223]
Good luck, HS2
Title: Re: List and search local symbols macro
Post by: asandler on May 03, 2010, 12:36:36 PM
I gave it a try. Indeed write$ matches .*write(...). However, ^write doesn't match anything. Could this be because write() is a class method? I.e. it tries to match ^write against class_name::write().
Title: Re: List and search local symbols macro
Post by: hs2 on May 03, 2010, 03:27:40 PM
Yes - '^' resp. '$' affect the whole pattern. So a class method 'write' is exactly matched e.g. by ':write$'.
HS2
Title: Re: List and search local symbols macro
Post by: asandler on May 03, 2010, 07:36:22 PM
Alright. This is basically what I was looking for.

I'd still think about adding some special syntax for this particular case. :write$ is a little cryptic if you ask me. Also, as you type the method name, you should know ahead that there are several methods named 'write something'. Otherwise you won't put colon ahead of the method name.
Title: Re: List and search local symbols macro
Post by: hs2 on May 03, 2010, 10:02:39 PM
You're right. It's a bit .. special. OTOH if want an exact match of a C++ class method you might be aware of using the leading colon.. ;)
However, I've added the generic regexp chars time ago to cope with use cases like that just a bit better.
A possible approach could be to add some language specific additional delimiters. Up to now ols is merely language agnostic.
Please keep me informed if you find a better solution.

BTW: When not using 'strict word order' (see context menu>More Options) you could also append ':w' separated by a SPACE to the existing 'write$' pattern to eliminate some more ambiguous matches since the parts of the pattern are ANDed together on filtering.

Thanks for the feedback, HS2
Title: Re: List and search local symbols macro
Post by: hs2 on June 11, 2012, 09:59:15 AM
It seems that there is bug in the SE v17 release which causes a 'deprecated' error when loading 'open_local_symbol.e'. I've already send a problem report.
However, for the time being a patch is required to use it with all supported SE versions.
I've re-uploaded a new version v4.0.8.4 here (http://community.slickedit.com/index.php?action=dlattach;topic=2245.0;attach=4833) compatible again with SE >= v12.0.3.

Best regards, HS2

PS: I hope I'll find the time soon to rework the module a bit for better integration into SE (toolwindow, clipboard support, etc.).
But I think this will be based on v17.
Title: Re: List and search local symbols macro
Post by: dunkers on June 11, 2012, 08:45:19 PM
Good job, HS2 :)
Title: Re: List and search local symbols macro
Post by: MindprisM on October 26, 2012, 08:55:49 AM
I don't know if this has been done, but I made some enhanced pattern matching for open_local_symbol v4.0.8.1

It takes the symbol names and then creates an abbreviation string for them, capturing logical transitions between case and non-alphas in a particular identifier. This is then integrated into OLS to operate when you enter a single word filter.

See the code documentation in the attached files for further info and integration instructions. @HS2, go ahead and pull this into your codebase if you like, though it probably needs some more testing/scrutiny.

Title: Re: List and search local symbols macro
Post by: eee on November 23, 2014, 07:44:21 AM
Does not compile in vs 19 (2014).
Is there a new version anyplace? Perhaps a replacement?
Title: Re: List and search local symbols macro
Post by: eee on November 23, 2014, 09:49:18 AM
Looks like 2 problems:
1. Some changes in the autohide api, I dosabled these just to get it to compile
2. looks like tag_get_num_of_context() (in init_tree()) sometimes (many-sometimes) returns 0.
I am not knowledgeable enough in these areas to solve these.
Help would be appreciated.
Title: Re: List and search local symbols macro
Post by: hs2 on November 23, 2014, 02:18:58 PM
@eee: I'm going to take care about it. Hope I get it done soon. I'll also try to integrate the enhancement MindprisM provided.
HS2
Title: Re: List and search local symbols macro
Post by: hs2 on November 23, 2014, 09:47:51 PM
Hi,
this is a new version v4.0.9.3 compatible with SE >= v12.0.3 up to v22.

changes:
- compatible with SE v19
- omit default 'Auto-activate Preview TB' for now due to focus issue with v19 (see know issues)
- added MindprisM subword/smart abbreviation matching (e.g. 'ad' matches 'abcDef')
  (see 'SubWord match' option in 2nd level context menu')
- removed '=+-' from OLS_WORD_SEPARATORS to support (C++) operator symbols

known issues:
- with 'Auto-activate Preview TB' selected and Preview toolwindow is not already active the 'ols' dialog looses focus (same applies to interactive 'Activate Preview TB' and 'References' - see context menu)

Best regards, HS2

PS: I'll contact the SE team to clarify the focus issue.

Edit : v4.0.9.1 uploaded
Edit2: v4.0.9.1 re-uploaded with fixed default font
Edit3: v4.0.9.2 uploaded with 'SubWord match' feature completed (thanks MindprisM)
Edit4: v4.0.9.3 uploaded with fix for missing icons with SE v22 (thanks Dennis - see this hotfix (https://community.slickedit.com/index.php/topic,2245.msg61400.html#msg61400))
Title: Re: List and search local symbols macro
Post by: eee on November 24, 2014, 08:26:31 AM
Thanx

Unfortunately, I am having problems with the tag filter.
The defs window uses "functions only" and works fine.
The ols, when set to either "funcs only" or "use defs TB", show all tags.
Attached screenshot.

Eli
Title: Re: List and search local symbols macro
Post by: hs2 on November 24, 2014, 09:01:39 AM
Oops - right  :-\ It was a bug in the SE v19 code path. I've uploaded a new, fixed v4.0.9.1.

Thanks, HS2
Title: Re: List and search local symbols macro
Post by: eee on November 24, 2014, 10:39:36 AM
Perfect. Works.
I took the liberty to modify the fonts back to CFG_DIALOG and the OLS_EOS back to "&.".
If these have any but a visual effect, please let me know.
Title: Re: List and search local symbols macro
Post by: hs2 on November 24, 2014, 11:09:49 AM
Argh .. my bad - again >:( Re-uploaded with fixed defaults.
Thanks, HS2
Title: Re: List and search local symbols macro
Post by: hs2 on November 25, 2014, 04:20:41 PM
Thanks to MindprisM the 'SubWord match' feature is now completed (uploaded v4.0.9.2 (http://community.slickedit.com/index.php?action=dlattach;topic=2245.0;attach=7063)).
HS2
Title: Re: List and search local symbols macro
Post by: chgmxx on November 28, 2014, 12:48:33 AM
Hi,
this is a new version v4.0.9.2 compatible with SE >= v12.0.3 up to v19.

changes:
- compatible with SE v19
- omit default 'Auto-activate Preview TB' for now due to focus issue with v19 (see know issues)
- added MindprisM subword/smart abbreviation matching (e.g. 'ad' matches 'abcDef')
  (see 'SubWord match' option in 2nd level context menu')
- removed '=+-' from OLS_WORD_SEPARATORS to support (C++) operator symbols

known issues:
- with 'Auto-activate Preview TB' selected and Preview toolwindow is not already active the 'ols' dialog looses focus (same applies to interactive 'Activate Preview TB' and 'References' - see context menu)

Best regards, HS2

PS: I'll contact the SE team to clarify the focus issue.

Edit: v4.0.9.1 uploaded
Edit2: v4.0.9.1 re-uploaded with fixed default font
Edit3: v4.0.9.2 uploaded with 'SubWord match' feature completed (thanks MindprisM)
Hi,hs2
Thanks a lot for your powerful macro. I used it in windows7,and it seems work all right.
But when I run it is Linux(ubuntu14.04), the macro has exception.
Could you please take a look?

Thanks
Title: Re: List and search local symbols macro
Post by: hs2 on November 28, 2014, 02:27:52 PM
chgmxx: Is it an exception like SIGSEGV (would be a problem of SE core code and I can't much except fwd.ing the issue to SE support) or just a Slick-C macro stack dump ?
However, could you please post/PM me more details about the problem incl. SE version you're using ?
Unfortunately I'm currently not using Linux so I hope I find sth. analyzing the error output.
HS2
Title: Re: List and search local symbols macro
Post by: chgmxx on December 01, 2014, 01:14:08 PM
dear hs2, sorry for reply late:
the error as below:
 This property or method is not allowed on this object
dlgeditv.ex 6082 show(-app -xy open_local_symbol)   p_window_id: 215   p_object: OI_EDITOR   p_name:
open_local_symbol.ex 9397 ols()   p_window_id: 215   p_object: OI_EDITOR   p_name:

SlickEdit 2014 (v19.0.0.14 64-bit)

OS: Linux
OS Version: Ubuntu 14.04.1 LTS
Kernel Level: 3.13.0-40-generic
I using the latest script you uploaded.
Thanks
chgmxx: Is it an exception like SIGSEGV (would be a problem of SE core code and I can't much except fwd.ing the issue to SE support) or just a Slick-C macro stack dump ?
However, could you please post/PM me more details about the problem incl. SE version you're using ?
Unfortunately I'm currently not using Linux so I hope I find sth. analyzing the error output.
HS2
Title: Re: List and search local symbols macro
Post by: hs2 on December 01, 2014, 11:45:49 PM
@chgmxx Ok - just a stack trace..

Strange, when I goto the error location I end up here:
macros\dlgeditv.e - line 1635:
Quote
   if (parent==VSWID_HIDDEN) {
Unfortunately I can't see what could cause an error there ???

Just to be sure:
So you just installed SEv19 on your Ubuntu powered machine, loaded the macro module and (always ?) when invoking the 'ols' command you get the stack trace ?

Is there anyone else running an Ubuntu box who could just try to load the macro module and invoke the 'ols' command ?
The macro module can be easily uninstalled by 'Macro>Unload Module' and select 'open_local_symbol.ex'.
Thanks in advance !

HS2

Title: Re: List and search local symbols macro
Post by: chgmxx on December 02, 2014, 12:54:43 PM
@hs2,thanks a lot for your help.
I tried to uninstall ols.e, and install again. everything goes well,
Thanks again.
@chgmxx Ok - just a stack trace..

Strange, when I goto the error location I end up here:
macros\dlgeditv.e - line 1635:
Quote
   if (parent==VSWID_HIDDEN) {
Unfortunately I can't see what could cause an error there ???

Just to be sure:
So you just installed SEv19 on your Ubuntu powered machine, loaded the macro module and (always ?) when invoking the 'ols' command you get the stack trace ?

Is there anyone else running an Ubuntu box who could just try to load the macro module and invoke the 'ols' command ?
The macro module can be easily uninstalled by 'Macro>Unload Module' and select 'open_local_symbol.ex'.
Thanks in advance !

HS2
Title: Re: List and search local symbols macro
Post by: vivitron on December 09, 2014, 01:06:28 AM
@h2 - thanks again for this.  I did not upgrade to v19 until this was updated - that's how critical this is to my workflow.

It really should just replace list-tags
Title: Re: List and search local symbols macro
Post by: eee on May 12, 2015, 09:17:33 AM
How can ols window be docked?
Title: Re: List and search local symbols macro
Post by: hs2 on May 12, 2015, 09:30:40 AM
Unfortunately they can't - it's not yet implemented..
Currently you only can deactivate 'More Options>Dismiss on goto tag' (use r-button 'ALT-M' for context menu) to keep it visible as floating window.
Sorry, HS2
Title: Re: List and search local symbols macro
Post by: JustAbitCool on January 25, 2018, 11:53:01 AM
In SlickEdit 2017, v22.0.1.0, I found the icon of each local symbol is missing,as the picture shows.
I'm not sure if this is a problem with my configuration. I really like this ols macro. so @h2, if you have time, please help check it.
Title: Re: List and search local symbols macro
Post by: Dennis on February 28, 2018, 11:32:00 PM
Code: [Select]
         
         //tag_tree_get_bitmap(CB_DEFAULTS, CB_DEFAULTS2, type_name,'', tag_flags, auto leaf_flag, auto pic);
         pic := tag_get_bitmap_for_type(tag_get_type_id(type_name), tag_flags, auto pic_overlay);

         index = symbols._TreeAddItem( 0, name, TREE_ADD_AS_CHILD|TREE_OVERLAY_BITMAP1, pic_overlay, pic, -1 );
         _ols_num_tags++;
/code]
Title: Re: List and search local symbols macro
Post by: JustAbitCool on March 01, 2018, 11:51:53 AM
great work! thank you very much, Dennis!
Title: Re: List and search local symbols macro
Post by: hs2 on March 01, 2018, 12:41:52 PM
Thanks a lot ++Dennis for your help :)
I've uploaded a new version v4.0.9.3 here (https://community.slickedit.com/index.php/topic,2245.msg46136.html#msg46136) (including a minor correction for legacy SE versions < v22)
HS2
Title: Re: List and search local symbols macro
Post by: at5dapa1 on October 01, 2018, 11:17:52 AM
After I'm loading this in SlickEdit Pro 2018 beta 5 (v23.0.0.6 64-bit) in Win7x64: it works, but it breaks menus editing.
Example: right-click in an opened buffer and select "Edit This Menu": I get an exclamation dialog:
Quote
Unable to temp menu
Error code out of range: 2146566144
Can anybody confirm?
Maybe related to https://community.slickedit.com/index.php/topic,16432.msg63300.html#msg63300 (https://community.slickedit.com/index.php/topic,16432.msg63300.html#msg63300) ?