From 00d4b6c735ee0d779c22210006d56f904cdc0d3c Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Tue, 2 Aug 2011 21:50:00 +0000 Subject: [PATCH] When previewing a format, change to the directory of the previewed file and invoke the previewer with only its filename without the path. This solves the problem about forward search on Windows reported here: http://thread.gmane.org/gmane.editors.lyx.general/71130 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_2_0_X@39413 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/doc/Additional.lyx | 44 +++--------------------------------------- src/Format.cpp | 4 +++- status.20x | 3 +++ 3 files changed, 9 insertions(+), 42 deletions(-) diff --git a/lib/doc/Additional.lyx b/lib/doc/Additional.lyx index 4c42d8a03a..e956349cec 100644 --- a/lib/doc/Additional.lyx +++ b/lib/doc/Additional.lyx @@ -6862,7 +6862,7 @@ In order to use SumatraPDF for inverse search, enter status collapsed \begin_layout Plain Layout -SumatraPDF.sh +SumatraPDF -inverse-search "lyxeditor -g %f %l" \end_layout \end_inset @@ -6880,46 +6880,8 @@ PDF (pdflatex) \end_inset -, where -\begin_inset Flex Code -status collapsed - -\begin_layout Plain Layout -SumatraPDF.sh -\end_layout - -\end_inset - - is the following script (to be placed in your command PATH, -\begin_inset Flex Code -status collapsed - -\begin_layout Plain Layout -/usr/local/bin -\end_layout - -\end_inset - - being the best choice): -\end_layout - -\begin_layout LyX-Code -#!/bin/bash -\begin_inset Newline newline -\end_inset - -cd $(dirname $1) -\begin_inset Newline newline -\end_inset - -SumatraPDF -inverse-search "lyxeditor -g %f %l" $(basename $1) -\end_layout - -\begin_layout Standard -This wrapper script is needed because SumatraPDF is a native Windows application - and does not understand the posix paths used by the Cygwin version of LyX. - If SumatraPDF.exe is not in your command PATH, use its full posix path in - the script above. +. + If SumatraPDF.exe is not in your command PATH, use its full posix path. The \begin_inset Flex Code status collapsed diff --git a/src/Format.cpp b/src/Format.cpp index cc85b85000..a528ce20c8 100644 --- a/src/Format.cpp +++ b/src/Format.cpp @@ -23,6 +23,7 @@ #include "support/gettext.h" #include "support/lstrings.h" #include "support/os.h" +#include "support/Path.h" #include "support/Systemcall.h" #include "support/textutils.h" #include "support/Translator.h" @@ -312,13 +313,14 @@ bool Formats::view(Buffer const & buffer, FileName const & filename, if (!contains(command, token_from_format)) command += ' ' + token_from_format; - command = subst(command, token_from_format, quoteName(filename.toFilesystemEncoding())); + command = subst(command, token_from_format, quoteName(onlyFileName(filename.toFilesystemEncoding()))); command = subst(command, token_path_format, quoteName(onlyPath(filename.toFilesystemEncoding()))); command = subst(command, token_socket_format, quoteName(theServerSocket().address())); LYXERR(Debug::FILES, "Executing command: " << command); // FIXME UNICODE utf8 can be wrong for files buffer.message(_("Executing command: ") + from_utf8(command)); + PathChanger p(filename.onlyPath()); Systemcall one; one.startscript(Systemcall::DontWait, command, buffer.filePath()); diff --git a/status.20x b/status.20x index f389b328e6..8076a5dcf5 100644 --- a/status.20x +++ b/status.20x @@ -166,6 +166,9 @@ What's new - Fix bug when exporting documents containing the command/character "\iddots" in math to LyX 1.6.x. +- Fix forward-search on Windows with SumatraPDF and, as a by-product, + allow using SumatraPDF on Cygwin without the need for a wrapper script. + * USER INTERFACE -- 2.39.5