Line breaks -> paragraph breaks
Converting all line breaks (added with Shift+Enter) to paragraph breaks (added with Enter).
Undoable. If selection is not empty, the procedure is applied to the selection. Otherwise, it is applied to the whole document (if the caret is in a table cell, it is applied to the whole cell).
This procedure is not applied to selected table cells.
Code: Select all
procedure NormalizeLineBreaksEd(rve: TCustomRichViewEdit);
var ItemNo1, Offs1, ItemNo2, Offs2: Integer;
Whole, FR: Boolean;
i: Integer;
begin
rve := rve.TopLevelEditor;
if not rve.BeforeChange(False) then
exit;
rve.GetSelectionBounds(ItemNo1, Offs1, ItemNo2, Offs2, True);
Whole := (ItemNo1<0) or ((ItemNo1=ItemNo2) and (Offs1=Offs2));
if Whole then begin
ItemNo1 := 0;
ItemNo2 := rve.ItemCount-1;
end;
rve.BeginUndoGroup(rvutPara);
rve.SetUndoGroupMode(True);
for i := ItemNo2 downto ItemNo1 do
if rve.IsFromNewLine(i) then
TRVEditRVData(rve.RVData).Do_BR(i, False, FR);
rve.SetUndoGroupMode(False);
rve.Change;
rve.Reformat;
end;
Paragraph breaks -> line breaks
The opposite procedure.
Code: Select all
procedure MakeSoftLineBreaksEd(rve: TCustomRichViewEdit);
var ItemNo1, Offs1, ItemNo2, Offs2: Integer;
Whole, FR: Boolean;
i: Integer;
begin
rve := rve.TopLevelEditor;
if not rve.BeforeChange(False) then
exit;
rve.GetSelectionBounds(ItemNo1, Offs1, ItemNo2, Offs2, True);
Whole := (ItemNo1<0) or ((ItemNo1=ItemNo2) and (Offs1=Offs2));
if Whole then begin
ItemNo1 := 0;
ItemNo2 := rve.ItemCount-1;
end;
rve.BeginUndoGroup(rvutPara);
rve.SetUndoGroupMode(True);
if ItemNo1<1 then
ItemNo1 := 1;
for i := ItemNo2 downto ItemNo1 do
if rve.IsParaStart(i) and (rve.GetItemStyle(i)<>rvsListMarker) and
not rve.GetItem(i-1).GetBoolValue(rvbpFullWidth) then
TRVEditRVData(rve.RVData).Do_BR(i, True, FR);
rve.SetUndoGroupMode(False);
rve.Change;
rve.Reformat;
end;
Unfortunately, TRichViewEdit does not have documented methods for converting line breaks, so these procedures use undocumented methods.