Skip to content

Draft: Highlight on synctex forward search

Gerd Wachsmuth requested to merge gerw/okular:synctex_highlight into master

The main goal of this branch is to show a highlight (with an orange rectangle) if a synctex forward search (from tex source code to pdf) is issued.

There is already some (partial) code for something similar, controlled by a setting ShowSourceLocationsGraphically. This setting seems to be undocumented, cannot be accessed by the GUI and it does not work with rotations, see https://invent.kde.org/graphics/okular/-/blob/master/gui/pagepainter.cpp#L489.

The highlight is implemented similar to a search highlight, such that the code in pagepainter.cpp can be reused. Therefore, I introduced a new SYNCTEX_SEARCH_ID. The highlight is deleted upon pressing Esc.

The PR further contains some improvements around synctex:

  • It adds column support. [Note that synctex itself is able to handle column numbers, but the main problem is that most (all?) tex engines does not output column numbers in the synctex file]
  • At one point, one have to use 72.27 to convert tex points to inches.
  • showSourceLocation is exposed (in particular) to the qdbus interface. Currently, one can only use openDocument which (unnecessarily reloads the document even if it is already open). Now, if the correct document is already opened, we can call
qdbus org.kde.okular-0815 /okular showSourceLocation something.tex 4711 1

Finally, I would like to add that I created this PR to get some feedback, the changes are not polished yet. The old code around the ShowSourceLocationsGraphically-option could be deleted, maybe the option could be reused?

Merge request reports