Page 2 of 2

Re: [Example] DeleteBlankLines, RemoveParagraphBreaks, etc.

Posted: Tue Jun 20, 2017 7:00 pm
by Sergey Tkachenko
Use CanUpdate:

Code: Select all

  SRichViewEdit1.CanUpdate := False;
  DeleteBlankLines(SRichViewEdit1.ActiveEditor.RVData);
  SRichViewEdit1.ActiveEditor.ClearUndo;
  SRichViewEdit1.Format;
  SRichViewEdit1.CanUpdate := True;

Re: [Example] DeleteBlankLines, RemoveParagraphBreaks, etc.

Posted: Tue Jun 20, 2017 7:52 pm
by filo
Solved, thank you!

Re: [Example] DeleteBlankLines, RemoveParagraphBreaks, etc.

Posted: Tue Apr 20, 2021 12:19 pm
by jonjon
Hi Sergey,
Could you please provide a fix for "Paragraph breaks -> line breaks" which converts the line before the first selected text?
See attached screenshot, when you select from test2 to test5, it will also convert the paragraph break before test2 when it shouldn't.
See attached sample project to quickly reproduce this problem.
Thank you.

Re: [Example] DeleteBlankLines, RemoveParagraphBreaks, etc.

Posted: Tue Apr 20, 2021 5:10 pm
by Sergey Tkachenko

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
  
  // ADDED
  
  else 
   inc(ItemNo1); 
  
  // END ADDED
  
  
  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;

Re: [Example] DeleteBlankLines, RemoveParagraphBreaks, etc.

Posted: Wed Apr 21, 2021 10:21 am
by jonjon
Thank you Sergey but it looks like this fix is incomplete: if only part of the first line is selected (e.g. instead of selecting "test2" you only select "st2") then the line before that one is converted when it shouldn't.

Re: [Example] DeleteBlankLines, RemoveParagraphBreaks, etc.

Posted: Wed Apr 21, 2021 8:19 pm
by Sergey Tkachenko
I modified the code in my previous reply to fix it.

Re: [Example] DeleteBlankLines, RemoveParagraphBreaks, etc.

Posted: Thu Apr 22, 2021 9:44 am
by jonjon
Great. Thanks.