Community
    • Login

    Template "new #"

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    16 Posts 5 Posters 2.5k 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 VincentM
      Michael Vincent
      last edited by

      Interesting - thanks. I"m not using PythonScript, but am using NppExec. Not sure NppExec has a way to receive N++ notifications (e.g., NOTIFICATION.BUFFERACTIVATED); it can send N++ messages.

      I"ll poke a bit with your idea on NppExec to see if I can do it with that plugin.

      Cheers.

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

        @Michael-Vincent

        I’m doubtful about NppExec for this application, but, maybe?

        Pythonscript is a bit of a bear to get installed these days. Luascript is dead-easy to install but I don’t know the equivalent code there. IIRC aren’t you a known plugin author? Something like this should be very easy to plugin-ize for someone that has made plugins before…and would have wider shareability. :)

        1 Reply Last reply Reply Quote 1
        • Michael VincentM
          Michael Vincent
          last edited by

          aren’t you a known plugin author?

          Well that’s a bit of an overstatement of my abilities. I recognize a difference between talented programmers creating a plugin vs. me taking their source code and adding a few features here and there. Now if there was a way to write plugins in Perl … :-)

          Cheers.

          1 Reply Last reply Reply Quote 2
          • Michael VincentM
            Michael Vincent
            last edited by

            IF "new " < "$(FULL_CURRENT_PATH)" THEN
                SEL_SETTEXT "My Copyright (c) 2019"
            ENDIF
            

            As a startup in NppExec would do it, but only when N++ first starts, not when “File->New” from an already opened N++ instance. To bad NppEventExec wasn’t built into NppExec. I could add it or just bite the bullet and install (Python | Lua)Script.

            Cheers.

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

              @Michael-Vincent said:

              Now if there was a way to write plugins in Perl … :-)

              Amen to that!

              I kept on hoping that you would at least write the PerlScript plugin, so I could stop using PythonScript. But I guess since I now have marginally more perlmonk XP than you, it would be more expected to be me. But I have the excuse that I’ve never compiled a Notepad++ plugin, and have virutally no experience with perlguts… so it will probably be a while before I can do it. (At one point, I at least started a perl module (Win32::Mechanize::NotepadPlusPlus ) to use Win32::API and Win32::GuiTest to automate Notepad++ from outside notepad++, so I don’t have to wait until I learn Notepad++ plugins or perlguts… but I never get very far. I am having trouble sending the right messages. Hmm, maybe one day, I’ll put it into a public github, and see if you or anyone else here or on perlmonks were able to help me see why my messages aren’t working. But to do that, I’d have to find enough time to remind myself what my cryptic comments mean, and come up with a simple example. Maybe I’ll try to find the time sooner rather than later. :-)

              EkopalypseE 1 Reply Last reply Reply Quote 1
              • EkopalypseE
                Ekopalypse @PeterJones
                last edited by

                @PeterJones

                so I could stop using PythonScript.

                Isn’t this already qualifying a ban, or at least a downvote?? :-D

                I guess a possible way to go would be to write a small c++ plugin which builds
                the bridge to FFI-Platypus.

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

                  @Ekopalypse said:

                  so I could stop using PythonScript.
                  Isn’t this already qualifying a ban, or at least a downvote?? :-D

                  :-D

                  I’ve been playing with Perl since the 90s when I started playing with writing cgi scripts for my ....edu/~username/ webpage, so I’m rather more familiar with Perl than Python. If PerlScript had already existed when I started automating Notepad++, I would have used that rather than PythonScript. I’d still be a Notepad++ user (which is the most important thing around here), and I’d probably be faster at hacking up scripting solutions for Notepad++ if I could be working in my more familiar language (which would be a bonus around here).

                  write a small c++ plugin

                  Therein lies the rub. I know enough C to hack a c++ program… but I’m not fluent in the ins-and-outs, and the only compiler I have is the mingw-based gcc that comes with the 32 and 64bit versions of strawberry perl. I’ve never even been able to compile the initial dummy plugin. (Unfortunately, @Michael-Vincent [under his previous incarnation of @vinsworldcom178] never showed progress on https://notepad-plus-plus.org/community/topic/16149/demo-plugin-docking-not-working-with-mingw-build , so I never got an example of how to do it. He can confirm, but I think he finally switched to VS2017)

                  Like I said, some day I’d like close communication between the Perl and Notepad++, but it’s a lot of effort, whatever direction you go.

                  EkopalypseE 1 Reply Last reply Reply Quote 2
                  • EkopalypseE
                    Ekopalypse @PeterJones
                    last edited by

                    @PeterJones

                    Caveat, I don’t know anything about the FFI-Platypus but, recently, I was playing around with cffi, which is a python-ffi and it seems, as far as I’ve understood, that both have the same origin.
                    With cffi it is, more or less, simple to build a dll.
                    My first test was something about 50 lines of code and a slightly modified plugin.h, which then was compiled (function within cffi) to a dll.
                    Npp loaded it and I was able to get a hello world. :-)
                    But the best thing was, that this generated a dll, which had the python interpreter included.

                    So, with this naive approach in mind and hoping that
                    Platypus can do the same or similar thing it shouldn’t be that difficult.

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

                      @Ekopalypse said:

                      But the best thing was, that this generated a dll, which had the python interpreter included.

                      Interesting. I’m not sure you’ve said enough for me to understand what you did, or how I would port that over to FFI-Platypus. But we’ve probably spent to much time hijacking @michael-vincent’s thread.

                      My initial skim to the intro of the FFI-Platypus docs make it sound like a way to access an external library (DLL) from within Perl; it doesn’t sound like a way to embed Perl into an external DLL. But I’m probably misunderstanding what you’ve said, and/or haven’t read enough of the docs to understand its full capability.

                      If you had the time (not necessarily right now, but in the near future), to write up a more detailed sequence of events of how you did that in python / cffi – probably as a post in the Plugin Development area – with embedded code or links to github code, I might be able to practice that sequence in python until I understand it, then see if I can replicate it in Perl / FFI-Platypus. (And that separate topic would give a place to ask questions of each other, and I could share my eventual Perl version, if anything ever came of it.)

                      EkopalypseE 1 Reply Last reply Reply Quote 1
                      • EkopalypseE
                        Ekopalypse @PeterJones
                        last edited by

                        @PeterJones

                        My initial skim to the intro of the FFI-Platypus docs make it sound like a way to access an external library (DLL) from within Perl

                        was my first thought as well but then I read that it is using libffi, as cffi does, then I thought, ok, so it is just to find out how cffi does this internally and then one should be
                        able to do the same with perl. Hopefully I’m right.

                        But yes, agreed, and sorry @michael-vincent for hijacking, enough off topic :-)

                        I should be able to post a little howto on monday/tuesday next week.

                        1 Reply Last reply Reply Quote 1
                        • Michael VincentM
                          Michael Vincent
                          last edited by

                          No worries - great discussion. I’ve found @PeterJones is my twin apparently:

                          perlmonk XP

                          playing with Perl since the 90s when I started playing with writing cgi scripts for my …edu/~username/ webpage

                          the only compiler I have is the mingw-based gcc that comes with the 32 and 64bit versions of strawberry perl

                          To answer your question - I did install VS2017 Community in order to compile N++ plugins since I could never get the MinGW route working for plugins with dockable components.

                          I too thought of writing a PerlScript plugin by looking at the code for both PythonScript and LuaScript thinking it’d be relatively easy to swap Python | Lua for Perl, but boy was I mistaken! Hats off to those authors, but I’d still love to see PerlScript someday.

                          Cheers.

                          1 Reply Last reply Reply Quote 2
                          • Michael VincentM
                            Michael Vincent
                            last edited by

                            I solved it a different way. Need “manual” intervention, but I can run a simple NppExec script in any document and get the copyright inserted:

                            ::template
                            NPP_CONSOLE keep
                            NPE_CONSOLE -- v+
                            
                            SET LOCAL TEMPLATESDIR = $(NPP_DIRECTORY)\plugins\TEMPLATES
                            SET LOCAL TEMPLATE =
                            
                            IF "$(ARGC)"=="0" GOTO GETINPUT
                            IF "$(ARGC)"=="1" THEN
                                dir $(TEMPLATESDIR)
                                GOTO END
                            ENDIF
                            IF "$(ARGC)">="2" THEN
                                IF "$(ARGV[1])"=="__INPUTBOX__" THEN
                                    GOTO GETINPUT
                                ELSE
                                    SET LOCAL TEMPLATE = $(ARGV[1])
                                ENDIF
                            ENDIF
                            GOTO EXECUTE
                            
                            :GETINPUT
                            INPUTBOX "Template Extension ."
                            IF "{$(INPUT)}"=="{}" THEN
                                cmd /c explorer.exe /e,"$(TEMPLATESDIR)"
                                GOTO END
                            ENDIF
                            SET LOCAL TEMPLATE = $(INPUT)
                            
                            :EXECUTE
                            cmd /c if exist "$(TEMPLATESDIR)\$(TEMPLATE)-TMPL.$(TEMPLATE)" echo "$(TEMPLATESDIR)\$(TEMPLATE)-TMPL.$(TEMPLATE)"
                            IF "$(OUTPUTL)" != "$(TEMPLATESDIR)\$(TEMPLATE)-TMPL.$(TEMPLATE)" GOTO ERROR
                            IF "$(TEMPLATE)"~="COPYRIGHT" THEN
                                SCI_SENDMSG SCI_GETCURRENTPOS
                                SET LOCAL ORIGINALPOS = $(MSG_RESULT)
                                // Lines start at 0, but we want to be under shebang line if exists
                                // so 0, select 2 characters and compare to #!
                                SCI_SENDMSG SCI_GOTOLINE 0
                                SCI_SENDMSG SCI_SETCURRENTPOS 2
                                IF "$(CURRENT_WORD)"=="#!" THEN
                                    SCI_SENDMSG SCI_GOTOLINE 1
                                ELSE
                                    // GOTOLINE clears the previous selection
                                    SCI_SENDMSG SCI_GOTOLINE 0
                                ENDIF
                                SCI_SENDMSG SCI_GETCURRENTPOS
                                SET LOCAL STARTPOS = $(MSG_RESULT)
                                SEL_LOADFROM "$(TEMPLATESDIR)\$(TEMPLATE)-TMPL.$(TEMPLATE)"
                                SCI_SENDMSG SCI_SETSELECTIONSTART $(STARTPOS)
                                NPP_MENUCOMMAND Edit\Comment/Uncomment\Single Line Comment
                                SCI_SENDMSG SCI_GOTOPOS $(ORIGINALPOS)
                            ELSE
                                NPP_OPEN "$(TEMPLATESDIR)\$(TEMPLATE)-TMPL.$(TEMPLATE)"
                                // cd $(SYS.USERPROFILE)
                                NPP_MENUCOMMAND "File\Save As..."
                            ENDIF
                            GOTO END
                            
                            :ERROR
                            NPP_CONSOLE on
                            echo No template for `.$(TEMPLATE)' at:
                            echo $(TEMPLATESDIR)\$(TEMPLATE)-TMPL.$(TEMPLATE)
                            
                            :END
                            NPE_CONSOLE -- v-
                            
                            
                            Alan KilbornA rinku singhR 2 Replies Last reply Reply Quote 4
                            • Alan KilbornA
                              Alan Kilborn @Michael Vincent
                              last edited by

                              @Michael-Vincent

                              Wow. I bet you are also very good at CMD.exe batch file programming! :)

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

                                @Michael-Vincent said:

                                Need “manual” intervention

                                Auto_Populate_x64 plugin
                                Auto_Populate_x86 plugin

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