From 0e218318da8bb2e31858c2cc37272f3a3c6987ed Mon Sep 17 00:00:00 2001 From: Roland Illig Date: Tue, 6 Sep 2005 06:41:35 +0000 Subject: [PATCH] * cmd.c: Added single_dirsize_cmd(), which computes the size of the currently selected panel entry and moves down. Suggested by ForestCreature on mc-devel. * cmd.h: Likewise. * main.c (midnight_callback): When the space key is pressed and the command line is empty, single_dirsize_cmd() is called. --- src/ChangeLog | 9 +++++++++ src/cmd.c | 23 +++++++++++++++++++++++ src/cmd.h | 1 + src/main.c | 5 +++++ 4 files changed, 38 insertions(+) diff --git a/src/ChangeLog b/src/ChangeLog index 7afdea97f..36a6c4ee1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2005-09-06 Roland Illig + + * cmd.c: Added single_dirsize_cmd(), which computes the size of + the currently selected panel entry and moves down. Suggested by + ForestCreature on mc-devel. + * cmd.h: Likewise. + * main.c (midnight_callback): When the space key is pressed and + the command line is empty, single_dirsize_cmd() is called. + 2005-09-05 Roland Illig * info.c: Switched from printw() to tty_printf() to avoid gcc diff --git a/src/cmd.c b/src/cmd.c index 0aa0e5c37..31a35e944 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1173,6 +1173,29 @@ void quick_cd_cmd (void) g_free (p); } +void +single_dirsize_cmd (void) +{ + WPanel *panel = current_panel; + file_entry *entry; + off_t marked; + double total; + + entry = &(panel->dir.list[panel->selected]); + if (S_ISDIR (entry->st.st_mode) && strcmp(entry->fname, "..") != 0) { + total = 0.0; + compute_dir_size (entry->fname, &marked, &total); + entry->st.st_size = (off_t) total; + entry->f.dir_size_computed = 1; + } + + if (mark_moves_down) + send_message (&(panel->widget), WIDGET_KEY, KEY_DOWN); + + recalculate_panel_summary (panel); + panel->dirty = 1; +} + void dirsizes_cmd (void) { diff --git a/src/cmd.h b/src/cmd.h index d5fbf789f..ace6c28c9 100644 --- a/src/cmd.h +++ b/src/cmd.h @@ -7,6 +7,7 @@ void fishlink_cmd (void); void smblink_cmd (void); void undelete_cmd (void); void help_cmd (void); +void single_dirsize_cmd (void); void dirsizes_cmd (void); int view_file_at_line (const char *filename, int plain_view, int internal, int start_line); diff --git a/src/main.c b/src/main.c index 04a802a81..e73abadc9 100644 --- a/src/main.c +++ b/src/main.c @@ -1543,6 +1543,11 @@ midnight_callback (struct Dlg_head *h, dlg_msg_t msg, int parm) reverse_selection_cmd (); return MSG_HANDLED; } + + if (parm == ' ') { + single_dirsize_cmd (); + return MSG_HANDLED; + } } } return MSG_NOT_HANDLED;