Forum > RichMemo

How to clipboard-copy line-breaks?


There is a line

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- 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:
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. 

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?


--- Quote from: Nicole on January 31, 2023, 06:16:06 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.

--- End quote ---
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.,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:
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  :)


[0] Message Index

Go to full version