1
1

Merge branch '2706_hexview_search_continue'

* 2706_hexview_search_continue:
  Don't adjust viewer parameters twice after search in the hex mode.
  Ticket #2706: hex viewer: continue search doesn't work.
Этот коммит содержится в:
Andrew Borodin 2013-06-28 14:30:26 +04:00
родитель fb7ee43d5b 1bb36fd589
Коммит 3f4397f812
3 изменённых файлов: 40 добавлений и 32 удалений

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

@ -98,10 +98,32 @@ mcview_remove_ext_script (mcview_t * view)
/* Both views */
static void
mcview_search (mcview_t * view)
mcview_search (mcview_t * view, gboolean start_search)
{
if (mcview_dialog_search (view))
if (start_search)
{
if (mcview_dialog_search (view))
{
if (view->hex_mode)
view->search_start = view->hex_cursor;
mcview_do_search (view);
}
}
else
{
if (view->hex_mode)
{
if (!mcview_search_options.backwards)
view->search_start = view->hex_cursor + 1;
else if (view->hex_cursor > 0)
view->search_start = view->hex_cursor - 1;
else
view->search_start = 0;
}
mcview_do_search (view);
}
}
/* --------------------------------------------------------------------------------------------- */
@ -110,13 +132,12 @@ static void
mcview_continue_search_cmd (mcview_t * view)
{
if (view->last_search_string != NULL)
{
mcview_do_search (view);
}
mcview_search (view, FALSE);
else
{
/* find last search string in history */
GList *history;
history = history_get (MC_HISTORY_SHARED_SEARCH);
if (history != NULL && history->data != NULL)
{
@ -128,12 +149,12 @@ mcview_continue_search_cmd (mcview_t * view)
view->search = mc_search_new (view->last_search_string, -1);
view->search_nroff_seq = mcview_nroff_seq_new (view);
if (!view->search)
if (view->search == NULL)
{
/* if not... then ask for an expression */
g_free (view->last_search_string);
view->last_search_string = NULL;
mcview_search (view);
mcview_search (view, TRUE);
}
else
{
@ -144,7 +165,7 @@ mcview_continue_search_cmd (mcview_t * view)
view->search->search_fn = mcview_search_cmd_callback;
view->search->update_fn = mcview_search_update_cmd_callback;
mcview_do_search (view);
mcview_search (view, FALSE);
}
}
else
@ -152,7 +173,7 @@ mcview_continue_search_cmd (mcview_t * view)
/* if not... then ask for an expression */
g_free (view->last_search_string);
view->last_search_string = NULL;
mcview_search (view);
mcview_search (view, TRUE);
}
}
}
@ -406,15 +427,15 @@ mcview_execute_cmd (mcview_t * view, unsigned long command)
mcview_hexedit_save_changes (view);
break;
case CK_Search:
mcview_search (view);
mcview_search (view, TRUE);
break;
case CK_SearchForward:
mcview_search_options.backwards = FALSE;
mcview_search (view);
mcview_search (view, TRUE);
break;
case CK_SearchBackward:
mcview_search_options.backwards = TRUE;
mcview_search (view);
mcview_search (view, TRUE);
break;
case CK_MagicMode:
mcview_toggle_magic_mode (view);

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

@ -95,8 +95,8 @@ mcview_movement_fixups (mcview_t * view, gboolean reset_search)
mcview_scroll_to_cursor (view);
if (reset_search)
{
view->search_start = view->dpy_start;
view->search_end = view->dpy_start;
view->search_start = view->hex_mode ? view->hex_cursor : view->dpy_start;
view->search_end = view->search_start;
}
view->dirty++;
}
@ -493,19 +493,15 @@ mcview_place_cursor (mcview_t * view)
void
mcview_moveto_match (mcview_t * view)
{
off_t offset;
offset = view->search_start;
if (view->hex_mode)
{
view->hex_cursor = offset;
view->dpy_start = offset - offset % view->bytes_per_line;
view->hex_cursor = view->search_start;
view->hexedit_lownibble = FALSE;
view->dpy_start = view->search_start - view->search_start % view->bytes_per_line;
view->dpy_end = view->search_end - view->search_end % view->bytes_per_line;
}
else
{
view->dpy_start = mcview_bol (view, offset, 0);
}
view->dpy_start = mcview_bol (view, view->search_start, 0);
mcview_scroll_to_cursor (view);
view->dirty++;

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

@ -135,14 +135,6 @@ mcview_search_show_result (mcview_t * view, WDialog ** d, size_t match_len)
match_len) : 0;
view->search_end = view->search_start + match_len + nroff_len;
if (view->hex_mode)
{
view->hex_cursor = view->search_start;
view->hexedit_lownibble = FALSE;
view->dpy_start = view->search_start - view->search_start % view->bytes_per_line;
view->dpy_end = view->search_end - view->search_end % view->bytes_per_line;
}
if (verbose)
{
dlg_run_done (*d);
@ -151,7 +143,6 @@ mcview_search_show_result (mcview_t * view, WDialog ** d, size_t match_len)
tty_refresh ();
}
mcview_moveto_match (view);
}
/* --------------------------------------------------------------------------------------------- */