mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-09 13:02:01 +03:00
Merge branch '1556_findall'
* 1556_findall: Fixed i18n of editor search dialog. Ticket #1556 (editor search: button 'Find all')
This commit is contained in:
commit
a59d6f6ff0
@ -321,6 +321,7 @@ extern int option_edit_top_extreme;
|
|||||||
extern int option_edit_bottom_extreme;
|
extern int option_edit_bottom_extreme;
|
||||||
|
|
||||||
extern const char *option_whole_chars_search;
|
extern const char *option_whole_chars_search;
|
||||||
|
extern int search_create_bookmark;
|
||||||
|
|
||||||
extern int column_highlighting;
|
extern int column_highlighting;
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@
|
|||||||
/* globals: */
|
/* globals: */
|
||||||
|
|
||||||
/* search and replace: */
|
/* search and replace: */
|
||||||
static int search_create_bookmark = 0;
|
int search_create_bookmark = 0;
|
||||||
/* static int search_in_all_charsets = 0; */
|
/* static int search_in_all_charsets = 0; */
|
||||||
|
|
||||||
/* queries on a save */
|
/* queries on a save */
|
||||||
@ -89,10 +89,14 @@ edit_search_cmd_search_create_bookmark(WEdit * edit)
|
|||||||
long q = 0;
|
long q = 0;
|
||||||
gsize len = 0;
|
gsize len = 0;
|
||||||
|
|
||||||
|
search_create_bookmark = 0;
|
||||||
|
book_mark_flush (edit, -1);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (!mc_search_run(edit->search, (void *) edit, q, edit->last_byte, &len))
|
if (!mc_search_run(edit->search, (void *) edit, q, edit->last_byte, &len))
|
||||||
break;
|
break;
|
||||||
|
if (found == 0)
|
||||||
|
edit->search_start = edit->search->normal_offset;
|
||||||
found++;
|
found++;
|
||||||
l += edit_count_lines (edit, q, edit->search->normal_offset);
|
l += edit_count_lines (edit, q, edit->search->normal_offset);
|
||||||
if (l != l_last) {
|
if (l != l_last) {
|
||||||
@ -103,11 +107,11 @@ edit_search_cmd_search_create_bookmark(WEdit * edit)
|
|||||||
q = edit->search->normal_offset + 1;
|
q = edit->search->normal_offset + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found) {
|
if (found == 0) {
|
||||||
/* in response to number of bookmarks added because of string being found %d times */
|
|
||||||
message (D_NORMAL, _("Search"), _(" %d items found, %d bookmarks added "), found, books);
|
|
||||||
} else {
|
|
||||||
edit_error_dialog (_ ("Search"), _ (" Search string not found "));
|
edit_error_dialog (_ ("Search"), _ (" Search string not found "));
|
||||||
|
} else {
|
||||||
|
edit_cursor_move (edit, edit->search_start - edit->curs1);
|
||||||
|
edit_scroll_screen_over_cursor (edit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,6 +135,7 @@ editcmd_dialog_replace_show (WEdit * edit, const char *search_default, const cha
|
|||||||
void
|
void
|
||||||
editcmd_dialog_search_show (WEdit * edit, char **search_text)
|
editcmd_dialog_search_show (WEdit * edit, char **search_text)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (*search_text == '\0')
|
if (*search_text == '\0')
|
||||||
*search_text = INPUT_LAST_TEXT;
|
*search_text = INPUT_LAST_TEXT;
|
||||||
|
|
||||||
@ -142,33 +143,79 @@ editcmd_dialog_search_show (WEdit * edit, char **search_text)
|
|||||||
gchar **list_of_types = mc_search_get_types_strings_array();
|
gchar **list_of_types = mc_search_get_types_strings_array();
|
||||||
int SEARCH_DLG_HEIGHT = SEARCH_DLG_MIN_HEIGHT + g_strv_length (list_of_types) - SEARCH_DLG_HEIGHT_SUPPLY;
|
int SEARCH_DLG_HEIGHT = SEARCH_DLG_MIN_HEIGHT + g_strv_length (list_of_types) - SEARCH_DLG_HEIGHT_SUPPLY;
|
||||||
|
|
||||||
|
int i;
|
||||||
|
int btn_pos, dlg_width;
|
||||||
|
int dialog_result;
|
||||||
|
|
||||||
QuickWidget quick_widgets[] =
|
QuickWidget quick_widgets[] =
|
||||||
{
|
{
|
||||||
/* 0 */ QUICK_BUTTON (6, 10, 11, SEARCH_DLG_HEIGHT, N_("&Cancel"), B_CANCEL, NULL),
|
/* 0 */
|
||||||
/* 1 */ QUICK_BUTTON (2, 10, 11, SEARCH_DLG_HEIGHT, N_("&OK"), B_ENTER, NULL),
|
QUICK_BUTTON (6, 10, 11, SEARCH_DLG_HEIGHT, N_("&Cancel"), B_CANCEL, NULL),
|
||||||
|
/* 1 */
|
||||||
|
QUICK_BUTTON (4, 10, 11, SEARCH_DLG_HEIGHT, N_("&Find all"), B_USER, NULL),
|
||||||
|
/* 2 */
|
||||||
|
QUICK_BUTTON (2, 10, 11, SEARCH_DLG_HEIGHT, N_("&OK"), B_ENTER, NULL),
|
||||||
#ifdef HAVE_CHARSET
|
#ifdef HAVE_CHARSET
|
||||||
/* 2 */ QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 9, SEARCH_DLG_HEIGHT, N_("All charsets"), &edit->all_codepages),
|
/* 3 */
|
||||||
|
QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 9, SEARCH_DLG_HEIGHT, N_("All charsets"), &edit->all_codepages),
|
||||||
#endif
|
#endif
|
||||||
/* 3 */ QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 8, SEARCH_DLG_HEIGHT, N_("&Whole words"), &edit->whole_words),
|
/* 4 */
|
||||||
/* 4 */ QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 7, SEARCH_DLG_HEIGHT, N_("In se&lection"), &edit->only_in_selection),
|
QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 8, SEARCH_DLG_HEIGHT, N_("&Whole words"), &edit->whole_words),
|
||||||
/* 5 */ QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 6, SEARCH_DLG_HEIGHT, N_("&Backwards"), &edit->replace_backwards),
|
/* 5 */
|
||||||
/* 6 */ QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT, N_("case &Sensitive"), &edit->replace_case),
|
QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 7, SEARCH_DLG_HEIGHT, N_("In se&lection"), &edit->only_in_selection),
|
||||||
/* 7 */ QUICK_RADIO ( 3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT,
|
/* 6 */
|
||||||
|
QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 6, SEARCH_DLG_HEIGHT, N_("&Backwards"), &edit->replace_backwards),
|
||||||
|
/* 7 */
|
||||||
|
QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT, N_("case &Sensitive"), &edit->replace_case),
|
||||||
|
/* 8 */
|
||||||
|
QUICK_RADIO ( 3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT,
|
||||||
g_strv_length (list_of_types), (const char **) list_of_types, &edit->search_type),
|
g_strv_length (list_of_types), (const char **) list_of_types, &edit->search_type),
|
||||||
/* 8 */ QUICK_INPUT (3, SEARCH_DLG_WIDTH, 3, SEARCH_DLG_HEIGHT,
|
/* 9 */
|
||||||
|
QUICK_INPUT (3, SEARCH_DLG_WIDTH, 3, SEARCH_DLG_HEIGHT,
|
||||||
*search_text, SEARCH_DLG_WIDTH - 6, 0, MC_HISTORY_SHARED_SEARCH, search_text),
|
*search_text, SEARCH_DLG_WIDTH - 6, 0, MC_HISTORY_SHARED_SEARCH, search_text),
|
||||||
/* 9 */ QUICK_LABEL (2, SEARCH_DLG_WIDTH, 2, SEARCH_DLG_HEIGHT, N_(" Enter search string:")),
|
/* 10 */
|
||||||
|
QUICK_LABEL (2, SEARCH_DLG_WIDTH, 2, SEARCH_DLG_HEIGHT, N_(" Enter search string:")),
|
||||||
QUICK_END
|
QUICK_END
|
||||||
};
|
};
|
||||||
|
|
||||||
QuickDialog Quick_input =
|
QuickDialog Quick_input =
|
||||||
{
|
{
|
||||||
SEARCH_DLG_WIDTH, SEARCH_DLG_HEIGHT, -1, -1, N_("Search"),
|
SEARCH_DLG_WIDTH, SEARCH_DLG_HEIGHT, -1, -1, N_("Search"),
|
||||||
"[Input Line Keys]", quick_widgets, FALSE
|
"[Input Line Keys]", quick_widgets, TRUE
|
||||||
};
|
};
|
||||||
|
|
||||||
if (quick_dialog (&Quick_input) == B_CANCEL)
|
|
||||||
|
#ifdef ENABLE_NLS
|
||||||
|
/* butons */
|
||||||
|
for (i = 0; i < 3; i++)
|
||||||
|
quick_widgets[i].u.button.text = _(quick_widgets[i].u.button.text);
|
||||||
|
/* checkboxes */
|
||||||
|
for (i = 3; i < 8; i++)
|
||||||
|
quick_widgets[i].u.checkbox.text = _(quick_widgets[i].u.checkbox.text);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* calculate button positions */
|
||||||
|
btn_pos = 7;
|
||||||
|
|
||||||
|
for (i = 2; i >= 0; i--) {
|
||||||
|
quick_widgets[i].relative_x = btn_pos;
|
||||||
|
btn_pos += str_term_width1 (quick_widgets[i].u.button.text) + 7;
|
||||||
|
if (i == 2) /* default button */
|
||||||
|
btn_pos += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
dlg_width = btn_pos + 2;
|
||||||
|
|
||||||
|
/* correct widget coordinates */
|
||||||
|
for (i = 0; i < sizeof (quick_widgets)/sizeof (quick_widgets[0]); i++)
|
||||||
|
quick_widgets[i].x_divisions = dlg_width;
|
||||||
|
|
||||||
|
dialog_result = quick_dialog (&Quick_input);
|
||||||
|
|
||||||
|
if (dialog_result == B_CANCEL)
|
||||||
*search_text = NULL;
|
*search_text = NULL;
|
||||||
|
else if (dialog_result == B_USER)
|
||||||
|
search_create_bookmark = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user