TeXworks / texworks

Main codebase for TeXworks, a simple interface for working with TeX documents
https://tug.org/texworks/
GNU General Public License v2.0
692 stars 127 forks source link

[enhancement] Implement a command line parser #113

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Suggested options that should be recognized:
{{{
--help
  displays a help text including command line options, maintainer, website,
etc.
--inipath path/to/ini (see issue 95)
--libpath path/to/lib (see issue 95)
--debug [level]
  enables output of debugging information
--use-editor <prog> (see issue 36)
}}}

Original issue reported on code.google.com by st.loeffler on 5 Mar 2009 at 3:07

GoogleCodeExporter commented 9 years ago

Original comment by st.loeffler on 22 Aug 2009 at 3:56

GoogleCodeExporter commented 9 years ago
Additional options:
--line (see issue 195)
--use-viewer <prog>
  use another pdf viewer. Probably needs program-dependent code, so should be
implemented as plugins/scripts

Original comment by st.loeffler on 24 Sep 2009 at 11:44

GoogleCodeExporter commented 9 years ago
The attached patch implements a simple command line parser. Supported options:
 * --help, -? (displays available options)
 * --version, -v (displays version information)
 * --position, -p (opens file at given line (.tex) or page (.pdf))

inipath and libpath are more difficult as they are used during TWApp::init(), 
but the
command line parser uses QCoreApplication::arguments which is not available 
before
TWApp is initialized.

Original comment by st.loeffler on 22 Apr 2010 at 6:56

Attachments:

GoogleCodeExporter commented 9 years ago
The attached (new) version should handle already opened windows correctly 
(i.e., it
passes the files to open to the existing instance of TW).

Notes:
* I had to move the creation of the TWApp instance to the beginning of main(). 
This
is necessary because the commandline parser requires an active QCoreApplication
object. If, for some reason, it should be a problem that the TWApp object is 
created
before the windows code for handling multiple instances of Tw is run, we'd have 
to
separate the TWApp::init() call from the TWApp constructor.
* I modified the windows code to pass data as utf8 instead of local8bit between
instances of Tw. This should not change the general behavior, though.

Original comment by st.loeffler on 10 May 2010 at 2:38

Attachments:

GoogleCodeExporter commented 9 years ago
I've checked this in, though we may want to think further about options - e.g. 
it might be nice to allow the 
command line to specify PDF viewing mode (zoom level, etc) in addition to just 
choosing a page.

Also note that this does not really work well on OS X, as we don't have "single 
instance" code there - but users 
don't normally start GUI applications with command lines, so it isn't a major 
issue. It would be more interesting 
to see how TW could be integrated with AppleScript and Automator workflows....

Original comment by jfkth...@gmail.com on 16 May 2010 at 1:32

GoogleCodeExporter commented 9 years ago
Thanks. Yes, we can add whatever options we want ;).

Re. Mac OS X: How are files passed to the app, then? And what happens if a user 
has
an open Tw and opens another tex file (through a file manager)? Would issue 195 
work
on Mac?

Original comment by st.loeffler on 17 May 2010 at 5:52