mirror of https://github.com/MidnightCommander/mc
(eval_marks): move from editcmd.c to edit.c.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
e2e34d82ab
commit
7feb865c88
|
@ -3090,6 +3090,72 @@ edit_set_markers (WEdit * edit, off_t m1, off_t m2, long c1, long c2)
|
|||
edit->column2 = c2;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
if mark2 is -1 then marking is from mark1 to the cursor.
|
||||
Otherwise its between the markers. This handles this.
|
||||
Returns FALSE if no text is marked.
|
||||
*/
|
||||
|
||||
gboolean
|
||||
eval_marks (WEdit * edit, off_t * start_mark, off_t * end_mark)
|
||||
{
|
||||
long end_mark_curs;
|
||||
|
||||
if (edit->mark1 == edit->mark2)
|
||||
{
|
||||
*start_mark = *end_mark = 0;
|
||||
edit->column2 = edit->column1 = 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (edit->end_mark_curs < 0)
|
||||
end_mark_curs = edit->buffer.curs1;
|
||||
else
|
||||
end_mark_curs = edit->end_mark_curs;
|
||||
|
||||
if (edit->mark2 >= 0)
|
||||
{
|
||||
*start_mark = MIN (edit->mark1, edit->mark2);
|
||||
*end_mark = MAX (edit->mark1, edit->mark2);
|
||||
}
|
||||
else
|
||||
{
|
||||
*start_mark = MIN (edit->mark1, end_mark_curs);
|
||||
*end_mark = MAX (edit->mark1, end_mark_curs);
|
||||
edit->column2 = edit->curs_col + edit->over_col;
|
||||
}
|
||||
|
||||
if (edit->column_highlight
|
||||
&& ((edit->mark1 > end_mark_curs && edit->column1 < edit->column2)
|
||||
|| (edit->mark1 < end_mark_curs && edit->column1 > edit->column2)))
|
||||
{
|
||||
off_t start_bol, start_eol;
|
||||
off_t end_bol, end_eol;
|
||||
long col1, col2;
|
||||
off_t diff1, diff2;
|
||||
|
||||
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);
|
||||
|
||||
diff1 = edit_move_forward3 (edit, start_bol, col2, 0) -
|
||||
edit_move_forward3 (edit, start_bol, col1, 0);
|
||||
diff2 = edit_move_forward3 (edit, end_bol, col2, 0) -
|
||||
edit_move_forward3 (edit, end_bol, col1, 0);
|
||||
|
||||
*start_mark -= diff1;
|
||||
*end_mark += diff2;
|
||||
*start_mark = MAX (*start_mark, start_eol);
|
||||
*end_mark = MIN (*end_mark, end_eol);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/** highlight marker toggle */
|
||||
|
||||
|
|
|
@ -1262,72 +1262,6 @@ edit_close_cmd (WEdit * edit)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
if mark2 is -1 then marking is from mark1 to the cursor.
|
||||
Otherwise its between the markers. This handles this.
|
||||
Returns FALSE if no text is marked.
|
||||
*/
|
||||
|
||||
gboolean
|
||||
eval_marks (WEdit * edit, off_t * start_mark, off_t * end_mark)
|
||||
{
|
||||
long end_mark_curs;
|
||||
|
||||
if (edit->mark1 == edit->mark2)
|
||||
{
|
||||
*start_mark = *end_mark = 0;
|
||||
edit->column2 = edit->column1 = 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (edit->end_mark_curs < 0)
|
||||
end_mark_curs = edit->buffer.curs1;
|
||||
else
|
||||
end_mark_curs = edit->end_mark_curs;
|
||||
|
||||
if (edit->mark2 >= 0)
|
||||
{
|
||||
*start_mark = MIN (edit->mark1, edit->mark2);
|
||||
*end_mark = MAX (edit->mark1, edit->mark2);
|
||||
}
|
||||
else
|
||||
{
|
||||
*start_mark = MIN (edit->mark1, end_mark_curs);
|
||||
*end_mark = MAX (edit->mark1, end_mark_curs);
|
||||
edit->column2 = edit->curs_col + edit->over_col;
|
||||
}
|
||||
|
||||
if (edit->column_highlight
|
||||
&& ((edit->mark1 > end_mark_curs && edit->column1 < edit->column2)
|
||||
|| (edit->mark1 < end_mark_curs && edit->column1 > edit->column2)))
|
||||
{
|
||||
off_t start_bol, start_eol;
|
||||
off_t end_bol, end_eol;
|
||||
long col1, col2;
|
||||
off_t diff1, diff2;
|
||||
|
||||
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);
|
||||
|
||||
diff1 = edit_move_forward3 (edit, start_bol, col2, 0) -
|
||||
edit_move_forward3 (edit, start_bol, col1, 0);
|
||||
diff2 = edit_move_forward3 (edit, end_bol, col2, 0) -
|
||||
edit_move_forward3 (edit, end_bol, col1, 0);
|
||||
|
||||
*start_mark -= diff1;
|
||||
*end_mark += diff2;
|
||||
*start_mark = MAX (*start_mark, start_eol);
|
||||
*end_mark = MIN (*end_mark, end_eol);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue