SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => Topic started by: IkerAriz on April 27, 2021, 07:12:35 pm

Title: selective display regions + defs view
Post by: IkerAriz on April 27, 2021, 07:12:35 pm
Hello all,

Is there a way to get regions defined using "search text" in selective display to show up in the defs view? (there was some talk of this in a 2011 thread titled "C# regions and defs view" but no updates since then).

Regards,
Iker

Title: Re: selective display regions + defs view
Post by: Dennis on April 27, 2021, 09:18:31 pm
There is no option to do that, but if you want to have a list of search matches, you could search within the current buffer and select "List all occurrences", then right click on the search results and sent them to the References tool window, or you could search and set bookmarks on all of the search matches.
Title: Re: selective display regions + defs view
Post by: IkerAriz on April 28, 2021, 01:11:54 pm
Thanks Dennis. I couldn't try "send to references" as I'm on v23 so I gave the bookmark suggestion a try. It almost did the job but for a couple of issues:

Iker
Title: Re: selective display regions + defs view
Post by: Dennis on April 28, 2021, 01:42:09 pm
I was referring to using the Find and Replace tool window and selecting "Bookmark all matches"

You can click and drag the header columns to resize the columns in the Bookmarks tool window, the tree control also has a horizontal scroll bar, so you could scroll the text into view.
Title: Re: selective display regions + defs view
Post by: IkerAriz on April 30, 2021, 02:01:46 pm
Thanks again. The "bookmark all" option worked well. However, the results in the bookmarks window are still rough as shown in the attached screenshot. Ie:
Is there a way to get a Find regex to match/display only a capture group? (in order to suppress the leading "<!-- #region" prefix)

Iker
Title: Re: selective display regions + defs view
Post by: Clark on April 30, 2021, 02:31:54 pm
The "List matches only" option reduces the line output to just the text that was matched (not obvious). If that's too much, try using a regex with lookbehind   (ex. " (?<=def)main" ). SlickEdit supports variable length look behind. As far as I know, there's no other regex engine which supports variable length look behind. It's awesome when you need it.
Title: Re: selective display regions + defs view
Post by: IkerAriz on April 30, 2021, 03:56:35 pm
Thanks Clark. I tried using lookbehind but unfortunately the reduced output is limited to the search results window. The Text column of the bookmarks window still displays the entire line (see attached screenshot).

Iker
Title: Re: selective display regions + defs view
Post by: IkerAriz on May 04, 2021, 04:26:18 pm
The bookmarks solution coupled with a custom selective display to fold regions makes for a pretty good solution but for the noisiness of the bookmarks window. Any chance an upcoming update could include support for hiding columns in the bookmark window and showing just the matching text in the "Text" column?

Thanks,
Iker
Title: Re: selective display regions + defs view
Post by: IkerAriz on May 11, 2021, 04:43:34 pm
Can these sorts of adjustments to the bookmark window be made with a macro?
Title: Re: selective display regions + defs view
Post by: Clark on May 11, 2021, 05:44:05 pm
No. Bookmarks can move. As soon as the bookmarks tool window is refreshed, it has to fetch the current line data. Also, there isn't a callback you can specify to fetch the line data that gets displayed.
Title: Re: selective display regions + defs view
Post by: Graeme on May 12, 2021, 07:22:30 am

You could try making a couple of small changes to bookmark.e.
It seems to work.

In updateBookmarksToolWindowOne()
         caption := LineData"\t"BookmarkName"\t"Filename"\t"Pathname"\t"RealLineNumber;

and this

Code: [Select]
void ctl_bookmarks_tree.on_create()
{
   TBBOOKMARKS_FORM_INFO info;
   info.m_form_wid=p_active_form;
   gtbBookmarksFormList:[p_active_form]=info;

   ctl_bookmarks_tree._TreeSetColButtonInfo(1,1000,TREE_BUTTON_PUSHBUTTON|TREE_BUTTON_SORT_COLUMN_ONLY|TREE_BUTTON_SORT,0,"Name");
   ctl_bookmarks_tree._TreeSetColButtonInfo(2,1000,TREE_BUTTON_PUSHBUTTON|TREE_BUTTON_SORT_COLUMN_ONLY|TREE_BUTTON_SORT|TREE_BUTTON_SORT_FILENAME|TREE_BUTTON_IS_FILENAME,0,"File");
   ctl_bookmarks_tree._TreeSetColButtonInfo(3,1000,TREE_BUTTON_PUSHBUTTON|TREE_BUTTON_SORT_COLUMN_ONLY|TREE_BUTTON_SORT|TREE_BUTTON_SORT_FILENAME|TREE_BUTTON_IS_FILENAME,0,"Path");
   ctl_bookmarks_tree._TreeSetColButtonInfo(4,500, TREE_BUTTON_PUSHBUTTON|TREE_BUTTON_SORT_COLUMN_ONLY|TREE_BUTTON_SORT|TREE_BUTTON_SORT_NUMBERS,0,"Line");
   ctl_bookmarks_tree._TreeSetColButtonInfo(0,1000,TREE_BUTTON_PUSHBUTTON|TREE_BUTTON_SORT_COLUMN_ONLY|TREE_BUTTON_SORT|TREE_BUTTON_AUTOSIZE,0,"Text");

   updateBookmarksToolWindowOne();
   ctl_bookmarks_tree._TreeTop();
}
Title: Re: selective display regions + defs view
Post by: Dennis on May 12, 2021, 05:17:07 pm
I am attaching an experimental change to the Find tool window code for setting bookmarks.  This will attempt to add the text that was matched by the search to the bookmark name.  If the match text is too short or too long, it opts not to do it, and if the match text is an exact match of the search expression, it opts not to do it also (because they would all be the same).

It does not look great, but then the bookmark names have always had a bit of an ugly look to them.
Title: Re: selective display regions + defs view
Post by: IkerAriz on May 12, 2021, 05:46:05 pm
Thanks Graeme! With your suggested changes the bookmarks are now much easier on the eyes. See attached screenshot.

Title: Re: selective display regions + defs view
Post by: IkerAriz on May 12, 2021, 05:48:01 pm
Dennis, I applied your patch but afterwards all attempts to "Find" resulted in the following error:

Code: [Select]
Procedure tool-gui-find not found
docsearch.ex 498 gui_find()   p_window_id: 50   p_object: OI_EDITOR   p_name:

Note that I'm on v23.

Thanks!
Iker
Title: Re: selective display regions + defs view
Post by: IkerAriz on May 12, 2021, 06:57:03 pm
I may have spoken too soon. I had applied Dennis's patch to tbfind.e first and reverted before applying Graeme's change to bookmark.e and at that point I was able to arrange the columns to produce the previous screenshot. However, after restarting VS I can no longer adjust the first column width to "push" the other columns to the right as I had before. As a sanity check, I reinstalled a fresh copy of VS 23.02 and reapplied the change and... it no longer works. The first column is now fixed width and resizing the other columns makes them "grow into" the first column :(
Title: Re: selective display regions + defs view
Post by: Dennis on May 12, 2021, 09:23:27 pm
Not sure if you really want to use both Graeme's solution and mine.  His is elegant.  I could see an argument being made to move the line data to the first column as a permanent fix.

Not sure what is happening with the column resizing for you, it could just be that you are not gripping the resize bar in the header in the exact right place.  It will not let you "push" a column to the left, but none of these are configured to be fixed with columns.
Title: Re: selective display regions + defs view
Post by: IkerAriz on May 13, 2021, 01:47:52 am
Quote
... it could just be that you are not gripping the resize bar in the header in the exact right place.

Ah, removing the TREE_BUTTON_AUTOSIZE option from the first column did the trick.

Thanks again,
Iker
Title: Re: selective display regions + defs view
Post by: IkerAriz on May 24, 2021, 04:36:37 pm
After applying Graeme's solution and using bookmarks for a week my user experience report is... not that great. Typical work on a file quickly throws the bookmarks off and requires deleting them all and re-running the Find operation to set them again. This was both tedious and error prone as I would often forget to uncheck the "bookmark all matches" option (so my next Find operation would accidentally pollute the bookmarks). First class support for regions in the defs view would - I think - provide far better results for this use case.

Regards,
Iker