diff -urp mc-4.7.5.4/src/viewer/coord_cache.c mc-4.7.5.4.new/src/viewer/coord_cache.c
old
|
new
|
mcview_ccache_lookup (mcview_t * view, c |
435 | 435 | |
436 | 436 | tty_disable_interrupt_key (); |
437 | 437 | |
| 438 | coord->cc_line = current.cc_line; |
438 | 439 | if (lookup_what == CCACHE_OFFSET) |
439 | 440 | { |
440 | 441 | coord->cc_offset = current.cc_offset; |
441 | 442 | } |
442 | 443 | else |
443 | 444 | { |
444 | | coord->cc_line = current.cc_line; |
445 | 445 | coord->cc_column = current.cc_column; |
446 | 446 | coord->cc_nroff_column = current.cc_nroff_column; |
447 | 447 | } |
diff -urp mc-4.7.5.4/src/viewer/dialogs.c mc-4.7.5.4.new/src/viewer/dialogs.c
old
|
new
|
mcview_dialog_goto (mcview_t * view, off |
274 | 274 | *offset = addr * mcview_get_filesize (view) / 100; |
275 | 275 | if (!view->hex_mode) |
276 | 276 | *offset = mcview_bol (view, *offset, 0); |
| 277 | view->dpy_lines_status = LINE_COUNT_UNKNOWN; |
| 278 | view->dpy_start_line = 0; |
277 | 279 | break; |
278 | 280 | case MC_VIEW_GOTO_OFFSET_DEC: |
279 | 281 | case MC_VIEW_GOTO_OFFSET_HEX: |
| 282 | view->dpy_lines_status = LINE_COUNT_UNKNOWN; |
| 283 | view->dpy_start_line = 0; |
280 | 284 | *offset = addr; |
281 | 285 | if (!view->hex_mode) |
282 | 286 | *offset = mcview_bol (view, *offset, 0); |
diff -urp mc-4.7.5.4/src/viewer/display.c mc-4.7.5.4.new/src/viewer/display.c
old
|
new
|
mcview_display_status (mcview_t * view) |
135 | 135 | const screen_dimen height = view->status_area.height; |
136 | 136 | const char *file_label; |
137 | 137 | screen_dimen file_label_width; |
| 138 | screen_dimen extra_space = 0; |
138 | 139 | |
139 | 140 | if (height < 1) |
140 | 141 | return; |
… |
… |
mcview_display_status (mcview_t * view) |
148 | 149 | if (width > 40) |
149 | 150 | { |
150 | 151 | char buffer[BUF_TINY]; |
151 | | widget_move (view, top, width - 32); |
152 | 152 | if (view->hex_mode) |
| 153 | { |
| 154 | widget_move (view, top, width - 32); |
153 | 155 | tty_printf ("0x%08" PRIxMAX, (uintmax_t) view->hex_cursor); |
| 156 | } |
154 | 157 | else |
155 | 158 | { |
156 | 159 | size_trunc_len (buffer, 5, mcview_get_filesize (view), 0, panels_options.kilobyte_si); |
| 160 | if (width - file_label_width - 32 > 6) |
| 161 | { |
| 162 | extra_space = width-file_label_width-32-4; |
| 163 | widget_move (view, top, width - 32 - extra_space); |
| 164 | tty_printf ("C:%ld L:", (ulong) view->dpy_text_column); |
| 165 | if (view->dpy_lines_status == LINE_COUNT_UNKNOWN) |
| 166 | tty_print_string("~? "); |
| 167 | else if (view->dpy_lines_status == LINE_COUNT_BACKWARD) |
| 168 | tty_print_string("EOF"); |
| 169 | tty_printf ("%ld+%ld=%ld /%ld", (long) view->dpy_start_line, (ulong) view->dpy_visible_lines, (long) (view->dpy_start_line+view->dpy_visible_lines), view->dpy_lines_total); |
| 170 | if (view->dpy_lines_status != LINE_COUNT_SET) |
| 171 | tty_print_string("+"); |
| 172 | } |
| 173 | widget_move (view, top, width - 32); |
157 | 174 | tty_printf ("%9" PRIuMAX "/%s%s %s", (uintmax_t) view->dpy_end, |
158 | 175 | buffer, mcview_may_still_grow (view) ? "+" : " ", |
159 | 176 | #ifdef HAVE_CHARSET |
… |
… |
mcview_display_status (mcview_t * view) |
166 | 183 | } |
167 | 184 | widget_move (view, top, left); |
168 | 185 | if (width > 40) |
169 | | tty_print_string (str_fit_to_term (file_label, width - 34, J_LEFT_FIT)); |
| 186 | tty_print_string (str_fit_to_term (file_label, width - 34 - extra_space, J_LEFT_FIT)); |
170 | 187 | else |
171 | 188 | tty_print_string (str_fit_to_term (file_label, width - 5, J_LEFT_FIT)); |
172 | 189 | if (width > 26) |
diff -urp mc-4.7.5.4/src/viewer/internal.h mc-4.7.5.4.new/src/viewer/internal.h
old
|
new
|
typedef struct mcview_struct |
138 | 138 | screen_dimen dpy_frame_size; /* Size of the frame surrounding the real viewer */ |
139 | 139 | off_t dpy_start; /* Offset of the displayed data */ |
140 | 140 | off_t dpy_end; /* Offset after the displayed data */ |
| 141 | off_t dpy_start_line; /* Line number of beginning of the displayed data */ |
| 142 | off_t dpy_visible_lines; /* Number of lines of the displayed data */ |
| 143 | off_t dpy_lines_total; /* Number of lines of entire file */ |
| 144 | enum |
| 145 | { |
| 146 | LINE_COUNT_UNKNOWN = -2, |
| 147 | LINE_COUNT_BACKWARD = -1, |
| 148 | LINE_COUNT_GROWING = 0, |
| 149 | LINE_COUNT_SET = 1 |
| 150 | } dpy_lines_status; /* Line counter status */ |
141 | 151 | off_t dpy_text_column; /* Number of skipped columns in non-wrap |
142 | 152 | * text mode */ |
143 | 153 | off_t hex_cursor; /* Hexview cursor position in file */ |
diff -urp mc-4.7.5.4/src/viewer/lib.c mc-4.7.5.4.new/src/viewer/lib.c
old
|
new
|
mcview_init (mcview_t * view) |
202 | 202 | view->dpy_start = 0; |
203 | 203 | view->dpy_text_column = 0; |
204 | 204 | view->dpy_end = 0; |
| 205 | view->dpy_start_line = 0; |
| 206 | view->dpy_visible_lines = 0; |
| 207 | view->dpy_lines_total = 0; |
| 208 | view->dpy_lines_status = LINE_COUNT_GROWING; |
205 | 209 | view->hex_cursor = 0; |
206 | 210 | view->cursor_col = 0; |
207 | 211 | view->cursor_row = 0; |
diff -urp mc-4.7.5.4/src/viewer/mcviewer.c mc-4.7.5.4.new/src/viewer/mcviewer.c
old
|
new
|
mcview_load (mcview_t * view, const char |
390 | 390 | finish: |
391 | 391 | view->command = g_strdup (command); |
392 | 392 | view->dpy_start = 0; |
| 393 | view->dpy_start_line = 0; |
| 394 | view->dpy_visible_lines = 0; |
| 395 | view->dpy_lines_total = 0; |
| 396 | view->dpy_lines_status = LINE_COUNT_GROWING; |
393 | 397 | view->search_start = 0; |
394 | 398 | view->search_end = 0; |
395 | 399 | view->dpy_text_column = 0; |
… |
… |
mcview_load (mcview_t * view, const char |
407 | 411 | load_file_position (canon_fname, &line, &col, &new_offset, &view->saved_bookmarks); |
408 | 412 | new_offset = min (new_offset, mcview_get_filesize (view)); |
409 | 413 | view->dpy_start = mcview_bol (view, new_offset, 0); |
| 414 | view->dpy_lines_status = LINE_COUNT_UNKNOWN; |
410 | 415 | g_free (canon_fname); |
411 | 416 | } |
412 | 417 | else if (start_line > 0) |
diff -urp mc-4.7.5.4/src/viewer/move.c mc-4.7.5.4.new/src/viewer/move.c
old
|
new
|
mcview_move_up (mcview_t * view, off_t l |
128 | 128 | * and move down all but the last rows */ |
129 | 129 | new_offset = view->dpy_start - (off_t) last_row_length; |
130 | 130 | } |
| 131 | view->dpy_start_line--; |
131 | 132 | } |
132 | 133 | else |
133 | 134 | { |
… |
… |
mcview_move_up (mcview_t * view, off_t l |
143 | 144 | /* if unwrapped -> current BOL equals dpy_start, just find BOL of previous line */ |
144 | 145 | new_offset = view->dpy_start - 1; |
145 | 146 | view->dpy_start = mcview_bol (view, new_offset, 0); |
| 147 | view->dpy_start_line--; |
146 | 148 | } |
147 | 149 | } |
148 | 150 | } |
… |
… |
mcview_move_down (mcview_t * view, off_t |
193 | 195 | else |
194 | 196 | new_offset = mcview_eol (view, view->dpy_start, last_byte); |
195 | 197 | if (new_offset < last_byte) |
| 198 | { |
196 | 199 | view->dpy_start = new_offset; |
| 200 | if(new_offset == mcview_bol (view, new_offset, new_offset - (off_t) 1)) |
| 201 | view->dpy_start_line++; |
| 202 | } |
197 | 203 | if (view->dpy_end >= last_byte) |
198 | 204 | break; |
199 | 205 | } |
… |
… |
mcview_move_down (mcview_t * view, off_t |
210 | 216 | else |
211 | 217 | new_offset = mcview_eol (view, view->dpy_start, last_byte); |
212 | 218 | if (new_offset < last_byte) |
| 219 | { |
213 | 220 | view->dpy_start = new_offset; |
| 221 | if(new_offset == mcview_bol (view, new_offset, new_offset - (off_t) 1)) |
| 222 | view->dpy_start_line++; |
| 223 | } |
214 | 224 | } |
215 | 225 | } |
216 | 226 | } |
… |
… |
void |
298 | 308 | mcview_moveto_top (mcview_t * view) |
299 | 309 | { |
300 | 310 | view->dpy_start = 0; |
| 311 | view->dpy_start_line = 0; |
301 | 312 | view->hex_cursor = 0; |
302 | 313 | view->dpy_text_column = 0; |
303 | 314 | mcview_movement_fixups (view, TRUE); |
| 315 | if (view->dpy_lines_status != LINE_COUNT_SET) |
| 316 | view->dpy_lines_status = LINE_COUNT_GROWING; |
304 | 317 | } |
305 | 318 | |
306 | 319 | /* --------------------------------------------------------------------------------------------- */ |
… |
… |
mcview_moveto_bottom (mcview_t * view) |
327 | 340 | const off_t datalines = view->data_area.height; |
328 | 341 | |
329 | 342 | view->dpy_start = filesize; |
| 343 | if (view->dpy_lines_status != LINE_COUNT_SET) { |
| 344 | view->dpy_lines_status = LINE_COUNT_BACKWARD; |
| 345 | view->dpy_start_line = 0; |
| 346 | } |
| 347 | else |
| 348 | view->dpy_start_line=view->dpy_lines_total; |
330 | 349 | mcview_move_up (view, datalines); |
331 | 350 | } |
332 | 351 | } |
… |
… |
mcview_coord_to_offset (mcview_t * view, |
447 | 466 | coord.cc_nroff_column = column; |
448 | 467 | mcview_ccache_lookup (view, &coord, CCACHE_OFFSET); |
449 | 468 | *ret_offset = coord.cc_offset; |
| 469 | view->dpy_start_line = coord.cc_line; |
450 | 470 | } |
451 | 471 | |
452 | 472 | /* --------------------------------------------------------------------------------------------- */ |
diff -urp mc-4.7.5.4/src/viewer/plain.c mc-4.7.5.4.new/src/viewer/plain.c
old
|
new
|
mcview_display_text (mcview_t * view) |
84 | 84 | |
85 | 85 | /* Find the first displayable changed byte */ |
86 | 86 | from = view->dpy_start; |
| 87 | view->dpy_visible_lines = 0; |
87 | 88 | while ((curr != NULL) && (curr->offset < from)) |
88 | 89 | curr = curr->next; |
89 | 90 | |
… |
… |
mcview_display_text (mcview_t * view) |
101 | 102 | |
102 | 103 | c = mcview_get_utf (view, from, &cw, &read_res); |
103 | 104 | if (!read_res) |
| 105 | { |
| 106 | if (view->dpy_lines_status == LINE_COUNT_GROWING) |
| 107 | view->dpy_lines_status = LINE_COUNT_SET; |
| 108 | if (view->dpy_lines_status == LINE_COUNT_UNKNOWN) { |
| 109 | view->dpy_lines_status = LINE_COUNT_BACKWARD; |
| 110 | view->dpy_start_line = -view->dpy_visible_lines; |
| 111 | } |
104 | 112 | break; |
| 113 | } |
105 | 114 | } |
106 | 115 | else |
107 | 116 | #endif |
108 | 117 | if (!mcview_get_byte (view, from, &c)) |
| 118 | { |
| 119 | if (view->dpy_lines_status == LINE_COUNT_GROWING) |
| 120 | view->dpy_lines_status = LINE_COUNT_SET; |
| 121 | if (view->dpy_lines_status == LINE_COUNT_UNKNOWN) { |
| 122 | view->dpy_lines_status = LINE_COUNT_BACKWARD; |
| 123 | view->dpy_start_line = -view->dpy_visible_lines; |
| 124 | } |
109 | 125 | break; |
| 126 | } |
110 | 127 | |
111 | 128 | last_row = FALSE; |
112 | 129 | from++; |
… |
… |
mcview_display_text (mcview_t * view) |
130 | 147 | { |
131 | 148 | col = 0; |
132 | 149 | row++; |
| 150 | view->dpy_visible_lines++; |
133 | 151 | continue; |
134 | 152 | } |
135 | 153 | |
… |
… |
mcview_display_text (mcview_t * view) |
193 | 211 | #endif |
194 | 212 | } |
195 | 213 | |
| 214 | if (view->dpy_lines_status != LINE_COUNT_BACKWARD && view->dpy_start_line+view->dpy_visible_lines>view->dpy_lines_total) |
| 215 | view->dpy_lines_total = view->dpy_start_line+view->dpy_visible_lines; |
| 216 | else if (view->dpy_lines_status != LINE_COUNT_BACKWARD && view->dpy_lines_total<-view->dpy_start_line+view->dpy_visible_lines) |
| 217 | view->dpy_lines_total = -view->dpy_start_line+view->dpy_visible_lines; |
| 218 | else if (view->dpy_lines_total<-view->dpy_start_line) |
| 219 | view->dpy_lines_total = -view->dpy_start_line; |
| 220 | if (view->dpy_start == 0) |
| 221 | { |
| 222 | view->dpy_start_line = 0; |
| 223 | if (view->dpy_lines_status == LINE_COUNT_BACKWARD) |
| 224 | view->dpy_lines_status = LINE_COUNT_SET; |
| 225 | if (view->dpy_lines_status == LINE_COUNT_UNKNOWN) |
| 226 | view->dpy_lines_status = LINE_COUNT_GROWING; |
| 227 | } |
196 | 228 | view->dpy_end = from; |
197 | 229 | if (mcview_show_eof != NULL && mcview_show_eof[0] != '\0') |
198 | 230 | { |
diff -urp mc-4.7.5.4/src/viewer/search.c mc-4.7.5.4.new/src/viewer/search.c
old
|
new
|
mcview_do_search (mcview_t * view) |
325 | 325 | } |
326 | 326 | while (mcview_may_still_grow (view)); |
327 | 327 | |
| 328 | view->dpy_lines_status = LINE_COUNT_UNKNOWN; |
| 329 | view->dpy_start_line = 0; |
| 330 | |
328 | 331 | if (view->search_start != 0 && !isFound && need_search_again |
329 | 332 | && !mcview_search_options.backwards) |
330 | 333 | { |