Recent

Author Topic: TSynEdit: linefeeds and Linebreaks  (Read 474 times)

Aruna

  • Sr. Member
  • ****
  • Posts: 458
TSynEdit: linefeeds and Linebreaks
« on: September 14, 2024, 04:44:06 pm »
I have a string:
Code: Pascal  [Select][+][-]
  1.  metaData:='{'+  #13#10+ ' *******'+ #13#10+ '* Project: <Project Name>'+ #13#10;  

Which I plug into
Code: Pascal  [Select][+][-]
  1. SynEdit1.Lines.Add(metaData);
It does not split the string at  my line endings. I have tried 'LineEndings' and #13#10 with no success. How do I fix this please?

EDIT: Screenshot attached
« Last Edit: September 14, 2024, 04:59:14 pm by Aruna »
Debian GNU/Linux 11 (bullseye)
https://pascal.chat/

Aruna

  • Sr. Member
  • ****
  • Posts: 458
Re: TSynEdit: linefeeds and Linebreaks
« Reply #1 on: September 14, 2024, 05:28:37 pm »
Found what I was doing wrong. This works:

Code: Pascal  [Select][+][-]
  1. SynEdit1.Lines.Text:=metaData;
Debian GNU/Linux 11 (bullseye)
https://pascal.chat/

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10309
  • Debugger - SynEdit - and more
    • wiki
Re: TSynEdit: linefeeds and Linebreaks
« Reply #2 on: September 14, 2024, 08:33:23 pm »
Well, yes: That.

But, if you want to add (or remove/change) to/from existing text, then you should use SynEdit.TextBetweenPoints or SynEdit.SetTextBetweenPoints. That will work with undo/redo and adjusting caret and existing selection. (And it should deal with linebreaks too)

Aruna

  • Sr. Member
  • ****
  • Posts: 458
Re: TSynEdit: linefeeds and Linebreaks
« Reply #3 on: September 14, 2024, 08:38:57 pm »
Well, yes: That.

But, if you want to add (or remove/change) to/from existing text, then you should use SynEdit.TextBetweenPoints or SynEdit.SetTextBetweenPoints. That will work with undo/redo and adjusting caret and existing selection. (And it should deal with linebreaks too)
Hi Martin, thank you I am just starting with SynEdit so have no clue am working blind and flying by night. If you have a moment please take a look at the attached screenshot and tell me if I am going down the right  path? Or I need to stop and re-think this?

« Last Edit: September 14, 2024, 08:47:23 pm by Aruna »
Debian GNU/Linux 11 (bullseye)
https://pascal.chat/

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10309
  • Debugger - SynEdit - and more
    • wiki
Re: TSynEdit: linefeeds and Linebreaks
« Reply #4 on: September 14, 2024, 09:05:50 pm »
You do want to start here https://wiki.freepascal.org/SynEdit
Otherwise the image is not much related on how to access SynEdit.

But as for ideas for the "class designer" (I guess you want to talk about that?):

The amount of options that you will actually need is going to grow.
So you may want
- a radiogroup: Field, Method, Property   (event is just a property)
- and then reuse fields like name
- and hide/show options like virtual or default as needed.


Just some examples:
Code: Pascal  [Select][+][-]
  1. property Foo: Integer read FFoo write FFoo; // field
  2. property Foo: Integer read GetFoo write SetFoo; // method
  3. property Foo: Integer read FFoo write SetFoo; // mixed
  4. property Foo[Bar: Boolean]: Integer read GeFoo write SetFoo; // indexed
  5. property Foo[Bar: Boolean]: Integer read GeFoo write SetFoo; default; // indexed default
  6. property Foo: Integer read FFoo write SetFoo default 5; // default val
  7. property Foo: Integer read FFoo write SetFoo stored GetStored;
  8. property Foo: Integer index 5 read GetFoo write SetFoo stored GetStored;  // indexed getter/setter
  9.  
  10. procedure Bar; inline;
  11. procedure Bar; reintroduce; virtual; abstract; overload;  stdcall;
  12. ...
  13.  


Aruna

  • Sr. Member
  • ****
  • Posts: 458
Re: TSynEdit: linefeeds and Linebreaks
« Reply #5 on: September 15, 2024, 02:20:09 am »
You do want to start here https://wiki.freepascal.org/SynEdit
Thank you for the link..

But as for ideas for the "class designer" (I guess you want to talk about that?):
Yes please.

Code: [Select]
property Foo: Integer index 5 read GetFoo write SetFoo stored GetStored;  // indexed getter/setter
<snip>
procedure Bar; reintroduce; virtual; abstract; overload;  stdcall;
...

Thank you very much. This helps me a lot.

@Martin_fr, In the attached screenshot in the IDE source editor the compiler directive displays as red text: {$mode objfpc}{$H+}
In the running app window using SynHighlighterPas it renders as black: {$mode objfpc}{$H+}

If I would like to change this to red how do I go about doing so please?

EDIT: I did go through synhighlighterpas.pp still trying to wrap my head around it.
« Last Edit: September 15, 2024, 02:52:11 am by Aruna »
Debian GNU/Linux 11 (bullseye)
https://pascal.chat/

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10309
  • Debugger - SynEdit - and more
    • wiki
Re: TSynEdit: linefeeds and Linebreaks
« Reply #6 on: September 15, 2024, 09:19:03 am »
@Martin_fr, In the attached screenshot in the IDE source editor the compiler directive displays as red text: {$mode objfpc}{$H+}
In the running app window using SynHighlighterPas it renders as black: {$mode objfpc}{$H+}

If I would like to change this to red how do I go about doing so please?

EDIT: I did go through synhighlighterpas.pp still trying to wrap my head around it.

property DirectiveAttri in the Object inspector.

The synedit page is linked should have a link to a syn highlighter tutorial, which explains how the highlighter works.

Aruna

  • Sr. Member
  • ****
  • Posts: 458
Re: TSynEdit: linefeeds and Linebreaks
« Reply #7 on: September 15, 2024, 01:55:30 pm »
@Martin_fr, In the attached screenshot in the IDE source editor the compiler directive displays as red text: {$mode objfpc}{$H+}
In the running app window using SynHighlighterPas it renders as black: {$mode objfpc}{$H+}

If I would like to change this to red how do I go about doing so please?

EDIT: I did go through synhighlighterpas.pp still trying to wrap my head around it.

property DirectiveAttri in the Object inspector.

The synedit page is linked should have a link to a syn highlighter tutorial, which explains how the highlighter works.
Thank you.
Debian GNU/Linux 11 (bullseye)
https://pascal.chat/

 

TinyPortal © 2005-2018