Recent

Author Topic: How to remove bookmarks with Lazarus' Synedit  (Read 16935 times)

Edson

  • Hero Member
  • *****
  • Posts: 1296
Re: How to remove bookmarks with Lazarus' Synedit
« Reply #15 on: January 13, 2014, 06:50:02 pm »
Well, I would expect that the debugger lets the App catches the exception without break the execution. Is it possible? How do we debug an exception rutine on Lazarus?

This is new for me on Lazarus. I'm used to have not break, on running code with exception rutine service.

But I guess, it's due to the GDB-Lazarus combination.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9754
  • Debugger - SynEdit - and more
    • wiki
Re: How to remove bookmarks with Lazarus' Synedit
« Reply #16 on: January 13, 2014, 07:02:37 pm »
How does the debugger, of the time of exception know if any existing try except is meant to deal with the exception?

And if it continues in good faith, then by the time it might know, the state of the app may have changed, and the user can no longer debug it.

Not to mention, that in a way all exception are handled. The LCL catches them, and displays them.

A debugger (any debugger) can not know, what I had in mind when I wrote an exception handler. So even if it does act on the presence of such a handler (without any other info from me) then this is at best based on heuristics.

---
You can choose to ignore exceptions by class. But only global. There is no fine tuning yet.


llutti

  • New Member
  • *
  • Posts: 23
Re: How to remove bookmarks with Lazarus' Synedit
« Reply #17 on: May 03, 2016, 10:48:29 pm »
Hi,

  I now this is a old topic, but I had the same problem of the original post (when a press SHIFT + CTRL + # in a line with the bookmark set don´t clear the mark).

  I have test usin lz 1.6 and 1.7 with the same problem.

  After same debug I found the problem in synedit.pp "function TCustomSynEdit.ExecuteCommand".

  The original code is:
Code: Pascal  [Select][+][-]
  1.  
  2. procedure TCustomSynEdit.ExecuteCommand(Command: TSynEditorCommand;
  3.   const AChar: TUTF8Char; Data: pointer);
  4. ...
  5. begin
  6. ...
  7.       ecSetMarker0..ecSetMarker9,ecToggleMarker0..ecToggleMarker9:
  8.         begin
  9.           if BookMarkOptions.EnableKeys then begin
  10.             if (Command >= ecSetMarker0) and (Command <= ecSetMarker9) then
  11.               CX := Command - ecSetMarker0
  12.             else
  13.               CX := Command - ecToggleMarker0;
  14.             if assigned(fBookMarks[CX]) then begin
  15.               moveBkm := ((Command >= ecSetMarker0) and (Command <= ecSetMarker9))
  16.                          or (fBookMarks[CX].Line <> CaretY);               // <<<<< the problem is the "or"
  17.               ClearBookMark(CX);
  18.               if moveBkm then
  19.                 SetBookMark(CX, CaretX, CaretY);
  20.             end else
  21.               SetBookMark(CX, CaretX, CaretY);
  22.           end; // if BookMarkOptions.EnableKeys
  23.         end;
  24. ...
  25. end;
  26.  
  27.  

  The original code chanded is:
Code: Pascal  [Select][+][-]
  1.  
  2. procedure TCustomSynEdit.ExecuteCommand(Command: TSynEditorCommand;
  3.   const AChar: TUTF8Char; Data: pointer);
  4. ...
  5. begin
  6. ...
  7.       ecSetMarker0..ecSetMarker9,ecToggleMarker0..ecToggleMarker9:
  8.         begin
  9.           if BookMarkOptions.EnableKeys then begin
  10.             if (Command >= ecSetMarker0) and (Command <= ecSetMarker9) then
  11.               CX := Command - ecSetMarker0
  12.             else
  13.               CX := Command - ecToggleMarker0;
  14.             if assigned(fBookMarks[CX]) then begin
  15.               moveBkm := ((Command >= ecSetMarker0) and (Command <= ecSetMarker9))
  16.                          and (fBookMarks[CX].Line <> CaretY);               // <<<<< the problem is the "or" the correct is "and"
  17.               ClearBookMark(CX);
  18.               if moveBkm then
  19.                 SetBookMark(CX, CaretX, CaretY);
  20.             end else
  21.               SetBookMark(CX, CaretX, CaretY);
  22.           end; // if BookMarkOptions.EnableKeys
  23.         end;
  24. ...
  25. end;
  26.  
  27.  

regards,

Luciano

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9754
  • Debugger - SynEdit - and more
    • wiki
Re: How to remove bookmarks with Lazarus' Synedit
« Reply #18 on: May 04, 2016, 04:29:17 am »
The "Or" is correct.

You want to have ecToggleMarker0..9, but you use ecSetMarker0..9

Edit the SynEdit.KeyStrokes property. You will find ecSetMarker0 (around pos 65), change it to ecToggleMarker0 and do the same for 1..9

llutti

  • New Member
  • *
  • Posts: 23
Re: How to remove bookmarks with Lazarus' Synedit
« Reply #19 on: May 04, 2016, 01:01:18 pm »
Hi,

  I think, the "and" is correct.

  I did a simple test:

- Create a new project
- Add a SynEdit (configure the images to bookmarks) component and two buttons
- In onclick the first button use this code:
Code: Pascal  [Select][+][-]
  1. SynEdit1.ExecuteCommand(ecSetMarker9, #0, nil);

- In onclick the second button use this code:
Code: Pascal  [Select][+][-]
  1. SynEdit1.ExecuteCommand(ecToggleMarker9, #0, nil);

  Now run the project.

  To simulate the situation do this:

- Create 10 lines in the synedit
- Click in line 2 and click the first button (SetMark) (will show the mark "9")
- Click in line 5 and click the second button (toggleMark) (the mark "9" will moved to this line)

  If you change the "or" to "and" and repeat the simulation, when you click the second button the mark "9" will clear.
 
  Regards,

   Luciano

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9754
  • Debugger - SynEdit - and more
    • wiki
Re: How to remove bookmarks with Lazarus' Synedit
« Reply #20 on: May 04, 2016, 02:54:59 pm »
The way "toggle is supposed to work is that  command toggles the bookmark on the current line:

1) If the marker in is SET on the current line, then clear it
2) If the marker in is NOT SET on the current line, then set it (incl move)

That is, toggle will not clear a marker, unless that marker is on the current line.


llutti

  • New Member
  • *
  • Posts: 23
Re: How to remove bookmarks with Lazarus' Synedit
« Reply #21 on: May 04, 2016, 04:06:49 pm »
That's ok.

Now I understand the concept. I was used to the SynEdit for Delphi that has the concept a little different.

Grateful for clarification.

Best Regards,

Luciano

M.A.R.C.

  • Jr. Member
  • **
  • Posts: 68
Re: How to remove bookmarks with Lazarus' Synedit
« Reply #22 on: April 21, 2018, 07:33:18 am »
Hi, how to make this programmatically, I'm trying:
Code: Pascal  [Select][+][-]
  1.   Editor.Keystrokes.Items[Editor.Keystrokes.FindCommand(ecSetMarker1)].Command:=ecToggleMarker1;
But there are no changes in the behavior of Ctrl-Shift-1

Thank you.

@Henppy

You have to go to the Object Inspector, and select "SynEdit1>KeyStrokes", then change the Shortcut number 64, 65, 66, ..
They are set to ecSetMarker0, ecSetMarker1, ...
You should change them to ecToggleMarker0, ecToggleMarker1, ...

@Martin,

I have found that when using the BookMark Shortcuts (enabled by default) with no assigning a ImageList to: "SynEdit1.BookMarkOptions.BookmarkImages", the SynEdit, crashes. At least in my system. Is that normal?

 

TinyPortal © 2005-2018