* * *

Author Topic: Again on IDE/editor bookmakrs  (Read 4061 times)

linuxfan

  • New member
  • *
  • Posts: 18
Again on IDE/editor bookmakrs
« on: April 26, 2016, 11:16:17 am »
Hi all. I am missing a functionality about bookmarks: "toggle bookmark" (set / unset), exactly the same way as it works with breakpoints.

My suggestion is, if possible, to turn "Set a free bookmark" to "Toggle bookmark".

Anyway, thanks for this great tool; even with some quirks, is already the best around.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4587
    • wiki
Re: Again on IDE/editor bookmakrs
« Reply #1 on: April 27, 2016, 07:31:43 pm »
please create a request on the bugtracker.

If you are interested in looking at it yourself:

1) Search all files in the folder ide (and maybe components/ideIntf) for ecSetFreeBookmark
and create a new command ecToggleFreeBookmark
(you do not necessarily need menu entries)

2) in ide/main.pp look at
procedure TMainIDE.OnSrcNotebookEditorDoSetBookmark
add something like
Code: Pascal  [Select]
  1.   if (ID < 0) and toggle then begin
  2.     // search all editors for a mark on the given line
  3.     // the code in the function serves well as example
  4.   end;
  5.  


advanced mouse options allow to assign this to the mouse buttons if you want.

linuxfan

  • New member
  • *
  • Posts: 18
Re: Again on IDE/editor bookmakrs
« Reply #2 on: April 28, 2016, 08:32:09 pm »
Hi Martin,

thanks to your instructions I made a modification. Here is what I've made, may be it is worth for someone. Sorry if this message will be ugly, I have still to learn how to use this forum.

In the file ide/main.pp I modified TMainIDE.OnSrcNotebookEditorDoSetBookmark().
The whole body has been replaced with this one:

  (* ignore toggle and assume is always true.
    if there is a bookmark here, delete it and exit.
    if there is not, search a free one; if none found, take "0"
    set it.
  *)
 
  {$push}{$R-}  // range check off
  Inc(BookmarksStamp);
  {$pop}

  ActEdit := Sender as TSourceEditor;
  NewXY := ActEdit.EditorComponent.CaretXY;
  for id := 0 to 9 do begin
   // is there a bookmark?
   AnUnitInfo := TUnitInfo(Project1.Bookmarks.UnitInfoForBookmarkWithIndex(ID));
   OldEdit := nil;
   if (AnUnitInfo <> nil) and (AnUnitInfo.OpenEditorInfoCount > 0)
     then OldEdit := TSourceEditor(AnUnitInfo.OpenEditorInfo[0].EditorComponent);
   if (OldEdit<>nil) and OldEdit.EditorComponent.GetBookMark(ID,OldX{%H-},OldY{%H-}) then begin
     if OldY=NewXY.Y then begin
       // it is there, remove and exit
      OldEdit.EditorComponent.ClearBookMark(ID);
      exit
     end
   end
  end;
 
  // search a free one, take 0 if no free found
  ID := 0;
  while Project1.Bookmarks.BookmarkWithID(ID) <> nil do begin
   inc(ID);
   if ID > 9 then begin
     id := 0;
     break
   end
  end;

  ActEdit.EditorComponent.SetBookMark(ID,NewXY.X,NewXY.Y);
  // < done


  // original code follows
  (* 
....  (original code commented out)
*)

This is a quick and maybe horrible hack; I just tested it for 30 seconds and it seems to do what I want.

Have a nice day, best regards,
linuxfan

MichaelBM

  • New member
  • *
  • Posts: 18
Re: Again on IDE/editor bookmakrs
« Reply #3 on: April 28, 2016, 08:44:53 pm »
I'm using Lazarus 1.6 on Windows 10 and all the requested functions are already implemented as default.

Just right-click with your mouse in the editor.
Development Tool: Lazarus 1.8.2 + FPC 3.0.4
Database: Firebird 2.5.7
Operating System: Windows 10 Pro 64-bit

linuxfan

  • New member
  • *
  • Posts: 18
Re: Again on IDE/editor bookmakrs
« Reply #4 on: April 29, 2016, 08:23:31 am »
> I'm using Lazarus 1.6 and all the requested functions are already implemented as default.

I didn't notice that: while editing, I use the mouse as less as possible. So, thank you. Instead of exploring right-click menu,  I went to "editor preferences"/"keyboard shortcuts", and only found "Set bookmark [0..9]" and "Goto bookmark [0..9]". There was no way to invert or delete a single bookmark. Very strange! So i rolled down my own solution...

Only now I see that, at least in my translation, functions for inverting bookmarks are called "Invert marker [0..9]". The different words bookmark-marker make impossible to see all the related functions at the same time. I discover that after your suggestion.

Anyway, I don't like the original lazarus way, and still prefer my modification because using a single keystroke I can set or delete a bookmark without worrying about its number. It's a matter of habit. Only now I fully understand the suggestion of Martin_fr, which was talking about a toggle flag which seemed never used...

I could think at a cleaner way to do what I want; meantime, I think that the text associated with bookmarks, or at least their translations, have a problem. I will post a bug report.

Thank you all and regards,
linuxfan

MichaelBM

  • New member
  • *
  • Posts: 18
Re: Again on IDE/editor bookmakrs
« Reply #5 on: April 30, 2016, 03:12:54 pm »
Have you tried using Ctrl+Shift+[1..9] ?

This key combination sets/deletes bookmarks in the Windows version af Lazarus. Pretty nice!
Development Tool: Lazarus 1.8.2 + FPC 3.0.4
Database: Firebird 2.5.7
Operating System: Windows 10 Pro 64-bit

totya

  • Sr. Member
  • ****
  • Posts: 437
Re: Again on IDE/editor bookmakrs
« Reply #6 on: June 06, 2018, 01:21:50 pm »
Hi, bookmarks works for me in IDE, except for package files... after open package, bookmarks seems to me lost.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4587
    • wiki
Re: Again on IDE/editor bookmakrs
« Reply #7 on: June 06, 2018, 02:14:02 pm »
Are you sure the same bookmark is not set in any other file that is already open?

totya

  • Sr. Member
  • ****
  • Posts: 437
Re: Again on IDE/editor bookmakrs
« Reply #8 on: June 06, 2018, 05:36:03 pm »
Hi!

Yes, I'm exactly soure.

My simple question, if I works with package files, where is the bookmark storage (config) file?

Okay, I play with it, and I found what is the problem, for bookmarks save, need a project. lol. For example: file-new/simple application. But is unneccessary for packages...
Packages doesn't save bookmarks without an open project as I see.


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4587
    • wiki
Re: Again on IDE/editor bookmakrs
« Reply #9 on: June 06, 2018, 08:09:12 pm »
Ok, I see. Yes bookmarks are stored in projects only.

If you set a bookmark in a package, then that is stored in the project which is open at the time.
Same as the rest of the session, e.g which files from which package are open in an editor.

If you open the same package in a diff project, then it will have whatever bookmarks that other project has.

-------------------
Note:
The Lazarus IDE *always* has a project open. It currently can not work without one.
Even if you close all files in all editors, the project is still open.

You can close the project in the project menu. But then the IDE will immediately ask you which other project to open, and you can do nothing until you open/create one.

totya

  • Sr. Member
  • ****
  • Posts: 437
Re: Again on IDE/editor bookmakrs
« Reply #10 on: June 06, 2018, 09:37:14 pm »
Martin_fr:

Thank you for these useful informations! :)

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus