Page 1 of 1

copy text from the cursor

Posted: Thu Jan 07, 2021 1:14 am
by tiagosis
how to do to select all the text from the point of the strokes down?

Re: copy text from the cursor

Posted: Fri Jan 08, 2021 12:46 pm
by tiagosis
hello, I insist, how can I do to copy the text programmatically from the point where the cursor is located by copying all the text below the cursor?

Re: copy text from the cursor

Posted: Fri Jan 08, 2021 3:55 pm
by Sergey Tkachenko
Sorry for the delay.
And sorry, I do not understand your question.

Do you want to copy to the Clipboard all text from the blinking caret position and to the end of the document?
Or may be you want to copy a word below the pointer?
Or something else?

Re: copy text from the cursor

Posted: Fri Jan 08, 2021 7:01 pm
by tiagosis
exactly, i need to copy all the text from the blinking cursor down. example:
AAAAAAAAAA
BBBBBBBBBB
CCCCCCCCC
DDDDDDDDD
FFFFFFFFFFF
GGGGGGGG

suppose user placed the cursor at the beginning of "ACPC" I need to copy to a secondary TSrichView from "CCC ..." to "GGGG ..."

or if there are more pages after "GGGG" to copy as well.

thanks

Re: copy text from the cursor

Posted: Fri Jan 08, 2021 7:17 pm
by Sergey Tkachenko
I suggest to select the fragment that you need to copy temporarily, then restore the original selection.
To prevent flickering, do it in BeginUpdate/EndUpdate.

Let we have rve: TRichViewEdit.

Code: Select all

uses
  RVLinear;

var
  SelStart, SelLength: Integer;

RVGetSelection(rve, SelStart, SelLength);
rve.BeginUpdate;
rve.SetSelectionBounds(rve.CurItemNo, rve.OffsetInCurItem, rve.ItemCount-1, rve.GetOffsAfterItem(rve.ItemCount-1));
rve.CopyDef;
RVSetSelection(rve, SelStart, SelLength);
rve.EndUpdate;

Re: copy text from the cursor

Posted: Fri Jan 08, 2021 7:23 pm
by Sergey Tkachenko
If you need to copy not to the clipboard but to another editor rve2:

Code: Select all

uses
  RVLinear;

var
  SelStart, SelLength: Integer;
  Stream: TMemoryStream;

Stream := TMemoryStream.Create;
RVGetSelection(rve, SelStart, SelLength);
rve.BeginUpdate;
rve.SetSelectionBounds(rve.CurItemNo, rve.OffsetInCurItem, rve.ItemCount-1, rve.GetOffsAfterItem(rve.ItemCount-1));
rve.SaveRVFToStream(Stream, False);
RVSetSelection(rve, SelStart, SelLength);
rve.EndUpdate;
Stream.Position := 0;
rve2.LoadRVFFromStream(Stream);
rve2.Format;
Stream.Free;
The same code for ScaleRichView, copying from srv to srv2:

Code: Select all

uses
  RVLinear;

var
  SelStart, SelLength: Integer;
  Stream: TMemoryStream;

Stream := TMemoryStream.Create;
RVGetSelection(srv.RichViewEdit, SelStart, SelLength);
srv.CanUpdate := False;
with srv.RichViewEdit do
  SetSelectionBounds(CurItemNo, OffsetInCurItem, ItemCount-1, GetOffsAfterItem(ItemCount-1));
srv.RichViewEdit.SaveRVFToStream(Stream, False);
RVSetSelection(srv.RichViewEdit, SelStart, SelLength);
srv.CanUpdate := True;
Stream.Position := 0;
srv2.RichViewEdit.LoadRVFFromStream(Stream);
srv2.Format;
Stream.Free;

Re: copy text from the cursor

Posted: Fri Jan 08, 2021 8:08 pm
by tiagosis
please friend, I insist that you read and see the examples I gave you, I need to copy only where the cursor is flashing on the screen until the end and not the entire text, I think the translation is getting bad because I don't think it you haven't understood.

"your code copies the entire text from and not just that of the blinking cursor down."

Re: copy text from the cursor

Posted: Fri Jan 08, 2021 8:12 pm
by tiagosis
in my example the cursor is positioned blinking at the beginning of the line "CCCCCCCCC"

I need a code that copies from the cursor line to the end. in this case the copy would be:
"CCCCCCCCC
DDDDDDDDD
FFFFFFFFFFF
GGGGGGGG "

Re: copy text from the cursor

Posted: Fri Jan 08, 2021 8:31 pm
by tiagosis
the first code worked well, the others were not successful, in any case it was resolved, thanks.

Re: copy text from the cursor

Posted: Sat Jan 09, 2021 8:27 pm
by Sergey Tkachenko
All code fragments in this topic select and copy text starting from the blinking caret and to the end of the document, as you asked.

If you have problems with the code I posted, please let me know what's wrong exactly.