Ticket #2229: mc-noEOLviewer.patch

File mc-noEOLviewer.patch, 4.6 KB (added by gotar, 14 years ago)

updated move.c part of the patch to master base

  • move.

    old new mcview_move_up (mcview_t * view, off_t l 
    108108        off_t i; 
    109109        for (i = 0; i < lines; i++) 
    110110        { 
    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; 
    118112            if (view->text_wrap_mode) 
    119113            { 
    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); 
    125127            } 
    126             view->dpy_start = new_offset; 
    127128        } 
    128129    } 
    129130    mcview_movement_fixups (view, TRUE); 
    mcview_move_down (mcview_t * view, off_t 
    160161        { 
    161162            while (lines-- > 0) 
    162163            { 
    163                 new_offset = mcview_eol (view, view->dpy_end); 
    164164                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); 
    167167 
    168                 new_offset = mcview_eol (view, view->dpy_start); 
    169168                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); 
    171171                if (new_offset < last_byte) 
    172172                    view->dpy_start = new_offset; 
    173173                if (view->dpy_end >= last_byte) 
    mcview_move_down (mcview_t * view, off_t 
    178178        { 
    179179            for (i = 0; i < lines && new_offset < last_byte; i++) 
    180180            { 
    181                 new_offset = mcview_eol (view, view->dpy_start); 
    182181                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); 
    184184                if (new_offset < last_byte) 
    185185                    view->dpy_start = new_offset; 
    186186            } 
    mcview_moveto_bol (mcview_t * view) 
    314314    } 
    315315    else if (!view->text_wrap_mode) 
    316316    { 
    317         view->dpy_start = mcview_bol (view, view->dpy_start); 
     317        view->dpy_start = mcview_bol (view, view->dpy_start, 0); 
    318318    } 
    319319    view->dpy_text_column = 0; 
    320320    mcview_movement_fixups (view, TRUE); 
    mcview_moveto_eol (mcview_t * view) 
    344344    else 
    345345    { 
    346346        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)); 
    349349        if (!view->utf8) 
    350350        { 
    351351            if (eol > bol) 
    mcview_moveto_match (mcview_t * view) 
    467467    } 
    468468    else 
    469469    { 
    470         view->dpy_start = mcview_bol (view, offset); 
     470        view->dpy_start = mcview_bol (view, offset, 0); 
    471471    } 
    472472 
    473473    mcview_scroll_to_cursor (view);