View previous topic :: View next topic |
Author |
Message |
mstaszew
Joined: 21 Jul 2006 Posts: 67 Location: North Carolina, USA
|
Posted: Mon Jul 31, 2006 8:42 pm Post subject: Virtual/Dynamic |
|
|
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 |
|
|
jfudickar
Joined: 12 Jun 2006 Posts: 38 Location: Eschborn, Germany
|
Posted: Mon Jul 31, 2006 9:35 pm Post subject: |
|
|
Your breakpoint bookmark sounds interesting.
Maybe michael can implement it as a special type of bookmark.
Greetings
Jens |
|
Back to top |
|
|
econtrol Site Admin
Joined: 09 Jun 2006 Posts: 202
|
Posted: Tue Aug 01, 2006 4:55 am Post subject: |
|
|
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 |
|
|
mstaszew
Joined: 21 Jul 2006 Posts: 67 Location: North Carolina, USA
|
Posted: Tue Aug 01, 2006 12:55 pm Post subject: |
|
|
Thanks alot Michael. |
|
Back to top |
|
|
mstaszew
Joined: 21 Jul 2006 Posts: 67 Location: North Carolina, USA
|
Posted: Tue Aug 01, 2006 7:28 pm Post subject: |
|
|
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 |
|
|
econtrol Site Admin
Joined: 09 Jun 2006 Posts: 202
|
Posted: Wed Aug 02, 2006 6:54 am Post subject: |
|
|
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 |
|
|
jfudickar
Joined: 12 Jun 2006 Posts: 38 Location: Eschborn, Germany
|
Posted: Wed Aug 02, 2006 7:35 am Post subject: |
|
|
I would suggest to rename
TBokkmarkDeleteEvent to TBookmarkDeleteEvent |
|
Back to top |
|
|
econtrol Site Admin
Joined: 09 Jun 2006 Posts: 202
|
Posted: Wed Aug 02, 2006 9:48 am Post subject: |
|
|
You are right! |
|
Back to top |
|
|
|