Forum > RichMemo

CopyToClipboard

(1/5) > >>

rick2691:
I am trying to use CopyToClipboard and PasteFromClipboard because they are the only way that I have found where text and formatting attributes can be transferred together. In particular I am wanting my Search and Replace functions to replace with both text and formatting.

What I have encountered is that CopyToClipboard can be hit, miss, and otherwise late on delivery. So I hear a horn warning, but the code keeps running without a proper execution.

Oddly, if I activate a showmessage('message'), just after CopyToClipboard, it performs correctly every time. But doing the same with sleep(1000), or at any value, it does not execute properly. So 'showmessage' is doing something different from 'sleep'.

Moreover, the hit and miss behavior is that the identical code in another 'begin ... end' section will have no problem at all. Yet if I use CopyToClipboard and PasteFromClipboard  in a 'replace every occurrence' routine it will miss all but the first instance.

However, the same routines with using PageMemo.SelText:=ReplaceBox.Lines.Text, instead of the clipboard functions is always faithful ... but I lose all of the formatting. Wherewith I have to do a CopyToClipboard as an independent function; then do a search; then activate an independent PasteFromClipboard again; in order to retain the formatting. Oddly, CopyToClipboard and PasteFromClipboard will always perform properly with that method.

So what's up with CopyToClipboard?

skalogryz:
is it Windows? or Gtk?
---
I've just committed CopyRichText() function under RichMemoUtils.
You might want to try to use, instead of clipboard operations.

It should copy the text formatting, BUT it will not copy paragraph formatting (and this is something yet to be done)

rick2691:
Thank you much! I will try to find it.

I am using Windows 10.

rick2691:

--- 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";}};} ---SearchBox.clear;  // RTF containerCopySum:= CopyRichText(PageMemo, // RTF container                                         PageMemo.SelStart,                                         PageMemo.SelLength,                                         SearchBox, // RTF container                                         SearchBox.SelStart,                                         SearchBox.SelLength,                                         []); 
The above is my implementation. It worked perfectly. Thank you much!!

I have a couple of questions:
How might I employ CopySum?
What options can I add to []?

skalogryz:

--- Quote from: rick2691 on September 04, 2021, 12:33:27 pm ---How might I employ CopySum?

--- End quote ---
what is CopySum?


--- Quote from: rick2691 on September 04, 2021, 12:33:27 pm ---What options can I add to []?

--- End quote ---
There's only one option available currently "coCopyBuf".
It forces the copy of the formatted text to be done via an intermediate buffer.

It is always used (even if not specified), if the source and destination of the copy is the same richmemo. Can be specified when the text is copied over from different richmemos.

Navigation

[0] Message Index

[#] Next page

Go to full version