Community
    • Login

    Using text in n++ window as input for function

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    4 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.
    • Michael GermonM
      Michael Germon
      last edited by

      Hello,

      I’m not really a programmer but am working on a plugin that alleviate some repetitive formatting I need to do multiple times daily for a system. So far I have the c# code functioning as intended and I’ve added it into a template from the plugin page while making some modifications to the template.

      I am at a point where I should just need to get the input for the plugin and it should be ready to start testing. Unfortunately I’m not sure how to do this. I imagine that the namespace or some other prebuilt template code is used for this but I’m having a heck of a time finding it on my own looking through everything. I’ve also tried looking for example source code in hopes of finding a plugin that does something similar but to no fruition.

      I guess, for a straight example, say I open up notepad++ and type in “Hello world !” - I would like to have my plugin use that text on the window to, lets say insert a new line for every space, so the plugin would alter the text on the window from…

      Hello world !

      to…

      Hello
      world
      !

      This seems like it would be a basic thing for plugins to do, so my apologies, I’m afraid my lack of experience makes sifting through the template a very overwhelming task. Thank you in advance for any assistance.

      Eko palypseE 1 Reply Last reply Reply Quote 0
      • Eko palypseE
        Eko palypse @Michael Germon
        last edited by

        @Michael-Germon

        the first hing to understand is that a plugin has to work with at least two core objects,
        namely notepad++ and scintilla.
        Scintilla is the core component which is responsible for modifying/styling the text.
        Which means that in your case in order to be able to retrieve the text you need to
        get a reference/instance of the scintilla object and send/call the SCI_GETTEXT method.
        How this is done in C# - I don’t know.
        With pythonscript plugin it is as easy as calling editor.getText() as the plugin
        provided editor being the scintilla component and getText being a wrapper around SCI_GETTEXT.

        1 Reply Last reply Reply Quote 2
        • Michael GermonM
          Michael Germon
          last edited by

          Thank you Eko! I should be able to figure it out from here.

          1 Reply Last reply Reply Quote 1
          • rinku singhR
            rinku singh
            last edited by

            well where is your repository at github.com

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