[texworks] Scripting: import libraries, retrieving saving text. web location, Api

Paul A Norman paul.a.norman at gmail.com
Sat Nov 6 12:38:07 CET 2010

Ok, as discussed earlier (August), here is a little bit of progress on
sharing notes, experiences, and information on Tw Scripting.

This is just a start - but even some of the Tw Api structure is in
place ready for filling out.

The table of contents gives an idea of where I am aiming (book marks
in the .pdf, or left hand TOC links in the .chm)

This is very much from our experiences with QtScript, so there is not
much that is Python or Lua specific.

Links to the .chm and .pdf  are at the top left hand column of this
page here: http://twscript.paulanorman.com/

Any early feedback would be appreciated thanks.


On 2 August 2010 03:08, Stefan Löffler <st.loeffler at gmail.com> wrote:
> Am 2010-07-27 02:53, schrieb Paul A Norman:
>> 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:
>>>>   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?
> Writing libraries for common code is definitely reasonable. I'm not too
> big a fan of another wrapper layer, though (the Tw.* objects are really
> just a wrapper for the C++ code). I don't think that this would make
> things easier.
> BTW: In my opinion, there shouldn't be any major API changes, as we're
> heading towards a stable release. Minor things, maybe (like the read
> function), but nothing major.
>> Or seperate function scripts as library memebrs? What do you think?
> As long as your archive doesn't get too large, I'd keep it in one file.
> Or separate it on a functionality level, at most (e.g., bundle all
> file-related functions in one file, all GUI-related functions in
> another). But having a hundred files to maintain is no easy task ;).
>>>>  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
>> Preferences/Script tag?
>> Allow scripting to test the values on that Scrits Preferences Tab and
>> so ask the user to change them if necessary?
> Yeah, such a flag should definitely come. Ideally, it should come on a
> per-script basis, though, in addition to the global ones. I'm not sure
> if this will come until the release, though.
>>>>  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? -
> Unfortunately, I have no notes yet. Some ideas, yes, but no notes. I'm
> currently working on updating Alain's manual. After that, I'll look into
> a scripting manual. But ask whatever you want to know (I'll try to find
> an answer ;)).
>>  - 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
> Sure (though whether I'm knowledgeable, I don't know ;))
>> 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?
> Of course you can do that. However, I don't think there are many Tw
> script authors out there, yet, and those who are would probably
> appreciate correct information ;). So it might be better to check things
> before publishing them.
>> And it might provide a framework for what you want to do later Stefan?
> Well, my intention is to whip up some stuff from the C++ POV. What is
> and isn't available, what can and can't be done, what should and
> shouldn't be done. Beyond that, I'll definitely ask you (or whoever has
> some experience with scripting and is willing to help) if you can
> contribute some stuff. Like common pitfalls, how to avoid them,
> important workarounds, etc.
> Stefan

More information about the texworks mailing list