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 

Virtual/Dynamic

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



Joined: 21 Jul 2006
Posts: 67
Location: North Carolina, USA

PostPosted: Mon Jul 31, 2006 8:42 pm    Post subject: Virtual/Dynamic Reply with quote

Can IntDeleteText be made virtual/dynamic? Or maybe you have a better solution to my issue. We are implementing breakpoints in our application. Your component doesn't seem to support breakpoints directly unless we maintain them internally ourselves and surface them via a gutter object. I have created my own breakpoint list and used gutter objects to display breakpoints. The problem is that breakpoints aren't automatically updating if the user adds/deletes lines above the breakpoint. To get around this, I made the breakpoints bookmarks so that their position is automatically adjusted in the above example and I can still assign an image, BgColor, FgColor, etc. It's working quite nicely, however, I want the breakpoint (underlying bookmark) to be removed when the user deletes the character position where the breakpoint is set. I didn't see anything in your code that gives this behavior, so I have overridden IntDeleteText and that seems to work well also. Can IntDeleteText be declared as virtual/dynamic?

Thanks.
Back to top
View user's profile Send private message
jfudickar



Joined: 12 Jun 2006
Posts: 38
Location: Eschborn, Germany

PostPosted: Mon Jul 31, 2006 9:35 pm    Post subject: Reply with quote

Your breakpoint bookmark sounds interesting.

Maybe michael can implement it as a special type of bookmark.

Greetings
Jens
Back to top
View user's profile Send private message Visit poster's website
econtrol
Site Admin


Joined: 09 Jun 2006
Posts: 202

PostPosted: Tue Aug 01, 2006 4:55 am    Post subject: Reply with quote

No problem, from this moment IntDeleteText and IntInsertText are dynamic.

Also new code to support this feature:

Code:
  TBookmark = class(TCustomGutterObject)
  private
...
    FAllowDelete: Boolean;
...
  public
...
    property AllowDelete: Boolean read FAllowDelete write FAllowDelete;
  end;


Code:
procedure TCustomSyntaxMemo.TextChanged(Sender: TObject; Pos, Count, LineChange: integer);
...
      // Correct bookmarks
      for i := FBookmarks.Count - 1 downto 0 do
       with FBookmarks[i] do
        begin
         if AllowDelete and (Count < 0) and
            (Pos - Position <= 0) and (Pos - Position > Count) then
           Free
         else
           Position := UpdatePos(Position);
        end;
...


Michael.
Back to top
View user's profile Send private message Send e-mail
mstaszew



Joined: 21 Jul 2006
Posts: 67
Location: North Carolina, USA

PostPosted: Tue Aug 01, 2006 12:55 pm    Post subject: Reply with quote

Thanks alot Michael.
Back to top
View user's profile Send private message
mstaszew



Joined: 21 Jul 2006
Posts: 67
Location: North Carolina, USA

PostPosted: Tue Aug 01, 2006 7:28 pm    Post subject: Reply with quote

I have another enhancement for bookmarks. Can an OnBookmarkFree event handler be added to the syntax memo that is fired when a bookmark is freed/removed and have it pass the TBookmark that is about to be freed in?

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


Joined: 09 Jun 2006
Posts: 202

PostPosted: Wed Aug 02, 2006 6:54 am    Post subject: Reply with quote

Corresponding changes in code (ecSyntMemo.pas):

Code:
interface
...
  TBookmarkDeleteEvent = procedure(Sender: TObject; Bookmark: TBookmark; var AllowDelete: Boolean) of object;
...

  TCustomSyntaxMemo = class(TCustomControl, {$IFNDEF EC_DOTNET}IUnknown,{$ENDIF} IecTextClient, IecSyntClient)
  private
  ...
    FOnDeleteBookmark: TBookmarkDeleteEvent;
  ...
  public
  ...
    property OnDeleteBookmark: TBookmarkDeleteEvent read FOnDeleteBookmark write FOnDeleteBookmark;
  end;
 
  TSyntaxMemo = class(TCustomSyntaxMemo)
  published
  ...
    property OnDeleteBookmark;
  ...
  end;
 
...

implementation
 
...

procedure TCustomSyntaxMemo.TextChanged(Sender: TObject; Pos, Count, LineChange: integer);
var AllowDelBmk: Boolean;
    i, Line: integer;
...
      // Correct bookmarks
      for i := FBookmarks.Count - 1 downto 0 do
       with FBookmarks[i] do
        begin
         if AllowDelete and (Count < 0) and
            (Pos - Position <= 0) and (Pos - Position > Count) then
          begin
            AllowDelBmk := True;
            if Assigned(FOnDeleteBookmark) then
              FOnDeleteBookmark(Self, FBookmarks[i], AllowDelBmk);
            if AllowDelBmk then
             begin
              Free;
              Continue;
             end;
          end;
         Position := UpdatePos(Position);
        end;
...



Michael.


Last edited by econtrol on Wed Aug 02, 2006 9:54 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
jfudickar



Joined: 12 Jun 2006
Posts: 38
Location: Eschborn, Germany

PostPosted: Wed Aug 02, 2006 7:35 am    Post subject: Reply with quote

I would suggest to rename
TBokkmarkDeleteEvent to TBookmarkDeleteEvent Cool Laughing Smile Very Happy
Back to top
View user's profile Send private message Visit poster's website
econtrol
Site Admin


Joined: 09 Jun 2006
Posts: 202

PostPosted: Wed Aug 02, 2006 9:48 am    Post subject: Reply with quote

You are right! Very Happy
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