SF.net SVN: geany:[5783] branches/0.20.1

colombanw at users.sourceforge.net colombanw at xxxxx
Mon May 9 17:37:40 UTC 2011


Revision: 5783
          http://geany.svn.sourceforge.net/geany/?rev=5783&view=rev
Author:   colombanw
Date:     2011-05-09 17:37:39 +0000 (Mon, 09 May 2011)

Log Message:
-----------
Create a new undo action when inserting templates

This makes sure the user can undo the template insertion without also
undoing a previous action.

Modified Paths:
--------------
    branches/0.20.1/ChangeLog
    branches/0.20.1/src/callbacks.c

Modified: branches/0.20.1/ChangeLog
===================================================================
--- branches/0.20.1/ChangeLog	2011-05-09 17:37:17 UTC (rev 5782)
+++ branches/0.20.1/ChangeLog	2011-05-09 17:37:39 UTC (rev 5783)
@@ -11,6 +11,9 @@
  * src/toolbar.c:
    Correctly expand the menubar if the toolbar is appended to it but
    not visible (closes #3204955).
+ * src/callbacks.c:
+   Create a new undo action when inserting templates, making sure the user
+   can undo the template insertion without also undoing a previous action.
 
 
 2011-05-08  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>

Modified: branches/0.20.1/src/callbacks.c
===================================================================
--- branches/0.20.1/src/callbacks.c	2011-05-09 17:37:17 UTC (rev 5782)
+++ branches/0.20.1/src/callbacks.c	2011-05-09 17:37:39 UTC (rev 5783)
@@ -1299,7 +1299,9 @@
 
 	text = templates_get_template_function(doc, cur_tag);
 
+	sci_start_undo_action(doc->editor->sci);
 	sci_insert_text(doc->editor->sci, pos, text);
+	sci_end_undo_action(doc->editor->sci);
 	g_free(text);
 }
 
@@ -1339,7 +1341,9 @@
 
 	verify_click_pos(doc); /* make sure that the click_pos is valid */
 
+	sci_start_undo_action(doc->editor->sci);
 	sci_insert_text(doc->editor->sci, editor_info.click_pos, text);
+	sci_end_undo_action(doc->editor->sci);
 	g_free(text);
 }
 
@@ -1358,7 +1362,9 @@
 
 	verify_click_pos(doc); /* make sure that the click_pos is valid */
 
+	sci_start_undo_action(doc->editor->sci);
 	sci_insert_text(doc->editor->sci, editor_info.click_pos, text);
+	sci_end_undo_action(doc->editor->sci);
 	g_free(text);
 
 }
@@ -1374,10 +1380,12 @@
 	g_return_if_fail(doc != NULL);
 
 	text = templates_get_template_changelog(doc);
+	sci_start_undo_action(doc->editor->sci);
 	sci_insert_text(doc->editor->sci, 0, text);
 	/* sets the cursor to the right position to type the changelog text,
 	 * the template has 21 chars + length of name and email */
 	sci_goto_pos(doc->editor->sci, 21 + strlen(template_prefs.developer) + strlen(template_prefs.mail), TRUE);
+	sci_end_undo_action(doc->editor->sci);
 
 	g_free(text);
 }
@@ -1398,8 +1406,10 @@
 	fname = doc->file_name;
 	text = templates_get_template_fileheader(FILETYPE_ID(ft), fname);
 
+	sci_start_undo_action(doc->editor->sci);
 	sci_insert_text(doc->editor->sci, 0, text);
 	sci_goto_pos(doc->editor->sci, 0, FALSE);
+	sci_end_undo_action(doc->editor->sci);
 	g_free(text);
 }
 
@@ -1451,8 +1461,10 @@
 	{
 		verify_click_pos(doc); /* make sure that the click_pos is valid */
 
+		sci_start_undo_action(doc->editor->sci);
 		sci_insert_text(doc->editor->sci, editor_info.click_pos, time_str);
 		sci_goto_pos(doc->editor->sci, editor_info.click_pos + strlen(time_str), FALSE);
+		sci_end_undo_action(doc->editor->sci);
 		g_free(time_str);
 	}
 	else
@@ -1487,7 +1499,9 @@
 		text = g_strconcat("#include <", user_data, ">\n", NULL);
 	}
 
+	sci_start_undo_action(doc->editor->sci);
 	sci_insert_text(doc->editor->sci, editor_info.click_pos, text);
+	sci_end_undo_action(doc->editor->sci);
 	g_free(text);
 	if (pos >= 0)
 		sci_goto_pos(doc->editor->sci, pos, FALSE);


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



More information about the Commits mailing list