mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 13:46:43 +00:00
e79782c4cc
The scripts have been initially developed by Benjamin Kellermann (2011) as a derivation of gedit-synctex-plugin by José Aliste (https://github.com/jaliste/gedit-synctex-plugin, 2010) and published on https://ubuntuforums.org/showthread.php?t=1716268. The work here is based on a further derivation of this work for Sublime Text LaTeX Tools (https://github.com/SublimeText/LaTeXTools/tree/master/evince). Adaptations for the use with LyX as well as the initial translation of the evince_sync bash script to python have been done by myself. The python code (particularly evince_sync_lyx) needs audit!
55 lines
1.5 KiB
Python
Executable File
55 lines
1.5 KiB
Python
Executable File
#!/usr/bin/python
|
|
|
|
# Copyright (C) 2010 Jose Aliste <jose.aliste@gmail.com>
|
|
# 2011 Benjamin Kellermann <Benjamin.Kellermann@tu-dresden.de>
|
|
#
|
|
# Translated from Bash to Python by Juergen Spitzmueller <spitz@lyx.org> 2017.
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify it under
|
|
# the terms of the GNU General Public Licence as published by the Free Software
|
|
# Foundation; either version 2 of the Licence, or (at your option) any later
|
|
# version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public Licence for more
|
|
# details.
|
|
#
|
|
# You should have received a copy of the GNU General Public Licence along with
|
|
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
|
|
# Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
import sys, os.path
|
|
from subprocess import Popen, call
|
|
|
|
editor_cmd = "lyxclient -g %f %l"
|
|
|
|
def print_usage():
|
|
print("Usage: evince_sync_lyx pdf_file")
|
|
sys.exit(1)
|
|
|
|
if len(sys.argv) != 2:
|
|
print_usage()
|
|
|
|
pdf_file = os.path.abspath(sys.argv[1])
|
|
|
|
if not os.path.isfile(pdf_file):
|
|
print_usage()
|
|
|
|
synctex_file, ext = os.path.splitext(pdf_file)
|
|
|
|
synctex_file += ".synctex.gz"
|
|
|
|
SyncTeX = False
|
|
|
|
if os.path.isfile(synctex_file):
|
|
bsproc = Popen(["evince_backward_search", pdf_file, editor_cmd])
|
|
SyncTeX = True
|
|
|
|
vproc = Popen(['evince', pdf_file])
|
|
vproc.wait()
|
|
|
|
if SyncTeX:
|
|
bsproc.terminate()
|
|
|