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
This commit is contained in:
Enrico Forestieri 2011-08-02 21:50:00 +00:00
parent 51ee38b7f5
commit 00d4b6c735
3 changed files with 9 additions and 42 deletions

View File

@ -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

View File

@ -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());

View File

@ -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