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

hs2

  • Senior Community Member
  • Posts: 2734
  • Hero Points: 284
Re: List and search local symbols macro
« Reply #15 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
« Last Edit: October 28, 2007, 03:31:49 pm by hs2 »

sdayts

  • Community Member
  • Posts: 42
  • Hero Points: 5
Re: List and search local symbols macro
« Reply #16 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!

hs2

  • Senior Community Member
  • Posts: 2734
  • Hero Points: 284
Re: List and search local symbols macro
« Reply #17 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

lambertia

  • Senior Community Member
  • Posts: 382
  • Hero Points: 14
  • I have nothing sufficiently witty to say.
Re: List and search local symbols macro
« Reply #18 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.

sdayts

  • Community Member
  • Posts: 42
  • Hero Points: 5
Re: List and search local symbols macro
« Reply #19 on: October 29, 2007, 12:24:18 am »
Thanks hs2!

This gives me a good start.

hs2

  • Senior Community Member
  • Posts: 2734
  • Hero Points: 284
Re: List and search local symbols macro
« Reply #20 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
« Last Edit: October 29, 2007, 09:30:04 am by hs2 »

hs2

  • Senior Community Member
  • Posts: 2734
  • Hero Points: 284
Re: List and search local symbols macro
« Reply #21 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
« Last Edit: October 29, 2007, 02:06:25 am by hs2 »

sdayts

  • Community Member
  • Posts: 42
  • Hero Points: 5
Re: List and search local symbols macro
« Reply #22 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!

hs2

  • Senior Community Member
  • Posts: 2734
  • Hero Points: 284
Re: List and search local symbols macro
« Reply #23 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:
  • quick tag filter support including (currently only one) user defined tag filter set
  • class names are included when filtering to support fully qualified symbol names (1)
  • begin / end regex [^,$] support to support prefix / suffix match (2)
  • strict / relaxed word order
  • sort by line / name
  • pseudo cursor useful when separating tokens by SPACE (3)
  • Preview TB support
  • (smart) CaSe sensitivity support (4)
  • leave bookmarks on goto symbol - go back with pop-bookmark (usually bound to CTRL-COMMA) (5)
  • context menu for interactive configuration of almost all configurable items (6)
  • improved 'show return type' (it's just displayed and not taken into account when filtering)
  • deletion: ALT-BACKSPACE deletes the whole filter, CTRL-BACKSPACE the last word (and BACKSPACE the last char)
  • changed the internal design to provide a better responsiveness for buffers containing a large number of symbols.

(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
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)
« Last Edit: November 27, 2007, 11:19:40 am by hs2 »

asandler

  • Senior Community Member
  • Posts: 279
  • Hero Points: 24
Re: List and search local symbols macro
« Reply #24 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.

hs2

  • Senior Community Member
  • Posts: 2734
  • Hero Points: 284
Re: List and search local symbols macro
« Reply #25 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
« Last Edit: November 27, 2007, 03:04:59 pm by hs2 »

asandler

  • Senior Community Member
  • Posts: 279
  • Hero Points: 24
Re: List and search local symbols macro
« Reply #26 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

hs2

  • Senior Community Member
  • Posts: 2734
  • Hero Points: 284
Re: List and search local symbols macro
« Reply #27 on: November 27, 2007, 02:06:11 pm »
Oops - my bad :-[ .. done. HS2

asandler

  • Senior Community Member
  • Posts: 279
  • Hero Points: 24
Re: List and search local symbols macro
« Reply #28 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.

hs2

  • Senior Community Member
  • Posts: 2734
  • Hero Points: 284
Re: List and search local symbols macro
« Reply #29 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