Remove "nearest" checkpoint

General TRichView support forum. Please post your questions here
Post Reply
Rael Bauer
Posts: 34
Joined: Tue Aug 21, 2007 4:47 am

Remove "nearest" checkpoint

Post by Rael Bauer » Sun Oct 14, 2018 2:17 pm

Hi,

I want to remove the "nearest" checkpoint - meaning the nearest checkpoint going "backwards", but not beyond the current paragraph.

Code: Select all

function TForm1.CheckPointNumber(rve: TCustomRichViewEdit): Integer;
var
  i: Integer;
begin
  Result := -1;
  rve := rve.TopLevelEditor;
  i := rve.CurItemNo;

  while not rve.IsParaStart(i) do
  begin
    if rve.RVData.GetItemCheckpoint(i) <> nil then
    begin
      Result := i;
      exit;
    end;
    dec(i);
  end;

  if rve.RVData.GetItemCheckpoint(i) <> nil then
    Result := i;
end;

Code: Select all

procedure TForm1.miRemoveCheckpointClick(Sender: TObject);
begin
  if Self.CheckPointNumber(rve) > -1 then
  begin
    rve.RemoveCheckpointEd(CheckPointNumber(rve));
    //rve.Invalidate;
  end;
end;
This works for me in a normal document, but does not handle Table cells. How can I also handle table cells with the same logic?

Thanks

Sergey Tkachenko
Site Admin
Posts: 14163
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Remove "nearest" checkpoint

Post by Sergey Tkachenko » Mon Oct 15, 2018 11:46 am

Simply apply this code to TopLevelEditor:

Code: Select all

procedure TForm1.miRemoveCheckpointClick(Sender: TObject);
var
  Editor: TCustomRichViewEdit;
  CPNumber: Integer;
begin
  Editor := rve.TopLevelEditor;
  CPNumber := CheckPointNumber(Editor);
  if CPNumber >= 0 then
    Editor.RemoveCheckpointEd(CPNumber);
end;

Post Reply