Skip to content

Commit

Permalink
Create a new undo action when inserting templates
Browse files Browse the repository at this point in the history
This makes sure the user can undo the template insertion without also
undoing a previous action.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/branches/0.20.1@5783 ea778897-0a13-0410-b9d1-a72fbfd435f5
  • Loading branch information
b4n committed May 9, 2011
1 parent 18d230f commit 1efa316
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Expand Up @@ -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>
Expand Down
14 changes: 14 additions & 0 deletions src/callbacks.c
Expand Up @@ -1299,7 +1299,9 @@ on_comments_function_activate (GtkMenuItem *menuitem,

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);
}

Expand Down Expand Up @@ -1339,7 +1341,9 @@ on_comments_gpl_activate (GtkMenuItem *menuitem,

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);
}

Expand All @@ -1358,7 +1362,9 @@ on_comments_bsd_activate (GtkMenuItem *menuitem,

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);

}
Expand All @@ -1374,10 +1380,12 @@ on_comments_changelog_activate (GtkMenuItem *menuitem,
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);
}
Expand All @@ -1398,8 +1406,10 @@ on_comments_fileheader_activate (GtkMenuItem *menuitem,
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);
}

Expand Down Expand Up @@ -1451,8 +1461,10 @@ on_insert_date_activate (GtkMenuItem *menuitem,
{
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
Expand Down Expand Up @@ -1487,7 +1499,9 @@ on_insert_include_activate (GtkMenuItem *menuitem,
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);
Expand Down

0 comments on commit 1efa316

Please sign in to comment.