Numbered lists and TAB key

General TRichView support forum. Please post your questions here
Post Reply
DmitriPopov
Posts: 29
Joined: Tue Dec 15, 2009 10:01 am

Numbered lists and TAB key

Post by DmitriPopov »

Hello!

I need to make TRichViewEdit to act like MS Word when user wants to change current list item level with TAB key.
Example.
Let's say a user has activated numbered list input. At first "1. " appears. He enters some text for this item:
1. First item
and presses "Enter". Then the "2." appears like this:
1. First item
2.
and now user presses TAB key and "2." turns to "a." with item level changed to one level deeper, like this:
1. First item
a. Second item.

By default RVE inserts just tab in the place of caret. Is it possible to implement needed behavior?
Sergey Tkachenko
Site Admin
Posts: 17554
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I modified a "smart indent" code to support numbered paragraphs:
http://www.trichview.com/forums/viewtop ... =8065#8065

Specifically, the following code changes a list level:

Code: Select all

  rve := rve.TopLevelEditor; 
    if rve.SelectionExists then 
      exit; 
    if (Step>0) and (rve.OffsetInCurItem<=rve.GetOffsBeforeItem(rve.CurItemNo)) and 
       (rve.CurItemNo>0) and (rve.GetItemStyle(rve.CurItemNo-1)=rvsListMarker) then begin 
       // changing list level 
       rve.GetListMarkerInfo(rve.CurItemNo, ListNo, ListLevel, StartFrom, Reset); 
       if (ListNo>=0) and (ListNo<rve.Style.ListStyles.Count) and 
          (ListLevel+1<rve.Style.ListStyles[ListNo].Levels.Count) then begin 
         rve.ChangeListLevels(+1); 
         Result := True; 
       end; 
       exit; 
    end; 
DmitriPopov
Posts: 29
Joined: Tue Dec 15, 2009 10:01 am

Post by DmitriPopov »

OK, thank you!
Post Reply