From efb28521f5bb73e836c5978a03da6b162fe6e952 Mon Sep 17 00:00:00 2001 From: Nikita Ofitserov Date: Sun, 17 Jan 2010 07:15:25 +0300 Subject: [PATCH] Fixed left/right movement in hex mode Signed-off-by: Nikita Ofitserov Signed-off-by: Ilia Maslakov --- src/viewer/move.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/viewer/move.c b/src/viewer/move.c index cf5e46d34..1c4b30bd9 100644 --- a/src/viewer/move.c +++ b/src/viewer/move.c @@ -148,13 +148,15 @@ void mcview_move_left (mcview_t * view, off_t columns) { if (view->hex_mode) { + off_t old_cursor = view->hex_cursor; assert (columns == 1); if (view->hexview_in_text || !view->hexedit_lownibble) { if (view->hex_cursor > 0) view->hex_cursor--; } if (!view->hexview_in_text) - view->hexedit_lownibble = !view->hexedit_lownibble; + if (old_cursor > 0 || view->hexedit_lownibble) + view->hexedit_lownibble = !view->hexedit_lownibble; } else if (view->text_wrap_mode) { /* nothing to do */ } else { @@ -172,12 +174,17 @@ void mcview_move_right (mcview_t * view, off_t columns) { if (view->hex_mode) { + off_t last_byte; + off_t old_cursor = view->hex_cursor; + last_byte = mcview_offset_doz(mcview_get_filesize (view), 1); assert (columns == 1); if (view->hexview_in_text || view->hexedit_lownibble) { - view->hex_cursor++; + if (view->hex_cursor < last_byte) + view->hex_cursor++; } if (!view->hexview_in_text) - view->hexedit_lownibble = !view->hexedit_lownibble; + if (old_cursor < last_byte || !view->hexedit_lownibble) + view->hexedit_lownibble = !view->hexedit_lownibble; } else if (view->text_wrap_mode) { /* nothing to do */ } else {