Ticket #1585: 0001-Fixed-left-right-movement-in-hex-mode.patch

File 0001-Fixed-left-right-movement-in-hex-mode.patch, 2.5 KB (added by himikof, 10 years ago)

Fixes a few issues in left/right movement in hex viewer

  • src/viewer/move.c

    From ddb60a820769a7514afff274fe58372b65472bc1 Mon Sep 17 00:00:00 2001
    From: Nikita Ofitserov <himikof@gmail.com>
    Date: Sun, 17 Jan 2010 07:15:25 +0300
    Subject: [PATCH] Fixed left/right movement in hex mode
    
    Also removed few unused variables
    ---
     src/viewer/move.c |   15 ++++++++++-----
     1 files changed, 10 insertions(+), 5 deletions(-)
    
    diff --git a/src/viewer/move.c b/src/viewer/move.c
    index 5bf5bbb..598a065 100644
    a b mcview_move_up (mcview_t * view, off_t lines) 
    9898            view->hex_cursor %= view->bytes_per_line; 
    9999        } 
    100100    } else { 
    101         const screen_dimen width = view->data_area.width; 
    102101        off_t i; 
    103102        for (i = 0; i < lines; i++) { 
    104103            new_offset = mcview_bol (view, view->dpy_start); 
    mcview_move_down (mcview_t * view, off_t lines) 
    134133        } 
    135134    } else { 
    136135        off_t i; 
    137         int c; 
    138136        for (i = 0; i < lines; i++) { 
    139137            off_t new_offset; 
    140138            new_offset = mcview_eol(view, view->dpy_start); 
    void 
    150148mcview_move_left (mcview_t * view, off_t columns) 
    151149{ 
    152150    if (view->hex_mode) { 
     151        off_t old_cursor = view->hex_cursor; 
    153152        assert (columns == 1); 
    154153        if (view->hexview_in_text || !view->hexedit_lownibble) { 
    155154            if (view->hex_cursor > 0) 
    156155                view->hex_cursor--; 
    157156        } 
    158157        if (!view->hexview_in_text) 
    159             view->hexedit_lownibble = !view->hexedit_lownibble; 
     158            if (old_cursor > 0 || view->hexedit_lownibble) 
     159                view->hexedit_lownibble = !view->hexedit_lownibble; 
    160160    } else if (view->text_wrap_mode) { 
    161161        /* nothing to do */ 
    162162    } else { 
    void 
    174174mcview_move_right (mcview_t * view, off_t columns) 
    175175{ 
    176176    if (view->hex_mode) { 
     177        off_t last_byte; 
     178        off_t old_cursor = view->hex_cursor; 
     179        last_byte = mcview_offset_doz(mcview_get_filesize (view), 1); 
    177180        assert (columns == 1); 
    178181        if (view->hexview_in_text || view->hexedit_lownibble) { 
    179             view->hex_cursor++; 
     182            if (view->hex_cursor < last_byte) 
     183                view->hex_cursor++; 
    180184        } 
    181185        if (!view->hexview_in_text) 
    182             view->hexedit_lownibble = !view->hexedit_lownibble; 
     186            if (old_cursor < last_byte || !view->hexedit_lownibble) 
     187                view->hexedit_lownibble = !view->hexedit_lownibble; 
    183188    } else if (view->text_wrap_mode) { 
    184189        /* nothing to do */ 
    185190    } else {