Re: Gedit/LaTeXPlugin/XDvi & Reverse Search



Hi, here are two patches fixing the problem for me (with
LaTeXPlugin-0.1.3.1 and gedit-2.20.3) with (at least I suppose from the
initial code) two features more: 1) the line corresponding to the point clicked on in the dvi is
highlighted in the source, instead of just having the cursor on it;
2) the gedit window is pulled to the front.

I don't know if I achieved this the "correct" way, as I'm really new to
PyGTK and to LaTeXPlugin, which is definitely not a ten-lines plugin, but
at least it works!

Many thanks to Michael for this really great plugin! It is really useful.

Best regards,
Yannick Voglaire


PS: I dont know how to attach files so here are the patches:


---------------- DBusController.patch ----------------

--- DBusController.py +++ DBusController.py.modif
@@ -23,6 +23,8 @@
BUS_NAME = 'org.gedit.LaTeXPlugin'
OBJECT_PATH = '/org/gedit/DBusInterface'

+DVI_INVERSE_SEARCH = 2 # 0, 1 are ERROR, WARNING in
builder/Messages.py
+
try:
from dbus import SessionBus
from dbus.service import Object, method, BusName
@@ -42,9 +44,16 @@
def inverse(self, filename, line):
debug(self, "Got inverse DVI search: %s %s" % (filename, line))

- self.__instance.set_active_tab_by_filename(filename)
- wrapper = self.__instance.get_active_wrapper()
- wrapper.select_line(line - 1)
+ tab = self.__instance.window.get_tab_from_uri(filename)
+ self.__instance.window.set_active_tab(tab)
+
+ helper =
self.__instance.document_helper_manager.find_helper(filename)
+ helper.jump_to_line(line - 1)
+
+ helper.language_helper.reset_dvi_highlight()
+ helper.language_helper.highlight_line(line-1, DVI_INVERSE_SEARCH)
+
+ self.__instance.window.present()

except ImportError:
error(self, None, "Failed to import D-Bus bindings")




---------------- LatexLanguageHelper.patch ----------------

--- LatexLanguageHelper.py +++ LatexLanguageHelper.py.modif
@@ -28,10 +28,12 @@
from LaTeXPlugin.autocomplete.Controller import Controller
from LaTeXPlugin.common import TEXT, MATH, ConditionalSource,
PrefaceSource
from LaTeXPlugin.builder.Message import ERROR, WARNING
+from LaTeXPlugin.ipc.DBusController import DVI_INVERSE_SEARCH
from LaTeXPlugin.bibtex.BibTeXFile import BibTeXFile

ERROR_COLOR = "#ffe6e6"
WARNING_COLOR = "#fff2cc"
+DVI_INVERSE_SEARCH_COLOR = "#edf2ff"

_pattern_indent = compile("[ \t]+")

@@ -51,6 +53,7 @@
try:
self.__buffer.create_tag("error", background=ERROR_COLOR)
self.__buffer.create_tag("warning", background=WARNING_COLOR)
+ self.__buffer.create_tag("dvi_inverse_search",
background=DVI_INVERSE_SEARCH_COLOR)
except TypeError, s:
# FIXME: this happens when deactivating and reactivating the plugin
error(self, "__init__", s)
@@ -337,6 +340,8 @@

if severity == WARNING:
self.__buffer.apply_tag_by_name("warning", iter_l, iter_r)
+ elif severity == DVI_INVERSE_SEARCH:
+ self.__buffer.apply_tag_by_name("dvi_inverse_search", iter_l, iter_r)
else:
self.__buffer.apply_tag_by_name("error", iter_l, iter_r)

@@ -349,6 +354,17 @@
self.__buffer.remove_tag_by_name("error",
self.__buffer.get_start_iter(), self.__buffer.get_end_iter())
self.__buffer.remove_tag_by_name("warning",
self.__buffer.get_start_iter(),
+ self.__buffer.get_end_iter())
+ self.__buffer.remove_tag_by_name("dvi_inverse_search",
self.__buffer.get_start_iter(),
+ self.__buffer.get_end_iter())
+
+ def reset_dvi_highlight(self):
+ """
+ Undo dvi inverse search highlighting
+
+ Called at inverse from DBusInterface
+ """
+ self.__buffer.remove_tag_by_name("dvi_inverse_search",
self.__buffer.get_start_iter(),
self.__buffer.get_end_iter())

@property




--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx



Relevant Pages

  • Re: Dropped Realbasic Feature: Export Project as Text File
    ... The Monkeybread Software Realbasic Plugin v6.1. ... with said said features so as to make people think the feature was not ... Real Software's attitude that you are their slave ...
    (comp.lang.basic.realbasic)
  • [ANN] Firedrop 0.2.2
    ... It keeps your blog source files on ... and has all the features you expect from a ... Addition of the Firedrop2 banner by Stewart Midwinter. ... Extension to the plugin protocol for extra plugin capabilities ...
    (comp.lang.python)
  • [ANN] Firedrop 0.2.2
    ... It keeps your blog source files on ... and has all the features you expect from a ... Addition of the Firedrop2 banner by Stewart Midwinter. ... Extension to the plugin protocol for extra plugin capabilities ...
    (comp.lang.python.announce)
  • Re: Tool for document management
    ... Like text to columns in Calc without resorting to a plugin? ... no-brainer. ... is useful though if you are desperate.) ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: Just Starting & Need Photo Editor Guidance
    ... Another freeware program is called PhotoFiltre and while it does not ... inherently have a means to constrain crop, there is supposedly a plugin ... so not sure what editing features it has. ... features disabled like the RAW converter. ...
    (rec.photo.digital)