diff -uNr mc-4.8.9/src/filemanager/find.c mc-4.8.9.status/src/filemanager/find.c
old
|
new
|
|
38 | 38 | #include <string.h> |
39 | 39 | #include <fcntl.h> |
40 | 40 | #include <sys/stat.h> |
| 41 | #include <unistd.h> |
| 42 | #include <signal.h> |
41 | 43 | |
42 | 44 | #include "lib/global.h" |
43 | 45 | |
… |
… |
|
154 | 156 | static int last_line; |
155 | 157 | static int last_pos; |
156 | 158 | |
| 159 | static gboolean refresh_status; |
| 160 | |
157 | 161 | static size_t ignore_count = 0; |
158 | 162 | |
159 | 163 | static WDialog *find_dlg; /* The dialog */ |
… |
… |
|
1013 | 1017 | return FIND_CONT; |
1014 | 1018 | } |
1015 | 1019 | |
| 1020 | /* use alarm to make status updates only once per second */ |
| 1021 | void set_refresh_and_alarm(int sig) { |
| 1022 | refresh_status = TRUE; |
| 1023 | alarm(1); |
| 1024 | } |
| 1025 | |
1016 | 1026 | /* --------------------------------------------------------------------------------------------- */ |
1017 | 1027 | /** |
1018 | 1028 | * search_content: |
… |
… |
|
1047 | 1057 | if (file_fd == -1) |
1048 | 1058 | return FALSE; |
1049 | 1059 | |
1050 | | g_snprintf (buffer, sizeof (buffer), _("Grepping in %s"), filename); |
1051 | | status_update (str_trunc (buffer, WIDGET (h)->cols - 8)); |
1052 | | |
1053 | | mc_refresh (); |
1054 | | |
1055 | 1060 | tty_enable_interrupt_key (); |
1056 | 1061 | tty_got_interrupt (); |
1057 | 1062 | |
… |
… |
|
1064 | 1069 | gboolean found = FALSE; |
1065 | 1070 | gsize found_len; |
1066 | 1071 | char result[BUF_MEDIUM]; |
| 1072 | gboolean status_updated = FALSE; |
1067 | 1073 | |
1068 | 1074 | if (resuming) |
1069 | 1075 | { |
… |
… |
|
1076 | 1082 | && (p = get_line_at (file_fd, buffer, sizeof (buffer), |
1077 | 1083 | &pos, &n_read, &has_newline)) != NULL) |
1078 | 1084 | { |
| 1085 | if (refresh_status == TRUE && status_updated == FALSE) { |
| 1086 | g_snprintf (buffer, sizeof (buffer), _("Grepping in %s/%s"), directory, filename); |
| 1087 | status_update (str_trunc (buffer, WIDGET (h)->cols - 8)); |
| 1088 | mc_refresh (); |
| 1089 | status_updated = TRUE; |
| 1090 | refresh_status = FALSE; |
| 1091 | } |
1079 | 1092 | if (!found /* Search in binary line once */ |
1080 | 1093 | && mc_search_run (search_content_handle, |
1081 | 1094 | (const void *) p, 0, strlen (p), &found_len)) |
… |
… |
|
1282 | 1295 | g_free (directory); |
1283 | 1296 | directory = g_strdup (vfs_path_as_str (tmp_vpath)); |
1284 | 1297 | |
| 1298 | /* //directory is shown along with file name now |
1285 | 1299 | if (verbose) |
1286 | 1300 | { |
1287 | 1301 | char buffer[BUF_MEDIUM]; |
… |
… |
|
1289 | 1303 | g_snprintf (buffer, sizeof (buffer), _("Searching %s"), directory); |
1290 | 1304 | status_update (str_trunc (directory, WIDGET (h)->cols - 8)); |
1291 | 1305 | } |
| 1306 | */ |
1292 | 1307 | /* mc_stat should not be called after mc_opendir |
1293 | 1308 | because vfs_s_opendir modifies the st_nlink |
1294 | 1309 | */ |
… |
… |
|
1669 | 1684 | { |
1670 | 1685 | int return_value = 0; |
1671 | 1686 | char *dir_tmp = NULL, *file_tmp = NULL; |
1672 | | |
1673 | 1687 | setup_gui (); |
1674 | 1688 | |
1675 | 1689 | /* FIXME: Need to cleanup this, this ought to be passed non-globaly */ |
… |
… |
|
1679 | 1693 | if (options.content_use && content != NULL && str_is_valid_string (content)) |
1680 | 1694 | content_pattern = g_strdup (content); |
1681 | 1695 | |
| 1696 | signal(SIGALRM, set_refresh_and_alarm); |
| 1697 | set_refresh_and_alarm(SIGALRM); |
| 1698 | |
1682 | 1699 | init_find_vars (); |
1683 | 1700 | parse_ignore_dirs (ignore_dirs); |
1684 | 1701 | push_directory (vfs_path_from_str (start_dir)); |
… |
… |
|
1794 | 1811 | g_free (old_dir); |
1795 | 1812 | old_dir = NULL; |
1796 | 1813 | rotate_dash (FALSE); |
| 1814 | alarm(0); |
1797 | 1815 | |
1798 | 1816 | return return_value; |
1799 | 1817 | } |