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) |
98 | 98 | view->hex_cursor %= view->bytes_per_line; |
99 | 99 | } |
100 | 100 | } else { |
101 | | const screen_dimen width = view->data_area.width; |
102 | 101 | off_t i; |
103 | 102 | for (i = 0; i < lines; i++) { |
104 | 103 | new_offset = mcview_bol (view, view->dpy_start); |
… |
… |
mcview_move_down (mcview_t * view, off_t lines) |
134 | 133 | } |
135 | 134 | } else { |
136 | 135 | off_t i; |
137 | | int c; |
138 | 136 | for (i = 0; i < lines; i++) { |
139 | 137 | off_t new_offset; |
140 | 138 | new_offset = mcview_eol(view, view->dpy_start); |
… |
… |
void |
150 | 148 | mcview_move_left (mcview_t * view, off_t columns) |
151 | 149 | { |
152 | 150 | if (view->hex_mode) { |
| 151 | off_t old_cursor = view->hex_cursor; |
153 | 152 | assert (columns == 1); |
154 | 153 | if (view->hexview_in_text || !view->hexedit_lownibble) { |
155 | 154 | if (view->hex_cursor > 0) |
156 | 155 | view->hex_cursor--; |
157 | 156 | } |
158 | 157 | 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; |
160 | 160 | } else if (view->text_wrap_mode) { |
161 | 161 | /* nothing to do */ |
162 | 162 | } else { |
… |
… |
void |
174 | 174 | mcview_move_right (mcview_t * view, off_t columns) |
175 | 175 | { |
176 | 176 | 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); |
177 | 180 | assert (columns == 1); |
178 | 181 | if (view->hexview_in_text || view->hexedit_lownibble) { |
179 | | view->hex_cursor++; |
| 182 | if (view->hex_cursor < last_byte) |
| 183 | view->hex_cursor++; |
180 | 184 | } |
181 | 185 | 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; |
183 | 188 | } else if (view->text_wrap_mode) { |
184 | 189 | /* nothing to do */ |
185 | 190 | } else { |