1
1

Merge commit 'origin/50_history_section_names' into 50_history_sections.metux

Этот коммит содержится в:
Enrico Weigelt, metux IT service 2009-01-24 21:26:41 +01:00
родитель 7fae75c0d6 22fada9ce0
Коммит b9b09436c4
12 изменённых файлов: 75 добавлений и 55 удалений

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

@ -58,9 +58,6 @@
#include "../src/charsets.h" #include "../src/charsets.h"
#include "../src/selcodepage.h" #include "../src/selcodepage.h"
#define edit_get_load_file(f,h) input_expand_dialog (h, _(" Enter file name: "), f)
#define edit_get_save_file(f,h) input_expand_dialog (h, _(" Enter file name: "), f)
struct selection { struct selection {
unsigned char * text; unsigned char * text;
int len; int len;
@ -525,7 +522,8 @@ edit_save_as_cmd (WEdit *edit)
int save_lock = 0; int save_lock = 0;
int different_filename = 0; int different_filename = 0;
exp = edit_get_save_file (edit->filename, _(" Save As ")); exp = input_expand_dialog (_(" Save As "), _(" Enter file name: "),
":edit_save_as_cmd: Save As ", edit->filename);
edit_push_action (edit, KEY_PRESS + edit->start_display); edit_push_action (edit, KEY_PRESS + edit->start_display);
if (exp) { if (exp) {
@ -907,7 +905,8 @@ edit_load_cmd (WEdit *edit)
} }
} }
exp = edit_get_load_file (edit->filename, _(" Load ")); exp = input_expand_dialog (_(" Load "), _(" Enter file name: "),
":edit_load_cmd: Load ", edit->filename);
if (exp) { if (exp) {
if (*exp) if (*exp)
@ -2338,7 +2337,8 @@ edit_goto_cmd (WEdit *edit)
char s[32]; char s[32];
g_snprintf (s, sizeof (s), "%ld", line); g_snprintf (s, sizeof (s), "%ld", line);
f = input_dialog (_(" Goto line "), _(" Enter line: "), line ? s : ""); f = input_dialog (_(" Goto line "), _(" Enter line: "), ":edit_goto_cmd: Goto line ",
line ? s : "");
if (!f) if (!f)
return; return;
@ -2372,8 +2372,9 @@ edit_save_block_cmd (WEdit *edit)
if (eval_marks (edit, &start_mark, &end_mark)) if (eval_marks (edit, &start_mark, &end_mark))
return 1; return 1;
exp = exp =
edit_get_save_file (catstrs (home_dir, PATH_SEP_STR CLIP_FILE, (char *) NULL), input_expand_dialog (_(" Save Block "), _(" Enter file name: "),
_(" Save Block ")); ":edit_save_block_cmd: Save Block ",
catstrs (home_dir, PATH_SEP_STR CLIP_FILE, (char *) NULL));
edit_push_action (edit, KEY_PRESS + edit->start_display); edit_push_action (edit, KEY_PRESS + edit->start_display);
if (exp) { if (exp) {
if (!*exp) { if (!*exp) {
@ -2401,8 +2402,9 @@ edit_save_block_cmd (WEdit *edit)
int int
edit_insert_file_cmd (WEdit *edit) edit_insert_file_cmd (WEdit *edit)
{ {
char *exp = edit_get_load_file (catstrs (home_dir, PATH_SEP_STR CLIP_FILE, (char *) NULL), char *exp = input_expand_dialog (_(" Insert File "), _(" Enter file name: "),
_(" Insert File ")); ":edit_insert_file_cmd: Insert File ",
catstrs (home_dir, PATH_SEP_STR CLIP_FILE, (char *) NULL));
edit_push_action (edit, KEY_PRESS + edit->start_display); edit_push_action (edit, KEY_PRESS + edit->start_display);
if (exp) { if (exp) {
if (!*exp) { if (!*exp) {
@ -2441,7 +2443,7 @@ int edit_sort_cmd (WEdit * edit)
exp = input_dialog (_(" Run Sort "), exp = input_dialog (_(" Run Sort "),
_(" Enter sort options (see manpage) separated by whitespace: "), _(" Enter sort options (see manpage) separated by whitespace: "),
(old != NULL) ? old : ""); ":edit_sort_cmd: Run Sort ", (old != NULL) ? old : "");
if (!exp) if (!exp)
return 1; return 1;
@ -2482,7 +2484,8 @@ edit_ext_cmd (WEdit *edit)
exp = exp =
input_dialog (_("Paste output of external command"), input_dialog (_("Paste output of external command"),
_("Enter shell command(s):"), NULL); _("Enter shell command(s):"),
":edit_ext_cmd: Paste output of ext.cmd ", NULL);
if (!exp) if (!exp)
return 1; return 1;

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

@ -229,7 +229,7 @@ view_file_cmd (void)
filename = filename =
input_expand_dialog (_(" View file "), _(" Filename:"), input_expand_dialog (_(" View file "), _(" Filename:"),
selection (current_panel)->fname); ":view_file_cmd: View file ", selection (current_panel)->fname);
if (!filename) if (!filename)
return; return;
@ -252,6 +252,7 @@ filtered_view_cmd (void)
command = command =
input_dialog (_(" Filtered view "), input_dialog (_(" Filtered view "),
_(" Filter command and arguments:"), _(" Filter command and arguments:"),
":filtered_view_cmd: Filtered view ",
selection (current_panel)->fname); selection (current_panel)->fname);
if (!command) if (!command)
return; return;
@ -350,7 +351,8 @@ mkdir_cmd (void)
dir = dir =
input_expand_dialog (_("Create a new Directory"), input_expand_dialog (_("Create a new Directory"),
_(" Enter directory name:"), ""); _(" Enter directory name:"),
":mkdir_cmd: Create a new Directory", "");
if (!dir) if (!dir)
return; return;
@ -422,7 +424,7 @@ set_panel_filter (WPanel *p)
reg_exp = input_dialog_help (_(" Filter "), reg_exp = input_dialog_help (_(" Filter "),
_(" Set expression for filtering filenames"), _(" Set expression for filtering filenames"),
"[Filter...]", x); "[Filter...]", ":set_panel_filter: Filter ", x);
if (!reg_exp) if (!reg_exp)
return; return;
set_panel_filter_to (p, reg_exp); set_panel_filter_to (p, reg_exp);
@ -468,14 +470,14 @@ void reverse_selection_cmd (void)
} }
static void static void
select_unselect_cmd (const char *title, int cmd) select_unselect_cmd (const char *title, const char *history_name, int cmd)
{ {
char *reg_exp, *reg_exp_t; char *reg_exp, *reg_exp_t;
int i; int i;
int c; int c;
int dirflag = 0; int dirflag = 0;
reg_exp = input_dialog (title, "", easy_patterns ? "*" : "."); reg_exp = input_dialog (title, "", history_name, easy_patterns ? "*" : ".");
if (!reg_exp) if (!reg_exp)
return; return;
if (!*reg_exp) { if (!*reg_exp) {
@ -521,12 +523,12 @@ select_unselect_cmd (const char *title, int cmd)
void select_cmd (void) void select_cmd (void)
{ {
select_unselect_cmd (_(" Select "), 1); select_unselect_cmd (_(" Select "), ":select_cmd: Select ", 1);
} }
void unselect_cmd (void) void unselect_cmd (void)
{ {
select_unselect_cmd (_(" Unselect "), 0); select_unselect_cmd (_(" Unselect "), ":unselect_cmd: Unselect ", 0);
} }
/* Check if the file exists */ /* Check if the file exists */
@ -903,7 +905,7 @@ do_link (int symbolic_link, const char *fname)
if (!symbolic_link) { if (!symbolic_link) {
src = g_strdup_printf (_("Link %s to:"), name_trunc (fname, 46)); src = g_strdup_printf (_("Link %s to:"), name_trunc (fname, 46));
dest = input_expand_dialog (_(" Link "), src, ""); dest = input_expand_dialog (_(" Link "), src, ":do_link: Link ", "");
if (!dest || !*dest) if (!dest || !*dest)
goto cleanup; goto cleanup;
save_cwds_stat (); save_cwds_stat ();
@ -972,7 +974,7 @@ void edit_symlink_cmd (void)
i = readlink (p, buffer, MC_MAXPATHLEN - 1); i = readlink (p, buffer, MC_MAXPATHLEN - 1);
if (i > 0) { if (i > 0) {
buffer [i] = 0; buffer [i] = 0;
dest = input_expand_dialog (_(" Edit symlink "), q, buffer); dest = input_expand_dialog (_(" Edit symlink "), q, ":edit_symlink_cmd: Edit symlink ", buffer);
if (dest) { if (dest) {
if (*dest && strcmp (buffer, dest)) { if (*dest && strcmp (buffer, dest)) {
save_cwds_stat (); save_cwds_stat ();
@ -1085,7 +1087,8 @@ get_random_hint (int force)
#if defined(USE_NETCODE) || defined(USE_EXT2FSLIB) #if defined(USE_NETCODE) || defined(USE_EXT2FSLIB)
static void static void
nice_cd (const char *text, const char *xtext, const char *help, const char *prefix, int to_home) nice_cd (const char *text, const char *xtext, const char *help,
const char *history_name, const char *prefix, int to_home)
{ {
char *machine; char *machine;
char *cd_path; char *cd_path;
@ -1093,9 +1096,7 @@ nice_cd (const char *text, const char *xtext, const char *help, const char *pref
if (!SELECTED_IS_PANEL) if (!SELECTED_IS_PANEL)
return; return;
machine = input_dialog_help (text, machine = input_dialog_help (text, xtext, help, history_name, "");
xtext,
help, "");
if (!machine) if (!machine)
return; return;
@ -1125,27 +1126,30 @@ static const char *machine_str = N_(" Enter machine name (F1 for details): ");
void netlink_cmd (void) void netlink_cmd (void)
{ {
nice_cd (_(" Link to a remote machine "), _(machine_str), nice_cd (_(" Link to a remote machine "), _(machine_str),
"[Network File System]", "/#mc:", 1); "[Network File System]", ":netlink_cmd: Link to a remote ",
"/#mc:", 1);
} }
#endif /* WITH_MCFS */ #endif /* WITH_MCFS */
void ftplink_cmd (void) void ftplink_cmd (void)
{ {
nice_cd (_(" FTP to machine "), _(machine_str), nice_cd (_(" FTP to machine "), _(machine_str),
"[FTP File System]", "/#ftp:", 1); "[FTP File System]", ":ftplink_cmd: FTP to machine ", "/#ftp:", 1);
} }
void fishlink_cmd (void) void fishlink_cmd (void)
{ {
nice_cd (_(" Shell link to machine "), _(machine_str), nice_cd (_(" Shell link to machine "), _(machine_str),
"[FIle transfer over SHell filesystem]", "/#sh:", 1); "[FIle transfer over SHell filesystem]", ":fishlink_cmd: Shell link to machine ",
"/#sh:", 1);
} }
#ifdef WITH_SMBFS #ifdef WITH_SMBFS
void smblink_cmd (void) void smblink_cmd (void)
{ {
nice_cd (_(" SMB link to machine "), _(machine_str), nice_cd (_(" SMB link to machine "), _(machine_str),
"[SMB File System]", "/#smb:", 0); "[SMB File System]", ":smblink_cmd: SMB link to machine ",
"/#smb:", 0);
} }
#endif /* WITH_SMBFS */ #endif /* WITH_SMBFS */
#endif /* USE_NETCODE */ #endif /* USE_NETCODE */
@ -1156,7 +1160,8 @@ void undelete_cmd (void)
nice_cd (_(" Undelete files on an ext2 file system "), nice_cd (_(" Undelete files on an ext2 file system "),
_(" Enter device (without /dev/) to undelete\n " _(" Enter device (without /dev/) to undelete\n "
" files on: (F1 for details)"), " files on: (F1 for details)"),
"[Undelete File System]", "/#undel:", 0); "[Undelete File System]", ":undelete_cmd: Undel on ext2 fs ",
"/#undel:", 0);
} }
#endif /* USE_EXT2FSLIB */ #endif /* USE_EXT2FSLIB */

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

@ -114,7 +114,7 @@ exec_extension (const char *filename, const char *data, int *move_dir,
if (*data == '}') { if (*data == '}') {
char *parameter; char *parameter;
parameter_found = 0; parameter_found = 0;
parameter = input_dialog (_(" Parameter "), prompt, ""); parameter = input_dialog (_(" Parameter "), prompt, ":exec_extension: Parameter ", "");
if (!parameter) { if (!parameter) {
/* User canceled */ /* User canceled */
fclose (cmd_file); fclose (cmd_file);

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

@ -1042,7 +1042,7 @@ void add2hotlist_cmd (void)
strip_password (label_string, 1); strip_password (label_string, 1);
prompt = g_strdup_printf (cp, path_trunc (current_panel->cwd, COLS-2*UX-(l+8))); prompt = g_strdup_printf (cp, path_trunc (current_panel->cwd, COLS-2*UX-(l+8)));
label = input_dialog (_(" Add to hotlist "), prompt, label_string); label = input_dialog (_(" Add to hotlist "), prompt, ":add2hotlist_cmd: Add to hotlist ", label_string);
g_free (prompt); g_free (prompt);
if (!label || !*label) { if (!label || !*label) {

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

@ -226,6 +226,7 @@ add2panelize_cmd (void)
if (pname->buffer && (*pname->buffer)) { if (pname->buffer && (*pname->buffer)) {
label = input_dialog (_(" Add to external panelize "), label = input_dialog (_(" Add to external panelize "),
_(" Enter command label: "), _(" Enter command label: "),
":add2panelize_cmd: Add to external panelize ",
""); "");
if (!label) if (!label)
return; return;

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

@ -598,7 +598,7 @@ static void tree_copy (WTree *tree, const char *default_dest)
return; return;
g_snprintf (cmd_buf, sizeof(cmd_buf), _("Copy \"%s\" directory to:"), g_snprintf (cmd_buf, sizeof(cmd_buf), _("Copy \"%s\" directory to:"),
name_trunc (tree->selected_ptr->name, 50)); name_trunc (tree->selected_ptr->name, 50));
dest = input_expand_dialog (_(" Copy "), cmd_buf, default_dest); dest = input_expand_dialog (_(" Copy "), cmd_buf, ":tree_copy: Copy ", default_dest);
if (!dest) if (!dest)
return; return;
@ -641,7 +641,7 @@ static void tree_move (WTree *tree, const char *default_dest)
return; return;
g_snprintf (cmd_buf, sizeof (cmd_buf), _("Move \"%s\" directory to:"), g_snprintf (cmd_buf, sizeof (cmd_buf), _("Move \"%s\" directory to:"),
name_trunc (tree->selected_ptr->name, 50)); name_trunc (tree->selected_ptr->name, 50));
dest = input_expand_dialog (_(" Move "), cmd_buf, default_dest); dest = input_expand_dialog (_(" Move "), cmd_buf, ":tree_move: Move ", default_dest);
if (!dest) if (!dest)
return; return;
if (!*dest){ if (!*dest){

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

@ -604,7 +604,7 @@ execute_menu_command (WEdit *edit_widget, const char *commands)
if (*commands == '}'){ if (*commands == '}'){
char *tmp; char *tmp;
*parameter = 0; *parameter = 0;
parameter = input_dialog (_(" Parameter "), prompt, ""); parameter = input_dialog (_(" Parameter "), prompt, ":execute_menu_command: Parameter ", "");
if (!parameter || !*parameter){ if (!parameter || !*parameter){
/* User canceled */ /* User canceled */
fclose (cmd_file); fclose (cmd_file);

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

@ -2734,7 +2734,7 @@ view_moveto_line_cmd (WView *view)
g_snprintf (prompt, sizeof (prompt), g_snprintf (prompt, sizeof (prompt),
_(" The current line number is %d.\n" _(" The current line number is %d.\n"
" Enter the new line number:"), (int) (line + 1)); " Enter the new line number:"), (int) (line + 1));
answer = input_dialog (_(" Goto line "), prompt, ""); answer = input_dialog (_(" Goto line "), prompt, ":view_moveto_line_cmd: Goto line ", "");
if (answer != NULL && answer[0] != '\0') { if (answer != NULL && answer[0] != '\0') {
errno = 0; errno = 0;
line = strtoul (answer, &answer_end, 10); line = strtoul (answer, &answer_end, 10);
@ -2755,7 +2755,7 @@ view_moveto_addr_cmd (WView *view)
g_snprintf (prompt, sizeof (prompt), g_snprintf (prompt, sizeof (prompt),
_(" The current address is 0x%lx.\n" _(" The current address is 0x%lx.\n"
" Enter the new address:"), view->hex_cursor); " Enter the new address:"), view->hex_cursor);
line = input_dialog (_(" Goto Address "), prompt, ""); line = input_dialog (_(" Goto Address "), prompt, ":view_moveto_addr_cmd: Goto Address ", "");
if (line != NULL) { if (line != NULL) {
if (*line != '\0') { if (*line != '\0') {
addr = strtoul (line, &error, 0); addr = strtoul (line, &error, 0);
@ -2788,7 +2788,7 @@ regexp_search (WView *view, int direction)
defval = (last_regexp != NULL ? last_regexp : ""); defval = (last_regexp != NULL ? last_regexp : "");
regexp = input_dialog (_("Search"), _(" Enter regexp:"), defval); regexp = input_dialog (_("Search"), _(" Enter regexp:"), ":regexp_search: Search", defval);
if (regexp == NULL || regexp[0] == '\0') { if (regexp == NULL || regexp[0] == '\0') {
g_free (regexp); g_free (regexp);
return; return;

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

@ -434,11 +434,15 @@ int quick_dialog (QuickDialog *qd)
* *
* If the arguments "header" and "text" should be translated, * If the arguments "header" and "text" should be translated,
* that MUST be done by the caller of fg_input_dialog_help(). * that MUST be done by the caller of fg_input_dialog_help().
*
* The argument "history_name" holds the name of a section
* in the history file. Data entered in the input field of
* the dialog box will be stored there.
* *
*/ */
static char * static char *
fg_input_dialog_help (const char *header, const char *text, const char *help, fg_input_dialog_help (const char *header, const char *text, const char *help,
const char *def_text) const char *history_name, const char *def_text)
{ {
QuickDialog Quick_input; QuickDialog Quick_input;
QuickWidget quick_widgets[] = { QuickWidget quick_widgets[] = {
@ -458,10 +462,10 @@ fg_input_dialog_help (const char *header, const char *text, const char *help,
char histname[64] = "inp|"; char histname[64] = "inp|";
char *p_text; char *p_text;
/* we need a unique name for histname because widget.c:history_tool() if (history_name != NULL && *history_name != '\0') {
needs a unique name for each dialog - using the header is ideal */ g_strlcpy (histname + 3, history_name, 61);
g_strlcpy (histname + 3, header, 61); quick_widgets[2].histname = histname;
quick_widgets[2].histname = histname; }
msglen (text, &lines, &cols); msglen (text, &lines, &cols);
len = max ((int) strlen (header), cols) + 4; len = max ((int) strlen (header), cols) + 4;
@ -525,32 +529,36 @@ fg_input_dialog_help (const char *header, const char *text, const char *help,
* that MUST be done by the caller of these wrappers. * that MUST be done by the caller of these wrappers.
*/ */
char * char *
input_dialog_help (const char *header, const char *text, const char *help, const char *def_text) input_dialog_help (const char *header, const char *text, const char *help,
const char *history_name, const char *def_text)
{ {
#ifdef WITH_BACKGROUND #ifdef WITH_BACKGROUND
if (we_are_background) if (we_are_background)
return parent_call_string ((void *) fg_input_dialog_help, 4, return parent_call_string ((void *) fg_input_dialog_help, 5,
strlen (header), header, strlen (text), strlen (header), header, strlen (text),
text, strlen (help), help, text, strlen (help), help,
strlen (history_name), history_name,
strlen (def_text), def_text); strlen (def_text), def_text);
else else
#endif /* WITH_BACKGROUND */ #endif /* WITH_BACKGROUND */
return fg_input_dialog_help (header, text, help, def_text); return fg_input_dialog_help (header, text, help, history_name, def_text);
} }
/* Show input dialog with default help, background safe */ /* Show input dialog with default help, background safe */
char *input_dialog (const char *header, const char *text, const char *def_text) char *input_dialog (const char *header, const char *text,
const char *history_name, const char *def_text)
{ {
return input_dialog_help (header, text, "[Input Line Keys]", def_text); return input_dialog_help (header, text, "[Input Line Keys]", history_name, def_text);
} }
char * char *
input_expand_dialog (const char *header, const char *text, const char *def_text) input_expand_dialog (const char *header, const char *text,
const char *history_name, const char *def_text)
{ {
char *result; char *result;
char *expanded; char *expanded;
result = input_dialog (header, text, def_text); result = input_dialog (header, text, history_name, def_text);
if (result) { if (result) {
expanded = tilde_expand (result); expanded = tilde_expand (result);
g_free (result); g_free (result);

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

@ -57,9 +57,12 @@ int quick_dialog_skip (QuickDialog *qd, int nskip);
/* Pass this as def_text to request a password */ /* Pass this as def_text to request a password */
#define INPUT_PASSWORD ((char *) -1) #define INPUT_PASSWORD ((char *) -1)
char *input_dialog (const char *header, const char *text, const char *def_text); char *input_dialog (const char *header, const char *text,
char *input_dialog_help (const char *header, const char *text, const char *help, const char *def_text); const char *history_name, const char *def_text);
char *input_expand_dialog (const char *header, const char *text, const char *def_text); char *input_dialog_help (const char *header, const char *text, const char *help,
const char *history_name, const char *def_text);
char *input_expand_dialog (const char *header, const char *text,
const char *history_name, const char *def_text);
void query_set_sel (int new_sel); void query_set_sel (int new_sel);

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

@ -499,7 +499,7 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super,
p = g_strdup_printf (_ p = g_strdup_printf (_
("FTP: Account required for user %s"), ("FTP: Account required for user %s"),
SUP.user); SUP.user);
op = input_dialog (p, _("Account:"), ""); op = input_dialog (p, _("Account:"), (char *) NULL, "");
g_free (p); g_free (p);
if (op == NULL) if (op == NULL)
ERRNOR (EPERM, 0); ERRNOR (EPERM, 0);

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

@ -839,5 +839,5 @@ vfs_die (const char *m)
char * char *
vfs_get_password (const char *msg) vfs_get_password (const char *msg)
{ {
return input_dialog (msg, _("Password:"), INPUT_PASSWORD); return input_dialog (msg, _("Password:"), (char *) NULL, INPUT_PASSWORD);
} }