* view.c (view_handle_key): Fixed invalid-offset-bug when handling

ctrl-e in hex mode.
This commit is contained in:
Roland Illig 2004-09-18 22:00:55 +00:00
parent 8335c0fab3
commit fd4b2d7d35
2 changed files with 19 additions and 4 deletions

View File

@ -1,4 +1,9 @@
2004-09-18 Roland Illig <roland.illig@gmx.de>
2004-09-18 Roland Illig <roland.illig@gmx.de>
* view.c (view_handle_key): Fixed invalid-offset-bug when handling
ctrl-e in hex mode.
2004-09-18 Roland Illig <roland.illig@gmx.de>
* help.c (search_string): Fixed a warning about a const qualifier.
A local copy of the string is used for modifying.

View File

@ -162,6 +162,18 @@ struct WView {
struct stat s; /* stat for file */
};
static void view_move_cursor_to_eol(WView *view)
{
offset_type last_line = (view->last_byte - 1) / view->bytes_per_line;
offset_type current_line = view->edit_cursor / view->bytes_per_line;
if (current_line == last_line) {
view->edit_cursor = view->last_byte - 1;
} else {
view->edit_cursor = (1 + current_line) * view->bytes_per_line - 1;
}
view->dirty++;
}
/* Maxlimit for skipping updates */
int max_dirt_limit = 10;
@ -2369,9 +2381,7 @@ view_handle_key (WView *view, int c)
return MSG_HANDLED;
case XCTRL ('e'): /* End of line */
view->edit_cursor -= view->edit_cursor % view->bytes_per_line;
view->edit_cursor += view->bytes_per_line - 1;
view->dirty++;
view_move_cursor_to_eol (view);
return MSG_HANDLED;
case XCTRL ('f'): /* Character forward */