[texworks] About the native PDF viewer (feature request and a question)

Paul A Norman paul.a.norman at gmail.com
Thu May 5 03:46:45 CEST 2011


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.

Also, as hinted at in the source code, it looks possible to gang-up
the files to be opened, each with a preceding line/page number switch
e.g.

>texworks  -p=1500 "/SomePath/MyFile01.tex"
-p=2500 "/SomePath/MyFile02.tex"
-p=25   "/SomePath/MyFile03.pdf"

Paul

On 5 May 2011 12:11, Paul A Norman <paul.a.norman at gmail.com> wrote:
> On 5 May 2011 04:55, Stefan Löffler <st.loeffler at gmail.com> wrote:
>> Hi,
>>
>> 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?
>
> At -
>  http://www.google.com/codesearch/p?hl=en#TCAOwTxChU8/trunk/man/texworks.1&q=position%3D%20package:http://texworks%5C.googlecode%5C.com&sa=N&cd=2&ct=rc
>
> -- Found this reference in the source code - are these all of the
> command line switches?
>
> .SH OPTIONS
>
> Form the cmd shell on Xp only one set of these worked ...
>
> ".TP
> .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.
>
> No message on the command line.
>
> .TP
> .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.
>
> ".TP
> .B --version, -v
> Display version information"
>
> texworks --version
> texworks -v
>
> Nothing happens at all, however if Tw is open already, but not in
> focus, it is brought to the front of the desktop.
>
> No message on the command line.
>
> With
>
> texworks -p=10 "/some/path/myTex.pdf"
>
> The source is not opened with it (just a note not a complaint)
>
> And with
>
> texworks -p=1000 "/some/path/myTex.tex"
>
> 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
>
> As might be expected, this does not happen when opening a .pdf to a
> page number -p=12
>
> My script ( FileTracker.js)  fails when something like this is used on
> the command line:
>
> texworks -p=1000 "/some/path/myTex.tex"
>
>  FileTracker.js is below - as I say it always manages to find its
> record file (in same directory as script itself) undedr normal
> circumstances (i.e. when not using -p=someLineNumber switch).
>
> Any advice appreciated please.
>
> Paul
>
>> HTH
>> Stefan
>>
>
> Sample of filelist.txt
> ===============
>
> D:/LaTeXPortable/LatexUtils/TeXworks/TeXworks/config/scripts/Graphics/GraphicInsertColWidth.js
> D:/LaTeXPortable/LatexUtils/TeXworks/TeXworks/config/scripts/text/autocomplete.js
> D:/LaTeXPortable/LatexUtils/TeXworks/TeXworks/config/scripts/FileTracker/fileList.txt
> D:/LaTeXPortable/LatexUtils/TeXworks/TeXworks/config/syntax/javascript.php
> D:/LaTeXPortable/LatexUtils/TeXworks/TeXworks/config/scripts/Scripting
> - Experiments/tw_OBJECT.js
> C:/Hold/MyFile.txt
> D:/LaTeXPortable/LatexUtils/TeXworks/TeXworks/config/configuration/texworks-config.txt
>
> FileTracker.js
> ==========
>
> // TeXworksScript
> // Title:  File Tracker
> // Description: Keeps track of first opening of a file
> // Author:  Paul Norman
> // Version: 0.3
> // Script-Type: hook
> // Hook: LoadFile
>
>
>  eval(TW.app.getGlobal("helper_twPan")); //  Comment if NOT Needed -
> This includes PhpJs ($P), twConst, msgBox, twPan ($tw)
>
>    function writeFileList(thisPath)
>          {
>           twPan.file_put_contents("fileList.txt"
>           , fileList
>           + thisPath
>           + PhpJs.chr(13) + PhpJs.chr(10)
>           );
>          }
>
>
>  var  currentFile  = TW.target.fileName;
>
>
>  var  fileList = twPan.file_get_contents("fileList.txt");
>
>
>   if (fileList == undefined)// first usage
>     {
>       fileList = "";
>       writeFileList(currentFile);
>            }
>      else
>      {
>        if (fileList.indexOf(currentFile) == -1)
>         {
>          writeFileList(currentFile);
>         }
>
>      }
>
>   null
>



More information about the texworks mailing list