Ident Bullet and Numbering

General TRichView support forum. Please post your questions here
Post Reply
AutoCorect
Posts: 84
Joined: Sun Dec 16, 2007 7:15 pm

Ident Bullet and Numbering

Post by AutoCorect »

Hi,
I try to ident Bullet and Numbering, I see it's not posible direct with TSclRVRuler.

I set TSclRVRuler at OnRulerItemRelease event to do this:

Code: Select all

procedure TfrmMainChild.SclRVRuler1RulerItemRelease(Sender: TObject);
begin
if srvEditor.RichViewEdit.GetItemStyle(ItemCurr-1) = rvsListMarker then begin
   if srvEditor.RichViewEdit.Style.ListStyles[ItemCurr-1].Levels.Count>=0 then begin
      srvEditor.RichViewEdit.Style.ListStyles[ItemCurr-1].Levels[0].MarkerIndent:=Trunc(SclRVRuler1.FirstIndent) ;
      srvEditor.RichViewEdit.GetRootEditor.Reformat ;
   end ;
end ;
end ;
I set ItemCurr in the TSRichEviewEdit.OnCaretMove event to get the curent Item (where it's carret)

Code: Select all

procedure TfrmMainChild.srvEditorCaretMove(Sender: TObject);
begin
ItemCurr:=srvEditor.RichViewEdit.GetItemNo(srvEditor.RichViewEdit.GetCurrentItem) ;
end;
Code work ok if I put the bullet at the first line, end the next, but if at the first line a put the text the application give error "List Index Out of Bounds"

Have you some solutions for this problem.

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

Post by Sergey Tkachenko »

Sorry for delay, I'll answer this question tomorrow.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Your code has several problems, the most important - you use incorrect value as an index of ListStyles.
The correct code is:

Code: Select all

procedure TForm3.SclRVRuler1RulerItemRelease(Sender: TObject);
var ItemNo, ListNo, LevelNo, StartFrom: Integer;
    UseStartFrom: Boolean;
    rve: TCustomRichViewEdit;
begin
  rve := SRichViewEdit1.RichViewEdit.TopLevelEditor;
  ItemNo := rve.CurItemNo;
  while not rve.IsParaStart(ItemNo) do
    dec(ItemNo);
  if rve.GetItemStyle(ItemNo) = rvsListMarker then begin
    rve.GetListMarkerInfo(ItemNo, ListNo, LevelNo, StartFrom, UseStartFrom);
   if (ListNo>=0) and (LevelNo>=0) then begin
      rve.Style.ListStyles[ListNo].Levels[LevelNo].MarkerIndent := Trunc(SclRVRuler1.FirstIndent) ;
      SRichViewEdit1.RichViewEdit.Reformat ;
   end;
  end;
end;
Note: this operation cannot be undone by undo command, but it does not do harm to undo buffer, so it is ok.
AutoCorect
Posts: 84
Joined: Sun Dec 16, 2007 7:15 pm

Post by AutoCorect »

Tanks, work ok.

Question :

Code: Select all

var
rve: TCustomRichViewEdit; 
begin
rve := SRichViewEdit1.RichViewEdit.TopLevelEditor;
  ItemNo := rve.CurItemNo; 
If I assing my SRichViewEdit1 to rve the memory incres with a new document ?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

No, rve becomes a pointer to the object, nothing is copied.
I added this variable only because writing "rve" in the subsequent code is shorter than "SRichViewEdit1.RichViewEdit.TopLevelEditor".
Post Reply