diff -uNr mc-4.8.10.configured/src/filemanager/find.c mc-4.8.10.refresh-size+time/src/filemanager/find.c
old
|
new
|
|
149 | 149 | static gboolean is_start = FALSE; /* Status of the start/stop toggle button */ |
150 | 150 | static char *old_dir = NULL; |
151 | 151 | |
| 152 | #define MAX_REFRESH_INTERVAL 50000000 /* 50 ms */ |
| 153 | #define MIN_REFRESH_FILE_SIZE (256 * 1024) /* 256 KB */ |
| 154 | static struct timespec last_refresh; |
| 155 | |
152 | 156 | /* Where did we stop */ |
153 | 157 | static gboolean resuming; |
154 | 158 | static int last_line; |
… |
… |
|
978 | 982 | int file_fd; |
979 | 983 | gboolean ret_val = FALSE; |
980 | 984 | vfs_path_t *vpath; |
| 985 | struct timespec tv; |
| 986 | time_t seconds; |
| 987 | long nanoseconds; |
| 988 | gboolean status_updated = FALSE; |
981 | 989 | |
982 | 990 | vpath = vfs_path_build_filename (directory, filename, (char *) NULL); |
983 | 991 | |
… |
… |
|
993 | 1001 | if (file_fd == -1) |
994 | 1002 | return FALSE; |
995 | 1003 | |
996 | | g_snprintf (buffer, sizeof (buffer), _("Grepping in %s"), filename); |
997 | | status_update (str_trunc (buffer, WIDGET (h)->cols - 8)); |
| 1004 | /* get time elapsed from last refresh */ |
| 1005 | if (-1 == clock_gettime(CLOCK_MONOTONIC, &tv)) { |
| 1006 | tv.tv_sec = 0; |
| 1007 | tv.tv_nsec = 0; |
| 1008 | last_refresh = tv; |
| 1009 | } |
| 1010 | seconds = tv.tv_sec - last_refresh.tv_sec; |
| 1011 | nanoseconds = tv.tv_nsec - last_refresh.tv_nsec; |
| 1012 | if (nanoseconds < 0) { |
| 1013 | seconds -= 1; |
| 1014 | nanoseconds += 1000000000; |
| 1015 | } |
| 1016 | |
| 1017 | if (s.st_size >= MIN_REFRESH_FILE_SIZE || |
| 1018 | seconds > 0 || |
| 1019 | nanoseconds > MAX_REFRESH_INTERVAL) |
| 1020 | { |
| 1021 | g_snprintf (buffer, sizeof (buffer), _("Grepping in %s"), filename); |
| 1022 | status_update (str_trunc (buffer, WIDGET (h)->cols - 8)); |
998 | 1023 | |
999 | | mc_refresh (); |
| 1024 | mc_refresh (); |
| 1025 | last_refresh = tv; |
| 1026 | status_updated = TRUE; |
| 1027 | } |
1000 | 1028 | |
1001 | 1029 | tty_enable_interrupt_key (); |
1002 | 1030 | tty_got_interrupt (); |
… |
… |
|
1063 | 1091 | && mc_search_run (search_content_handle, |
1064 | 1092 | (const void *) strbuf, 0, i, &found_len)) |
1065 | 1093 | { |
| 1094 | if (status_updated == FALSE) { |
| 1095 | /* if we add results for a file, we have to ensure that |
| 1096 | name of this file is shown in status bar */ |
| 1097 | g_snprintf (result, sizeof (result), _("Grepping in %s"), filename); |
| 1098 | status_update (str_trunc (result, WIDGET (h)->cols - 8)); |
| 1099 | mc_refresh (); |
| 1100 | last_refresh = tv; |
| 1101 | status_updated = TRUE; |
| 1102 | } |
| 1103 | |
1066 | 1104 | g_snprintf (result, sizeof (result), "%d:%s", line, filename); |
1067 | 1105 | find_add_match (directory, result); |
1068 | 1106 | found = TRUE; |
… |
… |
|
1804 | 1842 | if (pattern[0] == '\0') |
1805 | 1843 | break; /* nothing search */ |
1806 | 1844 | |
| 1845 | last_refresh.tv_sec = 0; |
| 1846 | last_refresh.tv_nsec = 0; |
| 1847 | |
1807 | 1848 | dirname = filename = NULL; |
1808 | 1849 | is_start = FALSE; |
1809 | 1850 | clock_gettime(CLOCK_MONOTONIC, &begin); |