SF.net SVN: geany-plugins:[480] trunk/geanylatex

frlan at users.sourceforge.net frlan at xxxxx
Sun Feb 15 22:54:13 UTC 2009


Revision: 480
          http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=480&view=rev
Author:   frlan
Date:     2009-02-15 22:54:13 +0000 (Sun, 15 Feb 2009)

Log Message:
-----------
GeanyLaTeX: Added a keybinding for newline \\ and extend insert_string() to also support reseting cursor after inserting text if needed

Modified Paths:
--------------
    trunk/geanylatex/ChangeLog
    trunk/geanylatex/src/bibtex.c
    trunk/geanylatex/src/geanylatex.c
    trunk/geanylatex/src/geanylatex.h

Modified: trunk/geanylatex/ChangeLog
===================================================================
--- trunk/geanylatex/ChangeLog	2009-02-15 22:09:33 UTC (rev 479)
+++ trunk/geanylatex/ChangeLog	2009-02-15 22:54:13 UTC (rev 480)
@@ -1,3 +1,10 @@
+2009-02-14  Frank Lanitz  <frank(at)frank(dot)uvena(dot)de>
+
+ * Added a keyboard shortcut for inserting a new line ( \\ ).
+ * Make cursor placed behind inserted text for most cases. 
+   (Inserting BibTeX entries will not reset the cursor)
+
+
 2009-01-19  Frank Lanitz  <frank(at)frank(dot)uvena(dot)de>
 
  * Improved reference dialog to offer labels based on aux file

Modified: trunk/geanylatex/src/bibtex.c
===================================================================
--- trunk/geanylatex/src/bibtex.c	2009-02-15 22:09:33 UTC (rev 479)
+++ trunk/geanylatex/src/bibtex.c	2009-02-15 22:54:13 UTC (rev 480)
@@ -135,7 +135,7 @@
 	}
 
 	output = g_strconcat(output, "}\n", NULL);
-	insert_string(output);
+	insert_string(output, FALSE);
 
 	g_free(output);
 }

Modified: trunk/geanylatex/src/geanylatex.c
===================================================================
--- trunk/geanylatex/src/geanylatex.c	2009-02-15 22:09:33 UTC (rev 479)
+++ trunk/geanylatex/src/geanylatex.c	2009-02-15 22:54:13 UTC (rev 480)
@@ -52,23 +52,29 @@
 	LATEX_WIZZARD_KB,
 	LATEX_INSERT_LABEL_KB,
 	LATEX_INSERT_REF_KB,
-/*	LATEX_INSERT_BIBTEX_ENTRY_KB,*/
+	LATEX_INSERT_NEWLINE,
 	COUNT_KB
 };
 
 PLUGIN_KEY_GROUP(geanylatex, COUNT_KB)
 
 void
-insert_string(gchar *string)
+insert_string(gchar *string, gboolean reset_position)
 {
 	GeanyDocument *doc = NULL;
 
+
 	doc = document_get_current();
 
-	if (doc != NULL)
+	if (doc != NULL && string != NULL)
 	{
 		gint pos = sci_get_current_position(doc->editor->sci);
 		sci_insert_text(doc->editor->sci, pos, string);
+		if (reset_position == TRUE)
+		{
+			gint len = strlen(string);
+			sci_set_current_position(doc->editor->sci, pos + len, TRUE);
+		}
 	}
 }
 
@@ -84,7 +90,7 @@
 char_insert_activated(G_GNUC_UNUSED GtkMenuItem * menuitem,
 					  G_GNUC_UNUSED gpointer gdata)
 {
-	insert_string(get_latex_command(GPOINTER_TO_INT(gdata)));
+	insert_string(get_latex_command(GPOINTER_TO_INT(gdata)), TRUE);
 }
 
 
@@ -127,7 +133,7 @@
 		gchar *label_str = NULL;
 		label_str = g_strconcat("\\label{",g_strdup(gtk_entry_get_text(
 			GTK_ENTRY(textbox_label))), "}", NULL);
-		insert_string(label_str);
+		insert_string(label_str, TRUE);
 	}
 
 	gtk_widget_destroy(dialog);
@@ -202,7 +208,7 @@
 
 		if (ref_string != NULL)
 		{
-			insert_string(ref_string);
+			insert_string(ref_string, TRUE);
 			g_free(ref_string);
 		}
 	}
@@ -223,6 +229,7 @@
 		G_CALLBACK(callback), GINT_TO_POINTER(letter));
 }
 
+
 /* returns -1, if there are more than gint can work with or any other error
  * returns 0, if categorie is empty
  * if gint categorie is -1, function will count every element.
@@ -268,6 +275,7 @@
 	return i;
 }
 
+
 void sub_menu_init(GtkWidget *base_menu, SubMenuTemplate *menu_template,
 				   CategoryName *category_name,
 				   SubMenuCallback callback_function)
@@ -832,6 +840,11 @@
 	wizard_activated(NULL, NULL);
 }
 
+static void kb_insert_newline(G_GNUC_UNUSED guint key_id)
+{
+	insert_string("\\\\\n", TRUE);
+}
+
 /*static void kb_bibtex_entry_insert(G_GNUC_UNUSED guint key_id)
 {
 	insert_bibtex_entry(NULL, NULL);
@@ -925,6 +938,8 @@
 		0, 0, "insert_latex_label", _("Insert \\label"), menu_latex_label);
 	keybindings_set_item(plugin_key_group, LATEX_INSERT_REF_KB, kbref_insert,
 		0, 0, "insert_latex_ref", _("Insert \\ref"), menu_latex_ref);
+	keybindings_set_item(plugin_key_group, LATEX_INSERT_NEWLINE, kb_insert_newline, 
+		0, 0, "insert_new_line", _("Insert linebreak \\\\ "), NULL);
 /*	keybindings_set_item(plugin_key_group, LATEX_INSERT_BIBTEX_ENTRY_KB,
 		kb_bibtex_entry_insert, 0, 0, "insert_latex_bibtex_entry", _("Add BiBTeX entry"),
 		menu_latex_bibtex); */

Modified: trunk/geanylatex/src/geanylatex.h
===================================================================
--- trunk/geanylatex/src/geanylatex.h	2009-02-15 22:09:33 UTC (rev 479)
+++ trunk/geanylatex/src/geanylatex.h	2009-02-15 22:54:13 UTC (rev 480)
@@ -106,6 +106,6 @@
 
 #define MAX_MENU_ENTRIES 20
 
-extern void insert_string(gchar *string);
+extern void insert_string(gchar *string, gboolean reset_position);
 
 #endif


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Plugins-Commits mailing list