1
1

Merge branch '2543_hexview_cursor_position'

* 2543_hexview_cursor_position:
  Fixed positions of text start and hex cursor
  Ticket #2543: Hex viewer mode does not restore cursor position.
Этот коммит содержится в:
Andrew Borodin 2011-09-27 11:18:43 +04:00
родитель 07c14a4a62 b471db4905
Коммит bcd5db8a6a
2 изменённых файлов: 18 добавлений и 6 удалений

Просмотреть файл

@ -130,8 +130,8 @@ mcview_toggle_hex_mode (mcview_t * view)
}
else
{
view->dpy_start = view->hex_cursor;
mcview_moveto_bol (view);
view->dpy_start = mcview_bol (view, view->hex_cursor, 0);
view->hex_cursor = view->dpy_start;
widget_want_cursor (view->widget, 0);
}
mcview_altered_hex_mode = 1;
@ -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);

Просмотреть файл

@ -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);
}