Author Topic: selective display regions + defs view  (Read 684 times)

IkerAriz

  • Senior Community Member
  • Posts: 159
  • Hero Points: 6
selective display regions + defs view
« 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

« Last Edit: April 28, 2021, 12:42:00 pm by IkerAriz »

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3254
  • Hero Points: 462
Re: selective display regions + defs view
« Reply #1 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.

IkerAriz

  • Senior Community Member
  • Posts: 159
  • Hero Points: 6
Re: selective display regions + defs view
« Reply #2 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:
  • One has to bookmark each search result one at a time which is tedious when a file has many regions (30+ in my case).
  • The Text column of the bookmarks window which has the name of the region is the last one and fixed at that position (I couldn't find any way to move it). I usually keep a relatively narrow sidebar panel so the useful info is hidden. See attached screenshot.

Iker

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3254
  • Hero Points: 462
Re: selective display regions + defs view
« Reply #3 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.

IkerAriz

  • Senior Community Member
  • Posts: 159
  • Hero Points: 6
Re: selective display regions + defs view
« Reply #4 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:
  • The initial columns still take up a lot of room even when resized to their minimum.
  • The horizontal scrollbar doesn't show up to allow centering the text column content into view.
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

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5779
  • Hero Points: 461
Re: selective display regions + defs view
« Reply #5 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.

IkerAriz

  • Senior Community Member
  • Posts: 159
  • Hero Points: 6
Re: selective display regions + defs view
« Reply #6 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

IkerAriz

  • Senior Community Member
  • Posts: 159
  • Hero Points: 6
Re: selective display regions + defs view
« Reply #7 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

IkerAriz

  • Senior Community Member
  • Posts: 159
  • Hero Points: 6
Re: selective display regions + defs view
« Reply #8 on: May 11, 2021, 04:43:34 pm »
Can these sorts of adjustments to the bookmark window be made with a macro?

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5779
  • Hero Points: 461
Re: selective display regions + defs view
« Reply #9 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.

Graeme

  • Senior Community Member
  • Posts: 2533
  • Hero Points: 329
Re: selective display regions + defs view
« Reply #10 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();
}

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3254
  • Hero Points: 462
Re: selective display regions + defs view
« Reply #11 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.

IkerAriz

  • Senior Community Member
  • Posts: 159
  • Hero Points: 6
Re: selective display regions + defs view
« Reply #12 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.


IkerAriz

  • Senior Community Member
  • Posts: 159
  • Hero Points: 6
Re: selective display regions + defs view
« Reply #13 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

IkerAriz

  • Senior Community Member
  • Posts: 159
  • Hero Points: 6
Re: selective display regions + defs view
« Reply #14 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 :(