RVGetSelection returns a different length if after a bullet

General TRichView support forum. Please post your questions here
Post Reply
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

RVGetSelection returns a different length if after a bullet

Post by jgkoehn »

Greetings
I am using RVGetSelection(RichViewEdit, StartInt, LenInt, 2)
I select after the bullet for example:
  • 20:1-10 test
No bullet:
20:1-10 test

The first with a bullet on LenInt returns 13
The second with NO bullet on LenInt returns 12

Perhaps this is intentional but the bullet is not being selected. Any ideas what is going on or how to make it with and without a bullet have the same length?
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: RVGetSelection returns a different length if after a bullet

Post by jgkoehn »

Nevermind, it is something else in my code. I am digging more.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: RVGetSelection returns a different length if after a bullet

Post by jgkoehn »

Any ideas why moving the selection to stream then working with it in another RichViewEdit would change the length? (Specifically connected to bullet that hasn't been selected.)

ms := TMemoryStream.Create;
RVE.SaveRVFToStream(ms,True);
ms.Position := 0;
//Now switch to TempRVE
TempRVE.LoadRVFFromStream(ms);
TempRVE.Format;
ms.Clear;
GRichViewEdit := TempRVE;
GRichViewEdit.Style := TempRVE.Style; //Use incoming style
GCRVE := TempRVE.TopLevelEditor;
GCRVE.SelectAll;
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: RVGetSelection returns a different length if after a bullet

Post by Sergey Tkachenko »

Sorry, it changes the length of what?
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: RVGetSelection returns a different length if after a bullet

Post by jgkoehn »

Greetings Sergey,
Sorry let me combine my posts and make it clearer.

Code: Select all

GCRVE := RichViewEdit.TopLevelEditor;
//A user selects a portion of text right after a bullet point.
 RVGetSelection(GCRVE,  LinearStarPos, LinearLen, 2);//Get the Selection in linear instead of Bounds.

If VariableTrue then 
   begin
   ms := TMemoryStream.Create;
   RichViewEdit.SaveRVFToStream(ms,True);
   ms.Position := 0;
   //Now switch to TempRVE
   TempRVE.LoadRVFFromStream(ms);
   TempRVE.Format;
  ms.Clear;
  GRichViewEdit := TempRVE;
  GRichViewEdit.Style := TempRVE.Style; //Use incoming style
  GCRVE := TempRVE.TopLevelEditor;
  GCRVE.SelectAll;
  //It seems like if I do (This function instead of SelectAll it works better)
  //RVSetSelection(GCRVE,  0, Abs(LinearLen), 2);
end;

RVGetSelection(GCRVE, StartInt, LenInt, 2);
If VariableTrue it uses a method to copy to a tempRichViewEdit and then to another for various reasons.
However, that process causes LenInt in RVGetSelection to be +1 in Length for example 13. If I turn VariableTrue = False and ignore this section then RVGetSelection LenInt = 12 it does not have the +1.
(I know it shifts between about 4 different RichViewEdits. There are odd reasons for that I probably could change that but ignoring that for now.)
I am thinking that the bullet point is partially getting copied somehow?
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Re: RVGetSelection returns a different length if after a bullet

Post by standay »

Sergey will know but my guess is if you are creating an rve, it gets created with one item in it. I think. If so, all you might have to do is clear it before putting data into it. I.e.,: TempRVE.Clear;

This is just a guess!

Stan
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: RVGetSelection returns a different length if after a bullet

Post by jgkoehn »

A good guess Stan, I did try that but oddly enough it is only connected to when there is a bullet point. If there is none it is fine.
Post Reply