Recent

Author Topic: Does anyone know how to put bullets in a RichMemo?  (Read 1102 times)

ReinaldoDuvida

  • Newbie
  • Posts: 6
Does anyone know how to put bullets in a RichMemo?
« on: April 11, 2024, 04:39:11 pm »
I'm studying RichMemo and I don't know how to add a bullet

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Does anyone know how to put bullets in a RichMemo?
« Reply #1 on: April 11, 2024, 05:01:24 pm »
I'm studying RichMemo and I don't know how to add a bullet
I am pretty sure that such exists but without read docs I can not answer, since you study it you will find it out soon and can let us know :D
While you are learning it you can play with this simple method that adds a "bullet" infront of text:
Code: Pascal  [Select][+][-]
  1. procedure AddLineWithBullet(var ARichMemo: TRichMemo; const AText: string);
  2. begin
  3.   ARichMemo.SelText := '• ' + AText + sLineBreak;
  4.   ARichMemo.SelLength := 0;
  5. end;
Of course you can add a million of other things for the layout.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

Thaddy

  • Hero Member
  • *****
  • Posts: 16194
  • Censorship about opinions does not belong here.
Re: Does anyone know how to put bullets in a RichMemo?
« Reply #2 on: April 12, 2024, 10:35:49 am »
there is comprehensive documentation for richmemo in the wiki.
what you need is https://wiki.freepascal.org/RichMemo#SetParaNumbering
If I smell bad code it usually is bad code and that includes my own code.

ReinaldoDuvida

  • Newbie
  • Posts: 6
Re: Does anyone know how to put bullets in a RichMemo?
« Reply #3 on: April 15, 2024, 03:39:21 pm »
Good morning, I've advanced a little on how to put a marker in a RichMemo.
I used the procedure SetParaNumbering(TextStart, TextLen: Integer; const ANumber: TParaNumbering); virtual;
In Text Start I passed RichMemo1.SelStart and in TextLen I passed RichMemo1.SelLength. Now the magic begins, it is in the third parameter that the programmer chooses which marker to use.


Procedure documentation:
https://wiki.freepascal.org/RichMemo#SetParaNumbering
Code: Pascal  [Select][+][-]
  1.  
  2. TParaNumStyle   = (pnNone, pnBullet, pnNumber, pnLowLetter
  3.     , pnLowRoman, pnUpLetter, pnUpRoman, pnCustomChar);
  4.  
  5.   TParaNumbering  = record
  6.     Style       : TParaNumStyle;
  7.     Indent      : Double;
  8.     CustomChar  : WideChar;
  9.     NumberStart : Integer;  // used for pnNumber only
  10.     SepChar     : WideChar;
  11.     ForceNewNum : Boolean;  // if true and Style is pnNumber, NumberStart is used for the new numbering
  12.   end;
  13.  
  14. const
  15.   SepNone = #0;
  16.   SepPar  = ')';
  17.   SepDot  = '.';  
  18.  

Placing a Bullet:
Code: Pascal  [Select][+][-]
  1. var
  2.   styleHighlighter : TParaNumbering;
  3. begin
  4.   with styleHighlighter do
  5.   begin
  6.     Style := pnBullet;
  7.     Indent := 4;
  8.   end;
  9.  
  10.   with RichMemo1 do
  11.   begin
  12.     SetParaNumbering(SelStart, SelLength, styleHighlighter);
  13.   end;  
  14.  

Colocando números como marcador:
Code: Pascal  [Select][+][-]
  1. var
  2.   styleHighlighter : TParaNumbering;
  3. begin
  4.   with styleHighlighter do
  5.   begin
  6.     Style := pnNumber;
  7.     Indent := 4;
  8.     NumberStart := 1;
  9.     SepChar     := SepDot;
  10.     ForceNewNum := True;
  11.     InitParaNumber(styleHighlighter, SepDot, 1);
  12.   end;
  13.  
  14.   with RichMemo1 do
  15.   begin
  16.     SetParaNumbering(SelStart, SelLength, styleHighlighter);
  17.   end;    
  18.  


When placing numbers as markers, the programmer can change the SepChar. Remember to execute the InitParaNumber procedure to start the order of numbers.
I hope it helped.

paule32

  • Sr. Member
  • ****
  • Posts: 280
Re: Does anyone know how to put bullets in a RichMemo?
« Reply #4 on: April 15, 2024, 06:07:15 pm »
you can take a look to my github.com repro:
https://github.com/paule32/HelpNDoc_EditTool

especially:
https://github.com/paule32/HelpNDoc_EditTool/blob/main/src/Unit1.pas

Hope this helps, and good luck !

 

TinyPortal © 2005-2018