SF.net SVN: geany: [578] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Tue Jul 18 10:49:00 UTC 2006
Revision: 578
Author: eht16
Date: 2006-07-18 03:48:51 -0700 (Tue, 18 Jul 2006)
ViewCVS: http://svn.sourceforge.net/geany/?rev=578&view=rev
Log Message:
-----------
Added option to replace escape sequences in Find and Replace dialog.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/callbacks.c
trunk/src/dialogs.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-07-17 19:48:42 UTC (rev 577)
+++ trunk/ChangeLog 2006-07-18 10:48:51 UTC (rev 578)
@@ -1,3 +1,9 @@
+2006-07-18 Enrico Tröger <enrico.troeger at uvena.de>
+
+ * src/dialogs.c, src/callbacks.c:
+ Added option to replace escape sequences in Find and Replace dialog.
+
+
2006-07-17 Nick Treleaven <nick.treleaven at btinternet.com>
* doc/scikeybinding.docbook, doc/geany.docbook, doc/geany_gpl.docbook:
Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c 2006-07-17 19:48:42 UTC (rev 577)
+++ trunk/src/callbacks.c 2006-07-18 10:48:51 UTC (rev 578)
@@ -80,8 +80,10 @@
// the flags given in the search dialog(stored statically for "find next" and "replace")
static gint search_flags;
static gboolean search_backwards;
+static gboolean search_replace_escape;
static gint search_flags_re;
static gboolean search_backwards_re;
+static gboolean search_replace_escape_re;
static gboolean search_in_all_buffers_re;
// holds the current position where the mouse pointer is when the popup menu for the scintilla
@@ -1824,6 +1826,8 @@
lookup_widget(GTK_WIDGET(app->find_dialog), "check_regexp"))),
fl4 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
lookup_widget(GTK_WIDGET(app->find_dialog), "check_wordstart")));
+ search_replace_escape = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
+ lookup_widget(GTK_WIDGET(app->find_dialog), "check_escape")));
search_backwards = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
lookup_widget(GTK_WIDGET(app->find_dialog), "check_back")));
@@ -1835,6 +1839,12 @@
gtk_widget_grab_focus(GTK_WIDGET(GTK_BIN(lookup_widget(app->find_dialog, "entry"))->child));
return;
}
+ else if (search_replace_escape)
+ {
+ app->search_text = utils_str_replace(app->search_text, "\\n", "\n");
+ app->search_text = utils_str_replace(app->search_text, "\\r", "\r");
+ app->search_text = utils_str_replace(app->search_text, "\\t", "\t");
+ }
gtk_widget_hide(app->find_dialog);
gtk_combo_box_prepend_text(GTK_COMBO_BOX(user_data), app->search_text);
@@ -1866,7 +1876,7 @@
GtkWidget *entry_find = lookup_widget(GTK_WIDGET(app->replace_dialog), "entry_find");
GtkWidget *entry_replace = lookup_widget(GTK_WIDGET(app->replace_dialog), "entry_replace");
gboolean fl1, fl2, fl3, fl4;
- const gchar *find, *replace;
+ gchar *find, *replace;
if (response == GTK_RESPONSE_CANCEL)
{
@@ -1884,10 +1894,12 @@
lookup_widget(GTK_WIDGET(app->replace_dialog), "check_wordstart")));
search_backwards_re = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
lookup_widget(GTK_WIDGET(app->replace_dialog), "check_back")));
+ search_replace_escape_re = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
+ lookup_widget(GTK_WIDGET(app->replace_dialog), "check_escape")));
search_in_all_buffers_re = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
lookup_widget(GTK_WIDGET(app->replace_dialog), "check_all_buffers")));
- find = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(entry_find))));
- replace = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(entry_replace))));
+ find = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(entry_find)))));
+ replace = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(entry_replace)))));
if ((! fl1) && (strcasecmp(find, replace) == 0))
{
@@ -1896,9 +1908,20 @@
return;
}
+
gtk_combo_box_prepend_text(GTK_COMBO_BOX(entry_find), find);
gtk_combo_box_prepend_text(GTK_COMBO_BOX(entry_replace), replace);
+ if (search_replace_escape_re)
+ {
+ find = utils_str_replace(find, "\\n", "\n");
+ find = utils_str_replace(find, "\\r", "\r");
+ find = utils_str_replace(find, "\\t", "\t");
+ replace = utils_str_replace(replace, "\\n", "\n");
+ replace = utils_str_replace(replace, "\\r", "\r");
+ replace = utils_str_replace(replace, "\\t", "\t");
+ }
+
search_flags_re = (fl1 ? SCFIND_MATCHCASE : 0) |
(fl2 ? SCFIND_WHOLEWORD : 0) |
(fl3 ? SCFIND_REGEXP : 0) |
@@ -1935,6 +1958,8 @@
}
}
}
+ g_free(find);
+ g_free(replace);
}
Modified: trunk/src/dialogs.c
===================================================================
--- trunk/src/dialogs.c 2006-07-17 19:48:42 UTC (rev 577)
+++ trunk/src/dialogs.c 2006-07-18 10:48:51 UTC (rev 578)
@@ -811,7 +811,8 @@
if (app->find_dialog == NULL)
{
- GtkWidget *label, *entry, *checkbox1, *checkbox2, *checkbox3, *checkbox4, *checkbox5;
+ GtkWidget *label, *entry, *checkbox1, *checkbox2, *checkbox3, *checkbox4, *checkbox5,
+ *checkbox6;
GtkTooltips *tooltips = GTK_TOOLTIPS(lookup_widget(app->window, "tooltips"));
app->find_dialog = gtk_dialog_new_with_buttons(_("Find"), GTK_WINDOW(app->window),
@@ -857,6 +858,13 @@
gtk_tooltips_set_tip(tooltips, checkbox3,
_("For detailed information about using regular expressions, please read the documentation."), NULL);
+ checkbox6 = gtk_check_button_new_with_mnemonic(_("_Replace control characters"));
+ g_object_set_data_full(G_OBJECT(app->find_dialog), "check_escape",
+ gtk_widget_ref(checkbox6), (GDestroyNotify)gtk_widget_unref);
+ gtk_button_set_focus_on_click(GTK_BUTTON(checkbox6), FALSE);
+ gtk_tooltips_set_tip(tooltips, checkbox6,
+ _("Replace \\t, \\n and \\r with the corresponding control characters."), NULL);
+
checkbox4 = gtk_check_button_new_with_mnemonic(_("_Search backwards"));
g_object_set_data_full(G_OBJECT(app->find_dialog), "check_back",
gtk_widget_ref(checkbox4), (GDestroyNotify)gtk_widget_unref);
@@ -871,6 +879,7 @@
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(app->find_dialog)->vbox), checkbox2);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(app->find_dialog)->vbox), checkbox5);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(app->find_dialog)->vbox), checkbox3);
+ gtk_container_add(GTK_CONTAINER(GTK_DIALOG(app->find_dialog)->vbox), checkbox6);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(app->find_dialog)->vbox), checkbox4);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(app->find_dialog)->vbox), gtk_label_new(""));
@@ -905,7 +914,8 @@
if (app->replace_dialog == NULL)
{
GtkWidget *label_find, *label_replace, *entry_find, *entry_replace;
- GtkWidget *checkbox1, *checkbox2, *checkbox3, *checkbox4, *checkbox5, *checkbox6;
+ GtkWidget *checkbox1, *checkbox2, *checkbox3, *checkbox4, *checkbox5, *checkbox6,
+ *checkbox7;
GtkWidget *button;
GtkTooltips *tooltips = GTK_TOOLTIPS(lookup_widget(app->window, "tooltips"));
@@ -977,6 +987,13 @@
gtk_tooltips_set_tip(tooltips, checkbox3,
_("For detailed information about using regular expressions, please read the documentation."), NULL);
+ checkbox7 = gtk_check_button_new_with_mnemonic(_("_Replace control characters"));
+ g_object_set_data_full(G_OBJECT(app->replace_dialog), "check_escape",
+ gtk_widget_ref(checkbox7), (GDestroyNotify)gtk_widget_unref);
+ gtk_button_set_focus_on_click(GTK_BUTTON(checkbox7), FALSE);
+ gtk_tooltips_set_tip(tooltips, checkbox7,
+ _("Replace \\t, \\n and \\r with the corresponding control characters."), NULL);
+
checkbox4 = gtk_check_button_new_with_mnemonic(_("_Search backwards"));
g_object_set_data_full(G_OBJECT(app->replace_dialog), "check_back",
gtk_widget_ref(checkbox4), (GDestroyNotify)gtk_widget_unref);
@@ -998,6 +1015,7 @@
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(app->replace_dialog)->vbox), checkbox2);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(app->replace_dialog)->vbox), checkbox5);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(app->replace_dialog)->vbox), checkbox3);
+ gtk_container_add(GTK_CONTAINER(GTK_DIALOG(app->replace_dialog)->vbox), checkbox7);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(app->replace_dialog)->vbox), checkbox4);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(app->replace_dialog)->vbox), checkbox6);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(app->replace_dialog)->vbox), gtk_label_new(""));
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