Jean-Marc,
I've re-written the 1.3.x script that performs the conversion of latex
file to a heap of bitmap images in python so that Win32 users have a
chance to use this stuff too.
Everything works fine, but I find that I have to use a wrapper script,
lyxpreview2bitmap.sh, simply to call the python script doing all the
work.
lyxpreview2bitmap.sh is simply:
#! /bin/sh
python `dirname $0`/lyxpreview2ppm.py $@
I've had to do that because I find that I hard-wired the code inside
LyX as:
// The conversion command.
ostringstream cs;
cs << pconverter_->command << ' ' << latexfile << ' '
<< int(font_scaling_factor_) << ' ' << pconverter_->to;
+ lyxerr << "cs is \"" << cs.str() << "\"\n" << std::endl;
string const command = "sh " + LibScriptSearch(STRCONV(cs.str()));
+ lyxerr << "command is \"" << command << "\"" << std::endl;
Adding the two print statements results in:
cs is "lyxpreview2bitmap.sh
/tmp/lyx_tmpdir4147MTsakg/lyx_tmpbuf0/0lyxpreview.tex 128 ppm"
command is "sh /home/angus/lyx/13x/lib/scripts/lyxpreview2bitmap.sh
/tmp/lyx_tmpdir4147MTsakg/lyx_tmpbuf0/0lyxpreview.tex 128 ppm"
I guess that I did that because, in LyX 1.3.x, LibScriptSearch
searches for the first space-delimited word in the string 'cs.str()'.
(We do things differently in 1.4.x, using a "%%s" placeholder which
allows us to define the converter properly in lyxrc.defaults.)
Thereafter, to ensure that execvp is happy to run the script, we must
either set its executable bit or pass it to the shell.
I chose the latter option. I guess that it'd be easy enough to check
what type of script it was, however, rather than just blindly prepend
a "sh ". I imagine a function similar to Herbert's
string const getExtFromContents(string const & filename);
which reads the first line of the script:
#! /bin/sh
#! /usr/bin/env python
returning either "sh" or "python" as appropriate. It would return
string() if the line did not start "#!".
Would you be happy with something like this in 1.3.5?
--
Angus