[texworks] About the native PDF viewer (feature request and a question)
st.loeffler at gmail.com
Thu May 5 21:31:33 CEST 2011
On 2011-05-05 02:11, Paul A Norman wrote:
> On 5 May 2011 04:55, Stefan Löffler <st.loeffler at gmail.com> wrote:
>> On 2011-05-02 16:01, Edoardo Vacchi wrote:
>>>> Can we make TeXworks monitor a port we could safely address in a
>>>> running copy of TeXworks - would be ideal and have a certain list of
>>>> accepted registered commands like open this .tex document (if not
>>>> already open) at this line number, and bring the appropriate editor
>>>> window into focus? Perhaps also a 'port' command in the acceptable
>>>> list that says insert this text at cursor position/line number?
>>> many applications (such as texniccenter or texmaker) accomplish this
>>> by allowing only one instance and looking at command line switches
>> This actually applies to TeXworks as well. It is a single-instance, and
>> it supports the --position=... switch (or the short form -p ...), which
>> currently can be used to jump to a specific line (for .tex files) or
>> page (for .pdf files).
> That got me hunting - sounded really useful :)
> I couldn't find it in the manual - searched over the files - did I
> miss it or is it yet to go in the manual?
I can't remember off-hand, but chances are high that it isn't in the
manual yet. Actually I don't really know where best to put it. Any
> At -
> -- Found this reference in the source code - are these all of the
> command line switches?
> .SH OPTIONS
Yes, all these (3) are command line options. The file you found
(man/texworks.1) is actually a man-page that is used on *nix (and Mac, I
think) as a brief documentation on the command line. The actual place in
the code where this is handed is in src/main.cpp (lines 52-95).
> Form the cmd shell on Xp only one set of these worked ...
Yes, only "position" works. This is a known problem
(http://code.google.com/p/texworks/issues/detail?id=475), but the
workaround I noted down there doesn't seem to work. In fact, after some
searching the internet, there doesn't seem to be any (simple)
possibility by design. Anyway, "version" and "help" are not crucial and
provided primarily for GNU compliance on Linux.
> .B --help, -?
> Display a short overview over all command line options"
> texworks --help
> texworks -h
> Nothing happens at all TeXworks does not appear as a running process
> as far as I can tell, however if Tw is open already, but not in focus,
> it is brought to the front of the desktop.
See above. The effect is the same as when trying to launch TeXworks
> .B --position=, -p
> Open the next specified file at the given position (line or page)
> texworks -p=1000 "/some/path/myTex.tex"
> texworks -p=10 "/some/path/myTex.pdf"
> Very nice.
> The switch MUST appear BEFORE the file name.
Precisely. It modifies the behavior for the next filename it finds only.
I.e., if you want to open to files at line 100 each, you'd need to say
"texworks -p=100 a.tex -p=100 b.tex".
> texworks -p=10 "/some/path/myTex.pdf"
> The source is not opened with it (just a note not a complaint)
This is always the case when opening pdf files.
> I have object modules (PhpJs ($P), twConst, msgBox, twPan ($tw) as in
> FileTracker.js ) loaded when Tw starts and there is no problem with
> them at all.
> // Script-Type: hook
> // Hook: TeXworksLaunched
> All is fine there.
> But I have a hookscript that works on ...
> // Hook: LoadFile
> That gets interfered with. That script monitors and records all files
> opened by TeXworks to give me an exhaustive list of unique filenames
> for when I need to look back beyond the Recent Files list.
> The .tex opens, and then it does not jump to line 1000 until I clear
> my hookscript error message in the Debugger. Once the debugger is
> cleared, the editor jumps correctly to line 1000 as indicated above.
> The error is that my script wants to open its monitoring file, but it
> can't find it - when I am using -p=someIntegerLineNumber while opening
> a .tex file
On 2011-05-05 03:46, Paul A Norman wrote:
> P.S. if a copy of TeXworks is already open even just on a new blank
> file, my previously reported probl;em with the hook script does not
> happen, it seems to only happen when Tw is being started from the
> command line from scratch.
I think I can explain this. When starting Tw, the sequence of events is
1) Parse command line
2) Load each file given on the command line (I omit the case when none
For each file:
2a) Load the file contents from disk
2b) Run LoadFile hook
2c) deal with presentation on screen (including moving the cursor around)
After all files are processed
3) Once the rest of the application is fully initialized, run the
Consequently, when you set up your frameworks/functions/etc. in
TeXworksLaunched, it will not be available in the first LoadFile
executions. If there is an error in LoadFile, the presentation stuff is
not dealt with, so the cursor only moves after that error is dismissed.
As a workaround for your case, you could set a global in
TeXworksLaunched once all your code is initialized. In LoadFile, you can
then check for that flag, and if it is not present defer logging to a
More information about the texworks