BACKGROUND:
FARR: v2.10.01 by DonationCoder
SCRIPT: fscript.js plugin script using the javascript plugin facility
RUN PROFILE: calling farr.exe with the argument -show -search ":myplugin";
SCENARIO:
I run farr using the prefix defined by my plugin as a commandline argument. All my plugin does is generate a list of suggestions
using FARR.emitResult. Then the user gets to pick one of the suggestions from the list. Once the user has chosen, the plugin
simply pastes what the user chose using the FARR "paste" command. This is done in the onProcessTrigger function of the jscript
file.
FARR.setStrValue("launch", "paste "+path);
return CLOSE;
This works fine when the user types something that is already inside the suggestion list. If the user types something that is not
yet in the list, however, the script has to handle the input using onRegexSearchMatch function.
PROBLEM:
I am having trouble figuring out how to treat user input the same way inside the onRegexSearchMatch function. All I want to do
is take what the user typed and then paste it with the paste command. I have gotten this to work halfway, but FARR refuses to
dismiss when the user presses ENTER. It just sits there. Also, when FARR is started up again the next time, the input box is frozen
and wont accept keystrokes. The only way I have figured out how to dismiss FARR is to use FARR.debug(), which seems to make
FARR go away.
function onRegexSearchMatch(querykey,querynokeyword) {
var curr_match = null;
curr_match = querynokeyword.match(scriptregex);
if(curr_match[curr_match.length-1].toString() != ''){
var stemp = '';
stemp = curr_match[curr_match.length-1].toString().strip();
// The paste works, but i dont want to have to use FARR.debug just to get the FARR window to close
// Also, when FARR is started up again the next time, the input box is frozen and wont accept
// keystrokes.
FARR.setStrValue("launch", "paste "+stemp+"\n");
FARR.debug('');
}
}
QUESTION:
What is the correct way to handle the scenario described here?
This is a step by step description of what I am trying to do.
1) Startup FARR so the prefix for my plugin is automatically filled into the search bar (doing that now with a script that calls FARR with command line args)
2) Allow the user to type in a string to be handled by my plugin
3) Generate a list of "suggestions" to the user, automatically generated by the plugin script
3) a) if the user input matches one of the auto-generated suggestions, take that input and just use FARR paste to get it into the last running app
3) b) if the user input does not match any of the auto-generated suggestions, match that input anyway and paste it into the last running app
4) keep track of whatever input the user supplied in either 3a) or 3b) and save it to a special history file
5) dismiss FARR window and make it wait in the background as usual
I can get all of the above steps to work as expected *except* for step 3) b) and step 5). When those two things happen together I cannot get FARR to exit normally nor startup and accept user input normally.
If you can help out, please do. Thanks.