1
1

Search does not find text that are bold or underlined (yellow or red) and contain accented letters.

Exception: it finds if only the first character is accented, but highlights the match incorrectly.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
Этот коммит содержится в:
Slava Zanko 2011-06-28 17:06:19 +03:00
родитель b944a0a6c2
Коммит c1aae6cb4e
2 изменённых файлов: 51 добавлений и 12 удалений

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

@ -57,6 +57,37 @@
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
static gboolean
mcview_nroff_get_char (mcview_nroff_t * nroff, int *ret_val, off_t nroff_index)
{
int c;
#ifdef HAVE_CHARSET
if (nroff->view->utf8)
{
gboolean utf_result;
c = mcview_get_utf (nroff->view, nroff_index, &nroff->char_width, &utf_result);
if (!utf_result)
{
/* we need got symbol in any case */
nroff->char_width = 1;
if (!mcview_get_byte (nroff->view, nroff_index, &c) || !g_ascii_isprint (c))
return FALSE;
}
}
else
#endif
{
nroff->char_width = 1;
if (!mcview_get_byte (nroff->view, nroff_index, &c))
return FALSE;
}
if (!g_unichar_isprint (c))
return FALSE;
*ret_val = c;
return TRUE;
}
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
@ -249,7 +280,7 @@ mcview__get_nroff_real_len (mcview_t * view, off_t start, off_t length)
{
if (nroff->type != NROFF_TYPE_NONE)
{
ret += 2;
ret += 1 + nroff->char_width;
}
i++;
mcview_nroff_seq_next (nroff);
@ -307,15 +338,13 @@ mcview_nroff_seq_info (mcview_nroff_t * nroff)
return NROFF_TYPE_NONE;
nroff->type = NROFF_TYPE_NONE;
if (!mcview_get_byte (nroff->view, nroff->index, &nroff->current_char) || !g_ascii_isprint (nroff->current_char)) /* FIXME: utf-8 and g_ascii_isprint */
if (!mcview_nroff_get_char (nroff, &nroff->current_char, nroff->index))
return nroff->type;
nroff->char_width = 1;
if (!mcview_get_byte (nroff->view, nroff->index + 1, &next) || next != '\b')
if (!mcview_get_byte (nroff->view, nroff->index + nroff->char_width, &next) || next != '\b')
return nroff->type;
if (!mcview_get_byte (nroff->view, nroff->index + 2, &next2) || !g_ascii_isprint (next2)) /* FIXME: utf-8 and g_ascii_isprint */
if (!mcview_nroff_get_char (nroff, &next2, nroff->index + 1 + nroff->char_width))
return nroff->type;
if (nroff->current_char == '_' && next2 == '_')
@ -337,7 +366,6 @@ mcview_nroff_seq_info (mcview_nroff_t * nroff)
{
/* ??? */
}
return nroff->type;
}

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

@ -53,6 +53,9 @@
/*** file scope variables ************************************************************************/
static int search_cb_char_curr_index = 0;
static char search_cb_char_buffer[6];
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
@ -168,17 +171,25 @@ mcview_search_cmd_callback (const void *user_data, gsize char_offset)
return MC_SEARCH_CB_SKIP;
}
lc_byte = view->search_nroff_seq->current_char;
if (search_cb_char_curr_index < view->search_nroff_seq->char_width)
{
lc_byte = search_cb_char_buffer[search_cb_char_curr_index];
search_cb_char_curr_index++;
if (lc_byte == -1)
return MC_SEARCH_CB_INVALID;
return (lc_byte != -1) ? lc_byte : MC_SEARCH_CB_INVALID;
}
mcview_nroff_seq_next (view->search_nroff_seq);
search_cb_char_curr_index = 0;
if (view->search_nroff_seq->char_width > 1)
g_unichar_to_utf8 (view->search_nroff_seq->current_char, search_cb_char_buffer);
else
search_cb_char_buffer[0] = (char) view->search_nroff_seq->current_char;
if (view->search_nroff_seq->type != NROFF_TYPE_NONE)
view->search_numNeedSkipChar = 2;
view->search_numNeedSkipChar = 1 + view->search_nroff_seq->char_width;
return lc_byte;
return MC_SEARCH_CB_SKIP;
}
/* --------------------------------------------------------------------------------------------- */