copy text from the cursor

General TRichView support forum. Please post your questions here
Post Reply
tiagosis
Posts: 41
Joined: Thu Apr 13, 2017 5:34 pm

copy text from the cursor

Post by tiagosis »

how to do to select all the text from the point of the strokes down?
tiagosis
Posts: 41
Joined: Thu Apr 13, 2017 5:34 pm

Re: copy text from the cursor

Post 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?
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: copy text from the cursor

Post 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?
tiagosis
Posts: 41
Joined: Thu Apr 13, 2017 5:34 pm

Re: copy text from the cursor

Post 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
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: copy text from the cursor

Post 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;
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: copy text from the cursor

Post 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;
tiagosis
Posts: 41
Joined: Thu Apr 13, 2017 5:34 pm

Re: copy text from the cursor

Post 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."
tiagosis
Posts: 41
Joined: Thu Apr 13, 2017 5:34 pm

Re: copy text from the cursor

Post 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 "
tiagosis
Posts: 41
Joined: Thu Apr 13, 2017 5:34 pm

Re: copy text from the cursor

Post by tiagosis »

the first code worked well, the others were not successful, in any case it was resolved, thanks.
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: copy text from the cursor

Post 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.
Post Reply