mcedit: rename functions:

edit_buffer_move_forward -> edit_buffer_get_forward_offset
edit_buffer_move_backward -> edit_buffer_get_backward_offset

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2016-03-14 11:47:56 +03:00
parent 2b8b1c56ea
commit 874be2de1e
6 changed files with 36 additions and 32 deletions

View File

@ -711,12 +711,12 @@ edit_find_line (WEdit * edit, long line)
i = 3 + (rand () % (N_LINE_CACHES - 3));
if (line > edit->line_numbers[j])
edit->line_offsets[i] =
edit_buffer_move_forward (&edit->buffer, edit->line_offsets[j],
line - edit->line_numbers[j], 0);
edit_buffer_get_forward_offset (&edit->buffer, edit->line_offsets[j],
line - edit->line_numbers[j], 0);
else
edit->line_offsets[i] =
edit_buffer_move_backward (&edit->buffer, edit->line_offsets[j],
edit->line_numbers[j] - line);
edit_buffer_get_backward_offset (&edit->buffer, edit->line_offsets[j],
edit->line_numbers[j] - line);
edit->line_numbers[i] = line;
return edit->line_offsets[i];
}
@ -1068,8 +1068,8 @@ edit_move_updown (WEdit * edit, long lines, gboolean do_scroll, gboolean directi
edit_scroll_downward (edit, lines);
}
p = edit_buffer_get_current_bol (&edit->buffer);
p = direction ? edit_buffer_move_backward (&edit->buffer, p, lines) :
edit_buffer_move_forward (&edit->buffer, p, lines, 0);
p = direction ? edit_buffer_get_backward_offset (&edit->buffer, p, lines) :
edit_buffer_get_forward_offset (&edit->buffer, p, lines, 0);
edit_cursor_move (edit, p - edit->buffer.curs1);
edit_move_to_prev_col (edit, p);
@ -1383,7 +1383,7 @@ edit_auto_indent (WEdit * edit)
p = edit->buffer.curs1;
/* use the previous line as a template */
p = edit_buffer_move_backward (&edit->buffer, p, 1);
p = edit_buffer_get_backward_offset (&edit->buffer, p, 1);
/* copy the leading whitespace of the line */
while (TRUE)
{ /* no range check - the line _is_ \n-terminated */
@ -2862,7 +2862,8 @@ edit_scroll_upward (WEdit * edit, long i)
if (i != 0)
{
edit->start_line -= i;
edit->start_display = edit_buffer_move_backward (&edit->buffer, edit->start_display, i);
edit->start_display =
edit_buffer_get_backward_offset (&edit->buffer, edit->start_display, i);
edit->force |= REDRAW_PAGE;
edit->force &= (0xfff - REDRAW_CHAR_ONLY);
}
@ -2883,7 +2884,8 @@ edit_scroll_downward (WEdit * edit, long i)
if (i > lines_below)
i = lines_below;
edit->start_line += i;
edit->start_display = edit_buffer_move_forward (&edit->buffer, edit->start_display, i, 0);
edit->start_display =
edit_buffer_get_forward_offset (&edit->buffer, edit->start_display, i, 0);
edit->force |= REDRAW_PAGE;
edit->force &= (0xfff - REDRAW_CHAR_ONLY);
}

View File

@ -591,7 +591,7 @@ edit_buffer_backspace (edit_buffer_t * buf)
*/
off_t
edit_buffer_move_forward (const edit_buffer_t * buf, off_t current, long lines, off_t upto)
edit_buffer_get_forward_offset (const edit_buffer_t * buf, off_t current, long lines, off_t upto)
{
if (upto != 0)
return (off_t) edit_buffer_count_lines (buf, current, upto);
@ -623,7 +623,7 @@ edit_buffer_move_forward (const edit_buffer_t * buf, off_t current, long lines,
*/
off_t
edit_buffer_move_backward (const edit_buffer_t * buf, off_t current, long lines)
edit_buffer_get_backward_offset (const edit_buffer_t * buf, off_t current, long lines)
{
lines = max (lines, 0);
current = edit_buffer_get_bol (buf, current);

View File

@ -54,8 +54,9 @@ void edit_buffer_insert_ahead (edit_buffer_t * buf, int c);
int edit_buffer_delete (edit_buffer_t * buf);
int edit_buffer_backspace (edit_buffer_t * buf);
off_t edit_buffer_move_forward (const edit_buffer_t * buf, off_t current, long lines, off_t upto);
off_t edit_buffer_move_backward (const edit_buffer_t * buf, off_t current, long lines);
off_t edit_buffer_get_forward_offset (const edit_buffer_t * buf, off_t current, long lines,
off_t upto);
off_t edit_buffer_get_backward_offset (const edit_buffer_t * buf, off_t current, long lines);
off_t edit_buffer_read_file (edit_buffer_t * buf, int fd, off_t size,
edit_buffer_read_file_status_msg_t * sm, gboolean * aborted);

View File

@ -543,7 +543,7 @@ edit_delete_column_of_text (WEdit * edit)
long b, c, d;
eval_marks (edit, &m1, &m2);
n = edit_buffer_move_forward (&edit->buffer, m1, 0, m2) + 1;
n = edit_buffer_get_forward_offset (&edit->buffer, m1, 0, m2) + 1;
c = (long) edit_move_forward3 (edit, edit_buffer_get_bol (&edit->buffer, m1), 0, m1);
d = (long) edit_move_forward3 (edit, edit_buffer_get_bol (&edit->buffer, m2), 0, m2);
b = max (min (c, d), min (edit->column1, edit->column2));
@ -569,8 +569,8 @@ edit_delete_column_of_text (WEdit * edit)
if (n)
/* move to next line except on the last delete */
edit_cursor_move (edit,
edit_buffer_move_forward (&edit->buffer, edit->buffer.curs1, 1,
0) - edit->buffer.curs1);
edit_buffer_get_forward_offset (&edit->buffer, edit->buffer.curs1, 1,
0) - edit->buffer.curs1);
}
}

View File

@ -918,13 +918,13 @@ render_edit_text (WEdit * edit, long start_row, long start_column, long end_row,
if ((force & REDRAW_PAGE) != 0)
{
row = start_row;
b = edit_buffer_move_forward (&edit->buffer, edit->start_display, start_row, 0);
b = edit_buffer_get_forward_offset (&edit->buffer, edit->start_display, start_row, 0);
while (row <= end_row)
{
if (key_pending (edit))
return;
edit_draw_this_line (edit, b, row, start_column, end_column);
b = edit_buffer_move_forward (&edit->buffer, b, 1, 0);
b = edit_buffer_get_forward_offset (&edit->buffer, b, 1, 0);
row++;
}
}
@ -943,7 +943,7 @@ render_edit_text (WEdit * edit, long start_row, long start_column, long end_row,
if (key_pending (edit))
return;
edit_draw_this_line (edit, b, row, start_column, end_column);
b = edit_buffer_move_forward (&edit->buffer, b, 1, 0);
b = edit_buffer_get_forward_offset (&edit->buffer, b, 1, 0);
}
}
@ -959,13 +959,13 @@ render_edit_text (WEdit * edit, long start_row, long start_column, long end_row,
if ((force & REDRAW_AFTER_CURSOR) != 0 && end_row > curs_row)
{
row = curs_row + 1 < start_row ? start_row : curs_row + 1;
b = edit_buffer_move_forward (&edit->buffer, b, 1, 0);
b = edit_buffer_get_forward_offset (&edit->buffer, b, 1, 0);
while (row <= end_row)
{
if (key_pending (edit))
return;
edit_draw_this_line (edit, b, row, start_column, end_column);
b = edit_buffer_move_forward (&edit->buffer, b, 1, 0);
b = edit_buffer_get_forward_offset (&edit->buffer, b, 1, 0);
row++;
}
}
@ -973,8 +973,9 @@ render_edit_text (WEdit * edit, long start_row, long start_column, long end_row,
if ((force & REDRAW_LINE_ABOVE) != 0 && curs_row >= 1)
{
row = curs_row - 1;
b = edit_buffer_move_backward (&edit->buffer,
edit_buffer_get_current_bol (&edit->buffer), 1);
b = edit_buffer_get_backward_offset (&edit->buffer,
edit_buffer_get_current_bol (&edit->buffer),
1);
if (row >= start_row && row <= end_row)
{
if (key_pending (edit))
@ -987,7 +988,7 @@ render_edit_text (WEdit * edit, long start_row, long start_column, long end_row,
{
row = curs_row + 1;
b = edit_buffer_get_current_bol (&edit->buffer);
b = edit_buffer_move_forward (&edit->buffer, b, 1, 0);
b = edit_buffer_get_forward_offset (&edit->buffer, b, 1, 0);
if (row >= start_row && row <= end_row)
{
if (key_pending (edit))

View File

@ -81,9 +81,9 @@ line_start (const edit_buffer_t * buf, long line)
p = buf->curs1;
if (line < l)
p = edit_buffer_move_backward (buf, p, l - line);
p = edit_buffer_get_backward_offset (buf, p, l - line);
else if (line > l)
p = edit_buffer_move_forward (buf, p, line - l, 0);
p = edit_buffer_get_forward_offset (buf, p, line - l, 0);
p = edit_buffer_get_bol (buf, p);
while (strchr ("\t ", edit_buffer_get_byte (buf, p)) != NULL)
@ -136,8 +136,8 @@ begin_paragraph (WEdit * edit, gboolean force, long *lines)
*lines = edit->buffer.curs_line - i;
return edit_buffer_move_backward (&edit->buffer, edit_buffer_get_current_bol (&edit->buffer),
*lines);
return edit_buffer_get_backward_offset (&edit->buffer,
edit_buffer_get_current_bol (&edit->buffer), *lines);
}
/* --------------------------------------------------------------------------------------------- */
@ -160,10 +160,10 @@ end_paragraph (WEdit * edit, gboolean force)
}
return edit_buffer_get_eol (&edit->buffer,
edit_buffer_move_forward (&edit->buffer,
edit_buffer_get_current_bol
(&edit->buffer),
i - edit->buffer.curs_line, 0));
edit_buffer_get_forward_offset (&edit->buffer,
edit_buffer_get_current_bol
(&edit->buffer),
i - edit->buffer.curs_line, 0));
}
/* --------------------------------------------------------------------------------------------- */