mirror of
https://github.com/MidnightCommander/mc
synced 2025-03-04 15:11:42 +03:00
Ticket #3262: rename variables.
Use 'char_length' name for variables that store the length of multi-byte character. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
42e7e39bd8
commit
6441fa0bfa
@ -576,17 +576,17 @@ dview_get_byte (char *str, gboolean * result)
|
||||
/**
|
||||
* Get utf multibyte char from string
|
||||
*
|
||||
* @param char * str, int * char_width, gboolean * result
|
||||
* @param char * str, int * char_length, gboolean * result
|
||||
* @return int as utf character or 0 and result == FALSE if fail
|
||||
*/
|
||||
|
||||
static int
|
||||
dview_get_utf (char *str, int *char_width, gboolean * result)
|
||||
dview_get_utf (char *str, int *char_length, gboolean * result)
|
||||
{
|
||||
int res = -1;
|
||||
gunichar ch;
|
||||
gchar *next_ch = NULL;
|
||||
int width = 0;
|
||||
int ch_len = 0;
|
||||
|
||||
*result = TRUE;
|
||||
|
||||
@ -603,14 +603,11 @@ dview_get_utf (char *str, int *char_width, gboolean * result)
|
||||
else
|
||||
{
|
||||
ch = res;
|
||||
/* Calculate UTF-8 char width */
|
||||
/* Calculate UTF-8 char length */
|
||||
next_ch = g_utf8_next_char (str);
|
||||
if (next_ch != NULL)
|
||||
width = next_ch - str;
|
||||
else
|
||||
ch = 0;
|
||||
ch_len = next_ch - str;
|
||||
}
|
||||
*char_width = width;
|
||||
*char_length = ch_len;
|
||||
return ch;
|
||||
}
|
||||
|
||||
@ -1415,12 +1412,12 @@ cvt_mget (const char *src, size_t srcsize, char *dst, int dstsize, int skip, int
|
||||
{
|
||||
int utf_ch = 0;
|
||||
gboolean res;
|
||||
int w;
|
||||
int ch_len;
|
||||
|
||||
skip--;
|
||||
utf_ch = dview_get_utf ((char *) src, &w, &res);
|
||||
if (w > 1)
|
||||
skip += w - 1;
|
||||
utf_ch = dview_get_utf ((char *) src, &ch_len, &res);
|
||||
if (ch_len > 1)
|
||||
skip += ch_len - 1;
|
||||
(void) utf_ch;
|
||||
}
|
||||
else
|
||||
@ -1516,12 +1513,12 @@ cvt_mgeta (const char *src, size_t srcsize, char *dst, int dstsize, int skip, in
|
||||
{
|
||||
int utf_ch = 0;
|
||||
gboolean res;
|
||||
int w;
|
||||
int ch_len;
|
||||
|
||||
skip--;
|
||||
utf_ch = dview_get_utf ((char *) src, &w, &res);
|
||||
if (w > 1)
|
||||
skip += w - 1;
|
||||
utf_ch = dview_get_utf ((char *) src, &ch_len, &res);
|
||||
if (ch_len > 1)
|
||||
skip += ch_len - 1;
|
||||
(void) utf_ch;
|
||||
}
|
||||
else
|
||||
@ -2604,14 +2601,15 @@ dview_display_file (const WDiff * dview, diff_place_t ord, int r, int c, int hei
|
||||
|
||||
for (cnt = 0; cnt < strlen (buf) && col < width; cnt++)
|
||||
{
|
||||
int w;
|
||||
gboolean ch_res;
|
||||
|
||||
if (dview->utf8)
|
||||
{
|
||||
next_ch = dview_get_utf (buf + cnt, &w, &ch_res);
|
||||
if (w > 1)
|
||||
cnt += w - 1;
|
||||
int ch_len;
|
||||
|
||||
next_ch = dview_get_utf (buf + cnt, &ch_len, &ch_res);
|
||||
if (ch_len > 1)
|
||||
cnt += ch_len - 1;
|
||||
if (!g_unichar_isprint (next_ch))
|
||||
next_ch = '.';
|
||||
}
|
||||
@ -2676,14 +2674,15 @@ dview_display_file (const WDiff * dview, diff_place_t ord, int r, int c, int hei
|
||||
col = 0;
|
||||
for (cnt = 0; cnt < strlen (buf) && col < width; cnt++)
|
||||
{
|
||||
int w;
|
||||
gboolean ch_res;
|
||||
|
||||
if (dview->utf8)
|
||||
{
|
||||
next_ch = dview_get_utf (buf + cnt, &w, &ch_res);
|
||||
if (w > 1)
|
||||
cnt += w - 1;
|
||||
int ch_len;
|
||||
|
||||
next_ch = dview_get_utf (buf + cnt, &ch_len, &ch_res);
|
||||
if (ch_len > 1)
|
||||
cnt += ch_len - 1;
|
||||
if (!g_unichar_isprint (next_ch))
|
||||
next_ch = '.';
|
||||
}
|
||||
|
@ -994,15 +994,15 @@ edit_right_word_move_cmd (WEdit * edit)
|
||||
static void
|
||||
edit_right_char_move_cmd (WEdit * edit)
|
||||
{
|
||||
int cw = 1;
|
||||
int char_length = 1;
|
||||
int c;
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
if (edit->utf8)
|
||||
{
|
||||
c = edit_buffer_get_utf (&edit->buffer, edit->buffer.curs1, &cw);
|
||||
if (cw < 1)
|
||||
cw = 1;
|
||||
c = edit_buffer_get_utf (&edit->buffer, edit->buffer.curs1, &char_length);
|
||||
if (char_length < 1)
|
||||
char_length = 1;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@ -1011,7 +1011,7 @@ edit_right_char_move_cmd (WEdit * edit)
|
||||
if (option_cursor_beyond_eol && c == '\n')
|
||||
edit->over_col++;
|
||||
else
|
||||
edit_cursor_move (edit, cw);
|
||||
edit_cursor_move (edit, char_length);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1019,7 +1019,7 @@ edit_right_char_move_cmd (WEdit * edit)
|
||||
static void
|
||||
edit_left_char_move_cmd (WEdit * edit)
|
||||
{
|
||||
int cw = 1;
|
||||
int char_length = 1;
|
||||
|
||||
if (edit->column_highlight
|
||||
&& option_cursor_beyond_eol
|
||||
@ -1029,16 +1029,16 @@ edit_left_char_move_cmd (WEdit * edit)
|
||||
#ifdef HAVE_CHARSET
|
||||
if (edit->utf8)
|
||||
{
|
||||
edit_buffer_get_prev_utf (&edit->buffer, edit->buffer.curs1, &cw);
|
||||
if (cw < 1)
|
||||
cw = 1;
|
||||
edit_buffer_get_prev_utf (&edit->buffer, edit->buffer.curs1, &char_length);
|
||||
if (char_length < 1)
|
||||
char_length = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (option_cursor_beyond_eol && edit->over_col > 0)
|
||||
edit->over_col--;
|
||||
else
|
||||
edit_cursor_move (edit, -cw);
|
||||
edit_cursor_move (edit, -char_length);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -2581,7 +2581,7 @@ int
|
||||
edit_delete (WEdit * edit, gboolean byte_delete)
|
||||
{
|
||||
int p = 0;
|
||||
int cw = 1;
|
||||
int char_length = 1;
|
||||
int i;
|
||||
|
||||
if (edit->buffer.curs2 == 0)
|
||||
@ -2591,9 +2591,9 @@ edit_delete (WEdit * edit, gboolean byte_delete)
|
||||
/* if byte_delete == TRUE then delete only one byte not multibyte char */
|
||||
if (edit->utf8 && !byte_delete)
|
||||
{
|
||||
edit_buffer_get_utf (&edit->buffer, edit->buffer.curs1, &cw);
|
||||
if (cw < 1)
|
||||
cw = 1;
|
||||
edit_buffer_get_utf (&edit->buffer, edit->buffer.curs1, &char_length);
|
||||
if (char_length < 1)
|
||||
char_length = 1;
|
||||
}
|
||||
#else
|
||||
(void) byte_delete;
|
||||
@ -2602,7 +2602,7 @@ edit_delete (WEdit * edit, gboolean byte_delete)
|
||||
if (edit->mark2 != edit->mark1)
|
||||
edit_push_markers (edit);
|
||||
|
||||
for (i = 1; i <= cw; i++)
|
||||
for (i = 1; i <= char_length; i++)
|
||||
{
|
||||
if (edit->mark1 > edit->buffer.curs1)
|
||||
{
|
||||
@ -2643,7 +2643,7 @@ int
|
||||
edit_backspace (WEdit * edit, gboolean byte_delete)
|
||||
{
|
||||
int p = 0;
|
||||
int cw = 1;
|
||||
int char_length = 1;
|
||||
int i;
|
||||
|
||||
if (edit->buffer.curs1 == 0)
|
||||
@ -2655,15 +2655,15 @@ edit_backspace (WEdit * edit, gboolean byte_delete)
|
||||
#ifdef HAVE_CHARSET
|
||||
if (edit->utf8 && !byte_delete)
|
||||
{
|
||||
edit_buffer_get_prev_utf (&edit->buffer, edit->buffer.curs1, &cw);
|
||||
if (cw < 1)
|
||||
cw = 1;
|
||||
edit_buffer_get_prev_utf (&edit->buffer, edit->buffer.curs1, &char_length);
|
||||
if (char_length < 1)
|
||||
char_length = 1;
|
||||
}
|
||||
#else
|
||||
(void) byte_delete;
|
||||
#endif
|
||||
|
||||
for (i = 1; i <= cw; i++)
|
||||
for (i = 1; i <= char_length; i++)
|
||||
{
|
||||
if (edit->mark1 >= edit->buffer.curs1)
|
||||
{
|
||||
@ -2779,18 +2779,18 @@ edit_move_forward3 (const WEdit * edit, off_t current, long cols, off_t upto)
|
||||
if (edit->utf8)
|
||||
{
|
||||
int utf_ch;
|
||||
int cw = 1;
|
||||
int char_length = 1;
|
||||
|
||||
utf_ch = edit_buffer_get_utf (&edit->buffer, p, &cw);
|
||||
utf_ch = edit_buffer_get_utf (&edit->buffer, p, &char_length);
|
||||
if (mc_global.utf8_display)
|
||||
{
|
||||
if (cw > 1)
|
||||
col -= cw - 1;
|
||||
if (char_length > 1)
|
||||
col -= char_length - 1;
|
||||
if (g_unichar_iswide (utf_ch))
|
||||
col++;
|
||||
}
|
||||
else if (cw > 1 && g_unichar_isprint (utf_ch))
|
||||
col -= cw - 1;
|
||||
else if (char_length > 1 && g_unichar_isprint (utf_ch))
|
||||
col -= char_length - 1;
|
||||
}
|
||||
|
||||
c = convert_to_display_c (c);
|
||||
|
@ -204,7 +204,7 @@ edit_buffer_get_byte (const edit_buffer_t * buf, off_t byte_index)
|
||||
*
|
||||
* @param buf pointer to editor buffer
|
||||
* @param byte_index byte index
|
||||
* @param char_width width of returned symbol
|
||||
* @param char_length length of returned symbol
|
||||
*
|
||||
* @return '\n' if byte_index is negative or larger than file size;
|
||||
* 0 if utf-8 symbol at specified index is invalid;
|
||||
@ -212,7 +212,7 @@ edit_buffer_get_byte (const edit_buffer_t * buf, off_t byte_index)
|
||||
*/
|
||||
|
||||
int
|
||||
edit_buffer_get_utf (const edit_buffer_t * buf, off_t byte_index, int *char_width)
|
||||
edit_buffer_get_utf (const edit_buffer_t * buf, off_t byte_index, int *char_length)
|
||||
{
|
||||
gchar *str = NULL;
|
||||
gunichar res;
|
||||
@ -221,14 +221,14 @@ edit_buffer_get_utf (const edit_buffer_t * buf, off_t byte_index, int *char_widt
|
||||
|
||||
if (byte_index >= (buf->curs1 + buf->curs2) || byte_index < 0)
|
||||
{
|
||||
*char_width = 0;
|
||||
*char_length = 0;
|
||||
return '\n';
|
||||
}
|
||||
|
||||
str = edit_buffer_get_byte_ptr (buf, byte_index);
|
||||
if (str == NULL)
|
||||
{
|
||||
*char_width = 0;
|
||||
*char_length = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -248,19 +248,19 @@ edit_buffer_get_utf (const edit_buffer_t * buf, off_t byte_index, int *char_widt
|
||||
if (res == (gunichar) (-2) || res == (gunichar) (-1))
|
||||
{
|
||||
ch = *str;
|
||||
*char_width = 0;
|
||||
*char_length = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ch = res;
|
||||
/* Calculate UTF-8 char width */
|
||||
/* Calculate UTF-8 char length */
|
||||
next_ch = g_utf8_next_char (str);
|
||||
if (next_ch != NULL)
|
||||
*char_width = next_ch - str;
|
||||
*char_length = next_ch - str;
|
||||
else
|
||||
{
|
||||
ch = 0;
|
||||
*char_width = 0;
|
||||
*char_length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -273,7 +273,7 @@ edit_buffer_get_utf (const edit_buffer_t * buf, off_t byte_index, int *char_widt
|
||||
*
|
||||
* @param buf pointer to editor buffer
|
||||
* @param byte_index byte index
|
||||
* @param char_width width of returned symbol
|
||||
* @param char_length length of returned symbol
|
||||
*
|
||||
* @return 0 if byte_index is negative or larger than file size;
|
||||
* 1-byte value before specified index if utf-8 symbol before specified index is invalid;
|
||||
@ -281,7 +281,7 @@ edit_buffer_get_utf (const edit_buffer_t * buf, off_t byte_index, int *char_widt
|
||||
*/
|
||||
|
||||
int
|
||||
edit_buffer_get_prev_utf (const edit_buffer_t * buf, off_t byte_index, int *char_width)
|
||||
edit_buffer_get_prev_utf (const edit_buffer_t * buf, off_t byte_index, int *char_length)
|
||||
{
|
||||
size_t i;
|
||||
gchar utf8_buf[3 * UTF8_CHAR_LEN + 1];
|
||||
@ -291,7 +291,7 @@ edit_buffer_get_prev_utf (const edit_buffer_t * buf, off_t byte_index, int *char
|
||||
|
||||
if (byte_index > (buf->curs1 + buf->curs2) || byte_index <= 0)
|
||||
{
|
||||
*char_width = 0;
|
||||
*char_length = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -304,18 +304,18 @@ edit_buffer_get_prev_utf (const edit_buffer_t * buf, off_t byte_index, int *char
|
||||
|
||||
if (str == NULL || g_utf8_next_char (str) != cursor_buf_ptr)
|
||||
{
|
||||
*char_width = 1;
|
||||
*char_length = 1;
|
||||
return *(cursor_buf_ptr - 1);
|
||||
}
|
||||
|
||||
res = g_utf8_get_char_validated (str, -1);
|
||||
if (res == (gunichar) (-2) || res == (gunichar) (-1))
|
||||
{
|
||||
*char_width = 1;
|
||||
*char_length = 1;
|
||||
return *(cursor_buf_ptr - 1);
|
||||
}
|
||||
|
||||
*char_width = cursor_buf_ptr - str;
|
||||
*char_length = cursor_buf_ptr - str;
|
||||
return (int) res;
|
||||
}
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
@ -40,8 +40,8 @@ void edit_buffer_clean (edit_buffer_t * buf);
|
||||
|
||||
int edit_buffer_get_byte (const edit_buffer_t * buf, off_t byte_index);
|
||||
#ifdef HAVE_CHARSET
|
||||
int edit_buffer_get_utf (const edit_buffer_t * buf, off_t byte_index, int *char_width);
|
||||
int edit_buffer_get_prev_utf (const edit_buffer_t * buf, off_t byte_index, int *char_width);
|
||||
int edit_buffer_get_utf (const edit_buffer_t * buf, off_t byte_index, int *char_length);
|
||||
int edit_buffer_get_prev_utf (const edit_buffer_t * buf, off_t byte_index, int *char_length);
|
||||
#endif
|
||||
long edit_buffer_count_lines (const edit_buffer_t * buf, off_t first, off_t last);
|
||||
off_t edit_buffer_get_bol (const edit_buffer_t * buf, off_t current);
|
||||
|
@ -119,10 +119,10 @@ status_string (WEdit * edit, char *s, int w)
|
||||
if (edit->utf8)
|
||||
{
|
||||
unsigned int cur_utf = 0;
|
||||
int cw = 1;
|
||||
int char_length = 1;
|
||||
|
||||
cur_utf = edit_buffer_get_utf (&edit->buffer, edit->buffer.curs1, &cw);
|
||||
if (cw > 0)
|
||||
cur_utf = edit_buffer_get_utf (&edit->buffer, edit->buffer.curs1, &char_length);
|
||||
if (char_length > 0)
|
||||
{
|
||||
g_snprintf (byte_str, sizeof (byte_str), "%04d 0x%03X",
|
||||
(unsigned) cur_utf, (unsigned) cur_utf);
|
||||
@ -310,10 +310,10 @@ edit_status_window (WEdit * edit)
|
||||
else if (edit->utf8)
|
||||
{
|
||||
unsigned int cur_utf;
|
||||
int cw = 1;
|
||||
int char_length = 1;
|
||||
|
||||
cur_utf = edit_buffer_get_utf (&edit->buffer, edit->buffer.curs1, &cw);
|
||||
if (cw <= 0)
|
||||
cur_utf = edit_buffer_get_utf (&edit->buffer, edit->buffer.curs1, &char_length);
|
||||
if (char_length <= 0)
|
||||
cur_utf = edit_buffer_get_current_byte (&edit->buffer);
|
||||
tty_printf ("[%05d 0x%04X]", cur_utf, cur_utf);
|
||||
}
|
||||
@ -578,7 +578,7 @@ edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c
|
||||
|
||||
while (col <= end_col - edit->start_col)
|
||||
{
|
||||
int cw = 1;
|
||||
int char_length = 1;
|
||||
unsigned int c;
|
||||
gboolean wide_width_char = FALSE;
|
||||
gboolean control_char = FALSE;
|
||||
@ -610,7 +610,7 @@ edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
if (edit->utf8)
|
||||
c = edit_buffer_get_utf (&edit->buffer, q, &cw);
|
||||
c = edit_buffer_get_utf (&edit->buffer, q, &char_length);
|
||||
else
|
||||
#endif
|
||||
c = edit_buffer_get_byte (&edit->buffer, q);
|
||||
@ -799,10 +799,8 @@ edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c
|
||||
} /* case */
|
||||
|
||||
q++;
|
||||
if (cw > 1)
|
||||
{
|
||||
q += cw - 1;
|
||||
}
|
||||
if (char_length > 1)
|
||||
q += char_length - 1;
|
||||
|
||||
if (col > (end_col - edit->start_col + 1))
|
||||
{
|
||||
|
@ -219,18 +219,18 @@ static inline off_t
|
||||
line_pixel_length (unsigned char *t, off_t b, off_t l, gboolean utf8)
|
||||
{
|
||||
off_t xn, x; /* position conters */
|
||||
off_t cw; /* character width in bytes */
|
||||
off_t char_length; /* character length in bytes */
|
||||
|
||||
#ifndef HAVE_CHARSET
|
||||
(void) utf8;
|
||||
#endif
|
||||
|
||||
for (xn = 0, x = 0; xn <= l; x = xn, b += cw)
|
||||
for (xn = 0, x = 0; xn <= l; x = xn, b += char_length)
|
||||
{
|
||||
char *tb;
|
||||
|
||||
tb = (char *) t + b;
|
||||
cw = 1;
|
||||
char_length = 1;
|
||||
|
||||
switch (tb[0])
|
||||
{
|
||||
@ -250,10 +250,10 @@ line_pixel_length (unsigned char *t, off_t b, off_t l, gboolean utf8)
|
||||
{
|
||||
char *next_ch;
|
||||
|
||||
/* Calculate UTF-8 char width */
|
||||
/* Calculate UTF-8 char length */
|
||||
next_ch = g_utf8_next_char (tb);
|
||||
if (next_ch != NULL)
|
||||
cw = next_ch - tb;
|
||||
char_length = next_ch - tb;
|
||||
|
||||
if (g_unichar_iswide (ch))
|
||||
x++;
|
||||
|
@ -355,16 +355,16 @@ mcview_get_next_char (mcview_t * view, mcview_state_machine_t * state, int *c)
|
||||
if (view->utf8)
|
||||
{
|
||||
gboolean result;
|
||||
int bytes_consumed;
|
||||
int char_length;
|
||||
|
||||
*c = mcview_get_utf (view, state->offset, &bytes_consumed, &result);
|
||||
*c = mcview_get_utf (view, state->offset, &char_length, &result);
|
||||
if (!result)
|
||||
return FALSE;
|
||||
/* Pretend EOF if we crossed force_max */
|
||||
if (view->force_max >= 0 && state->offset + bytes_consumed > view->force_max)
|
||||
if (view->force_max >= 0 && state->offset + char_length > view->force_max)
|
||||
return FALSE;
|
||||
|
||||
state->offset += bytes_consumed;
|
||||
state->offset += char_length;
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
@ -152,7 +152,7 @@ mcview_get_ptr_file (mcview_t * view, off_t byte_index)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
mcview_get_utf (mcview_t * view, off_t byte_index, int *bytes_consumed, gboolean * result)
|
||||
mcview_get_utf (mcview_t * view, off_t byte_index, int *char_length, gboolean * result)
|
||||
{
|
||||
gchar *str = NULL;
|
||||
int res = -1;
|
||||
@ -160,7 +160,7 @@ mcview_get_utf (mcview_t * view, off_t byte_index, int *bytes_consumed, gboolean
|
||||
gchar *next_ch = NULL;
|
||||
gchar utf8buf[UTF8_CHAR_LEN + 1];
|
||||
|
||||
*bytes_consumed = 0;
|
||||
*char_length = 0;
|
||||
*result = FALSE;
|
||||
|
||||
switch (view->datasource)
|
||||
@ -206,15 +206,15 @@ mcview_get_utf (mcview_t * view, off_t byte_index, int *bytes_consumed, gboolean
|
||||
if (res < 0)
|
||||
{
|
||||
ch = *str;
|
||||
*bytes_consumed = 1;
|
||||
*char_length = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ch = res;
|
||||
/* Calculate UTF-8 char width */
|
||||
/* Calculate UTF-8 char length */
|
||||
next_ch = g_utf8_next_char (str);
|
||||
if (next_ch)
|
||||
*bytes_consumed = next_ch - str;
|
||||
if (next_ch != NULL)
|
||||
*char_length = next_ch - str;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ typedef struct mcview_nroff_struct
|
||||
{
|
||||
mcview_t *view;
|
||||
off_t index;
|
||||
int char_width;
|
||||
int char_length;
|
||||
int current_char;
|
||||
nroff_type_t type;
|
||||
nroff_type_t prev_type;
|
||||
|
@ -65,11 +65,11 @@ mcview_nroff_get_char (mcview_nroff_t * nroff, int *ret_val, off_t nroff_index)
|
||||
if (nroff->view->utf8)
|
||||
{
|
||||
gboolean utf_result;
|
||||
c = mcview_get_utf (nroff->view, nroff_index, &nroff->char_width, &utf_result);
|
||||
c = mcview_get_utf (nroff->view, nroff_index, &nroff->char_length, &utf_result);
|
||||
if (!utf_result)
|
||||
{
|
||||
/* we need got symbol in any case */
|
||||
nroff->char_width = 1;
|
||||
nroff->char_length = 1;
|
||||
if (!mcview_get_byte (nroff->view, nroff_index, &c) || !g_ascii_isprint (c))
|
||||
return FALSE;
|
||||
}
|
||||
@ -77,7 +77,7 @@ mcview_nroff_get_char (mcview_nroff_t * nroff, int *ret_val, off_t nroff_index)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
nroff->char_width = 1;
|
||||
nroff->char_length = 1;
|
||||
if (!mcview_get_byte (nroff->view, nroff_index, &c))
|
||||
return FALSE;
|
||||
}
|
||||
@ -109,7 +109,7 @@ mcview__get_nroff_real_len (mcview_t * view, off_t start, off_t length)
|
||||
switch (nroff->type)
|
||||
{
|
||||
case NROFF_TYPE_BOLD:
|
||||
ret += 1 + nroff->char_width; /* real char width and 0x8 */
|
||||
ret += 1 + nroff->char_length; /* real char length and 0x8 */
|
||||
break;
|
||||
case NROFF_TYPE_UNDERLINE:
|
||||
ret += 2; /* underline symbol and ox8 */
|
||||
@ -117,7 +117,7 @@ mcview__get_nroff_real_len (mcview_t * view, off_t start, off_t length)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
i += nroff->char_width;
|
||||
i += nroff->char_length;
|
||||
mcview_nroff_seq_next (nroff);
|
||||
}
|
||||
|
||||
@ -175,10 +175,10 @@ mcview_nroff_seq_info (mcview_nroff_t * nroff)
|
||||
if (!mcview_nroff_get_char (nroff, &nroff->current_char, nroff->index))
|
||||
return nroff->type;
|
||||
|
||||
if (!mcview_get_byte (nroff->view, nroff->index + nroff->char_width, &next) || next != '\b')
|
||||
if (!mcview_get_byte (nroff->view, nroff->index + nroff->char_length, &next) || next != '\b')
|
||||
return nroff->type;
|
||||
|
||||
if (!mcview_nroff_get_char (nroff, &next2, nroff->index + 1 + nroff->char_width))
|
||||
if (!mcview_nroff_get_char (nroff, &next2, nroff->index + 1 + nroff->char_length))
|
||||
return nroff->type;
|
||||
|
||||
if (nroff->current_char == '_' && next2 == '_')
|
||||
@ -216,7 +216,7 @@ mcview_nroff_seq_next (mcview_nroff_t * nroff)
|
||||
switch (nroff->type)
|
||||
{
|
||||
case NROFF_TYPE_BOLD:
|
||||
nroff->index += 1 + nroff->char_width;
|
||||
nroff->index += 1 + nroff->char_length;
|
||||
break;
|
||||
case NROFF_TYPE_UNDERLINE:
|
||||
nroff->index += 2;
|
||||
@ -225,7 +225,7 @@ mcview_nroff_seq_next (mcview_nroff_t * nroff)
|
||||
break;
|
||||
}
|
||||
|
||||
nroff->index += nroff->char_width;
|
||||
nroff->index += nroff->char_length;
|
||||
|
||||
mcview_nroff_seq_info (nroff);
|
||||
return nroff->current_char;
|
||||
|
@ -202,13 +202,13 @@ mcview_search_cmd_callback (const void *user_data, gsize char_offset, int *curre
|
||||
}
|
||||
|
||||
if (search_cb_char_curr_index == -1
|
||||
|| search_cb_char_curr_index >= view->search_nroff_seq->char_width)
|
||||
|| search_cb_char_curr_index >= view->search_nroff_seq->char_length)
|
||||
{
|
||||
if (search_cb_char_curr_index != -1)
|
||||
mcview_nroff_seq_next (view->search_nroff_seq);
|
||||
|
||||
search_cb_char_curr_index = 0;
|
||||
if (view->search_nroff_seq->char_width > 1)
|
||||
if (view->search_nroff_seq->char_length > 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;
|
||||
@ -218,7 +218,7 @@ mcview_search_cmd_callback (const void *user_data, gsize char_offset, int *curre
|
||||
switch (view->search_nroff_seq->type)
|
||||
{
|
||||
case NROFF_TYPE_BOLD:
|
||||
view->search_numNeedSkipChar = 1 + view->search_nroff_seq->char_width; /* real char width and 0x8 */
|
||||
view->search_numNeedSkipChar = 1 + view->search_nroff_seq->char_length; /* real char length and 0x8 */
|
||||
break;
|
||||
case NROFF_TYPE_UNDERLINE:
|
||||
view->search_numNeedSkipChar = 2; /* underline symbol and ox8 */
|
||||
@ -285,11 +285,12 @@ mcview_do_search (mcview_t * view, off_t want_search_start)
|
||||
if (mcview_search_options.backwards)
|
||||
{
|
||||
mcview_nroff_t *nroff;
|
||||
|
||||
nroff = mcview_nroff_seq_new_num (view, view->search_start);
|
||||
if (mcview_nroff_seq_prev (nroff) != -1)
|
||||
search_start =
|
||||
-(mcview__get_nroff_real_len (view, nroff->index - 1, 2) +
|
||||
nroff->char_width + 1);
|
||||
nroff->char_length + 1);
|
||||
else
|
||||
search_start = -2;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user