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 

Bookmark being removed

 
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: Wed May 27, 2009 3:05 pm    Post subject: Bookmark being removed Reply with quote

In version 2.40 if I set a bookmark on line 10 and then remove line 10 the bookmark will move to line 9.

In version 2.60 if I do the same the bookmark is removed completely.

I wouldn't have noticed this, but our users are reporting bugs regarding this change. I personally think that the behavior in 2.40 is a little weird, but it is also what Delphi's IDE does. I have not tested with others. Is there a way to restore the behavior of version 2.40?

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


Joined: 09 Jun 2006
Posts: 202

PostPosted: Thu May 28, 2009 10:47 am    Post subject: Reply with quote

There is new option.
TBookmark.AllowDelete: Boolean;

It's default value is True. To change it use OnSetBookmark event as in example (from main demo) below:

Code:
procedure TEditorFrame.EditorMasterSetBookmark(Snder: TObject;
  Bookmark: TBookmark; var Accept: Boolean);
begin
  with Bookmark do
   if (BmIndex >= 0) and (BmIndex < 10) then
    begin
     ImageIndex := 13 + BmIndex;
     Hint := 'Bookmark ' + IntToStr(BmIndex);
     AllowDelete := False; // Disable deleting bookmark with text
    end;
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: Thu May 28, 2009 1:28 pm    Post subject: Reply with quote

Thanks, that did it.
Back to top
View user's profile Send private message
mstaszew



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

PostPosted: Tue Aug 04, 2009 5:44 pm    Post subject: Reply with quote

This fix has unfortunately introduced another problem. In past versions text removal would not free the bookmark, but pressing CTRL+SHIFT+<NUMBER> would toggle a bookmark. Meaning, if bookmark 0 was set on line 10 and the caret is on line 10 and CTRL+SHIFT+0 is pressed the bookmark was removed, but deleting all text on line 10 would not remove the bookmark. I'd like to get that old behavior back. Setting AllowDelete to False fixes the initial issue, but makes it such that CTRL+SHIFT+0 on line 10 will not remove the bookmark if it was already set.

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


Joined: 09 Jun 2006
Posts: 202

PostPosted: Thu Aug 13, 2009 7:31 pm    Post subject: Reply with quote

Yes, I agree.

Fix (ecSyntMemo.pas):

Code:

procedure TCustomSyntaxMemo.ToggleBookmark(Index: integer);
var bm: TBookmark;
    AllowDelBmk : boolean;
begin
  bm := GetBookmarkObj(Index);
  if bm = nil then SetBookmark(Index, CaretStrPos) else
    if CaretPos.Y = bm.Line then
      begin
        AllowDelBmk := True; //bm.AllowDelete;
        if Assigned(FOnDeleteBookmark) then
          FOnDeleteBookmark(Self, bm, AllowDelBmk);
        if AllowDelBmk then bm.Free
          else bm.Position := CaretStrPos;
      end
     else bm.Position := CaretStrPos;
  Invalidate;
end;


In this case Toggle bookmark will work as expected.

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