From e12b9e50db8be43bbfc314d38ad3ebbd82b62125 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Thu, 30 Apr 2009 16:58:28 +0300 Subject: [PATCH] edit/editcmd.c, edit/editcmd_dialigs.c: added 'search in all charsets' feature src/search/search.c: fixed error with multicharset search --- edit/edit-widget.h | 1 + edit/editcmd.c | 2 ++ edit/editcmd_dialogs.c | 20 +++++++++++++++----- src/search/search.c | 4 +--- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/edit/edit-widget.h b/edit/edit-widget.h index 1ba8bbc5c..c75291e4b 100644 --- a/edit/edit-widget.h +++ b/edit/edit-widget.h @@ -56,6 +56,7 @@ struct WEdit { int replace_mode; int replace_backwards; int replace_case; + int all_codepages; long search_start; /* First character to start searching from */ int found_len; /* Length of found string or 0 if none was found */ diff --git a/edit/editcmd.c b/edit/editcmd.c index b1b202b75..ee15611f1 100644 --- a/edit/editcmd.c +++ b/edit/editcmd.c @@ -1240,6 +1240,7 @@ edit_replace_cmd (WEdit *edit, int again) return; } edit->search->search_type = edit->search_type; + edit->search->is_all_charsets = edit->all_codepages; edit->search->is_case_sentitive = edit->replace_case; edit->search->search_fn = edit_search_cmd_callback; } @@ -1439,6 +1440,7 @@ void edit_search_cmd (WEdit * edit, int again) return; } edit->search->search_type = edit->search_type; + edit->search->is_all_charsets = edit->all_codepages; edit->search->is_case_sentitive = edit->replace_case; edit->search->search_fn = edit_search_cmd_callback; } diff --git a/edit/editcmd_dialogs.c b/edit/editcmd_dialogs.c index 96ac7aa90..f419f28d3 100644 --- a/edit/editcmd_dialogs.c +++ b/edit/editcmd_dialogs.c @@ -49,12 +49,12 @@ /*** file scope macro definitions **************************************/ #define SEARCH_DLG_WIDTH 58 -#define SEARCH_DLG_MIN_HEIGHT 10 -#define SEARCH_DLG_HEIGHT_SUPPLY 2 +#define SEARCH_DLG_MIN_HEIGHT 11 +#define SEARCH_DLG_HEIGHT_SUPPLY 3 #define REPLACE_DLG_WIDTH 58 -#define REPLACE_DLG_MIN_HEIGHT 15 -#define REPLACE_DLG_HEIGHT_SUPPLY 4 +#define REPLACE_DLG_MIN_HEIGHT 16 +#define REPLACE_DLG_HEIGHT_SUPPLY 5 /*** file scope type declarations **************************************/ @@ -108,6 +108,7 @@ editcmd_dialog_replace_show (WEdit * edit, const char *search_default, const cha int treplace_backwards = edit->replace_backwards; int treplace_case = edit->replace_case; int treplace_mode = edit->replace_mode; + int tall_codepages = edit->all_codepages; mc_search_type_t ttype_of_search = edit->search_type; int dialog_result; @@ -126,9 +127,12 @@ editcmd_dialog_replace_show (WEdit * edit, const char *search_default, const cha 0, 0, NULL, NULL, NULL}, - {quick_radio, 33, REPLACE_DLG_WIDTH, 9, REPLACE_DLG_HEIGHT, "", 2, 0, + {quick_radio, 33, REPLACE_DLG_WIDTH, 10, REPLACE_DLG_HEIGHT, "", 2, 0, &treplace_mode, const_cast (char **, replace_mode_str), NULL, NULL, NULL}, + {quick_checkbox, 33, REPLACE_DLG_WIDTH, 9, REPLACE_DLG_HEIGHT, N_("All charsets"), 0, 0, + &tall_codepages, 0, NULL, NULL, NULL}, + {quick_checkbox, 33, REPLACE_DLG_WIDTH, 8, REPLACE_DLG_HEIGHT, N_("&Backwards"), 0, 0, &treplace_backwards, 0, NULL, NULL, NULL}, @@ -174,6 +178,7 @@ editcmd_dialog_replace_show (WEdit * edit, const char *search_default, const cha if (dialog_result != B_CANCEL) { edit->search_type = ttype_of_search; edit->replace_mode = treplace_mode; + edit->all_codepages = tall_codepages; edit->replace_backwards = treplace_backwards; edit->replace_case = treplace_case; return; @@ -191,6 +196,7 @@ editcmd_dialog_search_show (WEdit * edit, char **search_text) { int tsearch_case = edit->replace_case; int tsearch_backwards = edit->replace_backwards; + int tall_codepages = edit->all_codepages; mc_search_type_t ttype_of_search = edit->search_type; gchar **list_of_types = editcmd_dialog__get_search_types_list(); int SEARCH_DLG_HEIGHT = SEARCH_DLG_MIN_HEIGHT + g_strv_length (list_of_types) - SEARCH_DLG_HEIGHT_SUPPLY; @@ -202,6 +208,9 @@ editcmd_dialog_search_show (WEdit * edit, char **search_text) {quick_button, 2, 10, 9, SEARCH_DLG_HEIGHT, N_("&OK"), 0, B_ENTER, 0, 0, NULL, NULL, NULL}, + {quick_checkbox, 33, SEARCH_DLG_WIDTH, 7, SEARCH_DLG_HEIGHT, N_("All charsets"), 0, 0, + &tall_codepages, 0, NULL, NULL, NULL}, + {quick_checkbox, 33, SEARCH_DLG_WIDTH, 6, SEARCH_DLG_HEIGHT, N_("&Backwards"), 0, 0, &tsearch_backwards, 0, NULL, NULL, NULL}, {quick_checkbox, 33, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT, N_("case &Sensitive"), 0, 0, @@ -228,6 +237,7 @@ editcmd_dialog_search_show (WEdit * edit, char **search_text) if (quick_dialog (&Quick_input) != B_CANCEL) { edit->search_type = ttype_of_search; edit->replace_backwards = tsearch_backwards; + edit->all_codepages = tall_codepages; edit->replace_case = tsearch_case; } else { *search_text = NULL; diff --git a/src/search/search.c b/src/search/search.c index 4a33e194b..8a5d61e2b 100644 --- a/src/search/search.c +++ b/src/search/search.c @@ -92,11 +92,9 @@ mc_search__conditions_new (mc_search_t * mc_search) if (mc_search->is_all_charsets) { gsize loop1, recoded_str_len; - gchar *buffer; - for (loop1 = 0; loop1 < (gsize) n_codepages; loop1++) { - if (g_ascii_strcasecmp (codepages[loop1].id, cp_source)) { + if (!g_ascii_strcasecmp (codepages[loop1].id, cp_source)) { g_ptr_array_add (ret, mc_search__cond_struct_new (mc_search, mc_search->original, mc_search->original_len, cp_source));