rewrite_reflow: Extract split_line
function
Extract `split_line` function from `reflow_lines` to reimplement it in the future without using SCI_SPLITLINES to achieve the behaviour consistent with the "Line breaking" option.
This commit is contained in:
parent
57dca02303
commit
390646a412
@ -2099,6 +2099,20 @@ static gint get_reflow_column(GeanyEditor *editor)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Split the line where the cursor is positioned, on `column`,
|
||||||
|
possibly many times if the line is long.
|
||||||
|
Return the number of lines added because of the splitting. */
|
||||||
|
static gint split_line(GeanyEditor *editor, gint column)
|
||||||
|
{
|
||||||
|
gint linescount = sci_get_line_count(editor->sci);
|
||||||
|
sci_set_anchor(editor->sci, -1);
|
||||||
|
sci_target_from_selection(editor->sci);
|
||||||
|
sci_lines_split(editor->sci, column * sci_text_width(editor->sci, STYLE_DEFAULT, " "));
|
||||||
|
/* use lines count to determine how many lines appeared after splitting */
|
||||||
|
return sci_get_line_count(editor->sci) - linescount;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void reflow_lines(GeanyEditor *editor, gint column)
|
static void reflow_lines(GeanyEditor *editor, gint column)
|
||||||
{
|
{
|
||||||
gint start, indent, linescount, i;
|
gint start, indent, linescount, i;
|
||||||
@ -2133,12 +2147,7 @@ static void reflow_lines(GeanyEditor *editor, gint column)
|
|||||||
indent = sci_get_line_indentation(editor->sci, start);
|
indent = sci_get_line_indentation(editor->sci, start);
|
||||||
sci_set_line_indentation(editor->sci, start, 0);
|
sci_set_line_indentation(editor->sci, start, 0);
|
||||||
|
|
||||||
sci_target_from_selection(editor->sci);
|
linescount = split_line(editor, column - indent);
|
||||||
linescount = sci_get_line_count(editor->sci);
|
|
||||||
sci_lines_split(editor->sci,
|
|
||||||
(column - indent) * sci_text_width(editor->sci, STYLE_DEFAULT, " "));
|
|
||||||
/* use lines count to determine how many lines appeared after splitting */
|
|
||||||
linescount = sci_get_line_count(editor->sci) - linescount;
|
|
||||||
|
|
||||||
/* Fix indentation. */
|
/* Fix indentation. */
|
||||||
for (i = start; i <= start + linescount; i++)
|
for (i = start; i <= start + linescount; i++)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user