mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
Refactoring: rename functions of getting BOL and EOFL:
edit_bol() -> edit_buffer_get_bol() edit_eol() -> edit_buffer_get_eol() Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
32ffd98e87
commit
506b3d4eee
@ -166,8 +166,6 @@ void edit_move_up (WEdit * edit, long i, gboolean do_scroll);
|
||||
void edit_move_down (WEdit * edit, long i, gboolean do_scroll);
|
||||
void edit_move_to_prev_col (WEdit * edit, off_t p);
|
||||
long edit_get_col (const WEdit * edit);
|
||||
off_t edit_bol (const WEdit * edit, off_t current);
|
||||
off_t edit_eol (const WEdit * edit, off_t current);
|
||||
void edit_update_curs_row (WEdit * edit);
|
||||
void edit_update_curs_col (WEdit * edit);
|
||||
void edit_find_bracket (WEdit * edit);
|
||||
|
@ -417,7 +417,7 @@ edit_load_position (WEdit * edit)
|
||||
|
||||
book_mark_restore (edit, BOOK_MARK_COLOR);
|
||||
|
||||
edit_move_to_prev_col (edit, edit_bol (edit, edit->buffer.curs1));
|
||||
edit_move_to_prev_col (edit, edit_buffer_get_current_bol (&edit->buffer));
|
||||
edit_move_display (edit, line - (WIDGET (edit)->lines / 2));
|
||||
}
|
||||
|
||||
@ -567,7 +567,7 @@ is_in_indent (const WEdit * edit)
|
||||
{
|
||||
off_t p;
|
||||
|
||||
for (p = edit_bol (edit, edit->buffer.curs1); p < edit->buffer.curs1; p++)
|
||||
for (p = edit_buffer_get_current_bol (&edit->buffer); p < edit->buffer.curs1; p++)
|
||||
if (strchr (" \t", edit_buffer_get_byte (&edit->buffer, p)) == NULL)
|
||||
return FALSE;
|
||||
|
||||
@ -589,8 +589,8 @@ is_blank (const WEdit * edit, off_t offset)
|
||||
off_t s, f;
|
||||
int c;
|
||||
|
||||
s = edit_bol (edit, offset);
|
||||
f = edit_eol (edit, offset) - 1;
|
||||
s = edit_buffer_get_bol (&edit->buffer, offset);
|
||||
f = edit_buffer_get_eol (&edit->buffer, offset) - 1;
|
||||
while (s <= f)
|
||||
{
|
||||
c = edit_buffer_get_byte (&edit->buffer, s++);
|
||||
@ -615,9 +615,9 @@ edit_find_line (WEdit * edit, long line)
|
||||
memset (edit->line_offsets, 0, sizeof (edit->line_offsets));
|
||||
/* three offsets that we *know* are line 0 at 0 and these two: */
|
||||
edit->line_numbers[1] = edit->buffer.curs_line;
|
||||
edit->line_offsets[1] = edit_bol (edit, edit->buffer.curs1);
|
||||
edit->line_offsets[1] = edit_buffer_get_current_bol (&edit->buffer);
|
||||
edit->line_numbers[2] = edit->buffer.lines;
|
||||
edit->line_offsets[2] = edit_bol (edit, edit->buffer.size);
|
||||
edit->line_offsets[2] = edit_buffer_get_bol (&edit->buffer, edit->buffer.size);
|
||||
edit->caches_valid = TRUE;
|
||||
}
|
||||
if (line >= edit->buffer.lines)
|
||||
@ -781,7 +781,7 @@ edit_move_to_bottom (WEdit * edit)
|
||||
static void
|
||||
edit_cursor_to_bol (WEdit * edit)
|
||||
{
|
||||
edit_cursor_move (edit, edit_bol (edit, edit->buffer.curs1) - edit->buffer.curs1);
|
||||
edit_cursor_move (edit, edit_buffer_get_current_bol (&edit->buffer) - edit->buffer.curs1);
|
||||
edit->search_start = edit->buffer.curs1;
|
||||
edit->prev_col = edit_get_col (edit);
|
||||
edit->over_col = 0;
|
||||
@ -793,7 +793,7 @@ edit_cursor_to_bol (WEdit * edit)
|
||||
static void
|
||||
edit_cursor_to_eol (WEdit * edit)
|
||||
{
|
||||
edit_cursor_move (edit, edit_eol (edit, edit->buffer.curs1) - edit->buffer.curs1);
|
||||
edit_cursor_move (edit, edit_buffer_get_current_eol (&edit->buffer) - edit->buffer.curs1);
|
||||
edit->search_start = edit->buffer.curs1;
|
||||
edit->prev_col = edit_get_col (edit);
|
||||
edit->over_col = 0;
|
||||
@ -852,7 +852,8 @@ edit_left_word_move (WEdit * edit, int s)
|
||||
|
||||
if (edit->column_highlight
|
||||
&& edit->mark1 != edit->mark2
|
||||
&& edit->over_col == 0 && edit->buffer.curs1 == edit_bol (edit, edit->buffer.curs1))
|
||||
&& edit->over_col == 0
|
||||
&& edit->buffer.curs1 == edit_buffer_get_current_bol (&edit->buffer))
|
||||
break;
|
||||
edit_cursor_move (edit, -1);
|
||||
if (edit->buffer.curs1 == 0)
|
||||
@ -890,7 +891,8 @@ edit_right_word_move (WEdit * edit, int s)
|
||||
|
||||
if (edit->column_highlight
|
||||
&& edit->mark1 != edit->mark2
|
||||
&& edit->over_col == 0 && edit->buffer.curs1 == edit_eol (edit, edit->buffer.curs1))
|
||||
&& edit->over_col == 0
|
||||
&& edit->buffer.curs1 == edit_buffer_get_current_eol (&edit->buffer))
|
||||
break;
|
||||
edit_cursor_move (edit, 1);
|
||||
if (edit->buffer.curs1 >= edit->buffer.size)
|
||||
@ -952,7 +954,8 @@ edit_left_char_move_cmd (WEdit * edit)
|
||||
if (edit->column_highlight
|
||||
&& option_cursor_beyond_eol
|
||||
&& edit->mark1 != edit->mark2
|
||||
&& edit->over_col == 0 && edit->buffer.curs1 == edit_bol (edit, edit->buffer.curs1))
|
||||
&& edit->over_col == 0
|
||||
&& edit->buffer.curs1 == edit_buffer_get_current_bol (&edit->buffer))
|
||||
return;
|
||||
#ifdef HAVE_CHARSET
|
||||
if (edit->utf8)
|
||||
@ -999,12 +1002,9 @@ edit_move_updown (WEdit * edit, long lines, gboolean do_scroll, gboolean directi
|
||||
else
|
||||
edit_scroll_downward (edit, lines);
|
||||
}
|
||||
p = edit_bol (edit, edit->buffer.curs1);
|
||||
|
||||
p = edit_buffer_get_current_bol (&edit->buffer);
|
||||
p = direction ? edit_move_backward (edit, p, lines) : edit_move_forward (edit, p, lines, 0);
|
||||
|
||||
edit_cursor_move (edit, p - edit->buffer.curs1);
|
||||
|
||||
edit_move_to_prev_col (edit, p);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
@ -1111,13 +1111,15 @@ edit_do_undo (WEdit * edit)
|
||||
{
|
||||
edit->mark1 = ac - MARK_1;
|
||||
edit->column1 =
|
||||
(long) edit_move_forward3 (edit, edit_bol (edit, edit->mark1), 0, edit->mark1);
|
||||
(long) edit_move_forward3 (edit, edit_buffer_get_bol (&edit->buffer, edit->mark1), 0,
|
||||
edit->mark1);
|
||||
}
|
||||
if (ac >= MARK_2 - 2 && ac < MARK_CURS - 2)
|
||||
{
|
||||
edit->mark2 = ac - MARK_2;
|
||||
edit->column2 =
|
||||
(long) edit_move_forward3 (edit, edit_bol (edit, edit->mark2), 0, edit->mark2);
|
||||
(long) edit_move_forward3 (edit, edit_buffer_get_bol (&edit->buffer, edit->mark2), 0,
|
||||
edit->mark2);
|
||||
}
|
||||
else if (ac >= MARK_CURS - 2 && ac < KEY_PRESS)
|
||||
{
|
||||
@ -1190,13 +1192,13 @@ edit_do_redo (WEdit * edit)
|
||||
{
|
||||
edit->mark1 = ac - MARK_1;
|
||||
edit->column1 =
|
||||
(long) edit_move_forward3 (edit, edit_bol (edit, edit->mark1), 0, edit->mark1);
|
||||
(long) edit_move_forward3 (edit, edit_buffer_get_bol (&edit->buffer, edit->mark1), 0, edit->mark1);
|
||||
}
|
||||
else if (ac >= MARK_2 - 2 && ac < KEY_PRESS)
|
||||
{
|
||||
edit->mark2 = ac - MARK_2;
|
||||
edit->column2 =
|
||||
(long) edit_move_forward3 (edit, edit_bol (edit, edit->mark2), 0, edit->mark2);
|
||||
(long) edit_move_forward3 (edit, edit_buffer_get_bol (&edit->buffer, edit->mark2), 0, edit->mark2);
|
||||
}
|
||||
/* more than one pop usually means something big */
|
||||
if (count++)
|
||||
@ -1501,8 +1503,8 @@ edit_move_block_to_right (WEdit * edit)
|
||||
if (eval_marks (edit, &start_mark, &end_mark))
|
||||
return;
|
||||
|
||||
start_bol = edit_bol (edit, start_mark);
|
||||
cur_bol = edit_bol (edit, end_mark - 1);
|
||||
start_bol = edit_buffer_get_bol (&edit->buffer, start_mark);
|
||||
cur_bol = edit_buffer_get_bol (&edit->buffer, end_mark - 1);
|
||||
|
||||
do
|
||||
{
|
||||
@ -1513,13 +1515,13 @@ edit_move_block_to_right (WEdit * edit)
|
||||
insert_spaces_tab (edit, option_fake_half_tabs);
|
||||
else
|
||||
edit_insert (edit, '\t');
|
||||
edit_cursor_move (edit, edit_bol (edit, cur_bol) - edit->buffer.curs1);
|
||||
edit_cursor_move (edit, edit_buffer_get_bol (&edit->buffer, cur_bol) - edit->buffer.curs1);
|
||||
}
|
||||
|
||||
if (cur_bol == 0)
|
||||
break;
|
||||
|
||||
cur_bol = edit_bol (edit, cur_bol - 1);
|
||||
cur_bol = edit_buffer_get_bol (&edit->buffer, cur_bol - 1);
|
||||
}
|
||||
while (cur_bol >= start_bol);
|
||||
|
||||
@ -1538,8 +1540,8 @@ edit_move_block_to_left (WEdit * edit)
|
||||
if (eval_marks (edit, &start_mark, &end_mark))
|
||||
return;
|
||||
|
||||
start_bol = edit_bol (edit, start_mark);
|
||||
cur_bol = edit_bol (edit, end_mark - 1);
|
||||
start_bol = edit_buffer_get_bol (&edit->buffer, start_mark);
|
||||
cur_bol = edit_buffer_get_bol (&edit->buffer, end_mark - 1);
|
||||
|
||||
do
|
||||
{
|
||||
@ -1567,7 +1569,7 @@ edit_move_block_to_left (WEdit * edit)
|
||||
if (cur_bol == 0)
|
||||
break;
|
||||
|
||||
cur_bol = edit_bol (edit, cur_bol - 1);
|
||||
cur_bol = edit_buffer_get_bol (&edit->buffer, cur_bol - 1);
|
||||
}
|
||||
while (cur_bol >= start_bol);
|
||||
|
||||
@ -2706,38 +2708,6 @@ edit_cursor_move (WEdit * edit, off_t increment)
|
||||
}
|
||||
}
|
||||
|
||||
/* These functions return positions relative to lines */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/** returns index of last char on line + 1 */
|
||||
|
||||
off_t
|
||||
edit_eol (const WEdit * edit, off_t current)
|
||||
{
|
||||
if (current >= edit->buffer.size)
|
||||
return edit->buffer.size;
|
||||
|
||||
for (; edit_buffer_get_byte (&edit->buffer, current) != '\n'; current++)
|
||||
;
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/** returns index of first char on line */
|
||||
|
||||
off_t
|
||||
edit_bol (const WEdit * edit, off_t current)
|
||||
{
|
||||
if (current <= 0)
|
||||
return 0;
|
||||
|
||||
for (; edit_buffer_get_byte (&edit->buffer, current - 1) != '\n'; current--)
|
||||
;
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* If lines is zero this returns the count of lines from current to upto. */
|
||||
/* If upto is zero returns index of lines forward current. */
|
||||
@ -2754,7 +2724,7 @@ edit_move_forward (const WEdit * edit, off_t current, long lines, off_t upto)
|
||||
lines = 0;
|
||||
while (lines-- != 0)
|
||||
{
|
||||
next = edit_eol (edit, current) + 1;
|
||||
next = edit_buffer_get_eol (&edit->buffer, current) + 1;
|
||||
if (next > edit->buffer.size)
|
||||
break;
|
||||
else
|
||||
@ -2772,9 +2742,9 @@ edit_move_backward (const WEdit * edit, off_t current, long lines)
|
||||
{
|
||||
if (lines < 0)
|
||||
lines = 0;
|
||||
current = edit_bol (edit, current);
|
||||
current = edit_buffer_get_bol (&edit->buffer, current);
|
||||
while (lines-- != 0 && current != 0)
|
||||
current = edit_bol (edit, current - 1);
|
||||
current = edit_buffer_get_bol (&edit->buffer, current - 1);
|
||||
return current;
|
||||
}
|
||||
|
||||
@ -2855,7 +2825,8 @@ edit_move_forward3 (const WEdit * edit, off_t current, long cols, off_t upto)
|
||||
long
|
||||
edit_get_col (const WEdit * edit)
|
||||
{
|
||||
return (long) edit_move_forward3 (edit, edit_bol (edit, edit->buffer.curs1), 0, edit->buffer.curs1);
|
||||
return (long) edit_move_forward3 (edit, edit_buffer_get_current_bol (&edit->buffer), 0,
|
||||
edit->buffer.curs1);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -2873,7 +2844,8 @@ edit_update_curs_row (WEdit * edit)
|
||||
void
|
||||
edit_update_curs_col (WEdit * edit)
|
||||
{
|
||||
edit->curs_col = (long) edit_move_forward3 (edit, edit_bol (edit, edit->buffer.curs1), 0, edit->buffer.curs1);
|
||||
edit->curs_col = (long) edit_move_forward3 (edit, edit_buffer_get_current_bol (&edit->buffer),
|
||||
0, edit->buffer.curs1);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -2966,8 +2938,8 @@ edit_move_to_prev_col (WEdit * edit, off_t p)
|
||||
{
|
||||
long line_len;
|
||||
|
||||
line_len = (long) edit_move_forward3 (edit, edit_bol (edit, edit->buffer.curs1), 0,
|
||||
edit_eol (edit, edit->buffer.curs1));
|
||||
line_len = (long) edit_move_forward3 (edit, edit_buffer_get_current_bol (&edit->buffer), 0,
|
||||
edit_buffer_get_current_eol (&edit->buffer));
|
||||
if (line_len < prev + edit->over_col)
|
||||
{
|
||||
edit->over_col = prev + over - line_len;
|
||||
@ -2997,7 +2969,7 @@ edit_move_to_prev_col (WEdit * edit, off_t p)
|
||||
|
||||
q = edit->curs_col;
|
||||
edit->curs_col -= (edit->curs_col % fake_half_tabs);
|
||||
p = edit_bol (edit, edit->buffer.curs1);
|
||||
p = edit_buffer_get_current_bol (&edit->buffer);
|
||||
edit_cursor_move (edit,
|
||||
edit_move_forward3 (edit, p, edit->curs_col, 0) - edit->buffer.curs1);
|
||||
if (!left_of_four_spaces (edit))
|
||||
@ -3139,10 +3111,8 @@ edit_mark_current_word_cmd (WEdit * edit)
|
||||
void
|
||||
edit_mark_current_line_cmd (WEdit * edit)
|
||||
{
|
||||
long pos = edit->buffer.curs1;
|
||||
|
||||
edit->mark1 = edit_bol (edit, pos);
|
||||
edit->mark2 = edit_eol (edit, pos);
|
||||
edit->mark1 = edit_buffer_get_current_bol (&edit->buffer);
|
||||
edit->mark2 = edit_buffer_get_current_eol (&edit->buffer);
|
||||
|
||||
edit->force |= REDRAW_LINE_ABOVE | REDRAW_AFTER_CURSOR;
|
||||
}
|
||||
|
@ -329,6 +329,50 @@ edit_buffer_count_lines (const edit_buffer_t * buf, off_t first, off_t last)
|
||||
return lines;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Get "begin-of-line" offset of line contained specified byte offset
|
||||
*
|
||||
* @param buf editor buffer
|
||||
* @param current byte offset
|
||||
*
|
||||
* @return index of first char of line
|
||||
*/
|
||||
|
||||
off_t
|
||||
edit_buffer_get_bol (const edit_buffer_t * buf, off_t current)
|
||||
{
|
||||
if (current <= 0)
|
||||
return 0;
|
||||
|
||||
for (; edit_buffer_get_byte (buf, current - 1) != '\n'; current--)
|
||||
;
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Get "end-of-line" offset of line contained specified byte offset
|
||||
*
|
||||
* @param buf editor buffer
|
||||
* @param current byte offset
|
||||
*
|
||||
* @return index of last char of line + 1
|
||||
*/
|
||||
|
||||
off_t
|
||||
edit_buffer_get_eol (const edit_buffer_t * buf, off_t current)
|
||||
{
|
||||
if (current >= buf->size)
|
||||
return buf->size;
|
||||
|
||||
for (; edit_buffer_get_byte (buf, current) != '\n'; current++)
|
||||
;
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Basic low level single character buffer alterations and movements at the cursor: insert character
|
||||
|
@ -62,6 +62,8 @@ int edit_buffer_get_utf (const edit_buffer_t * buf, off_t byte_index, int *char_
|
||||
int edit_buffer_get_prev_utf (const edit_buffer_t * buf, off_t byte_index, int *char_width);
|
||||
#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);
|
||||
off_t edit_buffer_get_eol (const edit_buffer_t * buf, off_t current);
|
||||
|
||||
void edit_buffer_insert (edit_buffer_t * buf, int c);
|
||||
void edit_buffer_insert_ahead (edit_buffer_t * buf, int c);
|
||||
@ -87,6 +89,36 @@ edit_buffer_get_previous_byte (const edit_buffer_t * buf)
|
||||
return edit_buffer_get_byte (buf, buf->curs1 - 1);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Get "begin-of-line" offset of current line
|
||||
*
|
||||
* @param buf editor buffer
|
||||
*
|
||||
* @return index of first char of current line
|
||||
*/
|
||||
|
||||
static inline off_t
|
||||
edit_buffer_get_current_bol (const edit_buffer_t * buf)
|
||||
{
|
||||
return edit_buffer_get_bol (buf, buf->curs1);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Get "end-of-line" offset of current line
|
||||
*
|
||||
* @param buf editor buffer
|
||||
*
|
||||
* @return index of first char of current line + 1
|
||||
*/
|
||||
|
||||
static inline off_t
|
||||
edit_buffer_get_current_eol (const edit_buffer_t * buf)
|
||||
{
|
||||
return edit_buffer_get_eol (buf, buf->curs1);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#endif /* MC__EDIT_BUFFER_H */
|
||||
|
@ -512,14 +512,14 @@ edit_delete_column_of_text (WEdit * edit)
|
||||
|
||||
eval_marks (edit, &m1, &m2);
|
||||
n = edit_move_forward (edit, m1, 0, m2) + 1;
|
||||
c = (long) edit_move_forward3 (edit, edit_bol (edit, m1), 0, m1);
|
||||
d = (long) edit_move_forward3 (edit, edit_bol (edit, m2), 0, m2);
|
||||
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));
|
||||
c = max (c, max (edit->column1, edit->column2));
|
||||
|
||||
while (n--)
|
||||
{
|
||||
r = edit_bol (edit, edit->buffer.curs1);
|
||||
r = edit_buffer_get_current_bol (&edit->buffer);
|
||||
p = edit_move_forward3 (edit, r, b, 0);
|
||||
q = edit_move_forward3 (edit, r, c, 0);
|
||||
if (p < m1)
|
||||
@ -593,8 +593,8 @@ edit_block_delete (WEdit * edit)
|
||||
/* move cursor to the saved position */
|
||||
edit_move_to_line (edit, curs_line);
|
||||
/* calculate line width and cursor position before cut */
|
||||
line_width = edit_move_forward3 (edit, edit_bol (edit, edit->buffer.curs1), 0,
|
||||
edit_eol (edit, edit->buffer.curs1));
|
||||
line_width = edit_move_forward3 (edit, edit_buffer_get_current_bol (&edit->buffer), 0,
|
||||
edit_buffer_get_current_eol (&edit->buffer));
|
||||
if (option_cursor_beyond_eol && curs_pos > line_width)
|
||||
edit->over_col = curs_pos - line_width;
|
||||
}
|
||||
@ -1011,7 +1011,7 @@ edit_get_block (WEdit * edit, off_t start, off_t finish, off_t * l)
|
||||
int c;
|
||||
off_t x;
|
||||
|
||||
x = edit_move_forward3 (edit, edit_bol (edit, start), 0, start);
|
||||
x = edit_move_forward3 (edit, edit_buffer_get_bol (&edit->buffer, start), 0, start);
|
||||
c = edit_buffer_get_byte (&edit->buffer, start);
|
||||
if ((x >= edit->column1 && x < edit->column2)
|
||||
|| (x >= edit->column2 && x < edit->column1) || c == '\n')
|
||||
@ -2242,10 +2242,10 @@ eval_marks (WEdit * edit, off_t * start_mark, off_t * end_mark)
|
||||
&& (((edit->mark1 > end_mark_curs) && (edit->column1 < edit->column2))
|
||||
|| ((edit->mark1 < end_mark_curs) && (edit->column1 > edit->column2))))
|
||||
{
|
||||
start_bol = edit_bol (edit, *start_mark);
|
||||
start_eol = edit_eol (edit, start_bol - 1) + 1;
|
||||
end_bol = edit_bol (edit, *end_mark);
|
||||
end_eol = edit_eol (edit, *end_mark);
|
||||
start_bol = edit_buffer_get_bol (&edit->buffer, *start_mark);
|
||||
start_eol = edit_buffer_get_eol (&edit->buffer, start_bol - 1) + 1;
|
||||
end_bol = edit_buffer_get_bol (&edit->buffer, *end_mark);
|
||||
end_eol = edit_buffer_get_eol (&edit->buffer, *end_mark);
|
||||
col1 = min (edit->column1, edit->column2);
|
||||
col2 = max (edit->column1, edit->column2);
|
||||
|
||||
@ -2356,10 +2356,12 @@ edit_block_move_cmd (WEdit * edit)
|
||||
x2 = x + edit->over_col;
|
||||
|
||||
/* do nothing when cursor inside first line of selected area */
|
||||
if ((edit_eol (edit, edit->buffer.curs1) == edit_eol (edit, start_mark)) && x2 > c1 && x2 <= c2)
|
||||
if ((edit_buffer_get_eol (&edit->buffer, edit->buffer.curs1) == edit_buffer_get_eol (&edit->buffer, start_mark))
|
||||
&& x2 > c1 && x2 <= c2)
|
||||
return;
|
||||
|
||||
if (edit->buffer.curs1 > start_mark && edit->buffer.curs1 < edit_eol (edit, end_mark))
|
||||
if (edit->buffer.curs1 > start_mark
|
||||
&& edit->buffer.curs1 < edit_buffer_get_eol (&edit->buffer, end_mark))
|
||||
{
|
||||
if (x > c2)
|
||||
x -= b_width;
|
||||
@ -2374,7 +2376,7 @@ edit_block_move_cmd (WEdit * edit)
|
||||
|
||||
edit->over_col = max (0, edit->over_col - b_width);
|
||||
/* calculate the cursor pos after delete block */
|
||||
current = edit_move_forward3 (edit, edit_bol (edit, edit->buffer.curs1), x, 0);
|
||||
current = edit_move_forward3 (edit, edit_buffer_get_current_bol (&edit->buffer), x, 0);
|
||||
edit_cursor_move (edit, current - edit->buffer.curs1);
|
||||
edit_scroll_screen_over_cursor (edit);
|
||||
|
||||
|
@ -570,7 +570,7 @@ edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c
|
||||
off_t tws = 0;
|
||||
if (tty_use_colors () && visible_tws)
|
||||
{
|
||||
tws = edit_eol (edit, b);
|
||||
tws = edit_buffer_get_eol (&edit->buffer, b);
|
||||
while (tws > b && ((c = edit_buffer_get_byte (&edit->buffer, tws - 1)) == ' ' || c == '\t'))
|
||||
tws--;
|
||||
}
|
||||
@ -827,7 +827,7 @@ edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c
|
||||
static inline void
|
||||
edit_draw_this_char (WEdit * edit, off_t curs, long row, long start_column, long end_column)
|
||||
{
|
||||
off_t b = edit_bol (edit, curs);
|
||||
off_t b = edit_buffer_get_bol (&edit->buffer, curs);
|
||||
|
||||
edit_draw_this_line (edit, b, row, start_column, end_column);
|
||||
}
|
||||
@ -933,7 +933,7 @@ render_edit_text (WEdit * edit, long start_row, long start_column, long end_row,
|
||||
}
|
||||
|
||||
/* if (force & REDRAW_LINE) ---> default */
|
||||
b = edit_bol (edit, edit->buffer.curs1);
|
||||
b = edit_buffer_get_current_bol (&edit->buffer);
|
||||
if (curs_row >= start_row && curs_row <= end_row)
|
||||
{
|
||||
if (key_pending (edit))
|
||||
@ -958,7 +958,7 @@ 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_move_backward (edit, edit_bol (edit, edit->buffer.curs1), 1);
|
||||
b = edit_move_backward (edit, edit_buffer_get_current_bol (&edit->buffer), 1);
|
||||
if (row >= start_row && row <= end_row)
|
||||
{
|
||||
if (key_pending (edit))
|
||||
@ -970,7 +970,7 @@ render_edit_text (WEdit * edit, long start_row, long start_column, long end_row,
|
||||
if ((force & REDRAW_LINE_BELOW) != 0 && row < w->lines - 1)
|
||||
{
|
||||
row = curs_row + 1;
|
||||
b = edit_bol (edit, edit->buffer.curs1);
|
||||
b = edit_buffer_get_current_bol (&edit->buffer);
|
||||
b = edit_move_forward (edit, b, 1, 0);
|
||||
if (row >= start_row && row <= end_row)
|
||||
{
|
||||
|
@ -529,8 +529,10 @@ edit_event (Gpm_Event * event, void *data)
|
||||
edit->prev_col = local.x - edit->start_col - option_line_state_width - 1;
|
||||
else
|
||||
{
|
||||
long line_len = edit_move_forward3 (edit, edit_bol (edit, edit->buffer.curs1), 0,
|
||||
edit_eol (edit, edit->buffer.curs1));
|
||||
long line_len;
|
||||
|
||||
line_len = edit_move_forward3 (edit, edit_buffer_get_current_bol (&edit->buffer), 0,
|
||||
edit_buffer_get_current_eol (&edit->buffer));
|
||||
|
||||
if (local.x > line_len)
|
||||
{
|
||||
@ -552,7 +554,7 @@ edit_event (Gpm_Event * event, void *data)
|
||||
else if (local.y < (edit->curs_row + 1))
|
||||
edit_move_up (edit, (edit->curs_row + 1) - local.y, 0);
|
||||
else
|
||||
edit_move_to_prev_col (edit, edit_bol (edit, edit->buffer.curs1));
|
||||
edit_move_to_prev_col (edit, edit_buffer_get_current_bol (&edit->buffer));
|
||||
|
||||
if ((local.type & GPM_DOWN) != 0)
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ line_start (WEdit * edit, long line)
|
||||
else if (line > l)
|
||||
p = edit_move_forward (edit, p, line - l, 0);
|
||||
|
||||
p = edit_bol (edit, p);
|
||||
p = edit_buffer_get_bol (&edit->buffer, p);
|
||||
while (strchr ("\t ", edit_buffer_get_byte (&edit->buffer, p)) != NULL)
|
||||
p++;
|
||||
return p;
|
||||
@ -134,7 +134,7 @@ begin_paragraph (WEdit * edit, gboolean force)
|
||||
break;
|
||||
}
|
||||
|
||||
return edit_move_backward (edit, edit_bol (edit, edit->buffer.curs1), edit->buffer.curs_line - i);
|
||||
return edit_move_backward (edit, edit_buffer_get_current_bol (&edit->buffer), edit->buffer.curs_line - i);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -156,8 +156,8 @@ end_paragraph (WEdit * edit, gboolean force)
|
||||
break;
|
||||
}
|
||||
|
||||
return edit_eol (edit,
|
||||
edit_move_forward (edit, edit_bol (edit, edit->buffer.curs1),
|
||||
return edit_buffer_get_eol (&edit->buffer,
|
||||
edit_move_forward (edit, edit_buffer_get_current_bol (&edit->buffer),
|
||||
i - edit->buffer.curs_line, 0));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user