After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 647146 - RFE: Non D-Bus forward/backward search for SyncTeX-enabled docs
RFE: Non D-Bus forward/backward search for SyncTeX-enabled docs
Status: RESOLVED OBSOLETE
Product: evince
Classification: Core
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: Evince Maintainers
Evince Maintainers
Depends on:
Blocks:
 
 
Reported: 2011-04-08 08:40 UTC by Luke Hutchison
Modified: 2018-05-22 14:11 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Luke Hutchison 2011-04-08 08:40:26 UTC
It would be very helpful if there were a non D-Bus version of forward and backward search for linking synctex-enabled PDF back to a source editor.

BACKWARD SEARCH:

An external editor command would be specified as a commandline parameter to evince.  e.g. when viewing a file, LyX could launch evince as:

evince /path/to/file.pdf --backward-search-cmd="lyxclient -g %f %l"

When the user Ctrl-clicks on a synctex-enabled doc, as well as the usual D-Bus method firing, if this parameter is specified then Evince will launch the specified external command.

FORWARD SEARCH:

Evince supports this already (though see Bug #647138). Evince's support only works to page resolution.  It would be helpful if Evince scrolled not just to the correct page, but also moved the search point to the middle of the window, and highlighted/selected the bounding box of the page element containing the search point (word/paragraph etc.), to make it much easier for your eye to find the search point.

Evince could add a commandline parameter that specifies a rectangle on a specific page of a document that should be scrolled to the center of the window upon opening the document, so that synctex output could be used with greater accuracy than just jumping to the right page.

Currently LyX has as its default forward search command something like:

synctex view -i $$n:0:$$t -o $$o -x "evince -i %{page+1} $$o"

It would be great if you could do something like:

synctex view -i $$n:0:$$t -o $$o -x "evince -i %{page+1} $$o
--jump-to-rect=%{x},%{y},%{h},%{v},%{width},%{height}"

The point %{x},%{y} would be displayed at the middle of the page specified with
the -i switch, and the rectangle %{h},%{v},%{width},%{height} could be selected
by default to draw the user's eye to the text unit that the forward search
point is contained within.

If you don't want to add another commandline parameter, maybe it would be possible to extend the -i and -p switches to take a page number followed by an optional x,y coord followed by an optional bounding box to select:

evince [-i pagenum[,x,y[,h,v,w,h]]] file.pdf



For reference, here is the relevant output from "synctex help view".  Note that %{x},%{y} etc. are floating point numbers:

-x viewer-command
       Normally the synctex tool outputs its result to the stdout.
       It is possible to launch an external tool with the result.
       The viewer-command is a printf like format string with following
specifiers.
       %{output} is the name specifier of the main document, without path
extension.
       %{page} is the 0 based page number specifier, %{page+1} is the 1 based
page number specifier.
       To synchronize by point, %{x} is the x coordinate specifier, %{y} is the
y coordinate specifier,
       both in dots and relative to the top left corner of the page.
       To synchronize by box,
       %{h} is the horizontal coordinate specifier of the origin of the
enclosing box,
       %{v} is the vertical coordinate specifier of the origin of the enclosing
box,
       both in dots and relative to the upper left corner of the page.
       They may be different from the preceding pair of coordinates.
       %{width} is the width specifier, %{height} is the height specifier of
the enclosing box.
       The latter dimension is naturally counted from bottom to top.
       There is no notion of depth for such a box.
       To synchronize by content, %{before} is the word before,
       %{offset} is the offset specifier, %{middle} is the middle word, and
%{after} is the word after.
Comment 1 Luke Hutchison 2011-04-08 08:41:12 UTC
For reference, the DBus support for SyncTeX is covered in Bug 543503.
Comment 2 José Aliste 2011-04-08 09:56:48 UTC
Do you use evince without DBUS support enabled? if you use evince with DBUS support enabled, then we are going to release soon a small set of python scripts that allow you to do what you want (using dbus under the hood)...
Comment 3 Luke Hutchison 2011-04-08 11:26:57 UTC
I do use evince with DBUS support enabled.  I discovered these scripts here: http://code.google.com/p/lundgaard/ , are those the scripts you are referring to?  They do work well.  I had to hack the bash script a bit to get it to work though, because the necessary directory name was missing from the lyxclient command and the if statement (maybe LyX-2.0.0-rc2 is not setting the current directory as expected or something?).


#!/bin/sh
PDFFILE="$1"
PDFDIR=`dirname "$PDFFILE"`
EDITORCMD="lyxclient -g $PDFDIR/%f %l"

if [ -f "$PDFFILE" ];then
	if [ -f "$PDFDIR"/`basename "$PDFFILE" .pdf`.synctex ];then
		evince_backward_search "$PDFFILE" "$EDITORCMD"&
		BACKWARD_SEARCH_PID=$!
		echo $BACKWARD_SEARCH_PID
	fi
fi

/usr/bin/evince "$@"

if [ "$BACKWARD_SEARCH_PID" ];then
	echo "Killing $BACKWARD_SEARCH_PID"
	kill $BACKWARD_SEARCH_PID
fi



Also the script needs to be modified to work with both .synctex and .synctex.gz extensions (whichever is present).

And lyx' default pdf viewing strategy of calling xdg-open won't work, the above bash script (that is named "evince") has to be called explicitly instead of calling /usr/bin/evince.  Is it possible when using xdg-open for Evince to figure out what client called it, so it would know how to automatically set up backwards search for a few clients?

A bigger problem is that if Evince is opened initially by a forward search operation, then the PDF document is opened without backward search enabled.  If it is opened through the "evince" bash script above (replacing xdg-open for viewing a refreshed document), then both forward and backward search work while the document stays open.
Comment 4 José Aliste 2011-04-08 11:49:27 UTC
I am not sure that these are the same scripts. I am referring to http://ubuntuforums.org/showthread.php?p=10610416. I still have to find the time to check that everything works, etc.
Comment 5 Luke Hutchison 2011-04-08 13:03:36 UTC
Sorry, I pasted the wrong link in Comment 3. I am using the exact same scripts as you. My previous comments apply to those scripts.

One other thing, I suggest renaming the bash wrapper script that is called "evince" something like "evince-synctex" instead, so that all three scripts can be installed in /usr/bin without naming conflicts.

Thanks!
Comment 6 Tobias Wolf 2011-04-08 20:12:14 UTC
For Vim it’s better to use "vim --remote-silent" and then system('evince_forward_search'. ...) to reduce message spam.

And adding ":match Search /\%%ll/" to give --remote '+%l<Enter>:match Search /\%%ll/' will transiently highlight the matched line.
Comment 7 GNOME Infrastructure Team 2018-05-22 14:11:19 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/evince/issues/210.