Ticket #2229: mc-null_viewer.patch
File mc-null_viewer.patch, 8.3 KB (added by gotar, 14 years ago) |
---|
-
src/viewer/dialogs.c
diff -urNp mc-4.7.4/src/viewer/dialogs.c mc-4.7.4.viewer/src/viewer/dialogs.c
old new mcview_dialog_goto (mcview_t * view, off 280 280 default: 281 281 break; 282 282 } 283 *offset = mcview_bol (view, *offset);283 *offset = mcview_bol (view, *offset, 0); 284 284 } 285 285 } 286 286 -
src/viewer/internal.h
diff -urNp mc-4.7.4/src/viewer/internal.h mc-4.7.4.viewer/src/viewer/internal.h
old new void mcview_done (mcview_t * view); 290 290 void mcview_select_encoding (mcview_t * view); 291 291 void mcview_set_codeset (mcview_t * view); 292 292 void mcview_show_error (mcview_t * view, const char *error); 293 off_t mcview_bol (mcview_t * view, off_t current );294 off_t mcview_eol (mcview_t * view, off_t current );293 off_t mcview_bol (mcview_t * view, off_t current, off_t limit); 294 off_t mcview_eol (mcview_t * view, off_t current, off_t limit); 295 295 char *mcview_get_title (const Dlg_head * h, size_t len); 296 296 gboolean mcview_lock_file (mcview_t * view); 297 297 gboolean mcview_unlock_file (mcview_t * view); -
src/viewer/lib.c
diff -urNp mc-4.7.4/src/viewer/lib.c mc-4.7.4.viewer/src/viewer/lib.c
old new void 96 96 mcview_toggle_wrap_mode (mcview_t * view) 97 97 { 98 98 if (view->text_wrap_mode) 99 view->dpy_start = mcview_bol (view, view->dpy_start);99 view->dpy_start = mcview_bol (view, view->dpy_start, 0); 100 100 view->text_wrap_mode = !view->text_wrap_mode; 101 101 view->dpy_bbar_dirty = TRUE; 102 102 view->dirty++; … … mcview_show_error (mcview_t * view, cons 339 339 /* returns index of the first char in the line */ 340 340 /* it is constant for all line characters */ 341 341 off_t 342 mcview_bol (mcview_t * view, off_t current )342 mcview_bol (mcview_t * view, off_t current, off_t limit) 343 343 { 344 344 int c; 345 345 off_t filesize; … … mcview_bol (mcview_t * view, off_t curre 357 357 if (c == '\r') 358 358 current--; 359 359 } 360 while (current > 0 )360 while (current > 0 && current >= limit) 361 361 { 362 362 if (!mcview_get_byte (view, current - 1, &c)) 363 363 break; … … mcview_bol (mcview_t * view, off_t curre 373 373 /* returns index of last char on line + width EOL */ 374 374 /* mcview_eol of the current line == mcview_bol next line */ 375 375 off_t 376 mcview_eol (mcview_t * view, off_t current )376 mcview_eol (mcview_t * view, off_t current, off_t limit) 377 377 { 378 378 int c, prev_ch = 0; 379 379 off_t filesize; … … mcview_eol (mcview_t * view, off_t curre 382 382 return 0; 383 383 if (current >= filesize) 384 384 return filesize; 385 while (current < filesize )385 while (current < filesize && current < limit) 386 386 { 387 387 if (!mcview_get_byte (view, current, &c)) 388 388 break; -
src/viewer/mcviewer.c
diff -urNp mc-4.7.4/src/viewer/mcviewer.c mc-4.7.4.viewer/src/viewer/mcviewer.c
old new mcview_load (mcview_t * view, const char 414 414 canon_fname = vfs_canon (view->filename); 415 415 load_file_position (canon_fname, &line, &col, &new_offset); 416 416 new_offset = min (new_offset, mcview_get_filesize (view)); 417 view->dpy_start = mcview_bol (view, new_offset);417 view->dpy_start = mcview_bol (view, new_offset, 0); 418 418 g_free (canon_fname); 419 419 } 420 420 else if (start_line > 0) -
src/viewer/move.c
diff -urNp mc-4.7.4/src/viewer/move.c mc-4.7.4.viewer/src/viewer/move.c
old new mcview_move_up (mcview_t * view, off_t l 108 108 off_t i; 109 109 for (i = 0; i < lines; i++) 110 110 { 111 off_t cur_bol; 112 cur_bol = new_offset = mcview_bol (view, view->dpy_start); 113 if (new_offset > 0) 114 new_offset--; 115 new_offset = mcview_bol (view, new_offset); 116 if (new_offset < 0) 117 new_offset = 0; 111 if (view->dpy_start==0) break; 118 112 if (view->text_wrap_mode) 119 113 { 120 size_t last_row_length = (view->dpy_start - new_offset) % view->data_area.width; 121 if (last_row_length != 0 && cur_bol == view->dpy_start) 122 new_offset = max (new_offset, (off_t) (view->dpy_start - last_row_length)); 123 else 124 new_offset = max (new_offset, view->dpy_start - view->data_area.width); 114 new_offset = mcview_bol (view, view->dpy_start, view->dpy_start - 1); // check if dpy_start==BOL or not (then new_offset=dpy_start-1, no need to check more) 115 if (new_offset == view->dpy_start) { 116 new_offset--; 117 new_offset = mcview_bol (view, new_offset, 0); 118 size_t last_row_length = (view->dpy_start - new_offset) % view->data_area.width; 119 if (last_row_length > 0) 120 new_offset = view->dpy_start - last_row_length; // if dpy_start==BOL in wrapped mode, find BOL of previous line and move down all but the last rows 121 } else new_offset = view->dpy_start - view->data_area.width; // if dpy_start!=BOL in wrapped mode, just move one row up; no need to check if > 0 as there is at least exactly one wrap between dpy_start and BOL 122 view->dpy_start = new_offset; 123 } else { // if unwrapped -> current BOL equals dpy_start, just find BOL of previous line 124 new_offset = view->dpy_start; 125 new_offset--; 126 view->dpy_start = mcview_bol (view, new_offset, 0); 125 127 } 126 view->dpy_start = new_offset;127 128 } 128 129 } 129 130 mcview_movement_fixups (view, TRUE); … … mcview_move_down (mcview_t * view, off_t 160 161 { 161 162 while (lines-- > 0) 162 163 { 163 new_offset = mcview_eol (view, view->dpy_end);164 164 if (view->text_wrap_mode) 165 new_offset = min (new_offset, view->dpy_end + view->data_area.width);166 view->dpy_end = new_offset;165 view->dpy_end = mcview_eol (view, view->dpy_end, view->dpy_end + view->data_area.width); 166 else view->dpy_end = mcview_eol (view, view->dpy_end, last_byte); 167 167 if(view->dpy_end>=last_byte) lines=0; 168 168 169 new_offset = mcview_eol (view, view->dpy_start);170 169 if (view->text_wrap_mode) 171 new_offset = min (new_offset, view->dpy_start + view->data_area.width); 170 new_offset = mcview_eol (view, view->dpy_start, view->dpy_start + view->data_area.width); 171 else new_offset = mcview_eol (view, view->dpy_start, last_byte); 172 172 if(new_offset<last_byte) view->dpy_start = new_offset; 173 173 } 174 174 } … … mcview_move_down (mcview_t * view, off_t 177 177 178 178 for (i = 0; i < lines && new_offset < last_byte; i++) 179 179 { 180 new_offset = mcview_eol (view, view->dpy_start);181 180 if (view->text_wrap_mode) 182 new_offset = min (new_offset, view->dpy_start + view->data_area.width); 181 new_offset = mcview_eol (view, view->dpy_start, view->dpy_start + view->data_area.width); 182 else new_offset = mcview_eol (view, view->dpy_start, last_byte); 183 183 if(new_offset<last_byte) view->dpy_start = new_offset; 184 184 } 185 185 } … … mcview_moveto_bol (mcview_t * view) 312 312 } 313 313 else if (!view->text_wrap_mode) 314 314 { 315 view->dpy_start = mcview_bol (view, view->dpy_start);315 view->dpy_start = mcview_bol (view, view->dpy_start, 0); 316 316 } 317 317 view->dpy_text_column = 0; 318 318 mcview_movement_fixups (view, TRUE); … … mcview_moveto_eol (mcview_t * view) 342 342 else 343 343 { 344 344 off_t eol; 345 bol = mcview_bol (view, view->dpy_start);346 eol = mcview_eol (view, view->dpy_start);345 bol = mcview_bol (view, view->dpy_start, 0); 346 eol = mcview_eol (view, view->dpy_start, mcview_get_filesize (view)); 347 347 if (!view->utf8) 348 348 { 349 349 if (eol > bol) … … mcview_moveto_match (mcview_t * view) 465 465 } 466 466 else 467 467 { 468 view->dpy_start = mcview_bol (view, offset);468 view->dpy_start = mcview_bol (view, offset, 0); 469 469 } 470 470 471 471 mcview_scroll_to_cursor (view);