mirror of
https://github.com/MidnightCommander/mc
synced 2025-02-27 04:34:34 +03:00
Retain search options in viewer across viewing session.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
63aa191e7a
commit
2eec76f8c5
@ -113,12 +113,12 @@ mcview_continue_search_cmd (mcview_t * view)
|
||||
view->last_search_string = NULL;
|
||||
mcview_search (view);
|
||||
} else {
|
||||
view->search->search_type = view->search_type;
|
||||
view->search->is_all_charsets = view->search_all_codepages;
|
||||
view->search->is_case_sentitive = view->search_case;
|
||||
view->search->search_type = mcview_search_options.type;
|
||||
view->search->is_all_charsets = mcview_search_options.all_codepages;
|
||||
view->search->is_case_sentitive = mcview_search_options.case_sens;
|
||||
view->search->whole_words = mcview_search_options.whole_words;
|
||||
view->search->search_fn = mcview_search_cmd_callback;
|
||||
view->search->update_fn = mcview_search_update_cmd_callback;
|
||||
view->search->whole_words = view->whole_words;
|
||||
|
||||
mcview_do_search (view);
|
||||
}
|
||||
|
@ -52,6 +52,15 @@
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
mcview_search_options_t mcview_search_options =
|
||||
{
|
||||
.type = MC_SEARCH_T_NORMAL,
|
||||
.case_sens = FALSE,
|
||||
.backwards = FALSE,
|
||||
.whole_words = FALSE,
|
||||
.all_codepages = FALSE
|
||||
};
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
@ -84,16 +93,17 @@ mcview_dialog_search (mcview_t * view)
|
||||
QUICK_BUTTON (2, 10, SEARCH_DLG_HEIGHT - 3, SEARCH_DLG_HEIGHT, N_("&OK"), B_ENTER, NULL),
|
||||
#ifdef HAVE_CHARSET
|
||||
QUICK_CHECKBOX (SEARCH_DLG_WIDTH / 2 + 3, SEARCH_DLG_WIDTH, 8, SEARCH_DLG_HEIGHT,
|
||||
N_("All charsets"), &view->search_all_codepages),
|
||||
N_("All charsets"), &mcview_search_options.all_codepages),
|
||||
#endif
|
||||
QUICK_CHECKBOX (SEARCH_DLG_WIDTH / 2 + 3, SEARCH_DLG_WIDTH, 7, SEARCH_DLG_HEIGHT,
|
||||
N_("&Whole words"), &view->whole_words),
|
||||
N_("&Whole words"), &mcview_search_options.whole_words),
|
||||
QUICK_CHECKBOX (SEARCH_DLG_WIDTH / 2 + 3, SEARCH_DLG_WIDTH, 6, SEARCH_DLG_HEIGHT,
|
||||
N_("&Backwards"), &view->search_backwards),
|
||||
N_("&Backwards"), &mcview_search_options.backwards),
|
||||
QUICK_CHECKBOX (SEARCH_DLG_WIDTH / 2 + 3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT,
|
||||
N_("case &Sensitive"), &view->search_case),
|
||||
N_("case &Sensitive"), &mcview_search_options.case_sens),
|
||||
QUICK_RADIO (3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT,
|
||||
num_of_types, (const char **) list_of_types, (int *) &view->search_type),
|
||||
num_of_types, (const char **) list_of_types,
|
||||
(int *) &mcview_search_options.type),
|
||||
QUICK_INPUT (3, SEARCH_DLG_WIDTH, 3, SEARCH_DLG_HEIGHT,
|
||||
INPUT_LAST_TEXT, SEARCH_DLG_WIDTH - 6, 0, MC_HISTORY_SHARED_SEARCH, &exp),
|
||||
QUICK_LABEL (2, SEARCH_DLG_WIDTH, 2, SEARCH_DLG_HEIGHT, N_(" Enter search string:")),
|
||||
@ -138,12 +148,12 @@ mcview_dialog_search (mcview_t * view)
|
||||
view->search = mc_search_new (view->last_search_string, -1);
|
||||
view->search_nroff_seq = mcview_nroff_seq_new (view);
|
||||
if (view->search != NULL) {
|
||||
view->search->search_type = view->search_type;
|
||||
view->search->is_all_charsets = view->search_all_codepages;
|
||||
view->search->is_case_sentitive = view->search_case;
|
||||
view->search->search_type = mcview_search_options.type;
|
||||
view->search->is_all_charsets = mcview_search_options.all_codepages;
|
||||
view->search->is_case_sentitive = mcview_search_options.case_sens;
|
||||
view->search->whole_words = mcview_search_options.whole_words;
|
||||
view->search->search_fn = mcview_search_cmd_callback;
|
||||
view->search->update_fn = mcview_search_update_cmd_callback;
|
||||
view->search->whole_words = view->whole_words;
|
||||
}
|
||||
|
||||
return (view->search != NULL);
|
||||
|
@ -180,11 +180,6 @@ typedef struct mcview_struct {
|
||||
/* handle of search engine */
|
||||
mc_search_t *search;
|
||||
gchar *last_search_string;
|
||||
mc_search_type_t search_type;
|
||||
gboolean search_all_codepages;
|
||||
gboolean whole_words;
|
||||
gboolean search_case;
|
||||
gboolean search_backwards;
|
||||
struct mcview_nroff_struct *search_nroff_seq;
|
||||
|
||||
int search_numNeedSkipChar;
|
||||
@ -199,8 +194,18 @@ typedef struct mcview_nroff_struct {
|
||||
nroff_type_t prev_type;
|
||||
} mcview_nroff_t;
|
||||
|
||||
typedef struct mcview_search_options_t {
|
||||
mc_search_type_t type;
|
||||
gboolean case_sens;
|
||||
gboolean backwards;
|
||||
gboolean whole_words;
|
||||
gboolean all_codepages;
|
||||
} mcview_search_options_t;
|
||||
|
||||
/*** global variables defined in .c file *******************************/
|
||||
|
||||
extern mcview_search_options_t mcview_search_options;
|
||||
|
||||
/*** declarations of public functions **********************************/
|
||||
|
||||
/* actions_cmd.c: */
|
||||
|
@ -78,7 +78,7 @@ mcview_find (mcview_t * view, gsize search_start, gsize * len)
|
||||
|
||||
view->search_numNeedSkipChar = 0;
|
||||
|
||||
if (view->search_backwards) {
|
||||
if (mcview_search_options.backwards) {
|
||||
search_end = mcview_get_filesize (view);
|
||||
while ((int) search_start >= 0) {
|
||||
view->search_nroff_seq->index = search_start;
|
||||
@ -220,14 +220,14 @@ mcview_do_search (mcview_t * view)
|
||||
/*for avoid infinite search loop we need to increase or decrease start offset of search */
|
||||
|
||||
if (view->search_start) {
|
||||
search_start = (view->search_backwards) ? -2 : 2;
|
||||
search_start = (mcview_search_options.backwards) ? -2 : 2;
|
||||
search_start = view->search_start + search_start +
|
||||
mcview__get_nroff_real_len (view, view->search_start, 2) * search_start;
|
||||
} else {
|
||||
search_start = view->search_start;
|
||||
}
|
||||
|
||||
if (view->search_backwards && (int) search_start < 0)
|
||||
if (mcview_search_options.backwards && (int) search_start < 0)
|
||||
search_start = 0;
|
||||
|
||||
/* Compute the percent steps */
|
||||
@ -262,7 +262,7 @@ mcview_do_search (mcview_t * view)
|
||||
break;
|
||||
} while (mcview_may_still_grow (view));
|
||||
|
||||
if (!isFound && need_search_again && !view->search_backwards) {
|
||||
if (!isFound && need_search_again && !mcview_search_options.backwards) {
|
||||
int result;
|
||||
mcview_update (view);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user