Community
    • Login

    Plugin development help

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    9 Posts 4 Posters 3.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.
    • Finn McCarthyF
      Finn McCarthy
      last edited by

      Hi,

      So i have decided that i want to make a plugin for NP++.

      I’m using (or trying to!) NP++ Plugin.NET, but i am having trouble understanding which commands to use.

      What i want to do is make a plugin that brings up call-tips if you type “(” or “{”.
      Can someone help?

      Cheers,
      Finn

      P.S: I don’t really know where to put this, in Plugin Development or Help wanted, so sorry if it is in the wrong place :)

      1 Reply Last reply Reply Quote 1
      • Vitaliy DovganV
        Vitaliy Dovgan
        last edited by

        You could look at the sources of
        https://sourceforge.net/projects/npp-plugins/files/XBrackets Lite/
        It’s in C++, but I believe it’s enough to catch the idea of what to do in C#.
        Search for SCN_CHARADDED in the source code.

        1 Reply Last reply Reply Quote 2
        • Finn McCarthyF
          Finn McCarthy
          last edited by

          Thanks @Vitaliy-Dovgan

          1 Reply Last reply Reply Quote 0
          • Finn McCarthyF
            Finn McCarthy
            last edited by

            @Vitaliy-Dovgan

            Hi,

            Well i found it and i know what i’m looking for (sort of?). I think i need some help. Again :)

            And your right about C being easy to understand

            I did what you said and found no trace of SCN_CHARADDED. Thought i did search the plugin template and that had it.
            By the way, what would i do with SCN_CHARADDED, what i mean is: what is it’s use?
            e.g.

                if NppData.SCN_CHARADDED         /*Would somthing like that work?*/
                {
                };
            

            I think this code is maybe what i’m looking for (it’s from XBrackets.h):

            public:
                enum TFileType {
                    tftNone = 0,
                    tftText,
                    tftC_Cpp,
                    tftH_Hpp,
                    tftPas,
                    tftHtmlCompatible
                };
                
                enum TBracketType {
                    tbtNone = 0,
                    tbtBracket,  //  (
                    tbtSquare,   //  [
                    tbtBrace,    //  {
                    tbtDblQuote, //  "
                    tbtSglQuote, //  '
                    tbtTag,      //  <
                    tbtTag2,
            
                    tbtCount
                };
            
                enum eConsts {
                    MAX_ESCAPED_PREFIX  = 20
                };
            
                static const TCHAR* PLUGIN_NAME;
                static const char*  strBrackets[tbtCount - 1];
            
            protected:
                // plugin menu
                CXBracketsMenu m_PluginMenu;
                
                // internal vars
                INT_PTR m_nAutoRightBracketPos;
                int     m_nFileType;
                bool    m_bSupportedFileType;
            
            public:
                CXBrackets();
                virtual ~CXBrackets();
            	
                // standard n++ plugin functions
                virtual void         nppBeNotified(SCNotification* pscn);
                virtual FuncItem*    nppGetFuncsArray(int* pnbFuncItems);
                virtual const TCHAR* nppGetName();
            

            Is it what i’m looking for?

            Cheers,
            Finn

            Scott SumnerS 1 Reply Last reply Reply Quote 0
            • Scott SumnerS
              Scott Sumner @Finn McCarthy
              last edited by

              @Finn-McCarthy said:

              would i do with SCN_CHARADDED, what i mean is: what is it’s use?

              I think the implication here is when you see that, you could check if what was added was ( or { (from your spec)…and do whatever actions you want your plugin to do when that occurs.

              1 Reply Last reply Reply Quote 1
              • Vitaliy DovganV
                Vitaliy Dovgan
                last edited by

                Source file XBrackets\src\XBrackets.cpp,

                void XBrackets::nppBeNotified(SCNotification* pscn)
                {
                  ...
                  switch ( pscn->nmhdr.code )
                  {
                    case SCN_CHARADDED:
                      OnSciCharAdded(pscn->ch);
                      break;
                    ...
                  }
                  ...
                }
                

                Basically, what needs to be done now is:

                1. implement own method Plugin.nppBeNotified to be called from the standard void beNotified(SCNotification* pscn);
                2. implement own Plugin.OnSciCharAdded (looking at the one in XBrackets as an example)
                1 Reply Last reply Reply Quote 1
                • chcgC
                  chcg
                  last edited by

                  See scintilla docu: https://www.scintilla.org/ScintillaDoc.html#SCN_CHARADDED. Scintilla is the framework N++ is based on.

                  1 Reply Last reply Reply Quote 1
                  • Finn McCarthyF
                    Finn McCarthy
                    last edited by Finn McCarthy

                    @Victor-Dronov

                    Hi,

                    I found out the proper name of what i’m trying to do: Call-Tips. (custom Call-Tips).

                    Ok. I have had a look…And i still don’t understand. I probably should mention that have never, ever coded in C, C++,C# or VB (well 3 years ago, anyway and i cannot remember practically anything). So yeah…(This next bit will probably sound lame…sorry)

                    What I am trying to say is: I basically need someone to write the plugin for me, and i can learn from their source code. That’s how i normally learn…

                    Cheers,
                    Finn

                    P.S: Sorry, (I know i probably sound whiny)

                    1 Reply Last reply Reply Quote 0
                    • Finn McCarthyF
                      Finn McCarthy
                      last edited by

                      EDIT: I found a way, yippee!!

                      jN Notepad++ Plugin

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