EControl Ltd. Forum Index EControl Ltd.
VCL libraries and software support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Line number /user range confusion

 
Post new topic   Reply to topic    EControl Ltd. Forum Index -> EControl Syntax Editor
View previous topic :: View next topic  
Author Message
itsatomic



Joined: 12 Jun 2006
Posts: 38

PostPosted: Mon Aug 14, 2006 7:04 am    Post subject: Line number /user range confusion Reply with quote

I know TStringList.Strings is a 0-based list / collection of strings and have
dealt with this enough to loop from 0 to .Count -1 etc.

I have started looking at User Ranges, from within the Delphi IDE, and
notice something a little disconcerting:

Example:
======
If I enter StartLine as 10 and EndLine as 20, (with a coloured background
for the style to make it easy to see), it highlights lines 11..20.

Now I set HighlightLines := True, and lines 11..21 are highlighted (ie one
more line at the end of the "block").

This user style is set to readonly. When I run the application, I cannot type
letters in the lines, as expected/intended, until I get to the last line (21),
where I can now type letters.

Because the last line (21) is displayed as part of the user range, using the
user style, i would expect the readonly flag to extend to this line also.

Aaron
Back to top
View user's profile Send private message
econtrol
Site Admin


Joined: 09 Jun 2006
Posts: 202

PostPosted: Mon Aug 14, 2006 12:41 pm    Post subject: Reply with quote

Fixing (ecSyntMemo.pas):


Code:
procedure TUserRange.SetEndLine(const Value: integer);
begin
  with Collection as TUserRanges do
   if FOwner <> nil then
    if (Value >= 0) and (Value < FOwner.Lines.Count) then
     EndPos := FOwner.CaretPosToStrPos(Point(0, Value + 1)); // fix
end;

procedure TUserRange.SetEndPos(const Value: integer);
begin
  FEndPos := Value;
  with Collection as TUserRanges do
   if FOwner <> nil then
     with FOwner.StrPosToCaretPos(FEndPos) do
      if (X = 0) and (Y > 0) then  // fix
        FEndLine := Y - 1
      else
        FEndLine := Y;
  Changed(False);
end;



Michael.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    EControl Ltd. Forum Index -> EControl Syntax Editor All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group