SlickEdit Product Discussion > SlickEdit User Macros
Trivial Question
lwb-ztexas:
I have used SE for years and written lots of macros. However, I have not used SE for the last 3 years and you forget things...
I want a macro, tied to a key that grabs the word under the cursor and pulls up the Find Files dialog and pastes it in the search field.
I have code that almost works, but I can't get the field selected in the dialog to paste. I'm certain this is a 30 second answer for one of you guys...
Here is my current code:
#include "slick.sh"
#pragma option( strict, on )
_command void SearchWorkspaceForWord() name_info(','VSARG2_EDITORCTL|VSARG2_READ_ONLY)
{
typeless old_pos, old_mark;
save_pos( old_pos );
save_selection( old_mark );
_str ch = get_text( -1 );
if ( _isSpaceChar( ch ) )
left();
select_whole_word();
copy_to_clipboard();
find_in_files();
select_whole_word();
====> I think I'm missing something here
paste();
}
Thanks!
patrick:
For that one, there's a lot of code doing things with the search string combo box, and you can't pass the search string in through the form parameters, so I'd probably take a different approach to avoid possibly fighting it. There's a var called old-search-string that find-in-files will put in the search string box as long as the options still have the default setting of using the search history. So you could sneak in your current word like this:
--- Code: ---#include "slick.sh"
#import "stdcmds.e"
#pragma option( strict, on )
_command void SearchWorkspaceForWord() name_info(','VSARG2_EDITORCTL|VSARG2_READ_ONLY)
{
typeless old_pos, old_mark;
save_pos( old_pos );
save_selection( old_mark );
_str ch = get_text( -1 );
if ( _isSpaceChar( ch ) )
left();
word := cur_word(auto col);
saved_search := old_search_string;
old_search_string = word;
find_in_files();
old_search_string = saved_search;
}
--- End code ---
lwb-ztexas:
Genius! Thanks!
lwb-ztexas:
Hmmm...
This won't compile...
old_search_string = word;
Is it possible this is a function call? (makes sense to not use a global...)
Or, is there a list of all the globals used by the internals of the editor?
Thanks
patrick:
That should be defined in the slick.sh you're including. What version are you on, and what's the error it's giving you?
Navigation
[0] Message Index
[#] Next page
Go to full version