Author Topic: Search Results window enhancements  (Read 6436 times)

mark0978

  • Community Member
  • Posts: 98
  • Hero Points: -2
Search Results window enhancements
« on: February 17, 2010, 02:31:49 AM »
I'd like the search results window to stay visible a little longer after a search.  As it is, it is visible until the search finishes, then it immediately auto hides.  Seems like the auto hide shouldn't be so aggressive, but should start several seconds after the search finishes..... (This is when I search using List All Occurrences)

Of course you could fix this altogether just by making it possible to tear the search results out of the editing frame and put them on my other screen.


dmw

  • Senior Community Member
  • Posts: 145
  • Hero Points: 15
Re: Search Results window enhancements
« Reply #1 on: February 17, 2010, 04:48:46 AM »
Of course you could fix this altogether just by making it possible to tear the search results out of the editing frame and put them on my other screen.

But you can.  Just drag the window out of the frame.  Put it wherever you want.  If it doesn't drag, you may need to un-pin it (click the thumbtack icon on the right).
« Last Edit: February 17, 2010, 04:50:32 AM by dmw »

mark0978

  • Community Member
  • Posts: 98
  • Hero Points: -2
Re: Search Results window enhancements
« Reply #2 on: February 17, 2010, 04:51:03 AM »
Well, well, well, you were right, only thing is you HAVE to PIN it before you can do that, exactly the opposite of VS2008.

dmw

  • Senior Community Member
  • Posts: 145
  • Hero Points: 15
Re: Search Results window enhancements
« Reply #3 on: February 17, 2010, 04:54:14 AM »
Pin, un-pin.  Heck, I can't even tell my left from my right.  But you're right, you do have to PIN it first, and that does seem strange.  Why limit it at all, I wonder.

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: Search Results window enhancements
« Reply #4 on: February 17, 2010, 11:15:01 PM »
I'd like the search results window to stay visible a little longer after a search.  As it is, it is visible until the search finishes, then it immediately auto hides.  Seems like the auto hide shouldn't be so aggressive, but should start several seconds after the search finishes..... (This is when I search using List All Occurrences)

Of course you could fix this altogether just by making it possible to tear the search results out of the editing frame and put them on my other screen.
SE is inconsistent about giving focus to the Search Results floating window when a search is performed.
If SE consistently gave focus to the Search Results floating window, then the window would not disappear until the user took a subsequent action that either implicitly or explicitly dismissed the Search Results floating window.

rowbearto

  • Senior Community Member
  • Posts: 2344
  • Hero Points: 132
Re: Search Results window enhancements
« Reply #5 on: September 03, 2013, 02:01:48 PM »
When performing a "Find in Files" - I'd like to be able to see the  search results in a way that is similar to the "References" window.  That is, for each time a search term is found, I would like to know which C/C++ function it is in alongside the search results.

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: Search Results window enhancements
« Reply #6 on: September 04, 2013, 07:02:46 AM »
When performing a "Find in Files" - I'd like to be able to see the  search results in a way that is similar to the "References" window.  That is, for each time a search term is found, I would like to know which C/C++ function it is in alongside the search results.
For those who are willing to patch the editor:
I wanted to see the function context in the Preview and References windows.
So a few years ago I patched tagwin.e and tagrefs.e, by inserting the code below inside the "#ifdef CHRISANT" blocks.
I'd like to see something like that get into the official version (see attached screenshot, with highlight showing what this patch adds).

TAGWIN.E (for Preview window)
Code: [Select]
// Set the filename and line number caption for the
// symbol window or references window, or whatever
// label is provided using 'label_id'.
// The the current object must be the tag window.
static void SetSymbolInfoCaption(int line_no)
{
   if (p_buf_id != EditWindowBufferID) {
      _str filename=p_buf_name;
      _str caption=ctlbufname._ShrinkFilename(filename,p_active_form.p_width-ctlbufname.p_x);
      if (line_no > 0) {
         caption = caption:+': 'line_no;
      } else if (p_RLine > 1) {
         caption = caption:+': 'p_RLine;
      }
#ifdef CHRISANT
      _str cur_tag_name, cur_type_name, cur_class, cur_class_only, cur_package;
      int cur_flags=0, cur_type_id=0;
      edit1._UpdateContext(true);
      int context_id = edit1.tag_get_current_context(cur_tag_name, cur_flags, cur_type_name, cur_type_id, cur_class, cur_class_only, cur_package);
      if (context_id > 0) {
         caption = caption:+"   @   ":+tag_tree_make_caption_fast(VS_TAGMATCH_context,context_id);
      }
#endif
      if (caption!=ctlbufname.p_caption) {
         ctlbufname.p_caption=caption;
      }
   }
   ctlbufname.p_width=ctlbufname._text_width(ctlbufname.p_caption);
}

TAGREFS.E (for References window)
Code: [Select]
// Set the filename and line number caption for the symbol window.
// The the current object must be the references window.
static void SetRefInfoCaption(struct VS_TAG_BROWSE_INFO cm)
{
   _str caption = ctlreferences.RefCountInfoCaption();
   caption = caption :+ " " :+
             ctlreflabel._ShrinkFilename(cm.file_name,
                                         p_active_form.p_width-ctlreflabel.p_x-
                                         ctlreflabel._text_width(caption)-
                                         ctlreflabel._text_width(' : 'cm.line_no)) :+
             ": " :+ cm.line_no;
#ifdef CHRISANT
   _str cur_tag_name, cur_type_name, cur_class, cur_class_only, cur_package;
   int cur_flags=0, cur_type_id=0;
   ctlrefedit._UpdateContext(true);
   int context_id = ctlrefedit.tag_get_current_context(cur_tag_name, cur_flags, cur_type_name, cur_type_id, cur_class, cur_class_only, cur_package);
   if (context_id > 0) {
      caption = caption:+"   @   ":+tag_tree_make_caption_fast(VS_TAGMATCH_context,context_id);
   }
#endif
   if (caption!=ctlreflabel.p_caption) {
      ctlreflabel.p_caption=caption;
   }
   //ctlreflabel.p_width=ctlreflabel._text_width(ctlreflabel.p_caption);
}

rowbearto

  • Senior Community Member
  • Posts: 2344
  • Hero Points: 132
Re: Search Results window enhancements
« Reply #7 on: May 02, 2014, 11:49:44 PM »
For my searches, I usually have "List all occurrences" checked, which is great so that all search results are listed in the bottom window.

But sometimes I have a really huge log file in the editor (current one is 1 GB).  If I don't forget to uncheck the "List all occurrences", then SE will freeze on me for a long time, and I have no way of aborting - I need to wait it out.

It would be a nice improvement if the user could abort this search.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 7041
  • Hero Points: 535
Re: Search Results window enhancements
« Reply #8 on: May 03, 2014, 09:20:02 PM »
For my searches, I usually have "List all occurrences" checked, which is great so that all search results are listed in the bottom window.

But sometimes I have a really huge log file in the editor (current one is 1 GB).  If I don't forget to uncheck the "List all occurrences", then SE will freeze on me for a long time, and I have no way of aborting - I need to wait it out.

It would be a nice improvement if the user could abort this search.

Hmm... There is an interesting performance issue with the _find_all() function. It doesn't check if it is searching through a huge file and always calls _SetAllOldLineNumbers(). While the _SetAllOldLineNumbers() feature is nice to have (it handles next/prev through the list where lines are deleted). It is NOT worth it if you have a huge file. Your entire file will end up being spilled to disk (ouch!) because it's modifying all line flags.

I added a test if the file size is too large for setting all old line numbers. I also added some code to assist in cancelling the search. It won't help you if the search string isn't found but that should be quick as long as you have an SSD.

(v18 only) Here's the code for a better _find_all() function for tbfind.e:

static int _find_all(_str search_text = '', _str search_options = '', boolean addBookmark = false, boolean listAll = false, SearchResults* results = null)
{
   if (search_text:=='') {
      return 0;
   }
   int num_bookmarks = 0;
   int num_matches = 0;
   int last_line = -1;

   if (listAll && p_buf_size<def_use_fundamental_mode_ksize) {
      _SetAllOldLineNumbers();
   }
   typeless p; save_pos(p);
   boolean search_mark = (pos('m', search_options, 1, 'I') != 0);
   if (search_mark) {
      _begin_select(); _begin_line();
   } else {
      top();
   }
   int status = search(search_text, 'xv,@'search_options'<+');
   if (!status) {
      // Check every .5 seconds
      typeless start_time=_time('b');
      while (!status) {
         if (addBookmark && (last_line != p_RLine)) {
            if (num_bookmarks > def_find_high_added_bookmarks) {
               int result = _message_box("Adding a large number bookmarks to this buffer.  Continue adding bookmarks?", "", MB_YESNOCANCEL|MB_ICONQUESTION);
               if (result == IDCANCEL) {
                  break;
               } else if (result == IDNO) {
                   addBookmark = false;
               }
            }
            if (addBookmark) {
               if (isEclipsePlugin()) {
                  set_bookmark("Bookmark: '"get_bookmark_name()"'");
               } else{
                  set_bookmark('-r 'get_bookmark_name(), true);
               }
               last_line = p_RLine;
               ++num_bookmarks;
            }
         }
         if (listAll && results != null) {
            results->insertCurrentMatch();
         }
         ++num_matches;
         typeless end_time=_time('b');
         if (end_time-start_time>500) { // More than .5 seconds
            start_time=end_time;
            if( _IsKeyPending(false)) {
               int orig_def_actapp=def_actapp;
               def_actapp=0;
               save_search(auto s1,auto s2,auto s3,auto s4,auto s5);
               flush_keyboard();
               int result1=_message_box('Would you like to cancel listing all occurences?','',MB_YESNOCANCEL);
               restore_search(s1,s2,s3,s4,s5);
               def_actapp=orig_def_actapp;
               if (result1!=IDNO) {
                  break;
               }
            }
         }
         _MaybeUnhideLine();
         status = repeat_search();
      }
   }
   restore_pos(p);
   return(num_matches);
}

rowbearto

  • Senior Community Member
  • Posts: 2344
  • Hero Points: 132
Re: Search Results window enhancements
« Reply #9 on: May 06, 2014, 12:27:06 AM »
Clark:

Thank you so much for looking into this!

For future SE version, if you could make the single file search a background task, then I could click on the first search result and start studying that part of the logfile while SE finds the rest of the locations in the background and prints the results as it finds them to the search results window.

I've needed to search through large files quite a bit debugging an important issue, this would have sped up my work.  Thanks for listening!

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 7041
  • Hero Points: 535
Re: Search Results window enhancements
« Reply #10 on: May 06, 2014, 12:29:36 AM »
We would like to thread a lot more features. There's a lot of work needed to make more code thread safe. Eventually we will have what we need.

rnelson

  • New Community Member
  • Posts: 1
  • Hero Points: 0
Re: Search Results window enhancements
« Reply #11 on: July 30, 2014, 04:07:13 PM »
  • The ability to lock tabs in tool windows so that they are not accidentally undocked or moved so easily. This seems to happen to me a lot with the Projects and Defs tabs.
  • When doing a search with the Search Results window set to <Auto Increment> and with multiple search tabs, the results are often displayed in a tab other that the one currently open. It would be nice if the tab with the search results would always open after a search.

jwiede

  • Senior Community Member
  • Posts: 120
  • Hero Points: 12
Re: Search Results window enhancements
« Reply #12 on: July 30, 2014, 09:14:05 PM »
Big +1 to both of rnelson's suggestions!

JimmieC

  • Senior Community Member
  • Posts: 506
  • Hero Points: 17
Re: Search Results window enhancements
« Reply #13 on: February 06, 2015, 08:56:42 PM »
Ability to search again from Search Results. It seems to me that half of programming is just search though derived classes and abstracted data types to get the origin. But, in SE, you can't just right click on something in the search results and say go search for that now. No, instead, you have to double click to open the file that you didn't need, then highlight(cursor into) the word there and search for that, repeat process until you find what you wanted with a bunch of files open that you didn't want open. Repeatedly search down the rabbit hole in SE is clunky.

Further, SE doesn't even let the user right click on a word in the search results and copy it to paste into the search dialog. If you highlight the word with the mouse, it can be copied with Ctl-C but I am sure this was by accident. Then this can be pasted into the Find dialog.

Of course, if the user opens the search results as Editor Window then these are available but the search dialog is using very valuable real estate.
« Last Edit: February 06, 2015, 08:58:19 PM by JimmieC »

Graeme

  • Senior Community Member
  • Posts: 2821
  • Hero Points: 347
Re: Search Results window enhancements
« Reply #14 on: February 07, 2015, 03:30:02 AM »
Ability to search again from Search Results. It seems to me that half of programming is just search though derived classes and abstracted data types to get the origin. But, in SE, you can't just right click on something in the search results and say go search for that now. No, instead, you have to double click to open the file that you didn't need, then highlight(cursor into) the word there and search for that, repeat process until you find what you wanted with a bunch of files open that you didn't want open. Repeatedly search down the rabbit hole in SE is clunky.

Further, SE doesn't even let the user right click on a word in the search results and copy it to paste into the search dialog. If you highlight the word with the mouse, it can be copied with Ctl-C but I am sure this was by accident. Then this can be pasted into the Find dialog.

Of course, if the user opens the search results as Editor Window then these are available but the search dialog is using very valuable real estate.

[updated to fix a problem with not selecting the correct search results tab when not doing auto increment]

You could try the following code.  Create a new macro file and load it using the load module command on the macro menu.  You can then add the commands to the right click menu in search results using the menu editor.  On the macro menu select Menus, then type in _grep_menu_default.  In the menu editor dialog, select the item that you want to add a command after, click the insert after button, type in a suitable caption e.g. search workspace or "search cur word", in the "Command" box type in the name of the macro e.g. search_workspace_cur_word_now.

search_workspace_cur_word_now runs the search without bringing up the gui.  It doesn't re-use the search options that you last used (e.g. whole word only)  - that requires support from the slick core code.  It searches with case insensitive and not whole word only - but you can change.  It puts the results in the same search results window as you searched from.  If you'd rather have auto increment, uncommment the commented line that calls auto inc and comment the first one - or create a second macro.

search_cur_word brings up the search dialog with whatever options you last had  - unless you've configured it to initialize with default options.
You can highlight some text to search for or it will search for the word where you right click.
I've tested in slick V19 but it should work in slick V2011 as well.


Code: [Select]
#include "slick.sh"

#pragma option(strictsemicolons,on)
#pragma option(strict,on)
#pragma option(autodecl,off)
#pragma option(strictparens,on)

static _str get_search_cur_word()
{
   int start_col = 0;
   word := "";
   if (select_active2()) {
      if (!_begin_select_compare()&&!_end_select_compare()) {
         /* get text out of selection */
         last_col := 0;
         buf_id   := 0;
         _get_selinfo(start_col,last_col,buf_id);
         if (_select_type('','I')) ++last_col;
         if (_select_type()=='LINE') {
            get_line(auto line);
            word=line;
            start_col=0;
         } else {
            word=_expand_tabsc(start_col,last_col-start_col);
         }
         _deselect();
      }else{
         deselect();
         word=cur_word(start_col,'',1);
      }
   }else{
      word=cur_word(start_col,'',1);
   }
   return word;
}


_command int search_workspace_cur_word_now() name_info(','VSARG2_READ_ONLY|VSARG2_REQUIRES_EDITORCTL|VSARG2_MARK)
{
   _str sw = get_search_cur_word();
   if (sw != '') {
      _str ss = _get_active_grep_view();
      _str grep_id = '0';
      if (ss != '') {
         parse ss with "_search" grep_id;
      }
      return _mffind2(sw,'I','<Workspace>','*.*','','32',grep_id);
      //return _mffind2(sw,'I','<Workspace>','*.*','','32',auto_increment_grep_buffer());
   }
   return 0;
}



_command int search_cur_word() name_info(','VSARG2_READ_ONLY|VSARG2_REQUIRES_EDITORCTL|VSARG2_MARK)
{
   _str sw = get_search_cur_word();
   if (sw == '')
      return 0;

   int formid;
   if (isEclipsePlugin()) {
      show('-xy _tbfind_form');
      formid = _find_object('_tbfind_form._findstring');
      if (formid) {
         formid._set_focus();
      }
   } else {
      formid = activate_tool_window('_tbfind_form', true, '_findstring');
   }

   if (!formid) {
      return 0;
   }
   _control _findstring;
   formid._findstring.p_text = sw;
   formid._findstring._set_sel(1,length(sw)+1);
   return 1;
}


« Last Edit: February 08, 2015, 12:38:46 AM by Graeme »