Community
    • Login

    [Need Help] npp c++ plugin

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    c++ plugin
    12 Posts 3 Posters 1.2k 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.
    • PeterJonesP
      PeterJones @Long TV
      last edited by

      @long-tv ,

      Getting selected text from the editor is done using the Scintilla message SCI_GETSELTEXT

      Creating a panel and writing text into that panel is not something I know how to do (I haven’t actually written a plugin). But maybe you could look at the source for PythonScript or NppConsole which make console windows, so presumably show how to write text into there, or maybe the NppFTP which will write statuses into one of its windows…

      Alan KilbornA Long TVL 2 Replies Last reply Reply Quote 3
      • Alan KilbornA
        Alan Kilborn @PeterJones
        last edited by

        @peterjones said in [Need Help] npp c++ plugin:

        Creating a panel and writing text into that panel is not something I know how to do (I haven’t actually written a plugin).

        Me, neither – the scripting plugins are just THAT good that writing a true plugin seems like too much trouble.

        BTW, @Long-TV , you have seen this section of the N++ user manual, right?: https://npp-user-manual.org/docs/plugin-communication/

        Long TVL 1 Reply Last reply Reply Quote 2
        • Long TVL
          Long TV @Alan Kilborn
          last edited by

          @alan-kilborn
          I got the template here https://github.com/npp-plugins/plugintemplate
          I am learning c++ now, so I chosed c++ to make the plugin.

          1 Reply Last reply Reply Quote 0
          • Long TVL
            Long TV @PeterJones
            last edited by

            @peterjones
            thank you for suggestion… I will look for PythonScript for code sample.

            1 Reply Last reply Reply Quote 0
            • Long TVL
              Long TV @Alan Kilborn
              last edited by

              BTW, @Long-TV , you have seen this section of the N++ user manual, right?: https://npp-user-manual.org/docs/plugin-communication/

              I have read it and did some practice code. but it too many… I just need 2 actions I mentioned.

              PeterJonesP 1 Reply Last reply Reply Quote 0
              • PeterJonesP
                PeterJones @Long TV
                last edited by PeterJones

                @long-tv said in [Need Help] npp c++ plugin:

                I have read it and did some practice code. but it too many… I just need 2 actions I mentioned.

                I gave you the Scintilla message for grabbing selected text. If you don’t know how to send that message to Scintilla, your problems go deeper, and you probably need to start with a C++ project that isn’t as complicated as a plugin.

                And as far as creating a window/panel inside Notepad++ and writing text into it: that’s a much more complicated task, and isn’t just “one” action from the “just need 2 actions” you mentioned. It is a large series of steps which you will have to learn how to do – and we cannot be expected to spoonfeed such things – because that would be us writing the plugin for you (and because not all of us even know how to create that window; it’s a more complicated task, though I thought the c++ plugin template including a “docking window” example in a subfolder… so I would start there).

                But honestly, as Alan suggested, if you wanted to learn the PythonScript plugin (rather than using its source code as an example of how to implement something), and use that plugin that to write and run a script in Notepad++ environment, then you could leverage the development-time-saving features built into a solution like the PythonScript plugin. For example:

                from Npp import * 
                console.show()
                selected_text = editor.getSelText()
                console.write(selected_text+"\n")
                

                That script will do everything you described you wanted your plugin to do. In 4 lines of code.

                As Alan says, using a scripting plugin rather than having to deal with all the overhead of writing a full plugin is a definite timesaver. Unless you are doing something computationally expensive, or something that’s trying to change the styles of large documents, it’s usually best to just stick with that.

                –
                edited: added more details on the adding a window task

                Long TVL Alan KilbornA 2 Replies Last reply Reply Quote 3
                • Long TVL
                  Long TV @PeterJones
                  last edited by

                  @peterjones
                  thank you for your advice!

                  1 Reply Last reply Reply Quote 0
                  • Alan KilbornA
                    Alan Kilborn @PeterJones
                    last edited by

                    @peterjones said in [Need Help] npp c++ plugin:

                    That script will do everything you described you wanted your plugin to do

                    Well… scripting plugins would NOT be great if you have to have a “docking panel” or similar kind of “fancy” output presentation.

                    PeterJonesP 1 Reply Last reply Reply Quote 2
                    • PeterJonesP
                      PeterJones @Alan Kilborn
                      last edited by

                      @alan-kilborn ,

                      Well, the PythonScript console is a docking panel of sorts, and could be used for outputting such data, as long as the OP just wants a simple text output, and doesn’t care about fancy formatting.

                      Alan KilbornA 1 Reply Last reply Reply Quote 2
                      • Alan KilbornA
                        Alan Kilborn @PeterJones
                        last edited by

                        @peterjones said in [Need Help] npp c++ plugin:

                        Well, the PythonScript console is a docking panel of sorts, and could be used for outputting such data, as long as the OP just wants a simple text output, and doesn’t care about fancy formatting.

                        All true, but I think the OP is going for something more sophisticated.

                        1 Reply Last reply Reply Quote 1
                        • First post
                          Last post
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors