Load and save filter parameters.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2022-04-10 17:03:09 +03:00
parent a705b67288
commit a92b6781b8
2 changed files with 29 additions and 0 deletions

View File

@ -4419,6 +4419,21 @@ panel_sized_empty_new (const char *panel_name, int y, int x, int lines, int cols
panel_load_setup (panel, section);
g_free (section);
if (panel->filter.value != NULL)
{
gboolean case_sens = (panel->filter.flags & SELECT_MATCH_CASE) != 0;
gboolean shell_patterns = (panel->filter.flags & SELECT_SHELL_PATTERNS) != 0;
panel->filter.handler = mc_search_new (panel->filter.value, NULL);
panel->filter.handler->search_type = shell_patterns ? MC_SEARCH_T_GLOB : MC_SEARCH_T_REGEX;
panel->filter.handler->is_entire_line = TRUE;
panel->filter.handler->is_case_sensitive = case_sens;
/* FIXME: silent check -- do not display an error message */
if (!mc_search_prepare (panel->filter.handler))
file_filter_clear (&panel->filter);
}
/* Load format strings */
err = set_panel_formats (panel);
if (err != 0)

View File

@ -1179,6 +1179,12 @@ panel_load_setup (WPanel * panel, const char *section)
panel->user_mini_status =
mc_config_get_bool (mc_global.panels_config, section, "user_mini_status", FALSE);
panel->filter.value =
mc_config_get_string (mc_global.panels_config, section, "filter_value", NULL);
panel->filter.flags =
mc_config_get_int (mc_global.panels_config, section, "filter_flags",
(int) FILE_FILTER_DEFAULT_FLAGS);
}
/* --------------------------------------------------------------------------------------------- */
@ -1218,6 +1224,14 @@ panel_save_setup (WPanel * panel, const char *section)
mc_config_set_bool (mc_global.panels_config, section, "user_mini_status",
panel->user_mini_status);
/* do not save the default filter */
if (panel->filter.handler != NULL)
mc_config_set_string (mc_global.panels_config, section, "filter_value",
panel->filter.value);
else
mc_config_del_key (mc_global.panels_config, section, "filter_value");
mc_config_set_int (mc_global.panels_config, section, "filter_flags", (int) panel->filter.flags);
}
/* --------------------------------------------------------------------------------------------- */