From e3a82ba1d8585c458f030688c6364e4102c2cc13 Mon Sep 17 00:00:00 2001 From: "Mikhail S. Pobolovets" Date: Thu, 22 Jan 2009 23:29:10 +0200 Subject: [PATCH] Signed-off-by: Mikhail S. Pobolovets Automatic new directory(Mkdir, F7) name filling. Can be configured (on|off) in 'Configure options'. --- src/cmd.c | 13 +++++++++++-- src/main.h | 1 + src/option.c | 3 ++- src/setup.c | 1 + 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/cmd.c b/src/cmd.c index a3ea05c85..84f6e071a 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -77,6 +77,8 @@ int output_starts_shell = 0; /* If set, use the builtin editor */ int use_internal_edit = 1; +/* Automatically fills name with current selected item name on mkdir */ +int auto_fill_mkdir_name = 1; int view_file_at_line (const char *filename, int plain_view, int internal, @@ -351,11 +353,18 @@ void mkdir_cmd (void) { char *dir, *absdir; + char *name = ""; + + /* If 'on' then automatically fills name with current selected item name */ + if (auto_fill_mkdir_name) + name = selection (current_panel)->fname; dir = input_expand_dialog (_("Create a new Directory"), - _(" Enter directory name:"), - MC_HISTORY_FM_MKDIR, ""); + _(" Enter directory name:"), + MC_HISTORY_FM_MKDIR, + name); + if (!dir) return; diff --git a/src/main.h b/src/main.h index fb38e7a38..1500548be 100644 --- a/src/main.h +++ b/src/main.h @@ -71,6 +71,7 @@ extern int output_starts_shell; extern int midnight_shutdown; extern char cmd_buf [512]; extern const char *shell; +extern int auto_fill_mkdir_name; /* Ugly hack in order to distinguish between left and right panel in menubar */ extern int is_right; /* If the selected menu was the right */ diff --git a/src/option.c b/src/option.c index 2898266f9..1649b0537 100644 --- a/src/option.c +++ b/src/option.c @@ -65,6 +65,7 @@ static struct { {N_("shell &Patterns"), &easy_patterns, TOGGLE_VARIABLE, 0 }, {N_("Compute &Totals"), &file_op_compute_totals, TOGGLE_VARIABLE, 0 }, {N_("&Verbose operation"), &verbose, TOGGLE_VARIABLE, 0 }, + {N_("Mkdir autoname"), &auto_fill_mkdir_name, TOGGLE_VARIABLE, 0 }, /* panel options */ {N_("&Fast dir reload"), &fast_reload, toggle_fast_reload, 0 }, {N_("mi&X all files"), &mix_all_files, toggle_mix_all_files, 0 }, @@ -76,7 +77,7 @@ static struct { }; /* Make sure this corresponds to the check_options structure */ -#define OTHER_OPTIONS 12 +#define OTHER_OPTIONS 13 #define PANEL_OPTIONS 6 static WRadio *pause_radio; diff --git a/src/setup.c b/src/setup.c index 3e24e6040..e806f10ca 100644 --- a/src/setup.c +++ b/src/setup.c @@ -223,6 +223,7 @@ static const struct { { "nice_rotating_dash", &nice_rotating_dash }, { "horizontal_split", &horizontal_split }, { "mcview_remember_file_position", &mcview_remember_file_position }, + { "auto_fill_mkdir_name", &auto_fill_mkdir_name }, { 0, 0 } };