SlickEdit Community

SlickEdit Product Discussion => SlickEditĀ® => Slick-CĀ® Macro Programming => Topic started by: noam on September 28, 2014, 10:41:45 am

Title: Create macro that focuses on "Find symbol" and modifies the "look in" option
Post by: noam on September 28, 2014, 10:41:45 am
Hi,
I would like to create a macro that puts the focus on the "Find symbol" window and changes the "look in" option to "<Current File>".
Could someone help please?
Thanks in advance,
Noam
Title: Re: Create macro that focuses on "Find symbol" and modifies the "look in" option
Post by: Graeme on September 28, 2014, 10:59:36 am
I did a similar thing here
http://community.slickedit.com/index.php/topic,3403.0.html (http://community.slickedit.com/index.php/topic,3403.0.html)

If you want the "search for" box to be empty you need to uncomment the two commented lines.

Code: [Select]
_command void find_symbol_word_at_cursor() name_info(','VSARG2_REQUIRES_EDITORCTL|VSARG2_CMDLINE)
{
   int xx;
   _control ctl_search_for;
   _str s = cur_word(xx);
   int wid = activate_toolbar('_tbfind_symbol_form', 'ctl_search_for', true);
   wid.ctl_search_for.p_text = s;
   wid.ctl_search_for._set_sel(1,length(s)+1);
}
 
 
_command void find_symbol_in_current_file() name_info(','VSARG2_REQUIRES_EDITORCTL|VSARG2_CMDLINE)
{
   int xx;
   _control ctl_search_for;
   _control ctl_lookin;
   int wid = activate_toolbar('_tbfind_symbol_form', 'ctl_search_for', true);
   wid.ctl_lookin.p_text = '<Current File>';
   //wid.ctl_search_for.p_text = '';
   //wid.ctl_search_for._set_sel(1,1);
}
Title: Re: Create macro that focuses on "Find symbol" and modifies the "look in" option
Post by: Graeme on September 28, 2014, 11:22:39 am
oops, forgot to say how to load it.  Put the stuff below into a file e..g mymacros.e, plus the code I already posted, then load it using the load module command on the macro menu.

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

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

Title: Re: Create macro that focuses on "Find symbol" and modifies the "look in" option
Post by: noam on September 28, 2014, 11:51:15 am
Thanks, it works!
Title: Re: Create macro that focuses on "Find symbol" and modifies the "look in" option
Post by: Graeme on October 18, 2014, 01:19:43 pm
At some point (perhaps in V19) you might need to call activate_tool_window instead of activate_toolbar

Code: [Select]
       

#include "slick.sh"

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


_command void find_symbol_word_at_cursor() name_info(','VSARG2_REQUIRES_EDITORCTL|VSARG2_CMDLINE)
{
   int xx;
   _control ctl_search_for;
   _str s = cur_word(xx);
   int wid = activate_tool_window('_tbfind_symbol_form', true, 'ctl_search_for');
   wid.ctl_search_for.p_text = s;
   wid.ctl_search_for._set_sel(1,length(s)+1);
}
 
 
_command void find_symbol_in_current_file() name_info(','VSARG2_REQUIRES_EDITORCTL|VSARG2_CMDLINE)
{
   int xx;
   _control ctl_search_for;
   _control ctl_lookin;
   int wid = activate_tool_window('_tbfind_symbol_form', true, 'ctl_search_for');
   wid.ctl_lookin.p_text = '<Current File>';
   //wid.ctl_search_for.p_text = '';
   //wid.ctl_search_for._set_sel(1,1);
}
 
 
Title: Re: Create macro that focuses on "Find symbol" and modifies the "look in" option
Post by: asandler on November 12, 2014, 05:55:26 pm
I am trying this on v19.
It complains about line: wid.ctl_lookin.p_text = '<Current File>';
The error is: Control 'ctl-lookin' must be declared or cannot be a member of non-struct/union/class type.

Actually I think the way wid defined confuses me. It's an int, but then you attempt to access its members. It does work on v18.
Title: Re: Create macro that focuses on "Find symbol" and modifies the "look in" option
Post by: Graeme on November 13, 2014, 12:19:21 am
It works for me with no error.  Maybe the call to activate_tool_window is failing for you.  Try this

   int wid = activate_tool_window('_tbfind_symbol_form', true, 'ctl_search_for');
   if (wid)
      wid.ctl_lookin.p_text = '<Current File>';

Does activate_find_symbol bring up the find symbol window?
What platform are you on?  I'm testing with V19.0.0.14 - what version are you?
Title: Re: Create macro that focuses on "Find symbol" and modifies the "look in" option
Post by: asandler on November 13, 2014, 02:11:28 pm
Yes, activate-find-symbol works as expected. I am on v19.0.0.14. Adding if statement doesn't help - kind of makes sense because it fails to compile. I checked wid value - 204, not 0. It seems to have problem accessing ctl_lookin sub-field of wid.
Title: Re: Create macro that focuses on "Find symbol" and modifies the "look in" option
Post by: asandler on November 13, 2014, 02:13:33 pm
Oh. I think I got it. I needed definition of _control ctl_lookin to make it work.
So eventually it looks like this:
Code: [Select]
_command void find_symbol_in_current_file() name_info(','VSARG2_REQUIRES_EDITORCTL|VSARG2_CMDLINE)
{
   _control ctl_lookin;
   int wid = activate_tool_window('_tbfind_symbol_form', true, 'ctl_search_for');
   wid.ctl_lookin.p_text = '<Current File>';
}