Recent

Author Topic: line break on jEditText ? [solved]  (Read 839 times)

rafman

  • New Member
  • *
  • Posts: 10
line break on jEditText ? [solved]
« on: December 28, 2023, 06:36:28 pm »
Hello everyone, Keep up the good work, is there any way to control line break (CR LF or LF) on jEditText ?
I need to display plain text only.

I use LAMW 0.8.6.3 (lazarus 2.0.12)  on a Linux (Ubuntu Mate 22.04)

The following code works but the contents of .ini file are displayed as wrapping text not with the correct format (Text line breaks are ignored)
when i open it on an editor its contents are ok.
Code: Pascal  [Select][+][-]
  1. procedure TSettingsFrm.DialogYN1ClickYN(Sender: TObject; YN: TClickYN);
  2. var
  3.  FileBase:string;
  4. begin
  5.   if (YN = ClickYes) then
  6.    begin
  7.       FileBase:=GetInternalAppStoragePath;
  8.       EditText1.LoadFromFile(FileBase + PathDelim + 'settings.ini');
  9.    end
  10.    else
  11.     ShowMessage('Canceled');
  12.  
  13. end;  
  14.  
Thanks for any response.

[Edit]
Solved by reading the file as text file and add the linebreaks manually, it seems that the jEditText.LoadFromFile() method strips control characters and is not possible to handle it as jEditText.Text.

Code: Pascal  [Select][+][-]
  1. procedure TSettingsFrm.SettingsFrmShow(Sender: TObject);
  2. var
  3.  AssetsBase:string;
  4.  infile: TextFile;
  5.  ch: Char;
  6. begin
  7. AssetsBase:=GetInternalAppStoragePath;
  8. AssignFile(infile, AssetsBase + PathDelim + 'settings.ini');
  9. Reset(infile);
  10. EditText1.Text:='';
  11. While not Eof(infile) do
  12. begin
  13.   Read(infile, ch);
  14.   if (ch = #10) then EditText1.AppendLn('')  
  15.     else
  16.       EditText1.Append(ch);
  17. end;
  18. CloseFile(infile);
  19. end;
  20.  
« Last Edit: December 29, 2023, 01:43:42 pm by rafman »

 

TinyPortal © 2005-2018