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 

Synedit conversion issue

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



Joined: 16 May 2008
Posts: 7

PostPosted: Mon May 19, 2008 2:33 am    Post subject: Synedit conversion issue Reply with quote

Hi,
Currently converting my app from synedit and I have run into a issue.
In synedit I could get the top line number of a selected block of text like this:

seltop:= editor.BlockBegin.Line;

Reading the docs I thought I could use:
editor.SelRect.Top

But this does not seem to work, it always comes back as a zero value.

I noticed in the docs it said the selection mode must be mscolumn, so at form create I set this, but it still did not seem to work.

Anyone have some insight for me?

Thanks,

Snorkel
Back to top
View user's profile Send private message
snorkel



Joined: 16 May 2008
Posts: 7

PostPosted: Tue May 20, 2008 7:15 am    Post subject: nevermid Reply with quote

I figured it out, in case anyone else runs into this you need to do:

editor.StrPosToCaretPos(editor.SelStart);

This returns a tpoint and the tpoint.y is the top line of the selected block of text.
Back to top
View user's profile Send private message
econtrol
Site Admin


Joined: 09 Jun 2006
Posts: 202

PostPosted: Mon May 26, 2008 5:37 pm    Post subject: Reply with quote

Hello,

There is function:

Code:
function TCustomSyntaxMemo.GetSelectedLines(var FirstLine, LastLine: integer): integer;
begin
  if SelectMode = msColumn then
   begin
     FirstLine := FBlock.Top;
     LastLine := FBlock.Bottom;
   end else
  begin
     FirstLine := StrPosToCaretPos(FSelStart).Y;
     with StrPosToCaretPos(FSelStart + FSelLength) do
      if (X = 0) and (Y > 0) then
       LastLine := Y - 1
      else
       LastLine := Y;
     if LastLine < FirstLine then
       LastLine := FirstLine;
  end;
  Result := LastLine - FirstLine + 1;
end;


You may see that start of selected block depends on selection mode (normal/columnar), so I recommend to use this function of editor.

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