• Login
Community
  • Login

How to get breakpoint list ?

Scheduled Pinned Locked Moved Notepad++ & Plugin Development
23 Posts 5 Posters 6.0k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A
    Alan Kilborn @Gregory D.
    last edited by May 18, 2020, 12:50 PM

    @Gregory-D said in How to get breakpoint list ?:

    is it possible to get a list of these circles fro a plugin

    Are you asking if it is possible for a plugin to know if a line has a bookmark or not?

    If so then the answer is yes.
    The bookmark is manipulated as something called a “marker”.
    You can read about their implementation HERE although that won’t make you an instant expert on how a plugin can gain access.

    1 Reply Last reply Reply Quote 1
    • G
      Gregory D.
      last edited by May 18, 2020, 12:53 PM

      @Alan-Kilborn said in How to get breakpoint list ?:

      You can read about their implementation HERE although that won’t make you an instant expert on how a plugin can gain access.

      Do you mean it’s complicated to get a list of bookmark ?

      A 1 Reply Last reply May 18, 2020, 1:05 PM Reply Quote 0
      • A
        Alan Kilborn @Gregory D.
        last edited by May 18, 2020, 1:05 PM

        @Gregory-D said in How to get breakpoint list ?:

        Do you mean it’s complicated to get a list of bookmark ?

        To ask such a question in that way leads me to believe that it might be complicated for you.
        Haha.
        Just a joke, don’t get offended!

        But, I pointed you to the documentation, which I presume you looked at before you replied with the above question.
        And did you see a function there that instantly provides you with a list of bookmarks?
        No, because there isn’t such a function.
        To get the bookmarks you have to iterate and build any list you want yourself.
        You would probably use THIS to do that.
        And you would also need to know that the marker number that N++ uses for bookmarks is decimal 24.

        So, overall, is it complicated?
        I suppose that depends upon your knowledge and your perspective.

        1 Reply Last reply Reply Quote 1
        • G
          Gregory D.
          last edited by May 18, 2020, 1:32 PM

          I’m not offended, just surprised of you’re way to reply, you should have just said, "no it’s not too much complicated, you just have to get the current scintilla, like that [little code] and retrieve the bookmark for each line like that [little code]. But that’s ok, I ask, I work.
          Then I did that :

          int which = -1;
          ::SendMessage(nppData._nppHandle, NPPM_GETCURRENTSCINTILLA, 0, (LPARAM)&which);
          if (which == -1)
          	return FALSE;
          HWND curScintilla = (which == 0) ? nppData._scintillaMainHandle : nppData._scintillaSecondHandle;
          

          Ok, that part work, I get the scintilla for the current document, but for the next part I don’t find example, I tried that:

          long line = 0;
          int marker = 0;
          ::SendMessage(curScintilla, SCI_MARKERGET, line, (LPARAM)&marker);

          But it always gave 0, can you enlighten me ?

          M A 3 Replies Last reply May 18, 2020, 1:40 PM Reply Quote 1
          • M
            Michael Vincent @Gregory D.
            last edited by May 18, 2020, 1:40 PM

            @Gregory-D said in How to get breakpoint list ?:

            Ok, that part work, I get the scintilla for the current document, but for the next part I don’t find example, I tried that:

            Here is some NppExec code to iterate the bookmarks in the active document.

            SET LOCAL POS = 0
            SET LOCAL FOUND = 0
            SET LOCAL MASK ~ 1<<24
            
            :LISTNEXT
            SCI_SENDMSG SCI_MARKERNEXT $(POS) $(MASK)
            IF $(MSG_RESULT)==-1 GOTO STOP
            
            NPP_CONSOLE on
            SET LOCAL FOUND = 1
            SET LOCAL LINE ~ $(MSG_RESULT) + 1
            SCI_SENDMSG SCI_GETLINE $(MSG_RESULT) @""
            ECHO $(FULL_CURRENT_PATH):$(LINE):	$(MSG_LPARAM)
            
            SET LOCAL POS = $(LINE)
            GOTO LISTNEXT
            
            :STOP
            IF $(FOUND)==0 THEN
                MESSAGEBOX "No Bookmarks Found"
            ENDIF
            

            The API calls are pretty much the same (SCI_SENDMSG = ::SendMessage(getCurrScintilla(), <MESSAGE>, wParam, lParam)) and you can do C++ looping much cleaner than the GOTO required in NppExec.

            I usually try to mock something up in NppExec (or “PerlScript” or PythonScript) before trying to add to a plugin.

            Cheers.

            G 1 Reply Last reply May 18, 2020, 3:42 PM Reply Quote 2
            • A
              Alan Kilborn @Gregory D.
              last edited by Alan Kilborn May 18, 2020, 1:42 PM May 18, 2020, 1:40 PM

              @Gregory-D

              In my notes on bookmark manipulation I have this thread and specifically THIS POST noted.
              The logic flow there can probably help you.

              1 Reply Last reply Reply Quote 1
              • A
                Alan Kilborn @Gregory D.
                last edited by May 18, 2020, 1:50 PM

                @Gregory-D said in How to get breakpoint list ?:

                you should have just said, "no it’s not too much complicated, you just have to get the current scintilla, like that [little code] and retrieve the bookmark for each line like that [little code].

                I don’t know…
                Nobody here is going to “spoon feed” you every little detail.
                If you’re a plugin writer, a certain level of “sophistication” is assumed.
                Pointing you to the documentation should be enough.
                Of course, I did point you to the documentation, and a specific function in those docs, but then in your follow-on posting you seemed to ignore that and went with a different function…
                I’m not sure what to think.
                I wish you good luck with your endeavors.

                1 Reply Last reply Reply Quote 2
                • G
                  Gregory D.
                  last edited by May 18, 2020, 3:36 PM

                  I just need help for notepad++ plugin development in c++, you redirect me to scintilla api documentation, which has nothing to do with c++.

                  @Alan-Kilborn said in How to get breakpoint list ?:

                  I did point you to the documentation, and a specific function in those docs, but then in your follow-on posting you seemed to ignore that and went with a different function

                  Sorry I followed your link and see that SCI_MARKERGET returns the bookmark at a specific line, perfect for a test. I tested and it doesn’t work. But even if you’re convinced I’m a bad programmer, you think I would have more chance with SCI_MARKERNEXT that seems more advanced.
                  If you tell me why I get “0”, I’ll can understand and make both work, but you doesn’t seem to know c++, then just tell me that.

                  1 Reply Last reply Reply Quote 0
                  • G
                    Gregory D. @Michael Vincent
                    last edited by Gregory D. May 18, 2020, 3:43 PM May 18, 2020, 3:42 PM

                    @Michael-Vincent Thank you for the code, what I don’t understand is how to turn that in c++, the functino is ::SendMessage(getCurrScintilla(), <MESSAGE>, wParam, lParam)), then I need to put pos, mask and the result in wparam and lparam, 3 parameters into 2 ?

                    M 1 Reply Last reply May 18, 2020, 3:57 PM Reply Quote 0
                    • G
                      Gregory D.
                      last edited by Gregory D. May 18, 2020, 3:54 PM May 18, 2020, 3:52 PM

                      @Gregory-D said in How to get breakpoint list ?:

                      long line = 0;
                      int marker = 0;
                      ::SendMessage(curScintilla, SCI_MARKERGET, line, (LPARAM)&marker);

                      This is :

                      long line = 0;
                      int marker=::SendMessage(curScintilla, SCI_MARKERGET, line, 0);
                      

                      Right ?

                      1 Reply Last reply Reply Quote 0
                      • M
                        Michael Vincent @Gregory D.
                        last edited by Michael Vincent May 18, 2020, 4:00 PM May 18, 2020, 3:57 PM

                        @Gregory-D

                        I think maybe you’re not connecting the dots. The Scintilla docs @Alan-Kilborn linked are crucial since the Notepad++ editing component is based on Scintilla. As for “translating” my NppExec script to C++:

                        [...]
                        
                        HWND getCurScintilla()
                        {
                            int which = -1;
                            ::SendMessage( nppData._nppHandle, NPPM_GETCURRENTSCINTILLA, 0,
                                           ( LPARAM )&which );
                            return ( which == 0 ) ? nppData._scintillaMainHandle :
                                   nppData._scintillaSecondHandle;
                        }
                        
                        [...]
                        int line = 0;
                        int mask = 1<<24;
                        SendMessage(getCurScintilla(), SCI_MARKERNEXT, line, mask);
                        

                        That should get you the first bookmark since N++ uses 24 as the bookmark marker and thus bitshitfted 24 is the mask the Scintilla call requires. You’ll need to put your own C++ code / logic around that to determine if you’ve found them all and how to find the next one, but again, my NppExec “pseudo” code should help you with that - as will the Scintilla docs.

                        Cheers.

                        M G 2 Replies Last reply May 18, 2020, 4:01 PM Reply Quote 2
                        • M
                          Michael Vincent @Michael Vincent
                          last edited by May 18, 2020, 4:01 PM

                          @Michael-Vincent said in How to get breakpoint list ?:

                          SendMessage(getCurScintilla(), SCI_MARKERNEXT, line, mask);

                          sorry:

                          int markerAtLine = ::SendMessage(getCurScintilla(), SCI_MARKERNEXT, line, mask);
                          

                          Cheers.

                          1 Reply Last reply Reply Quote 1
                          • G
                            Gregory D. @Michael Vincent
                            last edited by May 18, 2020, 4:02 PM

                            @Michael-Vincent said in How to get breakpoint list ?:

                            The Scintilla docs @Alan-Kilborn linked are crucial since the Notepad++ editing component is based on Scintilla. As for “translating” my NppExec script to C++:

                            I’m sure about that, but what Alan Kilborn doesn’t understand is that my problem is not about Scintilla api that is documented but with the c++ conversion.
                            Then right code is:

                            				long line = 1;
                            				int mask = (1 << 24);
                            				int result=::SendMessage(curScintilla, SCI_MARKERNEXT, line, mask);
                            

                            You helped me, thanks.

                            M 1 Reply Last reply May 18, 2020, 4:04 PM Reply Quote 0
                            • M
                              Michael Vincent @Gregory D.
                              last edited by May 18, 2020, 4:04 PM

                              @Gregory-D said in How to get breakpoint list ?:

                              Then right code is:

                              Yup - methinks that’s correct.

                              Cheers.

                              1 Reply Last reply Reply Quote 1
                              • A
                                Alan Kilborn
                                last edited by Alan Kilborn May 20, 2020, 2:24 PM May 20, 2020, 2:22 PM

                                Tangential to the topic, but not quite off-topic:

                                I started working with an older version of Visual Studio recently, due to what is used for certain projects at work.

                                I notice that its breakpointing symbol is VERY similar to Notepad’s bookmark image, the main difference being coloring:

                                f93d525e-93a7-4a2c-9890-145ab778a422-image.png

                                In the past I’ve had a passing thought of “where did the design for the N++ bookmark come from?” as it isn’t a stock Scintilla indicator symbol like those shown HERE (with a little “scrolldown” from where that link goes).

                                Perhaps this “red” older-Visual-Studio BP symbol (shown above) was the origin of the N++ bookmark symbol.

                                The obvious stock Scintilla choice (had it been used) would have been:

                                06636eee-70c1-41af-95d2-0980fe38644f-image.png

                                BTW, current VS (2019) BP symboling is much less “fancy”; appears rather flat:

                                0142c89a-c1d3-45d0-b448-5f7675597295-image.png

                                M 1 Reply Last reply May 20, 2020, 2:52 PM Reply Quote 2
                                • M
                                  Michael Vincent @Alan Kilborn
                                  last edited by May 20, 2020, 2:52 PM

                                  @Alan-Kilborn said in How to get breakpoint list ?:

                                  The obvious stock Scintilla choice (had it been used) would have been:

                                  Do you have NppExec (or Python Script) that allows a script to run at startup?

                                  SCI_SENDMSG SCI_MARKERDEFINE 24 SC_MARK_BOOKMARK
                                  SCI_SENDMSG SCI_MARKERSETFORE 24 255
                                  SCI_SENDMSG SCI_MARKERSETBACK 24 255
                                  

                                  (Python Scrip implementation will vary ;-)

                                  51712cda-f98a-4ef9-a53f-1ff0492dc7ab-image.png

                                  Cheers.

                                  A 1 Reply Last reply May 20, 2020, 3:01 PM Reply Quote 4
                                  • A
                                    Alan Kilborn @Michael Vincent
                                    last edited by May 20, 2020, 3:01 PM

                                    @Michael-Vincent

                                    Yes, that is good information.
                                    The Pythonscript implementation is very similar and straightforward.

                                    BTW, I wasn’t complaining about Notepad++'s default bookmark symbol image in any way. Just wondering/commenting on its possible origins. It hadn’t occurred to me that the origins might be with an earlier VS version.

                                    M 1 Reply Last reply May 20, 2020, 3:09 PM Reply Quote 2
                                    • M
                                      Michael Vincent @Alan Kilborn
                                      last edited by May 20, 2020, 3:09 PM

                                      @Alan-Kilborn said in How to get breakpoint list ?:

                                      BTW, I wasn’t complaining about Notepad++'s default bookmark symbol image in any way

                                      Didn’t think you were :-) it was more of an exercise to see if I could do it. I have an NppExec ‘marker’ script that adds different colored “bookmarks” by placing normal bookmarks and then converting them. So I though it’d be possible to just change the default symbol / color.

                                      Cheers.

                                      1 Reply Last reply Reply Quote 3
                                      • BambofyB
                                        Bambofy
                                        last edited by Bambofy Apr 17, 2023, 5:16 PM Apr 17, 2023, 5:13 PM

                                        Sorry to bump this really old thread but the NppExec scripts above weren’t working for me, so i tried to write one myself. Here it is, when it finishes running it will echo a string which can be copied into another file.

                                        cls
                                        set local currentline = 0
                                        set local breakpoints = ""
                                        :repeat
                                        sci_sendmsg SCI_MARKERNEXT $(currentline) 0xFFFFFF
                                        // If marker next fails then we exit.
                                        if $(MSG_RESULT) == -1) 
                                            exit
                                        // Next marker exists.
                                        else 
                                            // Check if the market has looped back to 0.
                                            if $(MSG_RESULT) < $(currentline)
                                                echo $(breakpoints)
                                                exit
                                            else
                                                // Increment the resulting line by 1.
                                                set local currentline ~ $(MSG_RESULT) + 1
                                                set local breakpoints = ${breakpoints} $(FILE_NAME) $(currentline) \r\n
                                            endif
                                            goto repeat
                                        endif
                                        
                                        
                                        

                                        I couldn’t quite figure out how to make NppExec write to a file, so if anyone can add that i’d be really grateful.

                                        PeterJonesP 1 Reply Last reply Apr 17, 2023, 5:39 PM Reply Quote 0
                                        • PeterJonesP
                                          PeterJones @Bambofy
                                          last edited by PeterJones Apr 17, 2023, 5:43 PM Apr 17, 2023, 5:39 PM

                                          @Bambofy ,

                                          I’m not sure why you completely reworked @Michael-Vincent’s script, instead of just fixing the third line to

                                          SET LOCAL MASK ~ (1<<24) -1
                                          

                                          It seems that would have been a lot less work for you than redoing all the logic, slightly differently.

                                          (I’m also really surprised that Michael’s code worked for him a few years ago; I don’t believe the definition of the MASK field of SCI_MARKERNEXT has changed in the last three years.)

                                          As far as redirecting the NppExec output to a file, did you look in Plugins > NppExec > Help/Manual, looking at section 4.5? Because section 4.5 is completely devoted to how to redirect output in NppExec, so that would seem like a natural place to start. As a hint, if you previously had

                                          echo HI
                                          

                                          you could replace it with

                                          cmd /c echo HI > outputfile.txt
                                          

                                          to redirect it to overwrite outputfile.txt,
                                          or

                                          cmd /c echo HI >> outputfile.txt
                                          

                                          to redirect it to append to outpputfile.txt

                                          PeterJonesP 1 Reply Last reply Apr 17, 2023, 5:51 PM Reply Quote 0
                                          • First post
                                            Last post
                                          The Community of users of the Notepad++ text editor.
                                          Powered by NodeBB | Contributors