Ticket #2229: mc-noEOLviewer.patch
File mc-noEOLviewer.patch, 4.6 KB (added by gotar, 14 years ago) |
---|
-
move.
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 - (off_t) view->data_area.width); 114 new_offset = mcview_bol (view, view->dpy_start, view->dpy_start - (off_t) 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 - (off_t) 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 - (off_t) 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 + (off_t) view->data_area.width);166 view->dpy_end = new_offset;165 view->dpy_end = mcview_eol (view, view->dpy_end, view->dpy_end + (off_t) view->data_area.width); 166 else view->dpy_end = mcview_eol (view, view->dpy_end, last_byte); 167 167 168 new_offset = mcview_eol (view, view->dpy_start);169 168 if (view->text_wrap_mode) 170 new_offset = min (new_offset, view->dpy_start + (off_t) view->data_area.width); 169 new_offset = mcview_eol (view, view->dpy_start, view->dpy_start + (off_t) view->data_area.width); 170 else new_offset = mcview_eol (view, view->dpy_start, last_byte); 171 171 if (new_offset < last_byte) 172 172 view->dpy_start = new_offset; 173 173 if (view->dpy_end >= last_byte) … … mcview_move_down (mcview_t * view, off_t 178 178 { 179 179 for (i = 0; i < lines && new_offset < last_byte; i++) 180 180 { 181 new_offset = mcview_eol (view, view->dpy_start);182 181 if (view->text_wrap_mode) 183 new_offset = min (new_offset, view->dpy_start + (off_t) view->data_area.width); 182 new_offset = mcview_eol (view, view->dpy_start, view->dpy_start + (off_t) view->data_area.width); 183 else new_offset = mcview_eol (view, view->dpy_start, last_byte); 184 184 if (new_offset < last_byte) 185 185 view->dpy_start = new_offset; 186 186 } … … mcview_moveto_bol (mcview_t * view) 314 314 } 315 315 else if (!view->text_wrap_mode) 316 316 { 317 view->dpy_start = mcview_bol (view, view->dpy_start);317 view->dpy_start = mcview_bol (view, view->dpy_start, 0); 318 318 } 319 319 view->dpy_text_column = 0; 320 320 mcview_movement_fixups (view, TRUE); … … mcview_moveto_eol (mcview_t * view) 344 344 else 345 345 { 346 346 off_t eol; 347 bol = mcview_bol (view, view->dpy_start);348 eol = mcview_eol (view, view->dpy_start);347 bol = mcview_bol (view, view->dpy_start, 0); 348 eol = mcview_eol (view, view->dpy_start, mcview_get_filesize (view)); 349 349 if (!view->utf8) 350 350 { 351 351 if (eol > bol) … … mcview_moveto_match (mcview_t * view) 467 467 } 468 468 else 469 469 { 470 view->dpy_start = mcview_bol (view, offset);470 view->dpy_start = mcview_bol (view, offset, 0); 471 471 } 472 472 473 473 mcview_scroll_to_cursor (view);