Recent

Author Topic: How to clipboard-copy line-breaks?  (Read 1795 times)

Nicole

  • Hero Member
  • *****
  • Posts: 970
How to clipboard-copy line-breaks?
« on: January 31, 2023, 06:16:06 pm »
There is a line
Code: Pascal  [Select][+][-]
  1.  Clipboard.AsText :=RichMemo_Test.Lines.Text;

This copies the text of the TRichMemo into a string for the clipboard.
A "paste" gives back this string, fine.
- But all line-breaks are gone.

What do I have to change to keep the line-breaks?

Curt Carpenter

  • Sr. Member
  • ****
  • Posts: 402
Re: How to clipboard-copy line-breaks?
« Reply #1 on: February 01, 2023, 08:30:40 pm »
In a similar context, I finally ended up replacing all of the line breaks received from richmemo with "%%" before saving the text in a string list, then replacing the "%%" pairs with line breaks on retrieving the text from the string list.  This may be the same thing you're encountering with the clipboard.

I don't think, though, that the line breaks are rendered at all by richmemo under linux.  It seems to be something peculiar to the Windows richmemo component.  Not sure about that though. 
« Last Edit: February 01, 2023, 08:32:41 pm by Curt Carpenter »

Nicole

  • Hero Member
  • *****
  • Posts: 970
Re: How to clipboard-copy line-breaks?
« Reply #2 on: February 01, 2023, 08:36:11 pm »
Thank you, this may be.

Linebreaks under Linux and Windows bother me since I had my first website and used ftp. Today this is corrected by the client. That time is was tricky not to break a perl-source.

Do you think, another type would be better - or are all the same?
RichMemo and TStringList - do they have the same root?
And TStrings?

Or I use this #10#13 thing. Which is ugly, because Linux would not take it, would it?

rvk

  • Hero Member
  • *****
  • Posts: 6162
Re: How to clipboard-copy line-breaks?
« Reply #3 on: February 01, 2023, 09:31:59 pm »
This copies the text of the TRichMemo into a string for the clipboard.
A "paste" gives back this string, fine.
- But all line-breaks are gone.
I'm not sure what you are doing but for me pasting back gives multiple lines again.

Are you under Windows or Linux?
(always mention OS and Laz versions)

It's already mentioned that the TRichMemo.Lines.Text does something strange with #13#10 on Linux.
https://forum.lazarus.freepascal.org/index.php/topic,60956.msg457944.html#msg457944

Somehow TRichMemo uses only #13 when putting together a TStringList for exporting.
And it should be #13#10 for TStringList.

Also note that the TRichEdit on Delphi always uses #13#10 (which is standard for both TRichEdit and TStringList).

I consider this a real bug in TRichMemo because it doesn't comform to TStringList standard.

Curt Carpenter

  • Sr. Member
  • ****
  • Posts: 402
Re: How to clipboard-copy line-breaks?
« Reply #4 on: February 01, 2023, 10:35:18 pm »
I don't know Nicole.  I just had to experiment until I found something that worked, noting that the solution was different for me depending on if the OS was Linux or Windows.  It was very confusing, compounded by my uncertainties about how the debugger was displaying line breaks.  I found something that worked and ran away  :)



 

TinyPortal © 2005-2018