3 # This file is part of LyX, the document processor.
4 # Licence details can be found in the file COPYING.
6 # author Ronald Florence
9 # author Enrico Forestieri
11 # Full author contact details are available in file CREDITS
13 # This script passes filename and line number of a latex file to the lyxpipe
14 # of a running instance of LyX. If the filename is an absolute path pointing
15 # to an already existing latex file in the temp dir (produced by a preview,
16 # for example), LyX will jump to the corresponding line in the .lyx file.
17 # It may also be invoked by a viewer for performing a reverse DVI/PDF search.
21 # The output of this sed script is output to STDOUT
22 LYXPIPE
=`sed -n '/^\\\\serverpipe /{
23 # First consider that the file path may be quoted
24 s/^ *\\\\serverpipe \{1,\}\"\([^"]\{1,\}\)\" *$/\1/
28 s/^ *\\\\serverpipe \{1,\}\(.*\)/\1/
32 # Change from single to double shell quoting temporarily...
35 # Revert to single shell quotes
47 echo "Usage: $0 <latexfile> <lineno>"
54 *darwin
*) OSTYPE
=macosx
;;
57 if [ "$OSTYPE" = "macosx" ]; then
58 LYXSYSDIRS
="/Applications/LyX.app/Contents/Resources"
60 pushd "${HOME}/Library/Application Support" > /dev
/null
62 LYXSYSDIRS
="/usr/share/lyx /usr/local/share/lyx /opt/share/lyx"
64 pushd "${HOME}" > /dev
/null
67 for LYXDIR
in ${LYXBASEDIR}*
69 PREFERENCES
="${LYXDIR}/preferences"
70 test -r "${PREFERENCES}" ||
continue
71 # See if preferences file contains a \serverpipe entry
72 LYXPIPE
=`parse_serverpipe "${PREFERENCES}"`
73 # If it does and $LYXPIPE.in exists, break out of the loop
74 test -n "${LYXPIPE}" -a -r "${LYXPIPE}".
in && break || LYXPIPE
=""
79 if [ -z "${LYXPIPE}" ]; then
80 # The preferences file does not set lyxpipe, so check lyxrc.dist
81 for SUBDIR
in ${LYXSYSDIRS}
83 for LYXSYSDIR
in ${SUBDIR}*
85 LYXRC_DIST
=${LYXSYSDIR}/lyxrc.dist
86 test -r "${LYXRC_DIST}" ||
continue
87 # See if lyxrc.dist contains a \serverpipe entry
88 LYXPIPE
=`parse_serverpipe "${LYXRC_DIST}"`
89 # If it does and $LYXPIPE.in exists, break out of the loop
90 test -n "${LYXPIPE}" -a -r "${LYXPIPE}".
in && break || LYXPIPE
=""
92 test -n "${LYXPIPE}" && break
96 if [ -z "${LYXPIPE}" ]; then
97 echo "Unable to find the lyxpipe!"
103 if [ "${OSTYPE}" = "macosx" ]; then
104 file=`echo "$1" | sed 's|^/private||'`
105 elif [ "${OSTYPE}" = "cygwin" ]; then
106 file=`cygpath -a "$1"`
111 echo "Using the lyxpipe ${LYXPIPE}"
112 COMMAND
="LYXCMD:revdvi:server-goto-file-row:$file $2"
114 echo "$COMMAND" > "${LYXPIPE}".
in ||
exit
115 read < "${LYXPIPE}".out ||
exit