[texworks] Script: Questions about the API
Stefan Löffler
st.loeffler at gmail.com
Tue Apr 13 08:06:04 CEST 2010
Hi Paul,
just a quick reply.
Am 2010-03-18 02:27, schrieb Paul A Norman:
> 1. is there any way I can call something like
> TW.app.showMessage('some text'); (like window.alert() in browsers) ?
>
Since r592, there is TW.information (see
http://code.google.com/p/texworks/issues/detail?id=221)
> 2. And do we have any mechanism for QTScript object / variable
> persistence between calls in same editor session?
>
No, not at the moment. Right now, scripts only live for the time they
are executed.
> 3. Can QTScript save text to a file on disk?
> (looks like an indirect flow could be
> app.fileNew(); target.inserText();
> target.saveAs(); target.close(); )
>
> Helps JSON type persistence between sessions.
>
Your indirect flow works (I used something like that for my "inline
bibliography" script -
http://code.google.com/p/texworks/issues/detail?id=261). There is no
direct way, though, and I'm not sure there will be one in the near
future. If you can write arbitrary data to arbitrary positions on the
disk, this can be pretty serious security vulnerability.
> 4. Can I request input form the user in, and returned to, QTScript -
> a) like an input dialogue box? (window.input() in browsers)
> b) ok - cancel, button box? (window.confirm() in browsers)
>
Since r592, there are several methods to do a confirmation dialog and to
query strings and numbers (see
http://code.google.com/p/texworks/issues/detail?id=221).
> 5. Can a file dialog box be used and the result returned as a
> string to script?
>
Isn't this possible with TW.app.getOpenFileName() /
TW.app.getOpenFileNames()?
> 6. a) Can I obtain the directory of the executable?
> b) Can I obtain the scripts directory?
>
No. The directory of the executable may be the current directory, though
even that is not guaranteed on all platforms. What do you need this for?
> Jonathan, did you mention a while ago that QT could display an html
> browser window?
>
> If so can QTScript call this and communicate with it through the
> browser's object's DOM?
>
> Then we could design user interaction windows and use them from script.
>
AFAIK, Qt can in principal display HTML (e.g. inside a label, text edit,
etc.). This is currently not exposed to the scripts. However, I don't
think it would be of much use as there is no easy way to communicate
with the html objects. So you could design a nice interface, but you
wouldn't get any of the user's input. But I'll have to look into this a
little more, maybe there is a way.
> do we have any access to the clipboard in QTScript?
>
No, sorry. Are you interested in copy & paste (text?), or in
manipulating the available content of the clipboard?
HTH
Stefan
More information about the texworks
mailing list