topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Tuesday March 19, 2024, 4:54 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: New FARR plugin : FSubScript enable loading of multiple javascript plugins  (Read 51031 times)

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
by the way -- this fsubscript thing is SOOO clearly a huge step forward for FARR plugins.. i mean just look at the sample color script: it's 30 short simple lines long, and it's just a .js file and an icon, as simple as can be.  really really going to make plugin writing accessible to a whole new group of people  :up: :up: :up:

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
FSubScript deserves a web page of its own.

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
For your question in the plugin about the settings : One way to create options is to send a autohotkey executable, however you can do it the way you like. You need to send a message WM_USER+1 to the window name FScript/FSubScript. Autohotkey program can do this. However an IE with a registered custom protocol could do it to. UI in javascript is a bit tricky. I think I like the autohotkey solution the more.

Wow, thanks for responding to a question I put in the plugin's source!

At the moment, it seems enough to just use FARR's User Variable support for configuring Akete, but perhaps as time goes on I'll change my mind about this :)

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
I improved the now renamed FSubScript.

As an exercise in reviewing plugin functionality, understanding FSubScript a bit better, and becoming more comfortable w/ gvim, I filled in more of the skeleton functions in fscript.js:

a piece of FSubScript/fscript.js
function setStatusBar(txt) { FARR.setStrValue("statusbar", txt); }
function setSearch(txt) { FARR.setStrValue("setsearch", txt); }
function setSearchNoGo() { FARR.setStrValue("setsearchnogo", txt); }
function stopSearch() { FARR.setStrValue("stopsearch"); }
function hideWindow() { FARR.setStrValue("window.hide"); }
function showWindow() { FARR.setStrValue("window.show"); }
function toggleWindow() { FARR.setStrValue("window.toggle"); }
function setRichEditMode(txt) { FARR.setStrValue("window.richeditmode", txt); }
function setRichEditHeight(height) { FARR.setStrValue("window.richeditheight", height); }
function setRichEditWidth(width) { FARR.setStrValue("window.richeditwidth", width); }
function setShowAllMode() { FARR.setStrValue("setshowallmode"); }
function exit() { FARR.setStrValue("exit"); }
function reportError(txt) { FARR.setStrValue("reporterror", txt); }
function setCliboard() { FARR.setStrValue("clipboard"); }
function pasteClipboardToLastActiveWindow(txt) { FARR.setStrValue("PasteClipboardToLastActiveWindow", txt) }
function displayAlertMessage(txt) { FARR.setStrValue("DisplayAlertMessage", txt); }
function displayAlertMessageNoTimeout(txt) { FARR.setStrValue("DisplayAlertMessageNoTimeout", txt); }
function displayBalloonMessage(txt) { FARR.setStrValue("DisplayBalloonMessage", txt); }
function execWebbrowserEmbededJavascript(txt) { FARR.setStrValue("EmbeddedWb.ExecJavascript", txt); }

function paste(txt) { FARR.setStrValue("launch", "paste " + txt); }
function copyClip(txt) { FARR.setStrValue("launch", "copyclip " + txt); }
function restartSearch(txt) { FARR.setStrValue("launch", "restartsearch " + txt); }
function doSearch(txt) { FARR.setStrValue("launch", "dosearch " + txt); }
function doSearchOnTrigger(txt) { FARR.setStrValue("launch", "dosearchontrigger " + txt); }
// txt: text with \n as newlines
function showMemo(txt) { FARR.setStrValue("launch", "showmemo " + txt); }
function showFile(filename) { FARR.setStrValue("launch", "showfile " + filename); }
function showFileRTF(filename) { FARR.setStrValue("launch", "showfilertf " + filename); }
function showFileHTML(filename) { FARR.setStrValue("launch", "showfilehtml " + filename); }
function showHTML(txt) { FARR.setStrValue("launch", "showhtml " + txt); }
// txt: url
function htmlViewURL(txt) { FARR.setStrValue("launch", "htmlviewurl " + txt); }
// txt: searchedit, mainpanel
function setFocus(txt) { FARR.setStrValue("launch", "setfocus " + txt); }
// txt: list, memo, html, user, spreadsheet
function setViewMode(txt) { FARR.setStrValue("launch", "setviewmode " + txt); }
function pcommand(txt) { FARR.setStrValue("launch", "pcommand " + txt); }
function setSize(minwidth, minheight, maxwidth, maxheight) {
  FARR.setStrValue("launch", "setsize " +
                   minwidth + ", " + minheight + ", " +
                   maxwidth + ", " + maxheight);
}
// XXX: bool: 0 or 1?
function setHTMLSafe(bool) { FARR.setStrValue("launch", "sethtmlsafe " + bool); }
function showPleaseWait(txt) { FARR.setStrValue("launch", "showpleasewait " + txt); }
function hidePleaseWait() { FARR.setStrValue("launch", "hidepleasewait"); }
//function alert(txt) { FARR.setStrValue("launch", "alert " + txt); }
function sleep(ms) { FARR.setStrValue("launch", "sleep " + ms); }


Don't know if they work, but perhaps it will save ecaradec some drudgery  ;)

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
There might be bugs. There are centainly bugs.

onSearchBegin() in FSubScript/fscript.js
Perhaps the following line:

  plugins.search(querykey, isExplicit, queryraw, modifier, triggermethod);

should be something like:

  plugins.search(querykey, isExplicit, queryraw, querynokeyword, modifier, triggermethod);



mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
ewe, it's fantastic seeing such progress  :up: :up:

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 410
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
ewemoa I've replaced my skeleton functions with those you did. Thanks.
The querynokeyword would probably a bit different from the farr one. I'll have to remove the whole "fssc +pluginAlias". If you do it I'll integrate it. Also the FARR querynokeyword seem broken : It always return the same thing as the queryraw.
Blog & Projects : Blog | Qatapult | SwiffOut | FScript

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
I've replaced my skeleton functions with those you did. Thanks.

Cool! I hope they work ;)

The querynokeyword would probably a bit different from the farr one. I'll have to remove the whole "fssc +pluginAlias". If you do it I'll integrate it.

In addition to what mouser mentioned earlier in this thread, he gave me some hints on the idea of being able to invoke FSubScript plugins w/o using "fssc +pluginAlias" syntax but rather "pluginAlias" syntax.  I am investigating this a bit and hope to report back with some results on this before too long.

Also the FARR querynokeyword seem broken : It always return the same thing as the queryraw.

I got the feeling querynokeyword seems broken too -- some of my querynokeyword-not-working experience is summarized at:

https://www.donation....msg136530#msg136530

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
It's a first attempt, but attached, please find an experiment with FSubScript's fscript.js and colors' fsubscript.js.

The idea here is to provide the plain plugin invocation syntax of "name" rather than "fssc +name".

I'm probably missing some important things, but may be the code is worth something ;)


P.S. I have limited screen space so I've reformatted -- hope that isn't a problem.

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
Attached is a further refinement after discussion with mouser.  Check it out...or not  ;)

Some changes include:

Fubscript/fscript.js:
  • Stops searching if there is an exact match for a plugin
  • Defined more postprocessing options
  • Renamed ADDSCORE to ADD_SCORE

colors/fsubscript.js:
  • An additional color -- grey
  • Regular expression handling of sorts
  • In plugins["colors"].search(), emitResult() is called w/ different args -- see source for details

Both:
  • other things I forgot
  • likely more unknown bugs :)

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 410
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
The stop search is a very good idea. I was painfully trying to have aliases without modifier. It just work now :) and its much better.

I think we should consider this version official. Thank you a lot!
Blog & Projects : Blog | Qatapult | SwiffOut | FScript

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 410
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
I'm not sure how stopsearch work. What would occured if previous plugins generates results (plugins and subplugins ). Wouldn't there be some random results depending on order of execution ?
Blog & Projects : Blog | Qatapult | SwiffOut | FScript

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
basically the first plugin that matches will prevent others from generating results.  but thats the way all plugins work.

alternatively if you think some plugins want to generate results and not stop others from making results, you could have a per-plugin option to say whether to stop or not.

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 410
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
I may be wrong but it seem that the plugin is now doing the filtering. Is there a way to keep FARR doing the filtering ? I would like to avoid burden plugins dev with the filtering except when they don't need it. That was the reason I used modifiers : they didn't affect the filtering.

Blog & Projects : Blog | Qatapult | SwiffOut | FScript

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
ecaradec is right -- the plugins should not do the filtering -- farr can do a smarter job (or else farr should be fired!)

i think it just requires an extra function for me to write that the plugins can call.

Let me explain:

There are two ways that a plugin normall gets called:
1) either because its keyword is typed by the user
2) or what user types matches a regular expression.

in case 1, usually what farr does is automatically filter the results returned by the user based on subsequent words on the search string after the first keyword that matched plugin name.

in case 2, usually you do not want subsequent filtering, since presumably you are catching other text on the line besides just the one keyword at the front.

---

now i think the problem with fsubscript is that the parent fsubscript script basically has to match on the raw string (or by matching .* regex) -- so farr doesnt know how to do subsequent filtering.

so i think what i need to add is a pluginp->set_strvalue("filteron",rest of typed search to filter on)

and then fsubscript can call this function with search words after the first matching keyword.

does that make sense?

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 410
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
Yes, it make sense for me.
Shouldn't we continue calling all the plugins even if one is explicit ? Why stopping the search ?
Blog & Projects : Blog | Qatapult | SwiffOut | FScript

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
Attached is a "sketch" of further ideas -- I think mouser may be the only one with a FARR that can execute the code appropriately (I know I don't have one yet).

Some changes include:

Fubscript/fscript.js:
  • onSearchBegin() requests FARR to 'filteron' based on regular expression matching results -- when regex supplied by plugin

colors/fsubscript.js:
  • Doesn't filter any more

Both:
  • other things I forgot
  • likely more unknown bugs :)

Regarding why search stops -- I don't have a clear memory of the reasons.  I think it might have had something to do with FARR's current behavior for non-FScript plugins, but it's probably best for mouser to answer this question :)
« Last Edit: November 20, 2008, 04:08 AM by ewemoa »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
cool, trying now.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
been tweaking a tiny bit and talking to ewemoa about how some things work and he is making great progress extending fsubscript to let each plugin script be triggered normally like all other plugins.  I'd say in very short time fsubscript scripts will be 100% as powerful and flexible as normal fscript plugins.  This is truly a great thing  :-* :-* :Thmbsup: :Thmbsup: :Thmbsup: :-* :-*

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 410
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
Good news I'm just waiting for the next farr that will add support for it.
Blog & Projects : Blog | Qatapult | SwiffOut | FScript

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
ecd,
take a well deserved rest until ewe has finished a round of work on your masterpiece  :up:
-mouser

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
I think that we are going to see the ability to use dqsd searches in FARR come pretty soon based on the work on fsubscript.

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
I hope ecaradec has gotten his hands on a version of FARR that can do ForceResultFilter :)

Attached, please find the latest attempt.

Some changes include:

Fubscript/fscript.js:
  • onSearchBegin() - let me sum up, no, there is too much...Use the source Luke!
  • wrapper function forceResultFilter()

colors/fsubscript.js:
  • More colors
  • Change value for grey
  • Change to arguments of emitResult() in search()

Both:
  • other things I forgot
  • likely more unknown bugs :)

Revision control, anyone?

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
Attached, please find attempt after mouser's corrective suggestions  ;)

Some changes include:

Fubscript/fscript.js:
  • onSearchBegin() - hopefully fixed problems and made clearer
  • fixed and modified types: CLIP=6; ALIASFILE=7;
  • likely more unknown bugs :)

Recursively searching for fsubscript.js to some depth has not been implemented yet.

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
Attached, please find an attempt at recursively searching for fsubscript.js to a limited depth.

Some changes include:

Fubscript/fscript.js:
  • onInit() - local function processFolder(), local variable maxdepth
  • likely more unknown bugs :)

For testing purposes, I put the colors subdirectory inside a subdirectory of the FSubScript directory.