I've had reverse/inverse search working on my standard version of lyx
for windows for a while without using cygwin. I've not noticed anyone
posting about how to do it or providing scripts so I thought I'd share
mine. I've written it up here http://www.thousandmonkeys.com/?p=96 but
here are the really important bits. Hope this gets it working for
someone.

Requirements:

    * Python 2.6 (might work with other versions not tried it)
    * win32api – Python extension (to find the short pathnames)
    * SumatraPDF – This is the only appropriate windows pdf viewer I
am aware of. It prints badly though in my experience.
    * ReverseSearch – The scripts defined below

Setup:

    * Set the lyxserver pipe (under paths in the settings) to
“\\.\pipe\lyxserver”
    * put “SumatraPDF.bat”, “search.py” and “SumatraPDF.exe” in “../lyx16/bin”
    * Update the paths in “SumatraPDF.bat” to be correct for your
setup (mine is 64bit), use pythonw.exe to supress the console
    * Set your in “PDF (pdflatex)” viewer field (in file formats) to:
SumatraPDF.bat
    * Set the “Latex (pdflatex) -> PDF (pdflatex)” converter to
“pdflatex –synctex=-1 $$i”

SumatraPDF.bat
-------------------------------------------
start "SumatraPDF.exe" "SumatraPDF.exe" -inverse-search
"C:/Progra~1/Python26/pythonw.exe C:/Progra~2/lyx16/bin/search.py %%l
%%f" %1
exit

search.py
------------------------------------------
# author Chris Lingwood
#
# This script (along with sumatra.bat) enables DVI/PDF search in
windows using Sumatra

import sys
import time
import os
import win32api

#Debug output to ensure the path name is picked up properly
print(sys.argv[1])
print(sys.argv[2:])

line = sys.argv[1]
filename = ' '.join(sys.argv[2:])
print(filename)

#We have to get the windows short filename to avoid having spaces
which upsets the command
filename = win32api.GetShortPathName(filename);
#create the command to be send to the lyx server pipe with an echo to
a windows pipe
command = "echo LYXCMD:revdvi:server-goto-file-row:"+filename+"
"+line+">> \\\\.\pipe\lyxserver.in"

#print it for debugging and send it to the os
print(command)
os.system(command)

#Uncomment the next line if there are problems, it lets you see  the
debugging output (this is still supressed with pythonw.exe though)
#time.sleep(100)

I attempted to post this the to the list a while back but it never
made it for some reason. That version doesn't work with newer versions
of lyx (or so I'm told), hence the repost.

Chris Lingwood

Reply via email to