Forum > IDE/CodeTools

Again on IDE/editor bookmakrs

(1/3) > >>

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.

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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  if (ID < 0) and toggle then begin    // search all editors for a mark on the given line     // the code in the function serves well as example  end; 

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

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

  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
  // search a free one, take 0 if no free found
  ID := 0;
  while Project1.Bookmarks.BookmarkWithID(ID) <> nil do begin
   if ID > 9 then begin
     id := 0;

  // < 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,

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.

> 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,


[0] Message Index

[#] Next page

Go to full version