SlickEdit Community
SlickEdit Product Discussion => SlickEditĀ® => Slick-CĀ® Macro Programming => Topic started 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
-
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.
_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);
}
-
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.
#include "slick.sh"
#pragma option(strictsemicolons,on)
#pragma option(strict,on)
#pragma option(autodecl,off)
#pragma option(strictparens,on)
-
Thanks, it works!
-
At some point (perhaps in V19) you might need to call activate_tool_window instead of activate_toolbar
#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);
}
-
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.
-
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?
-
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.
-
Oh. I think I got it. I needed definition of _control ctl_lookin to make it work.
So eventually it looks like this:
_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>';
}