SlickEdit Community
SlickEdit Product Discussion => SlickEdit® => Topic started 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
-
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.
-
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
-
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.
-
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
-
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.
-
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
-
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
-
Can these sorts of adjustments to the bookmark window be made with a macro?
-
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.
-
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
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();
}
-
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.
-
Thanks Graeme! With your suggested changes the bookmarks are now much easier on the eyes. See attached screenshot.
-
Dennis, I applied your patch but afterwards all attempts to "Find" resulted in the following error:
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
-
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 :(
-
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.
-
... 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
-
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