Recent

Author Topic: SynEdit auto End of line in text add  (Read 169 times)

eldonfsr

  • Hero Member
  • *****
  • Posts: 593
SynEdit auto End of line in text add
« on: May 10, 2026, 02:52:46 am »
Hi using synedit i have the problem when do something like this
 MSyn.Text := MSyn.Text + s;
auto add end of line
modem still sending all text show on 100 lines...
 
Code: Pascal  [Select][+][-]
  1. procedure TFormMain.AppendToTerminal(const s: string);
  2. begin
  3.   if( Not AppendHidenTerm(s)) then begin
  4.     MTerminal.Lines.BeginUpdate();
  5.     MTerminal.Text := MTerminal.Text + s; // this auto add  endline and start a new line
  6.   end;
  7.   if MTerminal.Lines.Count > 1200 then
  8.   begin
  9.     while MTerminal.Lines.Count > 1000 do
  10.       MTerminal.Lines.Delete(0);
  11.   end;
  12.   MTerminal.SelStart := MaxInt;
  13.   MTerminal.Lines.EndUpdate();
  14.   MTerminal.ScrollBy(0, -100000);
  15. end;
  16.  
  17.  
  18.  

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12430
  • Debugger - SynEdit - and more
    • wiki
Re: SynEdit auto End of line in text add
« Reply #1 on: May 10, 2026, 09:08:36 am »
There is no setting for that.

SynEdit currently does not store line endings. It stores each line as a string in a list. The line ending is implicitly assumed.
When you retrieve the "text" then it adds the line endings after each line, including the last line.

So SynEdit.Text in your code always ends with a line ending.


You can add text to the last line:
Code: Pascal  [Select][+][-]
  1. SynEdit.Lines[Max(0, SynEdit.Lines.Count-1)] := SynEdit.Lines[Max(0, SynEdit.Lines.Count-1)] + newtext;

This is on the list of "maybe one day it will be added/changed". But that someday may still be rather far away.



Note that using SynEdit.Text or SynEdit.Lines is only recommended for read-only text.

Changing text this way will reset SynEdits undo buffer. So if the user can also edit the text, then the user looses the ability to undo.
If undo is needed then there is SynEdit.TextBetweenPoints

eldonfsr

  • Hero Member
  • *****
  • Posts: 593
Re: SynEdit auto End of line in text add
« Reply #2 on: May 13, 2026, 05:02:39 pm »
Thanks for you help i change the to MTerminal.InsertTextAtCaret(s) and is working fine

Thanks so much

 

TinyPortal © 2005-2018