1
1

Merge branch '1874_save_findfile_options'

* 1874_save_findfile_options:
  Save find file options in user configuration file.
  Ticket #1874: save file find options between MC sessions.
Этот коммит содержится в:
Andrew Borodin 2010-01-06 18:05:30 +03:00
родитель e23a2df6fa 462315fe09
Коммит bea2fff1fd
9 изменённых файлов: 164 добавлений и 95 удалений

Просмотреть файл

@ -1286,17 +1286,17 @@ evitar búsquedas en un CDROM o en un directorio NFS que está montado a través
enlace lento).
.PP
Los directorios a ser omitidos deberían ser enumerados en la variable
.B find_ignore_dirs
.B ignore_dirs
en la sección
.B Misc
.B FindFile
de nuestro archivo ~/.mc/ini.
.PP
Los componentes del directorio deberían ser separados por dos puntos, como en
el ejemplo que sigue:
.PP
.nf
[Misc]
find_ignore_dirs=/cdrom:/nfs/wuarchive:/afs
[FindFile]
ignore_dirs=/cdrom:/nfs/wuarchive:/afs
.fi
.PP
Debemos valorar la utilización de

Просмотреть файл

@ -1215,17 +1215,17 @@ során el szeretnéd kerülni a CDROM\-ot, vagy az NFS könyvtárait amelyeket
slow linkkel csatoltak).
.PP
Az átlépendő könyvtárakat a
.B find_ignore_dirs
.B ignore_dirs
változó állítja be az ~/.mc/ini fájlod
.B Misc
.B FindFile
részében.
.PP
A könyvtár elemeket kettősponttal tudod elválasztani egymástól, emire
itt egy példát is láthatsz:
.PP
.nf
[Misc]
find_ignore_dirs=/cdrom:/nfs/wuarchive:/afs
[FindFile]
ignore_dirs=/cdrom:/nfs/wuarchive:/afs
.fi
.PP
A

Просмотреть файл

@ -1234,16 +1234,16 @@ saltare durante la ricerca (per esempio, si può evitare di fare ricerche su
un CDROM o su una directory NFS montata attraverso un collegamento lento).
.PP
Le directory che devono essere saltate devono essere impostate nella variabile
.B find_ignore_dirs
.B ignore_dirs
nella sezione
.B Misc
.B FindFile
del file ~/.mc/ini.
.PP
Le directory devono essere separate da una virgola, come nell'esempio:
.PP
.nf
[Misc]
find_ignore_dirs=/cdrom:/nfs/wuarchive:/afs
[FindFile]
ignore_dirs=/cdrom:/nfs/wuarchive:/afs
.fi
.PP
Si può prendere in considerazione l'uso del comando

Просмотреть файл

@ -1363,17 +1363,17 @@ searches on a CD\-ROM or on a NFS directory that is mounted across a slow
link).
.PP
Directories to be skipped should be set on the variable
.B find_ignore_dirs
.B ignore_dirs
in the
.B Misc
.B FindFile
section of your ~/.mc/ini file.
.PP
Directory components should be separated with a colon, here is an
example:
.PP
.nf
[Misc]
find_ignore_dirs=/cdrom:/nfs/wuarchive:/afs
[FindFile]
ignore_dirs=/cdrom:/nfs/wuarchive:/afs
.fi
.PP
You may consider using the

Просмотреть файл

@ -1019,17 +1019,17 @@ powinno uwzględniać (na przykład możesz chcieć ominąć przeszukiwanie CDRO
i innych podmontowanych systemów plików).
.PP
Katalogi do omijania powinny być umieszczone w zmiennej
.B find_ignore_dirs
.B ignore_dirs
w sekcji
.B Misc
.B FindFile
twojego pliku ~/.mc/ini.
.PP
Składowe katalogów powinny być oddzielone od siebie przez średniki, to jest
przykład:
.PP
.nf
[Misc]
find_ignore_dirs=/cdrom:/nfs/wuarchive:/afs
[FindFile]
ignore_dirs=/cdrom:/nfs/wuarchive:/afs
.fi
.PP
Możesz woleć używać panelu zewnętrznego do wykonywania niektórych operacji.

Просмотреть файл

@ -1466,16 +1466,16 @@ CDROM или не хотите искать в каталогах, подклю
медленному каналу).
.PP
Каталоги, которые надо пропустить, должны быть указаны в переменной
.B find_ignore_dirs
.B ignore_dirs
в секции
.B Misc
.B FindFile
вашего файла
.BR ~/.mc/ini .
Имена каталогов разделяются двоеточиями, следующим образом:
.PP
.nf
[Misc]
find_ignore_dirs=/cdrom:/nfs/wuarchive:/afs
[FindFile]
ignore_dirs=/cdrom:/nfs/wuarchive:/afs
.fi
.PP
Вы можете использовать перенаправление вывода на панель

Просмотреть файл

@ -1202,16 +1202,16 @@ egrep(1). Ово значи да морате да наводите знаков
.PP
Директоријуме које би требало избегавати би требало навести у
променљивој
.B find_ignore_dirs
.B ignore_dirs
у одељку
.B Misc
.B FindFile
ваше датотеке ~/.mc/ini.
.PP
Директоријуме би требало раздвајати двотачком; ево примера:
.PP
.nf
[Misc]
find_ignore_dirs=/cdrom:/nfs/wuarchive:/afs
[FindFile]
ignore_dirs=/cdrom:/nfs/wuarchive:/afs
.fi
.PP
Можете да размотрите и употребу наредбе

Просмотреть файл

@ -35,14 +35,14 @@
#include "global.h"
#include "../src/tty/tty.h"
#include "../src/skin/skin.h"
#include "../src/tty/key.h"
#include "../src/skin/skin.h"
#include "../src/search/search.h"
#include "../src/mcconfig/mcconfig.h"
#include "../vfs/vfs.h"
#include "setup.h"
#include "find.h"
#include "setup.h" /* verbose */
#include "strutil.h"
#include "dialog.h"
#include "widget.h"
@ -55,6 +55,8 @@
#include "history.h" /* MC_HISTORY_SHARED_SEARCH */
#include "layout.h" /* mc_refresh() */
#include "find.h"
/* Size of the find parameters window */
#if HAVE_CHARSET
static int FIND_Y = 16;
@ -151,21 +153,89 @@ static struct {
{ N_("&Edit - F4"), 13, 38 }
};
/* find file options */
typedef struct
{
/* file name options */
gboolean file_case_sens;
gboolean file_pattern;
gboolean find_recurs;
gboolean skip_hidden;
gboolean file_all_charsets;
/* file content options */
gboolean content_case_sens;
gboolean content_regexp;
gboolean content_first_hit;
gboolean content_whole_words;
gboolean content_all_charsets;
} find_file_options_t;
static find_file_options_t options =
{
TRUE, TRUE, TRUE, FALSE, FALSE,
TRUE, FALSE, FALSE, FALSE, FALSE
};
static char *in_start_dir = INPUT_LAST_TEXT;
static mc_search_t *search_file_handle = NULL;
static gboolean skip_hidden_flag = FALSE;
static gboolean file_pattern_flag = TRUE;
static gboolean file_all_charsets_flag = FALSE;
static gboolean file_case_sens_flag = TRUE;
static gboolean find_recurs_flag = TRUE;
static mc_search_t *search_content_handle = NULL;
static gboolean content_regexp_flag = FALSE;
static gboolean content_all_charsets_flag = FALSE;
static gboolean content_case_sens_flag = TRUE;
static gboolean content_first_hit_flag = FALSE;
static gboolean content_whole_words = FALSE;
static void
find_load_options (void)
{
static gboolean loaded = FALSE;
char *ignore_dirs;
if (loaded)
return;
loaded = TRUE;
/* Back compatibility: try load old parameter at first */
ignore_dirs = mc_config_get_string (mc_main_config, "Misc", "find_ignore_dirs", "");
if (ignore_dirs [0] != '\0') {
find_ignore_dirs = g_strconcat (":", ignore_dirs, ":", (char *) NULL);
mc_config_set_string (mc_main_config, "FindFile", "ignore_dirs", ignore_dirs);
}
g_free (ignore_dirs);
mc_config_del_param (mc_main_config, "Misc", "find_ignore_dirs");
/* Then load new parameters */
ignore_dirs = mc_config_get_string (mc_main_config, "FindFile", "ignore_dirs", "");
if (ignore_dirs [0] != '\0') {
g_free (find_ignore_dirs);
find_ignore_dirs = g_strconcat (":", ignore_dirs, ":", (char *) NULL);
}
g_free (ignore_dirs);
options.file_case_sens = mc_config_get_bool (mc_main_config, "FindFile", "file_case_sens", TRUE);
options.file_pattern = mc_config_get_bool (mc_main_config, "FindFile", "file_shell_pattern", TRUE);
options.find_recurs = mc_config_get_bool (mc_main_config, "FindFile", "file_find_recurs", TRUE);
options.skip_hidden = mc_config_get_bool (mc_main_config, "FindFile", "file_skip_hidden", FALSE);
options.file_all_charsets = mc_config_get_bool (mc_main_config, "FindFile", "file_all_charsets", FALSE);
options.content_case_sens = mc_config_get_bool (mc_main_config, "FindFile", "content_case_sens", TRUE);
options.content_regexp = mc_config_get_bool (mc_main_config, "FindFile", "content_regexp", FALSE);
options.content_first_hit = mc_config_get_bool (mc_main_config, "FindFile", "content_first_hit", FALSE);
options.content_whole_words = mc_config_get_bool (mc_main_config, "FindFile", "content_whole_words", FALSE);
options.content_all_charsets = mc_config_get_bool (mc_main_config, "FindFile", "content_all_charsets", FALSE);
}
static void
find_save_options (void)
{
mc_config_set_bool (mc_main_config, "FindFile", "file_case_sens", options.file_case_sens);
mc_config_set_bool (mc_main_config, "FindFile", "file_shell_pattern", options.file_pattern);
mc_config_set_bool (mc_main_config, "FindFile", "file_find_recurs", options.find_recurs);
mc_config_set_bool (mc_main_config, "FindFile", "file_skip_hidden", options.skip_hidden);
mc_config_set_bool (mc_main_config, "FindFile", "file_all_charsets", options.file_all_charsets);
mc_config_set_bool (mc_main_config, "FindFile", "content_case_sens", options.content_case_sens);
mc_config_set_bool (mc_main_config, "FindFile", "content_regexp", options.content_regexp);
mc_config_set_bool (mc_main_config, "FindFile", "content_first_hit", options.content_first_hit);
mc_config_set_bool (mc_main_config, "FindFile", "content_whole_words", options.content_whole_words);
mc_config_set_bool (mc_main_config, "FindFile", "content_all_charsets", options.content_all_charsets);
}
static inline char *
add_to_list (const char *text, void *data)
@ -260,7 +330,7 @@ find_parm_callback (Dlg_head *h, Widget *sender,
/*
* find_parameters: gets information from the user
*
* If the return value is true, then the following holds:
* If the return value is TRUE, then the following holds:
*
* START_DIR and PATTERN are pointers to char * and upon return they
* contain the information provided by the user.
@ -270,10 +340,10 @@ find_parm_callback (Dlg_head *h, Widget *sender,
* behavior for the other two parameters.
*
*/
static int
static gboolean
find_parameters (char **start_dir, char **pattern, char **content)
{
int return_value;
gboolean return_value;
char *temp_dir = NULL;
/* file name */
@ -323,7 +393,9 @@ find_parameters (char **start_dir, char **pattern, char **content)
b1 = str_term_width1 (buts[1]) + 4;
b2 = str_term_width1 (buts[2]) + 4;
find_par_start:
find_load_options ();
find_par_start:
if (in_start_dir == NULL)
in_start_dir = g_strdup (".");
@ -339,38 +411,38 @@ find_parameters (char **start_dir, char **pattern, char **content)
#ifdef HAVE_CHARSET
content_all_charsets_cbox = check_new (11, FIND_X / 2 + 1,
content_all_charsets_flag, content_all_charsets_label);
options.content_all_charsets, content_all_charsets_label);
add_widget (find_dlg, content_all_charsets_cbox);
#endif
content_whole_words_cbox = check_new (10, FIND_X / 2 + 1, content_whole_words, content_whole_words_label);
content_whole_words_cbox = check_new (10, FIND_X / 2 + 1, options.content_whole_words, content_whole_words_label);
add_widget (find_dlg, content_whole_words_cbox);
content_first_hit_cbox = check_new (9, FIND_X / 2 + 1, content_first_hit_flag, content_first_hit_label);
content_first_hit_cbox = check_new (9, FIND_X / 2 + 1, options.content_first_hit, content_first_hit_label);
add_widget (find_dlg, content_first_hit_cbox);
content_regexp_cbox = check_new (8, FIND_X / 2 + 1, content_regexp_flag, content_regexp_label);
content_regexp_cbox = check_new (8, FIND_X / 2 + 1, options.content_regexp, content_regexp_label);
add_widget (find_dlg, content_regexp_cbox);
content_case_sens_cbox = check_new (7, FIND_X / 2 + 1, content_case_sens_flag, content_case_label);
content_case_sens_cbox = check_new (7, FIND_X / 2 + 1, options.content_case_sens, content_case_label);
add_widget (find_dlg, content_case_sens_cbox);
#ifdef HAVE_CHARSET
file_all_charsets_cbox = check_new (11, 3,
file_all_charsets_flag, file_all_charsets_label);
options.file_all_charsets, file_all_charsets_label);
add_widget (find_dlg, file_all_charsets_cbox);
#endif
skip_hidden_cbox = check_new (10, 3, skip_hidden_flag, file_skip_hidden_label);
skip_hidden_cbox = check_new (10, 3, options.skip_hidden, file_skip_hidden_label);
add_widget (find_dlg, skip_hidden_cbox);
recursively_cbox = check_new (9, 3, find_recurs_flag, file_recurs_label);
recursively_cbox = check_new (9, 3, options.find_recurs, file_recurs_label);
add_widget (find_dlg, recursively_cbox);
file_pattern_cbox = check_new (8, 3, file_pattern_flag, file_pattern_label);
file_pattern_cbox = check_new (8, 3, options.file_pattern, file_pattern_label);
add_widget (find_dlg, file_pattern_cbox);
file_case_sens_cbox = check_new (7, 3, file_case_sens_flag, file_case_label);
file_case_sens_cbox = check_new (7, 3, options.file_case_sens, file_case_label);
add_widget (find_dlg, file_case_sens_cbox);
in_with = input_new (6, FIND_X / 2 + 1, INPUT_COLOR, FIND_X / 2 - 4, INPUT_LAST_TEXT,
@ -395,22 +467,22 @@ find_parameters (char **start_dir, char **pattern, char **content)
switch (run_dlg (find_dlg)) {
case B_CANCEL:
return_value = 0;
return_value = FALSE;
break;
case B_TREE:
#ifdef HAVE_CHARSET
file_all_charsets_flag = file_all_charsets_cbox->state & C_BOOL;
content_all_charsets_flag = content_all_charsets_cbox->state & C_BOOL;
options.file_all_charsets = file_all_charsets_cbox->state & C_BOOL;
options.content_all_charsets = content_all_charsets_cbox->state & C_BOOL;
#endif
content_case_sens_flag = content_case_sens_cbox->state & C_BOOL;
content_regexp_flag = content_regexp_cbox->state & C_BOOL;
content_first_hit_flag = content_first_hit_cbox->state & C_BOOL;
content_whole_words = content_whole_words_cbox->state & C_BOOL;
file_pattern_flag = file_pattern_cbox->state & C_BOOL;
file_case_sens_flag = file_case_sens_cbox->state & C_BOOL;
find_recurs_flag = recursively_cbox->state & C_BOOL;
skip_hidden_flag = skip_hidden_cbox->state & C_BOOL;
options.content_case_sens = content_case_sens_cbox->state & C_BOOL;
options.content_regexp = content_regexp_cbox->state & C_BOOL;
options.content_first_hit = content_first_hit_cbox->state & C_BOOL;
options.content_whole_words = content_whole_words_cbox->state & C_BOOL;
options.file_pattern = file_pattern_cbox->state & C_BOOL;
options.file_case_sens = file_case_sens_cbox->state & C_BOOL;
options.find_recurs = recursively_cbox->state & C_BOOL;
options.skip_hidden = skip_hidden_cbox->state & C_BOOL;
destroy_dlg (find_dlg);
if (in_start_dir != INPUT_LAST_TEXT)
@ -431,17 +503,17 @@ find_parameters (char **start_dir, char **pattern, char **content)
default:
#ifdef HAVE_CHARSET
file_all_charsets_flag = file_all_charsets_cbox->state & C_BOOL;
content_all_charsets_flag = content_all_charsets_cbox->state & C_BOOL;
options.file_all_charsets = file_all_charsets_cbox->state & C_BOOL;
options.content_all_charsets = content_all_charsets_cbox->state & C_BOOL;
#endif
content_case_sens_flag = content_case_sens_cbox->state & C_BOOL;
content_regexp_flag = content_regexp_cbox->state & C_BOOL;
content_first_hit_flag = content_first_hit_cbox->state & C_BOOL;
content_whole_words = content_whole_words_cbox->state & C_BOOL;
find_recurs_flag = recursively_cbox->state & C_BOOL;
file_pattern_flag = file_pattern_cbox->state & C_BOOL;
file_case_sens_flag = file_case_sens_cbox->state & C_BOOL;
skip_hidden_flag = skip_hidden_cbox->state & C_BOOL;
options.content_case_sens = content_case_sens_cbox->state & C_BOOL;
options.content_regexp = content_regexp_cbox->state & C_BOOL;
options.content_first_hit = content_first_hit_cbox->state & C_BOOL;
options.content_whole_words = content_whole_words_cbox->state & C_BOOL;
options.find_recurs = recursively_cbox->state & C_BOOL;
options.file_pattern = file_pattern_cbox->state & C_BOOL;
options.file_case_sens = file_case_sens_cbox->state & C_BOOL;
options.skip_hidden = skip_hidden_cbox->state & C_BOOL;
*content = (in_with->buffer[0] != '\0') ? g_strdup (in_with->buffer) : NULL;
*start_dir = g_strdup ((in_start->buffer[0] != '\0') ? in_start->buffer : ".");
@ -449,7 +521,10 @@ find_parameters (char **start_dir, char **pattern, char **content)
if (in_start_dir != INPUT_LAST_TEXT)
g_free (in_start_dir);
in_start_dir = g_strdup (*start_dir);
return_value = 1;
find_save_options ();
return_value = TRUE;
}
destroy_dlg (find_dlg);
@ -704,7 +779,7 @@ search_content (Dlg_head *h, const char *directory, const char *filename)
}
g_free (p);
if (found && content_first_hit_flag)
if (found && options.content_first_hit)
break;
if (has_newline) {
@ -763,16 +838,16 @@ do_search (struct Dlg_head *h)
search_content_handle = mc_search_new(content_pattern, -1);
if (search_content_handle) {
search_content_handle->search_type = (content_regexp_flag) ? MC_SEARCH_T_REGEX : MC_SEARCH_T_NORMAL;
search_content_handle->is_case_sentitive = content_case_sens_flag;
search_content_handle->whole_words = content_whole_words;
search_content_handle->is_all_charsets = content_all_charsets_flag;
search_content_handle->search_type = options.content_regexp ? MC_SEARCH_T_REGEX : MC_SEARCH_T_NORMAL;
search_content_handle->is_case_sentitive = options.content_case_sens;
search_content_handle->whole_words = options.content_whole_words;
search_content_handle->is_all_charsets = options.content_all_charsets;
}
search_file_handle = mc_search_new(find_pattern, -1);
search_file_handle->search_type = (file_pattern_flag) ? MC_SEARCH_T_GLOB : MC_SEARCH_T_REGEX;
search_file_handle->is_case_sentitive = file_case_sens_flag;
search_file_handle->is_all_charsets = file_all_charsets_flag;
search_file_handle->is_entire_line = file_pattern_flag;
search_file_handle->search_type = options.file_pattern ? MC_SEARCH_T_GLOB : MC_SEARCH_T_REGEX;
search_file_handle->is_case_sentitive = options.file_case_sens;
search_file_handle->is_all_charsets = options.file_all_charsets;
search_file_handle->is_entire_line = options.file_pattern;
count = 0;
@ -857,10 +932,10 @@ do_search (struct Dlg_head *h)
return 1;
}
if (!(skip_hidden_flag && (dp->d_name[0] == '.'))) {
if (!(options.skip_hidden && (dp->d_name[0] == '.'))) {
gboolean search_ok;
if ((subdirs_left != 0) && find_recurs_flag
if ((subdirs_left != 0) && options.find_recurs
&& (directory != NULL)) { /* Can directory be NULL ? */
char *tmp_name = concat_dir_and_file (directory, dp->d_name);
if (!mc_lstat (tmp_name, &tmp_stat)

Просмотреть файл

@ -73,8 +73,6 @@
#include "../src/strutil.h" /* str_isutf8 () */
extern char *find_ignore_dirs;
extern int num_history_items_recorded;
char *profile_name; /* .mc/ini */
@ -788,10 +786,6 @@ load_setup (void)
#ifdef USE_NETCODE
ftpfs_proxy_host = mc_config_get_string(mc_main_config, "Misc", "ftp_proxy_host", "gate");
#endif
setup_color_string = mc_config_get_string(mc_main_config, "Misc", "find_ignore_dirs", "");
if (setup_color_string [0])
find_ignore_dirs = g_strconcat (":", setup_color_string, ":", (char *) NULL);
g_free(setup_color_string);
/* The default color and the terminal dependent color */
setup_color_string = mc_config_get_string(mc_main_config, "Colors", "base_color", "");