[latexila] SyncTeX: always use the cursor position for the forward search
- From: SÃbastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] SyncTeX: always use the cursor position for the forward search
- Date: Sun, 9 Sep 2012 22:15:37 +0000 (UTC)
commit bc9778cb6b2296b17e51cf6a998d0f129b109abc
Author: SÃbastien Wilmet <swilmet gnome org>
Date: Sun Sep 9 18:44:18 2012 +0200
SyncTeX: always use the cursor position for the forward search
src/main_window.vala | 9 +--------
src/synctex.vala | 29 +++++++++++++++++++++--------
2 files changed, 22 insertions(+), 16 deletions(-)
---
diff --git a/src/main_window.vala b/src/main_window.vala
index 2d1b1bb..2b92961 100644
--- a/src/main_window.vala
+++ b/src/main_window.vala
@@ -1087,15 +1087,8 @@ public class MainWindow : Window
{
return_if_fail (active_tab != null);
- TextIter iter;
- TextMark insert = active_document.get_insert ();
- active_document.get_iter_at_mark (out iter, insert);
-
- int line = iter.get_line () + 1;
- int column = iter.get_line_offset ();
-
Synctex synctex = new Synctex ();
- synctex.forward_search (active_document, line, column);
+ synctex.forward_search (active_document);
}
/* Projects */
diff --git a/src/synctex.vala b/src/synctex.vala
index c822dcf..d49a017 100644
--- a/src/synctex.vala
+++ b/src/synctex.vala
@@ -21,6 +21,8 @@
// SyncTeX: forward and backward search with evince.
+using Gtk;
+
[DBus (name = "org.gnome.evince.Daemon")]
interface EvinceDaemon : Object
{
@@ -52,7 +54,7 @@ interface EvinceWindow : Object
public class Synctex : Object
{
- public void forward_search (Document doc, int line, int column)
+ public void forward_search (Document doc)
{
string? pdf_uri = get_pdf_uri (doc);
return_if_fail (pdf_uri != null);
@@ -63,7 +65,22 @@ public class Synctex : Object
return_if_fail (doc.location != null);
string tex_path = doc.location.get_path ();
- sync_view (ev_window, tex_path, line, column);
+ DocPosition pos = get_doc_position (doc);
+ sync_view (ev_window, tex_path, pos);
+ }
+
+ private DocPosition get_doc_position (Document doc)
+ {
+ TextIter iter;
+ TextMark insert = doc.get_insert ();
+ doc.get_iter_at_mark (out iter, insert);
+
+ DocPosition pos = DocPosition ();
+
+ pos.line = iter.get_line () + 1;
+ pos.column = iter.get_line_offset ();
+
+ return pos;
}
private string? get_pdf_uri (Document doc)
@@ -151,15 +168,11 @@ public class Synctex : Object
return window;
}
- private void sync_view (EvinceWindow window, string tex_path, int line, int column)
+ private void sync_view (EvinceWindow window, string tex_path, DocPosition pos)
{
- DocPosition source_point = DocPosition ();
- source_point.line = line;
- source_point.column = column;
-
try
{
- window.sync_view (tex_path, source_point, Gdk.CURRENT_TIME);
+ window.sync_view (tex_path, pos, Gdk.CURRENT_TIME);
}
catch (IOError e)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]