[texworks] Scripting: import libraries, retrieving saving text. web location, Api
Paul A Norman
paul.a.norman at gmail.com
Tue Jul 27 02:53:43 CEST 2010
On 27 July 2010 05:25, Stefan Löffler <st.loeffler at gmail.com> wrote:
> Am 2010-07-26 07:51, schrieb Paul A Norman:
>> I would really appreciate getting some clarity on the whole scripting
>> area please. Here are just a few things...
>> 1. Did we finally agree to do a C++ Script function for file
>> getText() mechanism?
> That was my impression, yes. Still waiting for Jonathan to reply/comment
> and commit some old patches, though.
>> 2. I have been holding off doing my own mechanism for importing
>> QtScript function libraries thinking about these things
> Please note that there will most likely be a mechanism for this in the
> future (when we tackle library scripts, asynchronous scripts, etc.).
> This won't happen before the next release, though.
Been holding off waiting for clarity, but I am starting to write
cumbersome code and so ....
What I am planning to do is basically write a QtScript wrapper arround
the whole TwScript (Api) to future proof against any Api changes, and
to allow for future enhancements like library import being added...
I imagine that such a wrapper should port easily to Python etc...
Perhaps two or three mega objects?
1) One for the QtTwAPi,
2) and one for common core functionality,
3) one for common lessor 'helper' functions.
Or seperate function scripts as library memebrs? What do you think?
>> a) where they can be placed
> <resources>/scripts sounds like a good place, doesn't it? Maybe a
> subfolder, but that would probably show up in the menu. Note that Tw
> only puts menu items up for script that end with .js and that have
> proper headers. If you ensure your scripts don't comply with either of
> these rules, they shouldn't show up in the menu.
>> b) naming conventions (perhaps our initails or something as a
>> prefix on the file names? Mine would be e.g.: pan_someting.js )
> I'd suggest you'd also add something that marks it as a library. Either
> by using a different extension (e.g., .jsl), or by putting "lib"
> somewhere in the filename. E.g., lib-pan_something.js
>> c) I have found eval() is being used around the place in other
>> projects using EMCA script for library imports
> Sounds reasonable. Not necessarily secure, but reasonable ;).
>> d) Are there core libraries to be maintained by the Tw project?
> Not at the moment. All the stuff we did so far was on the C++ side of
> it. Maybe in the future, but ATM I doubt that.
Ok I am looking at trying to build in main core functionality in the
wrapper(s) I flag above.
>> 3. Where do we stand on some sort of saveText() ?
> I guess at a similar spot as with the read() function. Note that it will
> most likely have some limitations, like only being able to write in the
> <resources>/scripts folder.
What about security options for scope of saving on the TeXworks
Allow scripting to test the values on that Scrits Preferences Tab and
so ask the user to change them if necessary?
>> 4. http://twscript.paulanorman.com/ - I'm happy to - and will
>> host/ put a page up with such Tw Scripting information etc as I have,
>> but ...
> Cool :).
>> 5. If anyone has any further information on things realting to the
>> TwScript Api, could they please forward to me anything they have?
> As I stated some time ago, I intend to write a short documentation to
> scripting, similar to Alain's (general) manual. However, when I'll have
> time for that I don't know :(.
Would you like to send me any notes you may have, or do you mind me
asking specific questions on various scripted objects and functions? -
- I am planning to look through the source code now that C++ is
making a bit more sense to me, and having studied Qt's embedded
Scripting model, and see what I can glean from it all anyway, but I
would like to run the results of that survey past anyone knowledgible
Or may be I should just put it up on web, mark it all as tenataive,
and wait for the howls of protest, derrsion, confirmation and
correction :) :) :) - seriously though - might be easier that way?
And it might provide a framework for what you want to do later Stefan?
More information about the texworks