mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Introduce the possibility of setting a prefix for the TEXINPUTS environment
variable. This is done in the preferences, much like as the PATH prefix. A single '.' in the paths will get replaced with the current document dir and also non-absolute paths will be prefixed with that dir. The default semantics of TEXINPUTS apply, such that, for example, if a path is terminated with a double slash, all subdirectories will be also searched by both the TeX engine and ancillary programs such as dvi previewers or dvips. As an example, if the prefix is set to ".:figs", the TEXINPUTS variable will be set as ".:<docdir>:<docdir>/figs:$ORIGTEXINPUTS", where <docdir> is the document directory. The initial '.' is necessary to address the actual current dir (this will be the temp dir at preview time), while if TEXINPUTS was initially unset, such that $ORIGTEXINPUTS is empty, a colon (or semicolon on Windows) will end the path list. This is very important, because we don't want to replace the system directories but to complement them and, in order to do that, an empty element has to be present in the list. Indeed, according to the TEXINPUTS semantics, an empty element means the standard search path. This works whether TEXINPUTS is originally set or not, because if the original TEXINPUTS starts with a colon (meaning that the standard search path is wanted there) we will have an empty element at that point, otherwise the final colon will simply serve as a path separator. Of course, on Windows a ';' has to be used as a path separator. LyX will take care of transforming the platform path list into one understandable by the TeX engine. For example, this will be the case for a Cygwin version of LyX using a native Windows TeX engine or viceversa. I tested all of this and it works for me. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38681 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
161e60b7ea
commit
1717ef203c
@ -2083,7 +2083,7 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
|
|||||||
|
|
||||||
// Execute the command in the background
|
// Execute the command in the background
|
||||||
Systemcall call;
|
Systemcall call;
|
||||||
call.startscript(Systemcall::DontWait, command);
|
call.startscript(Systemcall::DontWait, command, filePath());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2261,7 +2261,8 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
|
|||||||
command2 += quoteName(psname);
|
command2 += quoteName(psname);
|
||||||
// First run dvips.
|
// First run dvips.
|
||||||
// If successful, then spool command
|
// If successful, then spool command
|
||||||
res = one.startscript(Systemcall::Wait, command);
|
res = one.startscript(Systemcall::Wait, command,
|
||||||
|
filePath());
|
||||||
|
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
// If there's no GUI, we have to wait on this command. Otherwise,
|
// If there's no GUI, we have to wait on this command. Otherwise,
|
||||||
@ -2269,7 +2270,8 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
|
|||||||
// file, before it can be printed!!
|
// file, before it can be printed!!
|
||||||
Systemcall::Starttype stype = use_gui ?
|
Systemcall::Starttype stype = use_gui ?
|
||||||
Systemcall::DontWait : Systemcall::Wait;
|
Systemcall::DontWait : Systemcall::Wait;
|
||||||
res = one.startscript(stype, command2);
|
res = one.startscript(stype, command2,
|
||||||
|
filePath());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// case 2: print directly to a printer
|
// case 2: print directly to a printer
|
||||||
@ -2278,7 +2280,8 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
|
|||||||
// as above....
|
// as above....
|
||||||
Systemcall::Starttype stype = use_gui ?
|
Systemcall::Starttype stype = use_gui ?
|
||||||
Systemcall::DontWait : Systemcall::Wait;
|
Systemcall::DontWait : Systemcall::Wait;
|
||||||
res = one.startscript(stype, command + quoteName(dviname));
|
res = one.startscript(stype, command +
|
||||||
|
quoteName(dviname), filePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -2301,7 +2304,7 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
|
|||||||
// as above....
|
// as above....
|
||||||
Systemcall::Starttype stype = use_gui ?
|
Systemcall::Starttype stype = use_gui ?
|
||||||
Systemcall::DontWait : Systemcall::Wait;
|
Systemcall::DontWait : Systemcall::Wait;
|
||||||
res = one.startscript(stype, command);
|
res = one.startscript(stype, command, filePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
|
@ -307,7 +307,7 @@ bool Converters::convert(Buffer const * buffer,
|
|||||||
LYXERR(Debug::FILES, "No converter defined! "
|
LYXERR(Debug::FILES, "No converter defined! "
|
||||||
"I use convertDefault.py:\n\t" << command);
|
"I use convertDefault.py:\n\t" << command);
|
||||||
Systemcall one;
|
Systemcall one;
|
||||||
one.startscript(Systemcall::Wait, command);
|
one.startscript(Systemcall::Wait, command, buffer->filePath());
|
||||||
if (to_file.isReadableFile()) {
|
if (to_file.isReadableFile()) {
|
||||||
if (conversionflags & try_cache)
|
if (conversionflags & try_cache)
|
||||||
ConverterCache::get().add(orig_from,
|
ConverterCache::get().add(orig_from,
|
||||||
@ -443,12 +443,14 @@ bool Converters::convert(Buffer const * buffer,
|
|||||||
int res;
|
int res;
|
||||||
if (dummy) {
|
if (dummy) {
|
||||||
res = one.startscript(Systemcall::DontWait,
|
res = one.startscript(Systemcall::DontWait,
|
||||||
to_filesystem8bit(from_utf8(command)));
|
to_filesystem8bit(from_utf8(command)),
|
||||||
|
buffer->filePath());
|
||||||
// We're not waiting for the result, so we can't do anything
|
// We're not waiting for the result, so we can't do anything
|
||||||
// else here.
|
// else here.
|
||||||
} else {
|
} else {
|
||||||
res = one.startscript(Systemcall::Wait,
|
res = one.startscript(Systemcall::Wait,
|
||||||
to_filesystem8bit(from_utf8(command)));
|
to_filesystem8bit(from_utf8(command)),
|
||||||
|
buffer->filePath());
|
||||||
if (!real_outfile.empty()) {
|
if (!real_outfile.empty()) {
|
||||||
Mover const & mover = getMover(conv.to);
|
Mover const & mover = getMover(conv.to);
|
||||||
if (!mover.rename(outfile, real_outfile))
|
if (!mover.rename(outfile, real_outfile))
|
||||||
@ -468,7 +470,8 @@ bool Converters::convert(Buffer const * buffer,
|
|||||||
" < " + quoteName(infile2 + ".out") +
|
" < " + quoteName(infile2 + ".out") +
|
||||||
" > " + quoteName(logfile);
|
" > " + quoteName(logfile);
|
||||||
one.startscript(Systemcall::Wait,
|
one.startscript(Systemcall::Wait,
|
||||||
to_filesystem8bit(from_utf8(command2)));
|
to_filesystem8bit(from_utf8(command2)),
|
||||||
|
buffer->filePath());
|
||||||
if (!scanLog(*buffer, command, makeAbsPath(logfile, path), errorList))
|
if (!scanLog(*buffer, command, makeAbsPath(logfile, path), errorList))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -612,7 +615,8 @@ bool Converters::runLaTeX(Buffer const & buffer, string const & command,
|
|||||||
|
|
||||||
// do the LaTeX run(s)
|
// do the LaTeX run(s)
|
||||||
string const name = buffer.latexName();
|
string const name = buffer.latexName();
|
||||||
LaTeX latex(command, runparams, FileName(makeAbsPath(name)));
|
LaTeX latex(command, runparams, FileName(makeAbsPath(name)),
|
||||||
|
buffer.filePath());
|
||||||
TeXErrors terr;
|
TeXErrors terr;
|
||||||
ShowMessage show(buffer);
|
ShowMessage show(buffer);
|
||||||
latex.message.connect(show);
|
latex.message.connect(show);
|
||||||
|
@ -285,7 +285,7 @@ bool Formats::view(Buffer const & buffer, FileName const & filename,
|
|||||||
}
|
}
|
||||||
// viewer is 'auto'
|
// viewer is 'auto'
|
||||||
if (format->viewer() == "auto") {
|
if (format->viewer() == "auto") {
|
||||||
if (os::autoOpenFile(filename.absFileName(), os::VIEW))
|
if (os::autoOpenFile(filename.absFileName(), os::VIEW, buffer.filePath()))
|
||||||
return true;
|
return true;
|
||||||
else {
|
else {
|
||||||
Alert::error(_("Cannot view file"),
|
Alert::error(_("Cannot view file"),
|
||||||
@ -320,7 +320,7 @@ bool Formats::view(Buffer const & buffer, FileName const & filename,
|
|||||||
buffer.message(_("Executing command: ") + from_utf8(command));
|
buffer.message(_("Executing command: ") + from_utf8(command));
|
||||||
|
|
||||||
Systemcall one;
|
Systemcall one;
|
||||||
one.startscript(Systemcall::DontWait, command);
|
one.startscript(Systemcall::DontWait, command, buffer.filePath());
|
||||||
|
|
||||||
// we can't report any sort of error, since we aren't waiting
|
// we can't report any sort of error, since we aren't waiting
|
||||||
return true;
|
return true;
|
||||||
@ -364,7 +364,7 @@ bool Formats::edit(Buffer const & buffer, FileName const & filename,
|
|||||||
|
|
||||||
// editor is 'auto'
|
// editor is 'auto'
|
||||||
if (format->editor() == "auto") {
|
if (format->editor() == "auto") {
|
||||||
if (os::autoOpenFile(filename.absFileName(), os::EDIT))
|
if (os::autoOpenFile(filename.absFileName(), os::EDIT, buffer.filePath()))
|
||||||
return true;
|
return true;
|
||||||
else {
|
else {
|
||||||
Alert::error(_("Cannot edit file"),
|
Alert::error(_("Cannot edit file"),
|
||||||
@ -387,7 +387,7 @@ bool Formats::edit(Buffer const & buffer, FileName const & filename,
|
|||||||
buffer.message(_("Executing command: ") + from_utf8(command));
|
buffer.message(_("Executing command: ") + from_utf8(command));
|
||||||
|
|
||||||
Systemcall one;
|
Systemcall one;
|
||||||
one.startscript(Systemcall::DontWait, command);
|
one.startscript(Systemcall::DontWait, command, buffer.filePath());
|
||||||
|
|
||||||
// we can't report any sort of error, since we aren't waiting
|
// we can't report any sort of error, since we aren't waiting
|
||||||
return true;
|
return true;
|
||||||
|
@ -93,8 +93,8 @@ bool operator!=(AuxInfo const & a, AuxInfo const & o)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
LaTeX::LaTeX(string const & latex, OutputParams const & rp,
|
LaTeX::LaTeX(string const & latex, OutputParams const & rp,
|
||||||
FileName const & f)
|
FileName const & f, string const & p)
|
||||||
: cmd(latex), file(f), runparams(rp)
|
: cmd(latex), file(f), path(p), runparams(rp)
|
||||||
{
|
{
|
||||||
num_errors = 0;
|
num_errors = 0;
|
||||||
if (prefixIs(cmd, "pdf")) { // Do we use pdflatex ?
|
if (prefixIs(cmd, "pdf")) { // Do we use pdflatex ?
|
||||||
@ -421,7 +421,7 @@ int LaTeX::startscript()
|
|||||||
+ quoteName(onlyFileName(file.toFilesystemEncoding()))
|
+ quoteName(onlyFileName(file.toFilesystemEncoding()))
|
||||||
+ " > " + os::nulldev();
|
+ " > " + os::nulldev();
|
||||||
Systemcall one;
|
Systemcall one;
|
||||||
return one.startscript(Systemcall::Wait, tmp);
|
return one.startscript(Systemcall::Wait, tmp, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -448,7 +448,7 @@ bool LaTeX::runMakeIndex(string const & f, OutputParams const & runparams,
|
|||||||
tmp += quoteName(f);
|
tmp += quoteName(f);
|
||||||
tmp += params;
|
tmp += params;
|
||||||
Systemcall one;
|
Systemcall one;
|
||||||
one.startscript(Systemcall::Wait, tmp);
|
one.startscript(Systemcall::Wait, tmp, path);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,7 +464,7 @@ bool LaTeX::runMakeIndexNomencl(FileName const & file,
|
|||||||
tmp += " -o "
|
tmp += " -o "
|
||||||
+ onlyFileName(changeExtension(file.toFilesystemEncoding(), nls));
|
+ onlyFileName(changeExtension(file.toFilesystemEncoding(), nls));
|
||||||
Systemcall one;
|
Systemcall one;
|
||||||
one.startscript(Systemcall::Wait, tmp);
|
one.startscript(Systemcall::Wait, tmp, path);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -604,7 +604,7 @@ bool LaTeX::runBibTeX(vector<AuxInfo> const & bibtex_info,
|
|||||||
tmp += quoteName(onlyFileName(removeExtension(
|
tmp += quoteName(onlyFileName(removeExtension(
|
||||||
it->aux_file.absFileName())));
|
it->aux_file.absFileName())));
|
||||||
Systemcall one;
|
Systemcall one;
|
||||||
one.startscript(Systemcall::Wait, tmp);
|
one.startscript(Systemcall::Wait, tmp, path);
|
||||||
}
|
}
|
||||||
// Return whether bibtex was run
|
// Return whether bibtex was run
|
||||||
return result;
|
return result;
|
||||||
|
@ -151,7 +151,8 @@ public:
|
|||||||
path = name of the files original path.
|
path = name of the files original path.
|
||||||
*/
|
*/
|
||||||
LaTeX(std::string const & cmd, OutputParams const &,
|
LaTeX(std::string const & cmd, OutputParams const &,
|
||||||
support::FileName const & file);
|
support::FileName const & file,
|
||||||
|
std::string const & path = empty_string());
|
||||||
|
|
||||||
/// runs LaTeX several times
|
/// runs LaTeX several times
|
||||||
int run(TeXErrors &);
|
int run(TeXErrors &);
|
||||||
@ -210,6 +211,9 @@ private:
|
|||||||
///
|
///
|
||||||
support::FileName file;
|
support::FileName file;
|
||||||
|
|
||||||
|
///
|
||||||
|
std::string path;
|
||||||
|
|
||||||
/// used by scanLogFile
|
/// used by scanLogFile
|
||||||
int num_errors;
|
int num_errors;
|
||||||
|
|
||||||
|
@ -192,6 +192,7 @@ LexerKeyword lyxrcTags[] = {
|
|||||||
{ "\\template_path", LyXRC::RC_TEMPLATEPATH },
|
{ "\\template_path", LyXRC::RC_TEMPLATEPATH },
|
||||||
{ "\\tex_allows_spaces", LyXRC::RC_TEX_ALLOWS_SPACES },
|
{ "\\tex_allows_spaces", LyXRC::RC_TEX_ALLOWS_SPACES },
|
||||||
{ "\\tex_expects_windows_paths", LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS },
|
{ "\\tex_expects_windows_paths", LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS },
|
||||||
|
{ "\\texinputs_prefix", LyXRC::RC_TEXINPUTS_PREFIX },
|
||||||
{ "\\thesaurusdir_path", LyXRC::RC_THESAURUSDIRPATH },
|
{ "\\thesaurusdir_path", LyXRC::RC_THESAURUSDIRPATH },
|
||||||
{ "\\ui_file", LyXRC::RC_UIFILE },
|
{ "\\ui_file", LyXRC::RC_UIFILE },
|
||||||
{ "\\use_converter_cache", LyXRC::RC_USE_CONVERTER_CACHE },
|
{ "\\use_converter_cache", LyXRC::RC_USE_CONVERTER_CACHE },
|
||||||
@ -227,6 +228,8 @@ void LyXRC::setDefaults()
|
|||||||
bind_file = "cua";
|
bind_file = "cua";
|
||||||
def_file = "default";
|
def_file = "default";
|
||||||
ui_file = "default";
|
ui_file = "default";
|
||||||
|
// The current document directory
|
||||||
|
texinputs_prefix = ".";
|
||||||
// Get printer from the environment. If fail, use default "",
|
// Get printer from the environment. If fail, use default "",
|
||||||
// assuming that everything is set up correctly.
|
// assuming that everything is set up correctly.
|
||||||
printer = getEnv("PRINTER");
|
printer = getEnv("PRINTER");
|
||||||
@ -499,6 +502,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
|
|||||||
lexrc >> tex_allows_spaces;
|
lexrc >> tex_allows_spaces;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RC_TEXINPUTS_PREFIX:
|
||||||
|
lexrc >> texinputs_prefix;
|
||||||
|
break;
|
||||||
|
|
||||||
case RC_KBMAP:
|
case RC_KBMAP:
|
||||||
lexrc >> use_kbmap;
|
lexrc >> use_kbmap;
|
||||||
break;
|
break;
|
||||||
@ -2213,6 +2220,14 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
|
|||||||
<< "# TEX SECTION #######################################\n"
|
<< "# TEX SECTION #######################################\n"
|
||||||
<< "#\n\n";
|
<< "#\n\n";
|
||||||
|
|
||||||
|
case RC_TEXINPUTS_PREFIX:
|
||||||
|
if (ignore_system_lyxrc ||
|
||||||
|
texinputs_prefix != system_lyxrc.texinputs_prefix) {
|
||||||
|
os << "\\texinputs_prefix \"" << texinputs_prefix << "\"\n";
|
||||||
|
}
|
||||||
|
if (tag != RC_LAST)
|
||||||
|
break;
|
||||||
|
|
||||||
case RC_FONT_ENCODING:
|
case RC_FONT_ENCODING:
|
||||||
if (ignore_system_lyxrc ||
|
if (ignore_system_lyxrc ||
|
||||||
fontenc != system_lyxrc.fontenc) {
|
fontenc != system_lyxrc.fontenc) {
|
||||||
@ -3020,6 +3035,10 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
|
|||||||
if (lyxrc_orig.windows_style_tex_paths != lyxrc_new.windows_style_tex_paths) {
|
if (lyxrc_orig.windows_style_tex_paths != lyxrc_new.windows_style_tex_paths) {
|
||||||
os::windows_style_tex_paths(lyxrc_new.windows_style_tex_paths);
|
os::windows_style_tex_paths(lyxrc_new.windows_style_tex_paths);
|
||||||
}
|
}
|
||||||
|
case LyXRC::RC_TEXINPUTS_PREFIX:
|
||||||
|
if (lyxrc_orig.texinputs_prefix != lyxrc_new.texinputs_prefix) {
|
||||||
|
lyxrc.texinputs_prefix = lyxrc_new.texinputs_prefix;
|
||||||
|
}
|
||||||
case LyXRC::RC_THESAURUSDIRPATH:
|
case LyXRC::RC_THESAURUSDIRPATH:
|
||||||
case LyXRC::RC_UIFILE:
|
case LyXRC::RC_UIFILE:
|
||||||
case LyXRC::RC_USER_EMAIL:
|
case LyXRC::RC_USER_EMAIL:
|
||||||
@ -3470,6 +3489,13 @@ string const LyXRC::getDescription(LyXRCTags tag)
|
|||||||
case RC_TEX_EXPECTS_WINDOWS_PATHS:
|
case RC_TEX_EXPECTS_WINDOWS_PATHS:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RC_TEXINPUTS_PREFIX:
|
||||||
|
str = _("Specify those directories which should be "
|
||||||
|
"prepended to the TEXINPUTS environment variable. "
|
||||||
|
"A '.' represents the current document directory. "
|
||||||
|
"Use the OS native format.");
|
||||||
|
break;
|
||||||
|
|
||||||
case RC_UIFILE:
|
case RC_UIFILE:
|
||||||
str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories.");
|
str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories.");
|
||||||
break;
|
break;
|
||||||
|
@ -174,6 +174,7 @@ public:
|
|||||||
RC_TEMPLATEPATH,
|
RC_TEMPLATEPATH,
|
||||||
RC_TEX_ALLOWS_SPACES,
|
RC_TEX_ALLOWS_SPACES,
|
||||||
RC_TEX_EXPECTS_WINDOWS_PATHS,
|
RC_TEX_EXPECTS_WINDOWS_PATHS,
|
||||||
|
RC_TEXINPUTS_PREFIX,
|
||||||
RC_THESAURUSDIRPATH,
|
RC_THESAURUSDIRPATH,
|
||||||
RC_UIFILE,
|
RC_UIFILE,
|
||||||
RC_USELASTFILEPOS,
|
RC_USELASTFILEPOS,
|
||||||
@ -469,6 +470,11 @@ public:
|
|||||||
* The string is input, stored and output in native format.
|
* The string is input, stored and output in native format.
|
||||||
*/
|
*/
|
||||||
std::string path_prefix;
|
std::string path_prefix;
|
||||||
|
/** Prepend paths to the TEXINPUTS environment variable.
|
||||||
|
* The string is input, stored and output in native format.
|
||||||
|
* A '.' here stands for the current document directory.
|
||||||
|
*/
|
||||||
|
std::string texinputs_prefix;
|
||||||
/// Use the cache for file converters?
|
/// Use the cache for file converters?
|
||||||
bool use_converter_cache;
|
bool use_converter_cache;
|
||||||
/// The maximum age of cache files in seconds
|
/// The maximum age of cache files in seconds
|
||||||
|
@ -43,7 +43,7 @@ int VCS::doVCCommandCall(string const & cmd, FileName const & path)
|
|||||||
LYXERR(Debug::LYXVC, "doVCCommandCall: " << cmd);
|
LYXERR(Debug::LYXVC, "doVCCommandCall: " << cmd);
|
||||||
Systemcall one;
|
Systemcall one;
|
||||||
support::PathChanger p(path);
|
support::PathChanger p(path);
|
||||||
return one.startscript(Systemcall::Wait, cmd, false);
|
return one.startscript(Systemcall::Wait, cmd, string(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1312,6 +1312,9 @@ PrefPaths::PrefPaths(GuiPreferences * form)
|
|||||||
|
|
||||||
connect(pathPrefixED, SIGNAL(textChanged(QString)),
|
connect(pathPrefixED, SIGNAL(textChanged(QString)),
|
||||||
this, SIGNAL(changed()));
|
this, SIGNAL(changed()));
|
||||||
|
|
||||||
|
connect(texinputsPrefixED, SIGNAL(textChanged(QString)),
|
||||||
|
this, SIGNAL(changed()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1325,6 +1328,7 @@ void PrefPaths::apply(LyXRC & rc) const
|
|||||||
rc.thesaurusdir_path = internal_path(fromqstr(thesaurusDirED->text()));
|
rc.thesaurusdir_path = internal_path(fromqstr(thesaurusDirED->text()));
|
||||||
rc.hunspelldir_path = internal_path(fromqstr(hunspellDirED->text()));
|
rc.hunspelldir_path = internal_path(fromqstr(hunspellDirED->text()));
|
||||||
rc.path_prefix = internal_path_list(fromqstr(pathPrefixED->text()));
|
rc.path_prefix = internal_path_list(fromqstr(pathPrefixED->text()));
|
||||||
|
rc.texinputs_prefix = internal_path_list(fromqstr(texinputsPrefixED->text()));
|
||||||
// FIXME: should be a checkbox only
|
// FIXME: should be a checkbox only
|
||||||
rc.lyxpipes = internal_path(fromqstr(lyxserverDirED->text()));
|
rc.lyxpipes = internal_path(fromqstr(lyxserverDirED->text()));
|
||||||
}
|
}
|
||||||
@ -1340,6 +1344,7 @@ void PrefPaths::update(LyXRC const & rc)
|
|||||||
thesaurusDirED->setText(toqstr(external_path(rc.thesaurusdir_path)));
|
thesaurusDirED->setText(toqstr(external_path(rc.thesaurusdir_path)));
|
||||||
hunspellDirED->setText(toqstr(external_path(rc.hunspelldir_path)));
|
hunspellDirED->setText(toqstr(external_path(rc.hunspelldir_path)));
|
||||||
pathPrefixED->setText(toqstr(external_path_list(rc.path_prefix)));
|
pathPrefixED->setText(toqstr(external_path_list(rc.path_prefix)));
|
||||||
|
texinputsPrefixED->setText(toqstr(external_path_list(rc.texinputs_prefix)));
|
||||||
// FIXME: should be a checkbox only
|
// FIXME: should be a checkbox only
|
||||||
lyxserverDirED->setText(toqstr(external_path(rc.lyxpipes)));
|
lyxserverDirED->setText(toqstr(external_path(rc.lyxpipes)));
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="11" column="0" colspan="3" >
|
<item row="12" column="0" colspan="3" >
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@ -46,7 +46,20 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="10" column="1" colspan="2" >
|
<item row="10" column="1" colspan="2" >
|
||||||
<widget class="QLineEdit" name="pathPrefixED" />
|
<widget class="QLineEdit" name="pathPrefixED"/>
|
||||||
|
</item>
|
||||||
|
<item row="11" column="0">
|
||||||
|
<widget class="QLabel" name="texinputsPrefixLA">
|
||||||
|
<property name="text">
|
||||||
|
<string>TEX&INPUTS prefix:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>texinputsPrefixED</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="11" column="1" colspan="2">
|
||||||
|
<widget class="QLineEdit" name="texinputsPrefixED"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="2" >
|
<item row="6" column="2" >
|
||||||
<widget class="QPushButton" name="thesaurusDirPB" >
|
<widget class="QPushButton" name="thesaurusDirPB" >
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include "support/debug.h"
|
#include "support/debug.h"
|
||||||
|
#include "support/environment.h"
|
||||||
|
#include "support/filetools.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
#include "support/qstring_helpers.h"
|
#include "support/qstring_helpers.h"
|
||||||
#include "support/Systemcall.h"
|
#include "support/Systemcall.h"
|
||||||
@ -21,6 +23,7 @@
|
|||||||
#include "support/os.h"
|
#include "support/os.h"
|
||||||
#include "support/ProgressInterface.h"
|
#include "support/ProgressInterface.h"
|
||||||
|
|
||||||
|
#include "LyXRC.h"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -96,9 +99,26 @@ ProgressInterface* ProgressInterface::instance()
|
|||||||
// Reuse of instance
|
// Reuse of instance
|
||||||
#ifndef USE_QPROCESS
|
#ifndef USE_QPROCESS
|
||||||
int Systemcall::startscript(Starttype how, string const & what,
|
int Systemcall::startscript(Starttype how, string const & what,
|
||||||
bool /*process_events*/)
|
std::string const & path, bool /*process_events*/)
|
||||||
{
|
{
|
||||||
string command = what;
|
string command;
|
||||||
|
string const texinputs = os::latex_path_list(
|
||||||
|
replaceCurdirPath(path, lyxrc.texinputs_prefix));
|
||||||
|
string const sep = string(1, os::path_separator(os::TEXENGINE));
|
||||||
|
string const env = getEnv("TEXINPUTS");
|
||||||
|
|
||||||
|
switch (os::shell()) {
|
||||||
|
case os::UNIX:
|
||||||
|
command = path.empty() || lyxrc.texinputs_prefix.empty() ? what
|
||||||
|
: "env TEXINPUTS='." + sep + texinputs
|
||||||
|
+ sep + env + "' " + what;
|
||||||
|
break;
|
||||||
|
case os::CMD_EXE:
|
||||||
|
command = path.empty() || lyxrc.texinputs_prefix.empty() ? what
|
||||||
|
: "set TEXINPUTS=." + sep + texinputs
|
||||||
|
+ sep + env + " & " + what;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (how == DontWait) {
|
if (how == DontWait) {
|
||||||
switch (os::shell()) {
|
switch (os::shell()) {
|
||||||
@ -204,7 +224,8 @@ string const parsecmd(string const & inputcmd, string & outfile)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int Systemcall::startscript(Starttype how, string const & what, bool process_events)
|
int Systemcall::startscript(Starttype how, string const & what,
|
||||||
|
string const & path, bool process_events)
|
||||||
{
|
{
|
||||||
string outfile;
|
string outfile;
|
||||||
QString cmd = toqstr(parsecmd(what, outfile));
|
QString cmd = toqstr(parsecmd(what, outfile));
|
||||||
@ -212,7 +233,7 @@ int Systemcall::startscript(Starttype how, string const & what, bool process_eve
|
|||||||
SystemcallPrivate d(outfile);
|
SystemcallPrivate d(outfile);
|
||||||
|
|
||||||
|
|
||||||
d.startProcess(cmd);
|
d.startProcess(cmd, path);
|
||||||
if (!d.waitWhile(SystemcallPrivate::Starting, process_events, -1)) {
|
if (!d.waitWhile(SystemcallPrivate::Starting, process_events, -1)) {
|
||||||
LYXERR0("Systemcall: '" << cmd << "' did not start!");
|
LYXERR0("Systemcall: '" << cmd << "' did not start!");
|
||||||
LYXERR0("error " << d.errorMessage());
|
LYXERR0("error " << d.errorMessage());
|
||||||
@ -264,10 +285,24 @@ SystemcallPrivate::SystemcallPrivate(const std::string& of) :
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SystemcallPrivate::startProcess(const QString& cmd)
|
void SystemcallPrivate::startProcess(QString const & cmd, string const & path)
|
||||||
{
|
{
|
||||||
cmd_ = cmd;
|
cmd_ = cmd;
|
||||||
if (process_) {
|
if (process_) {
|
||||||
|
if (!path.empty() && !lyxrc.texinputs_prefix.empty()) {
|
||||||
|
QString const texinputs = toqstr(os::latex_path_list(
|
||||||
|
replaceCurdirPath(path, lyxrc.texinputs_prefix)));
|
||||||
|
QChar const sep = os::path_separator(os::TEXENGINE);
|
||||||
|
QString const prefix = QLatin1String("TEXINPUTS=.")
|
||||||
|
+ sep + texinputs + sep;
|
||||||
|
QStringList env = QProcess::systemEnvironment();
|
||||||
|
if (env.filter("TEXINPUTS=").isEmpty())
|
||||||
|
env << prefix;
|
||||||
|
else
|
||||||
|
env.replaceInStrings(QRegExp("^TEXINPUTS=(.*)"),
|
||||||
|
prefix + "\\1");
|
||||||
|
process_->setEnvironment(env);
|
||||||
|
}
|
||||||
state = SystemcallPrivate::Starting;
|
state = SystemcallPrivate::Starting;
|
||||||
process_->start(cmd_);
|
process_->start(cmd_);
|
||||||
}
|
}
|
||||||
|
@ -40,10 +40,13 @@ public:
|
|||||||
|
|
||||||
/** Start child process.
|
/** Start child process.
|
||||||
* The string "what" contains a commandline with arguments separated
|
* The string "what" contains a commandline with arguments separated
|
||||||
* by spaces. Unset "process_events" in case UI should be blocked while
|
* by spaces. The string "path" contains the path to be prepended to
|
||||||
* processing the external command.
|
* the TEXINPUTS environment variable. Unset "process_events" in
|
||||||
|
* case UI should be blocked while processing the external command.
|
||||||
*/
|
*/
|
||||||
int startscript(Starttype how, std::string const & what, bool process_events = false);
|
int startscript(Starttype how, std::string const & what,
|
||||||
|
std::string const & path = empty_string(),
|
||||||
|
bool process_events = false);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace support
|
} // namespace support
|
||||||
|
@ -44,7 +44,7 @@ public:
|
|||||||
State state;
|
State state;
|
||||||
|
|
||||||
bool waitWhile(State, bool processEvents, int timeout = -1);
|
bool waitWhile(State, bool processEvents, int timeout = -1);
|
||||||
void startProcess(const QString& cmd);
|
void startProcess(QString const & cmd, std::string const & path);
|
||||||
|
|
||||||
int exitCode();
|
int exitCode();
|
||||||
|
|
||||||
|
@ -577,6 +577,42 @@ string const replaceEnvironmentPath(string const & path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Replace current directory in all elements of a path list with a given path.
|
||||||
|
string const replaceCurdirPath(string const & path, string const & pathlist)
|
||||||
|
{
|
||||||
|
string const oldpathlist = replaceEnvironmentPath(pathlist);
|
||||||
|
char const sep = os::path_separator();
|
||||||
|
string newpathlist;
|
||||||
|
|
||||||
|
for (size_t i = 0, k = 0; i != string::npos; k = i) {
|
||||||
|
i = oldpathlist.find(sep, i);
|
||||||
|
string p = oldpathlist.substr(k, i - k);
|
||||||
|
if (FileName::isAbsolute(p)) {
|
||||||
|
newpathlist += p;
|
||||||
|
} else if (i > k) {
|
||||||
|
size_t offset = 0;
|
||||||
|
if (p == ".") {
|
||||||
|
offset = 1;
|
||||||
|
} else if (prefixIs(p, "./")) {
|
||||||
|
offset = 2;
|
||||||
|
while (p[offset] == '/')
|
||||||
|
++offset;
|
||||||
|
}
|
||||||
|
newpathlist += addPath(path, p.substr(offset));
|
||||||
|
if (suffixIs(p, "//"))
|
||||||
|
newpathlist += '/';
|
||||||
|
}
|
||||||
|
if (i != string::npos) {
|
||||||
|
newpathlist += sep;
|
||||||
|
// Stop here if the last element is empty
|
||||||
|
if (++i == oldpathlist.length())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newpathlist;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Make relative path out of two absolute paths
|
// Make relative path out of two absolute paths
|
||||||
docstring const makeRelPath(docstring const & abspath, docstring const & basepath)
|
docstring const makeRelPath(docstring const & abspath, docstring const & basepath)
|
||||||
// Makes relative path out of absolute path. If it is deeper than basepath,
|
// Makes relative path out of absolute path. If it is deeper than basepath,
|
||||||
|
@ -247,6 +247,12 @@ std::string const onlyFileName(std::string const & fname);
|
|||||||
*/
|
*/
|
||||||
std::string const replaceEnvironmentPath(std::string const & path);
|
std::string const replaceEnvironmentPath(std::string const & path);
|
||||||
|
|
||||||
|
/** Replace all references to a current directory (a lonely '.' or
|
||||||
|
the prefix "./") in \c pathlist with \c path. Also prefixes
|
||||||
|
all non-absolute paths with \c path.
|
||||||
|
*/
|
||||||
|
std::string const replaceCurdirPath(std::string const & path, std::string const & pathlist);
|
||||||
|
|
||||||
/** Set \c link to the path \c file points to as a symbolic link.
|
/** Set \c link to the path \c file points to as a symbolic link.
|
||||||
\return true if successful.
|
\return true if successful.
|
||||||
*/
|
*/
|
||||||
|
@ -104,6 +104,12 @@ std::string internal_path_list(std::string const & p);
|
|||||||
*/
|
*/
|
||||||
std::string latex_path(std::string const & p);
|
std::string latex_path(std::string const & p);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a platform style path list into a form suitable for the TeX engine.
|
||||||
|
* \p p is encoded in utf8.
|
||||||
|
*/
|
||||||
|
std::string latex_path_list(std::string const & p);
|
||||||
|
|
||||||
/// Checks if the format string is suitable on the OS
|
/// Checks if the format string is suitable on the OS
|
||||||
bool is_valid_strftime(std::string const & p);
|
bool is_valid_strftime(std::string const & p);
|
||||||
|
|
||||||
@ -112,10 +118,15 @@ bool is_valid_strftime(std::string const & p);
|
|||||||
*/
|
*/
|
||||||
char const * popen_read_mode();
|
char const * popen_read_mode();
|
||||||
|
|
||||||
/** The character used to separate paths returned by the
|
enum path_type {
|
||||||
* PATH environment variable.
|
PLATFORM,
|
||||||
|
TEXENGINE
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The character used to separate paths for platform environment variables
|
||||||
|
* (such as PATH) or for the TeX engine.
|
||||||
*/
|
*/
|
||||||
char path_separator();
|
char path_separator(path_type type = PLATFORM);
|
||||||
|
|
||||||
/** If @c use_windows_paths is true, LyX will output Windows-style paths to
|
/** If @c use_windows_paths is true, LyX will output Windows-style paths to
|
||||||
* latex files rather than posix ones. Obviously, this option is used only
|
* latex files rather than posix ones. Obviously, this option is used only
|
||||||
@ -133,14 +144,15 @@ enum auto_open_mode {
|
|||||||
* \param mode can be opened in VIEW or EDIT mode
|
* \param mode can be opened in VIEW or EDIT mode
|
||||||
* \returns whether or not the format can be opened according to \p mode
|
* \returns whether or not the format can be opened according to \p mode
|
||||||
*/
|
*/
|
||||||
bool canAutoOpenFile(std::string const & ext, auto_open_mode const mode = VIEW);
|
bool canAutoOpenFile(std::string const & ext, auto_open_mode const mode);
|
||||||
|
|
||||||
/** View or edit a file with the default viewer or editor.
|
/** View or edit a file with the default viewer or editor.
|
||||||
* \param filename file to open (encoded in utf8)
|
* \param filename file to open (encoded in utf8)
|
||||||
* \param mode open in VIEW or EDIT mode
|
* \param mode open in VIEW or EDIT mode
|
||||||
* \returns whether or not the file is viewed (or edited) successfully.
|
* \returns whether or not the file is viewed (or edited) successfully.
|
||||||
*/
|
*/
|
||||||
bool autoOpenFile(std::string const & filename, auto_open_mode const mode = VIEW);
|
bool autoOpenFile(std::string const & filename, auto_open_mode const mode,
|
||||||
|
std::string const & path = empty_string());
|
||||||
|
|
||||||
/** Resolves a path such that it does not contain '.', '..', or symbolic links.
|
/** Resolves a path such that it does not contain '.', '..', or symbolic links.
|
||||||
* \p path and the return value are encoded in utf8.
|
* \p path and the return value are encoded in utf8.
|
||||||
|
@ -15,12 +15,16 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#include "LyXRC.h"
|
||||||
|
|
||||||
#include "support/os.h"
|
#include "support/os.h"
|
||||||
|
|
||||||
|
#include "support/debug.h"
|
||||||
|
#include "support/environment.h"
|
||||||
#include "support/FileName.h"
|
#include "support/FileName.h"
|
||||||
|
#include "support/filetools.h"
|
||||||
#include "support/lassert.h"
|
#include "support/lassert.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
#include "support/debug.h"
|
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
@ -343,6 +347,19 @@ string latex_path(string const & p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string latex_path_list(string const & p)
|
||||||
|
{
|
||||||
|
// We may need a posix style path or a windows style path (depending
|
||||||
|
// on windows_style_tex_paths_), but we use always forward slashes,
|
||||||
|
// since this is standard for all tex engines.
|
||||||
|
|
||||||
|
if (windows_style_tex_paths_)
|
||||||
|
return convert_path_list(p, PathStyle(windows));
|
||||||
|
|
||||||
|
return convert_path_list(p, PathStyle(posix));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool is_valid_strftime(string const & p)
|
bool is_valid_strftime(string const & p)
|
||||||
{
|
{
|
||||||
string::size_type pos = p.find_first_of('%');
|
string::size_type pos = p.find_first_of('%');
|
||||||
@ -387,8 +404,11 @@ int timeout_min()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char path_separator()
|
char path_separator(path_type type)
|
||||||
{
|
{
|
||||||
|
if (type == TEXENGINE)
|
||||||
|
return windows_style_tex_paths_ ? ';' : ':';
|
||||||
|
|
||||||
return ':';
|
return ':';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,13 +435,30 @@ bool canAutoOpenFile(string const & ext, auto_open_mode const mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool autoOpenFile(string const & filename, auto_open_mode const mode)
|
bool autoOpenFile(string const & filename, auto_open_mode const mode,
|
||||||
|
string const & path)
|
||||||
{
|
{
|
||||||
|
string const texinputs = os::latex_path_list(
|
||||||
|
replaceCurdirPath(path, lyxrc.texinputs_prefix));
|
||||||
|
string const sep = windows_style_tex_paths_ ? ";" : ":";
|
||||||
|
string const oldval = getEnv("TEXINPUTS");
|
||||||
|
string const newval = "." + sep + texinputs + sep + oldval;
|
||||||
|
if (!path.empty() && !lyxrc.texinputs_prefix.empty()) {
|
||||||
|
setEnv("TEXINPUTS", newval);
|
||||||
|
cygwin_internal(CW_SYNC_WINENV);
|
||||||
|
}
|
||||||
|
|
||||||
// reference: http://msdn.microsoft.com/en-us/library/bb762153.aspx
|
// reference: http://msdn.microsoft.com/en-us/library/bb762153.aspx
|
||||||
string const win_path = to_local8bit(from_utf8(convert_path(filename, PathStyle(windows))));
|
string const win_path = to_local8bit(from_utf8(convert_path(filename, PathStyle(windows))));
|
||||||
char const * action = (mode == VIEW) ? "open" : "edit";
|
char const * action = (mode == VIEW) ? "open" : "edit";
|
||||||
return reinterpret_cast<int>(ShellExecute(NULL, action,
|
bool success = reinterpret_cast<int>(ShellExecute(NULL, action,
|
||||||
win_path.c_str(), NULL, NULL, 1)) > 32;
|
win_path.c_str(), NULL, NULL, 1)) > 32;
|
||||||
|
|
||||||
|
if (!path.empty() && !lyxrc.texinputs_prefix.empty()) {
|
||||||
|
setEnv("TEXINPUTS", oldval);
|
||||||
|
cygwin_internal(CW_SYNC_WINENV);
|
||||||
|
}
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,9 +12,13 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#include "LyXRC.h"
|
||||||
|
|
||||||
#include "support/os.h"
|
#include "support/os.h"
|
||||||
#include "support/docstring.h"
|
#include "support/docstring.h"
|
||||||
|
#include "support/environment.h"
|
||||||
#include "support/FileName.h"
|
#include "support/FileName.h"
|
||||||
|
#include "support/filetools.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
#include "support/lassert.h"
|
#include "support/lassert.h"
|
||||||
|
|
||||||
@ -176,6 +180,12 @@ string latex_path(string const & p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string latex_path_list(string const & p)
|
||||||
|
{
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool is_valid_strftime(string const & p)
|
bool is_valid_strftime(string const & p)
|
||||||
{
|
{
|
||||||
string::size_type pos = p.find_first_of('%');
|
string::size_type pos = p.find_first_of('%');
|
||||||
@ -218,7 +228,7 @@ int timeout_min()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char path_separator()
|
char path_separator(path_type)
|
||||||
{
|
{
|
||||||
return ':';
|
return ':';
|
||||||
}
|
}
|
||||||
@ -258,7 +268,8 @@ bool canAutoOpenFile(string const & ext, auto_open_mode const mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool autoOpenFile(string const & filename, auto_open_mode const mode)
|
bool autoOpenFile(string const & filename, auto_open_mode const mode,
|
||||||
|
string const & path)
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
// Reference: http://developer.apple.com/documentation/Carbon/Reference/LaunchServicesReference/
|
// Reference: http://developer.apple.com/documentation/Carbon/Reference/LaunchServicesReference/
|
||||||
@ -279,6 +290,13 @@ bool autoOpenFile(string const & filename, auto_open_mode const mode)
|
|||||||
if (status == kLSApplicationNotFoundErr)
|
if (status == kLSApplicationNotFoundErr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
string const texinputs = os::latex_path_list(
|
||||||
|
replaceCurdirPath(path, lyxrc.texinputs_prefix));
|
||||||
|
string const oldval = getEnv("TEXINPUTS");
|
||||||
|
string const newval = ".:" + texinputs + ":" + oldval;
|
||||||
|
if (!path.empty() && !lyxrc.texinputs_prefix.empty())
|
||||||
|
setEnv("TEXINPUTS", newval);
|
||||||
|
|
||||||
LSLaunchFSRefSpec inLaunchSpec;
|
LSLaunchFSRefSpec inLaunchSpec;
|
||||||
inLaunchSpec.appRef = &outAppRef;
|
inLaunchSpec.appRef = &outAppRef;
|
||||||
inLaunchSpec.numDocs = 1;
|
inLaunchSpec.numDocs = 1;
|
||||||
@ -288,11 +306,15 @@ bool autoOpenFile(string const & filename, auto_open_mode const mode)
|
|||||||
inLaunchSpec.asyncRefCon = NULL;
|
inLaunchSpec.asyncRefCon = NULL;
|
||||||
status = LSOpenFromRefSpec(&inLaunchSpec, NULL);
|
status = LSOpenFromRefSpec(&inLaunchSpec, NULL);
|
||||||
|
|
||||||
|
if (!path.empty() && !lyxrc.texinputs_prefix.empty())
|
||||||
|
setEnv("TEXINPUTS", oldval);
|
||||||
|
|
||||||
return status != kLSApplicationNotFoundErr;
|
return status != kLSApplicationNotFoundErr;
|
||||||
#else
|
#else
|
||||||
// silence compiler warnings
|
// silence compiler warnings
|
||||||
(void)filename;
|
(void)filename;
|
||||||
(void)mode;
|
(void)mode;
|
||||||
|
(void)path;
|
||||||
|
|
||||||
// currently, no default viewer is tried for non-windows system
|
// currently, no default viewer is tried for non-windows system
|
||||||
// support for KDE/Gnome/Macintosh may be added later
|
// support for KDE/Gnome/Macintosh may be added later
|
||||||
|
@ -15,10 +15,13 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#include "LyXRC.h"
|
||||||
|
|
||||||
#include "support/os.h"
|
#include "support/os.h"
|
||||||
#include "support/os_win32.h"
|
#include "support/os_win32.h"
|
||||||
|
|
||||||
#include "support/debug.h"
|
#include "support/debug.h"
|
||||||
|
#include "support/environment.h"
|
||||||
#include "support/FileName.h"
|
#include "support/FileName.h"
|
||||||
#include "support/gettext.h"
|
#include "support/gettext.h"
|
||||||
#include "support/filetools.h"
|
#include "support/filetools.h"
|
||||||
@ -385,6 +388,38 @@ string latex_path(string const & p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string latex_path_list(string const & p)
|
||||||
|
{
|
||||||
|
if (p.empty())
|
||||||
|
return p;
|
||||||
|
|
||||||
|
// We may need a posix style path or a windows style path (depending
|
||||||
|
// on windows_style_tex_paths_), but we use always forward slashes,
|
||||||
|
// since this is standard for all tex engines.
|
||||||
|
|
||||||
|
if (!windows_style_tex_paths_) {
|
||||||
|
string pathlist;
|
||||||
|
for (size_t i = 0, k = 0; i != string::npos; k = i) {
|
||||||
|
i = p.find(';', i);
|
||||||
|
string path = subst(p.substr(k, i - k), '\\', '/');
|
||||||
|
if (FileName::isAbsolute(path)) {
|
||||||
|
string const drive = path.substr(0, 2);
|
||||||
|
string const cygprefix = cygdrive + "/"
|
||||||
|
+ drive.substr(0, 1);
|
||||||
|
path = subst(path, drive, cygprefix);
|
||||||
|
}
|
||||||
|
pathlist += path;
|
||||||
|
if (i != string::npos) {
|
||||||
|
pathlist += ':';
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pathlist;
|
||||||
|
}
|
||||||
|
return subst(p, '\\', '/');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool is_valid_strftime(string const & p)
|
bool is_valid_strftime(string const & p)
|
||||||
{
|
{
|
||||||
string::size_type pos = p.find_first_of('%');
|
string::size_type pos = p.find_first_of('%');
|
||||||
@ -429,8 +464,11 @@ int timeout_min()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char path_separator()
|
char path_separator(path_type type)
|
||||||
{
|
{
|
||||||
|
if (type == TEXENGINE)
|
||||||
|
return windows_style_tex_paths_ ? ';' : ':';
|
||||||
|
|
||||||
return ';';
|
return ';';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -507,12 +545,25 @@ bool canAutoOpenFile(string const & ext, auto_open_mode const mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool autoOpenFile(string const & filename, auto_open_mode const mode)
|
bool autoOpenFile(string const & filename, auto_open_mode const mode,
|
||||||
|
string const & path)
|
||||||
{
|
{
|
||||||
|
string const texinputs = os::latex_path_list(
|
||||||
|
replaceCurdirPath(path, lyxrc.texinputs_prefix));
|
||||||
|
string const sep = windows_style_tex_paths_ ? ";" : ":";
|
||||||
|
string const oldval = getEnv("TEXINPUTS");
|
||||||
|
string const newval = "." + sep + texinputs + sep + oldval;
|
||||||
|
if (!path.empty() && !lyxrc.texinputs_prefix.empty())
|
||||||
|
setEnv("TEXINPUTS", newval);
|
||||||
|
|
||||||
// reference: http://msdn.microsoft.com/en-us/library/bb762153.aspx
|
// reference: http://msdn.microsoft.com/en-us/library/bb762153.aspx
|
||||||
char const * action = (mode == VIEW) ? "open" : "edit";
|
char const * action = (mode == VIEW) ? "open" : "edit";
|
||||||
return reinterpret_cast<int>(ShellExecute(NULL, action,
|
bool success = reinterpret_cast<int>(ShellExecute(NULL, action,
|
||||||
to_local8bit(from_utf8(filename)).c_str(), NULL, NULL, 1)) > 32;
|
to_local8bit(from_utf8(filename)).c_str(), NULL, NULL, 1)) > 32;
|
||||||
|
|
||||||
|
if (!path.empty() && !lyxrc.texinputs_prefix.empty())
|
||||||
|
setEnv("TEXINPUTS", oldval);
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user