[texworks] Lua Extension - put into Sentance Case, Trim, Date Time, lowercase, uppercase
jfkthame at googlemail.com
Fri Sep 11 02:15:26 CEST 2009
On 10 Sep 2009, at 11:53, Stefan Löffler wrote:
> I have no experience with this kind of Qt scripting, but a preliminary
> search of the docs tells me "yes and no". If what Jonathan has in mind
> the same syntax and the same basic functions (e.g. for string
> calculations, etc.; technically speaking it implements the ECMA-262
> standard), but it doesn't have all the browser/internet related
Right, the obvious thing to do in texworks is to enable QtScript,
which (as I understand it) is an implementation of ECMAScript, which
specifically web-browser-related objects and functions.
I've been pleasantly surprised at how well it seems to work in
general, though: for example, prompted by Paul's Lua examples, I
googled for a JS Title Case function (as titlecasing is a non-trivial
operation, if you want to do it well); found something promising at <http://individed.com/code/to-title-case/
>, so I put that into a TW script, wondering if it would handle the
tricky regexes, etc.... worked perfectly.
> No window, document,
Qt objects such as the document and window are scriptable, actually,
though we may want to add setters for more properties: for example,
AFAICT a script can read the window geometry (position, size) but
cannot change it to arbitrary values, only call specific functions
such as showMaximized (which works fine from script, I just tried).
But we can trivially add things like move() and size() to allow a
script more control (so you could write a custom window-arranging
script, for example, to configure them to your liking).
> location and also no XMLHttpRequest
> (which, IIRC, wasn't supported by many browsers for quite a while). So
> much for the bad news.
> The good news is that it could be relatively easy to work around this.
> Qt does support HTTP requests, and it has additional classes to handle
> XML. So one could fabricate something similar to XMLHttpRequest().
> However, I'm not sure if this can be done from within the script (I
> think it would have to be done on the C++ side and then made available
> to the script; but these are details).
Right, I don't think there's any ready-made networking support, but I
don't think it would be hard to add a scriptable object that can make
requests and receive responses.
>> It just seems mind blowing what could be achieved. Tap directly into
>> databases .., well do anything that the server that recives the
>> request can process.
> Just one word of caution at the end. This mechanism can be incredibly
> dangerous. If you execute scripts that you don't trust (and many
> seem to do this every day), you open the gates to viruses, hackers and
> who knows what else. So I'd discourage automatic internet requests
> within scripts, and in any case the user has to be informed and has to
> be able to choose whether or not a particular request should be made.
We'll need to label the package "Handle With Care". :)
More information about the texworks