Ticket #2543: Hex viewer mode does not restore cursor position.

If you are in hex viewer mode and viewer remembers file positions, the
viewer restores the start position, but does not restore the position
of cursor.
So the restored position is basically useless in hex mode, because when
you move cursor, you go back to the beginning of file.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Vitaliy Filippov 2011-09-22 21:29:40 +04:00 committed by Andrew Borodin
parent 07c14a4a62
commit 6253decba5
2 changed files with 16 additions and 4 deletions

View File

@ -239,7 +239,9 @@ mcview_done (mcview_t * view)
vfs_path_t *vpath;
vpath = vfs_path_from_str (view->filename);
canon_fname = vfs_path_to_str (vpath);
save_file_position (canon_fname, -1, 0, view->dpy_start, view->saved_bookmarks);
save_file_position (canon_fname, -1, 0,
view->hex_mode ? view->hex_cursor : view->dpy_start,
view->saved_bookmarks);
view->saved_bookmarks = NULL;
g_free (canon_fname);
vfs_path_free (vpath);

View File

@ -386,14 +386,24 @@ mcview_load (mcview_t * view, const char *command, const char *file, int start_l
{
char *canon_fname;
long line, col;
off_t new_offset;
off_t new_offset, max_offset;
vfs_path_t *vpath;
vpath = vfs_path_from_str (view->filename);
canon_fname = vfs_path_to_str (vpath);
load_file_position (canon_fname, &line, &col, &new_offset, &view->saved_bookmarks);
new_offset = min (new_offset, mcview_get_filesize (view));
view->dpy_start = mcview_bol (view, new_offset, 0);
max_offset = mcview_get_filesize (view) - 1;
if (max_offset < 0)
new_offset = 0;
else
new_offset = min (new_offset, max_offset);
if (!view->hex_mode)
view->dpy_start = mcview_bol (view, new_offset, 0);
else
{
view->dpy_start = new_offset - new_offset % view->bytes_per_line;
view->hex_cursor = new_offset;
}
g_free (canon_fname);
vfs_path_free (vpath);
}