Ed Sykes writes:

> 
> Hi,
> 
> Just wondering if someone could help on this issue:
> 
> Is there a way to configure LyX so that when I double-click on an area in 
> Yap it brings me to that line in LyX?

Yes, but you have to use the Cygwin version of LyX.

> Right now, when I double-click in Yap, it comes up with:
> "MiKTeX Problem Report:
> The source file could not be opened because the page contains no source 
> links."

You have to change the LaTeX->DVI converter in Tools->Preferences->Converters
to "latex -src-specials $$i". As an alternative to redefining the converter,
you can put "\usepackage[active]{srcltx}" in the preamble of the LyX file.

Now, in the View->Options menu in yap, under the "Inverse DVI Search" tab,
set the path to the batch file lyxeditor.bat below. Enter something like
"C:\cygwin\usr\local\bin\lyxeditor.bat %f %l"

This 2-line batch file is a wrapper for the lyxeditor.sh bash script which
does the real work and that you also find pasted below (put both files in
/usr/local/bin and make sure that they are executable).

-----8<-----8<----- lyxeditor.bat  -----8<-----8<-----8<-----
@echo off
c:\cygwin\bin\bash /usr/local/bin/lyxeditor.sh %1 %2
-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----

-----8<-----8<-----  lyxeditor.sh  -----8<-----8<-----8<-----
# Pass filename and line number of a latex file to the lyxpipe of a running
# instance of LyX. LyX will jump to the corresponding line in the .lyx file
# being previewed in either yap or xdvi.
# This script is directly invoked by the dvi viewer when initiating a
# reverse dvi search (yap uses double click, xdvi ctrl-click).
# When using yap, this script should be called through a wrapper batch file.
# Author: Enrico Forestieri.

# parse_serverpipe is by Angus Leeming
parse_serverpipe()
{
        # The output of this sed script is output to STDOUT
        LYXPIPE=`sed -n '/^\\\\serverpipe /{
# First consider that the file path may be quoted
s/^ *\\\\serverpipe \{1,\}\"\([^"]\{1,\}\)\" *$/\1/
tfound

# Now, unquoted
s/^ *\\\\serverpipe \{1,\}\(.*\)/\1/
s/ *$//

:found
# Change from single to double shell quoting temporarily...
'"
[EMAIL PROTECTED]/@${HOME}/@
# Revert to single shell quotes
"'

p
q
}' "$1"`

        echo "${LYXPIPE}"
        unset LYXPIPE
}

LYXPIPE=""

for LYXDIR in .lyx .lyx-1.6.0svn .lyx-1.3.7
do
        PREFERENCES="${HOME}/${LYXDIR}/preferences"
        test -r "${PREFERENCES}" || continue
        # See if preferences file contains a \serverpipe entry
        LYXPIPE=`parse_serverpipe "${PREFERENCES}"`
        # If it does and $LYXPIPE.in exists, break out of the loop
        test -n "${LYXPIPE}" -a -r "${LYXPIPE}".in && break || LYXPIPE=""
done


test -z "${LYXPIPE}" && {
        # The preferences file does not set lyxpipe, so check lyxrc.dist
        LYXRC_DIST="/usr/local/share/lyx/lyxrc.dist"
        test -r "${LYXRC_DIST}" || exit
        # See if lyxrc.dist contains a \serverpipe entry
        LYXPIPE=`parse_serverpipe "${LYXRC_DIST}"`
        # If it does not, or $LYXPIPE.in does not exists, exit
        test -z "${LYXPIPE}" -o ! -r "${LYXPIPE}".in && exit
}

# Let's do the job

file=`cygpath $1`

echo "Using the lyxpipe ${LYXPIPE}"
COMMAND="LYXCMD:revdvi:server-goto-file-row:$file $2"
echo "$COMMAND"
echo "$COMMAND" > "${LYXPIPE}".in || exit
read < "${LYXPIPE}".out || exit
-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----

Reply via email to