From aeb893354368d08d082c4d759a5f8a1909222725 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sat, 25 May 2013 11:33:26 +0400 Subject: [PATCH] Ticket #2163: rotating dash is not removed when mc finishes reading the directory ...or when other long aperation is finished. (rotate_dash): add argument to show/hide dash. Move dash to the corner of the right/top panel from corner of the screen. Thanks Egmont Koblinger for the original patch. Signed-off-by: Andrew Borodin --- src/filemanager/cmd.c | 6 ++++-- src/filemanager/dir.c | 9 ++++++--- src/filemanager/file.c | 4 +++- src/filemanager/find.c | 5 +++-- src/filemanager/layout.c | 20 +++++++++++++------- src/filemanager/layout.h | 2 +- src/filemanager/panelize.c | 6 ++++-- 7 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/filemanager/cmd.c b/src/filemanager/cmd.c index 9f169bcf9..8d4215ffc 100644 --- a/src/filemanager/cmd.c +++ b/src/filemanager/cmd.c @@ -315,7 +315,7 @@ compare_files (const vfs_path_t * vpath1, const vfs_path_t * vpath2, off_t size) data2 = mmap (0, size, PROT_READ, MAP_FILE | MAP_PRIVATE, file2, 0); if (data2 != (char *) -1) { - rotate_dash (); + rotate_dash (TRUE); result = memcmp (data1, data2, size); munmap (data2, size); } @@ -325,7 +325,7 @@ compare_files (const vfs_path_t * vpath1, const vfs_path_t * vpath2, off_t size) /* Don't have mmap() :( Even more ugly :) */ char buf1[BUFSIZ], buf2[BUFSIZ]; int n1, n2; - rotate_dash (); + rotate_dash (TRUE); do { while ((n1 = read (file1, buf1, BUFSIZ)) == -1 && errno == EINTR); @@ -338,6 +338,8 @@ compare_files (const vfs_path_t * vpath1, const vfs_path_t * vpath2, off_t size) } close (file1); } + rotate_dash (FALSE); + return result; } diff --git a/src/filemanager/dir.c b/src/filemanager/dir.c index db0ba4bcb..1ec2e4270 100644 --- a/src/filemanager/dir.c +++ b/src/filemanager/dir.c @@ -604,7 +604,7 @@ do_load_dir (const vfs_path_t * vpath, dir_list * list, sortfn * sort, gboolean next_free++; if ((next_free & 31) == 0) - rotate_dash (); + rotate_dash (TRUE); } if (next_free != 0) @@ -613,6 +613,7 @@ do_load_dir (const vfs_path_t * vpath, dir_list * list, sortfn * sort, gboolean ret: mc_closedir (dirp); tree_store_end_check (); + rotate_dash (FALSE); return next_free; } @@ -742,8 +743,8 @@ do_reload_dir (const vfs_path_t * vpath, dir_list * list, sortfn * sort, int cou list->list[next_free].sort_key = NULL; list->list[next_free].second_sort_key = NULL; next_free++; - if (!(next_free % 16)) - rotate_dash (); + if ((next_free % 16) == 0) + rotate_dash (TRUE); } mc_closedir (dirp); tree_store_end_check (); @@ -753,6 +754,8 @@ do_reload_dir (const vfs_path_t * vpath, dir_list * list, sortfn * sort, int cou do_sort (list, sort, next_free - 1, lc_reverse, lc_case_sensitive, exec_ff); } clean_dir (&dir_copy, count); + rotate_dash (FALSE); + return next_free; } diff --git a/src/filemanager/file.c b/src/filemanager/file.c index 4b4071e3e..49f466722 100644 --- a/src/filemanager/file.c +++ b/src/filemanager/file.c @@ -85,6 +85,7 @@ #include "filenot.h" #include "tree.h" #include "midnight.h" /* current_panel */ +#include "layout.h" /* rotate_dash() */ #include "file.h" @@ -828,7 +829,7 @@ copy_file_file_display_progress (FileOpTotalContext * tctx, FileOpContext * ctx, long dt; /* 1. Update rotating dash after some time */ - rotate_dash (); + rotate_dash (TRUE); /* 3. Compute ETA */ dt = (tv_current.tv_sec - tv_transfer_start.tv_sec); @@ -1916,6 +1917,7 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx, dst_status = DEST_FULL; /* copy successful, don't remove target file */ ret: + rotate_dash (FALSE); while (src_desc != -1 && mc_close (src_desc) < 0 && !ctx->skip_all) { temp_status = file_error (_("Cannot close source file \"%s\"\n%s"), src_path); diff --git a/src/filemanager/find.c b/src/filemanager/find.c index bac23f9b9..d20728697 100644 --- a/src/filemanager/find.c +++ b/src/filemanager/find.c @@ -1766,8 +1766,8 @@ do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs, list->list[next_free].second_sort_key = NULL; next_free++; g_free (name); - if (!(next_free & 15)) - rotate_dash (); + if ((next_free & 15) == 0) + rotate_dash (TRUE); } if (next_free) @@ -1793,6 +1793,7 @@ do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs, do_search (NULL); /* force do_search to release resources */ g_free (old_dir); old_dir = NULL; + rotate_dash (FALSE); return return_value; } diff --git a/src/filemanager/layout.c b/src/filemanager/layout.c index cb8a22343..42e34b2db 100644 --- a/src/filemanager/layout.c +++ b/src/filemanager/layout.c @@ -879,21 +879,27 @@ set_hintbar (const char *str) /* --------------------------------------------------------------------------------------------- */ void -rotate_dash (void) +rotate_dash (gboolean show) { - static const char rotating_dash[] = "|/-\\"; + static const char rotating_dash[4] = "|/-\\"; static size_t pos = 0; + Widget *w = WIDGET (midnight_dlg); if (!nice_rotating_dash || (ok_to_refresh <= 0)) return; - if (pos >= sizeof (rotating_dash) - 1) - pos = 0; - tty_gotoyx (0, COLS - 1); + widget_move (w, (menubar_visible != 0) ? 1 : 0, w->cols - 1); tty_setcolor (NORMAL_COLOR); - tty_print_char (rotating_dash[pos]); + + if (!show) + tty_print_alt_char (ACS_URCORNER, FALSE); + else + { + tty_print_char (rotating_dash[pos]); + pos = (pos + 1) % sizeof (rotating_dash); + } + mc_refresh (); - pos++; } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/filemanager/layout.h b/src/filemanager/layout.h index a5c2292bb..f5c7c87a6 100644 --- a/src/filemanager/layout.h +++ b/src/filemanager/layout.h @@ -79,7 +79,7 @@ void set_hintbar (const char *str); /* Rotating dash routines */ void use_dash (gboolean flag); /* Disable/Enable rotate_dash routines */ -void rotate_dash (void); +void rotate_dash (gboolean show); #ifdef ENABLE_SUBSHELL gboolean do_load_prompt (void); diff --git a/src/filemanager/panelize.c b/src/filemanager/panelize.c index 1e30f0de1..5c609df9f 100644 --- a/src/filemanager/panelize.c +++ b/src/filemanager/panelize.c @@ -52,6 +52,7 @@ #include "dir.h" #include "midnight.h" /* current_panel */ +#include "layout.h" /* rotate_dash() */ #include "panel.h" /* WPanel */ #include "panelize.h" @@ -366,8 +367,8 @@ do_external_panelize (char *command) list->list[next_free].sort_key = NULL; list->list[next_free].second_sort_key = NULL; next_free++; - if (!(next_free & 32)) - rotate_dash (); + if ((next_free & 32) == 0) + rotate_dash (TRUE); } current_panel->is_panelized = TRUE; @@ -395,6 +396,7 @@ do_external_panelize (char *command) close_error_pipe (D_NORMAL, NULL); try_to_select (current_panel, NULL); panel_re_sort (current_panel); + rotate_dash (FALSE); } /* --------------------------------------------------------------------------------------------- */