Ticket #2543: viewer-remember-hex-position.diff

File viewer-remember-hex-position.diff, 1.5 KB (added by vitalif, 14 years ago)

Restore position in hex viewer mode, save hex_cursor, not dpy_start in hex mode

  • src/viewer/lib.c

    diff --git a/src/viewer/lib.c b/src/viewer/lib.c
    index 00be8d0..7eec141 100644
    a b mcview_done (mcview_t * view) 
    237237    { 
    238238        char *canon_fname; 
    239239        canon_fname = vfs_canon (view->filename); 
    240         save_file_position (canon_fname, -1, 0, view->dpy_start, view->saved_bookmarks); 
     240        save_file_position (canon_fname, -1, 0, 
     241            view->hex_mode ? view->hex_cursor : view->dpy_start, 
     242            view->saved_bookmarks); 
    241243        view->saved_bookmarks = NULL; 
    242244        g_free (canon_fname); 
    243245    } 
  • src/viewer/mcviewer.c

    diff --git a/src/viewer/mcviewer.c b/src/viewer/mcviewer.c
    index 3cf9948..c28adc8 100644
    a b mcview_load (mcview_t * view, const char *command, const char *file, int start_l 
    390390 
    391391        canon_fname = vfs_canon (view->filename); 
    392392        load_file_position (canon_fname, &line, &col, &new_offset, &view->saved_bookmarks); 
    393         new_offset = min (new_offset, mcview_get_filesize (view)); 
    394         view->dpy_start = mcview_bol (view, new_offset, 0); 
     393        new_offset = min (new_offset, mcview_get_filesize (view)-1); 
     394        if (new_offset < 0) 
     395            new_offset = 0; 
     396        if (view->hex_mode) 
     397        { 
     398            view->dpy_start = new_offset - new_offset % view->bytes_per_line; 
     399            view->hex_cursor = new_offset; 
     400        } 
     401        else 
     402            view->dpy_start = mcview_bol (view, new_offset, 0); 
    395403        g_free (canon_fname); 
    396404    } 
    397405    else if (start_line > 0)