Community
    • Login

    Python 3 and Python scripts plugin

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    24 Posts 7 Posters 18.7k 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.
    • chcgC
      chcg
      last edited by

      Latest version of https://sourceforge.net/projects/npppythonscript/files/ is from 2014-09-27 and python 3 was not so popular at that time.

      Bill WinderB 1 Reply Last reply Reply Quote 0
      • Bill WinderB
        Bill Winder @chcg
        last edited by

        @chcg I wonder whether six would allow pyscript to transition to 3. …I have never used six, so I don’t know what I’m asking! (for the moment, npp is pretty restrictive: a 3 installation won’t allow pyscript to be installed…)

        Scott SumnerS 1 Reply Last reply Reply Quote 0
        • guy038G
          guy038
          last edited by guy038

          Hi, @scott-sumner, and All,

          Here are three links, on that eternal question : Python 2.x or Python 3.x !

          The first one is a very interesting article ! See also the comments. As for the third one, it seems more code-oriented.

          Probably, you are already aware of all that stuff, but who knows ?

          http://python-notes.curiousefficiency.org/en/latest/python3/questions_and_answers.html

          https://wiki.python.org/moin/Python2orPython3

          https://docs.python.org/3/whatsnew/3.0.html

          I wish you good reading !

          Cheers,

          guy038

          1 Reply Last reply Reply Quote 0
          • Scott SumnerS
            Scott Sumner @Bill Winder
            last edited by

            @Scott-Sumner said:

            I am looking forward to being enlightened

            And I am enlightened…to your need… Yes, this is one area where Python3 is advantageous over Python2. Fortunately, for myself, I don’t encounter the unicode need very often. Back to the why of Python2 for the Pythonscript plugin, I believe that there were some issues with Scintilla interaction which necessitated (at the time) using Python2 byte-strings versus Python3 unicode strings. I’m sure you can read about all the details of the design decisions on the old Pythonscript Soucreforge forums if you’d like…

            1 Reply Last reply Reply Quote 1
            • dailD
              dail @Bill Winder
              last edited by dail

              @Bill-Winder said:

              And then it became: What!??? pythonscript can only use 2.7? Why?

              @Scott-Sumner said:

              I’m sure you can read about all the details of the design decisions on the old Pythonscript Soucreforge forums if you’d like…

              Discussion from a few years ago which discusses some of the hurdles switching from v2 to v3: https://sourceforge.net/p/npppythonscript/discussion/1188885/thread/cf066585/

              Bill WinderB 1 Reply Last reply Reply Quote 2
              • Bill WinderB
                Bill Winder @dail
                last edited by

                @dail Wow! Hairy!

                I do encounter just that problem in my normal use of npp. I can paste in è or ã and it generally works fine. But when I open or paste in certain texts (like phonetic transcription from espeak), I get o~ where I should get õ. Npp interprets some accent encoding as two characters, not one (works fine here):

                la diskysjˈɔ̃ fˈy syspɑ̃dˈy pɑ̃dˈɑ̃ lə ʁˈɔbʁ
                mɛ bjɛ̃tˈoˈandʁuː styˈaʁ la ʁəpʁənˈɛ

                I have found no way to fix it by shifting the encoding. (Jedit does the same thing…, but notepad does not.)

                Claudia FrankC 1 Reply Last reply Reply Quote 0
                • Claudia FrankC
                  Claudia Frank @Bill Winder
                  last edited by

                  @Bill-Winder said:

                  la diskysjˈɔ̃ fˈy syspɑ̃dˈy pɑ̃dˈɑ̃ lə ʁˈɔbʁ
                  mɛ bjɛ̃tˈoˈandʁuː styˈaʁ la ʁəpʁənˈɛ

                  make sure that the font you use is capable of displaying needed symbols

                  Cheers
                  Claudia

                  Bill WinderB 1 Reply Last reply Reply Quote 3
                  • Bill WinderB
                    Bill Winder @Claudia Frank
                    last edited by

                    @Claudia-Frank Thanks Claudia! – that fixed it, the moment I checked “enable global font”.

                    Thanks! (It’s been bugging me…for a long time…)

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

                      Here is one of possible ways to get the text from an unsaved file tab in NppExec to allow further processing of the text:

                      // temporary file name
                      set local tmpfile = $(SYS.TEMP)\text.txt
                      // current selection
                      sci_sendmsg SCI_GETSELECTIONSTART
                      set local selStart = $(MSG_RESULT)
                      sci_sendmsg SCI_GETSELECTIONEND
                      set local selEnd = $(MSG_RESULT)
                      // select all the text and save it
                      sci_sendmsg SCI_SELECTALL
                      sel_saveto "$(tmpfile)"
                      // restore the selection
                      sci_sendmsg SCI_SETSELECTIONSTART $(selStart)
                      sci_sendmsg SCI_SETSELECTIONEND $(selEnd)
                      // now it's time to process the tmpfile...
                      
                      1 Reply Last reply Reply Quote 1
                      • Vitaliy DovganV
                        Vitaliy Dovgan
                        last edited by

                        Here is more “advanced” version that avoids visible selection change:

                        // temporary file name
                        set local tmpfile = $(SYS.TEMP)\text.txt
                        // disable redrawing
                        sci_sendmsg 0x000B 0 // WM_SETREDRAW FALSE
                        // current selection
                        sci_sendmsg SCI_GETSELECTIONSTART
                        set local selStart = $(MSG_RESULT)
                        sci_sendmsg SCI_GETSELECTIONEND
                        set local selEnd = $(MSG_RESULT)
                        // select all the text and save it
                        sci_sendmsg SCI_SELECTALL
                        sel_saveto "$(tmpfile)"
                        // restore the selection
                        sci_sendmsg SCI_SETSELECTIONSTART $(selStart)
                        sci_sendmsg SCI_SETSELECTIONEND $(selEnd)
                        // enable redrawing
                        sci_sendmsg 0x000B 1 // WM_SETREDRAW TRUE
                        // now it's time to process the tmpfile...
                        
                        1 Reply Last reply Reply Quote 1
                        • Vitaliy DovganV
                          Vitaliy Dovgan
                          last edited by

                          NppExec v0.6 beta 1 will introduce new command TEXT_SAVETO and TEXT_LOADFROM that will work with the whole current text. Apart from that, these commands will be similar to SEL_SAVETO and SEL_LOADFROM.

                          Bill WinderB 1 Reply Last reply Reply Quote 1
                          • guy038G
                            guy038
                            last edited by guy038

                            Hello, @bill-winder, and All,

                            I’m quite late, but I had have to update my list of fonts and to do some tests, in Notepad++, first ;-))

                            So, Bill, here is below, a list of Unicode fonts which can, correctly, display your text example :

                            la diskysjˈɔ̃ fˈy syspɑ̃dˈy pɑ̃dˈɑ̃ lə ʁˈɔbʁ
                            mɛ bjɛ̃tˈoˈandʁuː styˈaʁ la ʁəpʁənˈɛ

                            • The first table concerns Monospaced fonts, where all characters have the same width

                            • The second table concerns Proportional fonts, with variable width


                            Notes :

                            • The Unicode number of code-points, handled by the font, is located in the Glyphs column

                            • The different fonts are sorted out by increasing number of their glyphs

                            • The default regular weight, only, of each font, is listed. The other weights ( Bold, Italic… ) are absent of the tables, below

                            • The Lucida Sans Unicode is certainly already installed on your configuation ( v5.00 or higher )

                            • The Segoe UI family font is probably installed, too ( v5.28 or higher )

                            • For the Ioveska and Ioveska Slab fonts, read very carefully the README.md part, scrolling downwards, because these fonts are highly configurable ! Refer to :

                            https://github.com/be5invis/Iosevka

                            • You may also consult this valuable article, Large, multi-script Unicode fonts for Windows computers, at :

                            http://www.alanwood.net/unicode/fonts.html


                            •------------------------•------------•--------•-----------------------------------------------------------------------------------•
                            |  MONOSPACED Font Name  |   Version  | Glyphs |                                Web Site Link                                      |
                            •------------------------•------------•--------•-----------------------------------------------------------------------------------•
                            | Linux Libertine Mono   |   v5.17    |  1,021 | http://www.linuxlibertine.org                                                     |
                            | SourceCodePro          |   v2.030   |  1,585 | https://github.com/adobe-fonts/source-code-pro/releases/tag/2.030R-ro%2F1.050R-it |
                            | DejaVu Sans Mono       |   v2.37    |  3,377 | https://dejavu-fonts.github.io/Download.html                                      |
                            |                        |            |        |                                                                                   |
                            | Iosevka                |   v1.14.0  |  3,654 | https://github.com/be5invis/Iosevka/releases                                      |
                            | Iosevka Slab           |   v1.14.0  |  3,654 | https://github.com/be5invis/Iosevka/releases                                      |
                            |                        |            |        |                                                                                   |
                            | FreeMono               | v0412.2268 |  4,177 | http://ftp.gnu.org/gnu/freefont/freefont-ttf-20120503.zip                         |
                            •------------------------•------------•--------•-----------------------------------------------------------------------------------•
                            
                            •------------------------•------------•--------•-----------------------------------------------------------------------------------•
                            | PROPORTIONAL Font Name |   Version  | Glyphs |                                Web Site Link                                      |
                            •------------------------•------------•--------•-----------------------------------------------------------------------------------•
                            | Lucida Sans Unicode    |   v2.00    |  1,776 | https://fr.ffonts.net/Lucida-Sans-Unicode.font.zip                                |
                            | Lucida Sans Unicode    |   v5.00    |  1,779 | Usually installed in Windows 8 and higher                                         |
                            |                        |            |        |                                                                                   |
                            | Linux Biolinum         |   v1.1.8   |  2,403 | http://www.linuxlibertine.org                                                     |
                            | Linux Libertine        |   v5.3.0   |  2,676 | http://www.linuxlibertine.org                                                     |
                            |                        |            |        |                                                                                   |
                            | SegoeUI                |   v5.05    |  2,901 | https://github.com/KingRider/frontcom/tree/master/css/fonts                       |
                            | SegoeUI                |   v5.28    |  4,516 | Usually installed in Windows 8 and higher                                         |
                            |                        |            |        |                                                                                   |
                            | Junicode               |   v0.78    |  3,286 | http://sourceforge.net/projects/junicode                                          |
                            |                        |            |        |                                                                                   |
                            | DejaVuSerif            |   v2.37    |  3,528 | https://dejavu-fonts.github.io/Download.html                                      |
                            | DejaVuSans             |   v2.37    |  6,253 | https://dejavu-fonts.github.io/Download.html                                      |
                            |                        |            |        |                                                                                   |
                            | FreeIdgSerif           |   v1.52    |  6,256 | https://en.m.fontke.com/font/10352047/download/                                   |
                            |                        |            |        |                                                                                   |
                            | FreeSans               | v0412.2268 |  6,272 | http://ftp.gnu.org/gnu/freefont/freefont-ttf-20120503.zip                         |
                            | FreeSerif              | v0412.2263 | 10,538 | http://ftp.gnu.org/gnu/freefont/freefont-ttf-20120503.zip                         |
                            |                        |            |        |                                                                                   |
                            | Quivira                |   v4.1     | 10,486 | http://www.quivira-font.com                                                       |
                            |                        |            |        |                                                                                   |
                            | Arial Unicode MS       |   v1.01    | 50,377 | https://www.wfonts.com/font/arial-unicode-ms                                      |
                            |                        |            |        |                                                                                   |
                            | Code 2000              |   v1.171   | 63,546 | http://www.fontspace.com/james-kass/code2000                                      |
                            •------------------------•------------•--------•-----------------------------------------------------------------------------------•
                            

                            Best Regards,

                            guy038

                            Bill WinderB 1 Reply Last reply Reply Quote 0
                            • Bill WinderB
                              Bill Winder @Vitaliy Dovgan
                              last edited by

                              @Vitaliy-Dovgan Thanks! Good work around. There must be somewhere direct access to an unsaved tab, because I can close npp with an unsaved tab and when I reopen, it is there. So the unsaved tab is actually saved somewhere. Curious!

                              Scott SumnerS 1 Reply Last reply Reply Quote 0
                              • Scott SumnerS
                                Scott Sumner @Bill Winder
                                last edited by

                                @Bill-Winder said:

                                So the unsaved tab is actually saved somewhere.

                                Yes, saved under a “Backup” folder by default. I just made 5 “new files” and they were created in this folder with the following names:

                                new 1@2018-02-19_155611
                                new 2@2018-02-19_155613
                                new 3@2018-02-19_155613
                                new 4@2018-02-19_155615
                                new 5@2018-02-19_155618
                                
                                Bill WinderB 1 Reply Last reply Reply Quote 0
                                • Bill WinderB
                                  Bill Winder @guy038
                                  last edited by

                                  @guy038 Very cool! I just chose fonts at random until things looked right. Useful description, which will serve elsewhere also – same issue in Jedit. (Though I use Jedit less and less - npp has everything I need and is very fast.)

                                  1 Reply Last reply Reply Quote 0
                                  • Bill WinderB
                                    Bill Winder @Scott Sumner
                                    last edited by

                                    @Scott-Sumner and they are numbered! Perfect. Which essentially solves my problem.

                                    I hope! There is one further step. I will have to capture the name of the active tab and give it to NPPEXec.

                                    But that should be possible through the sci_sendmessage function (will look into that), since this is possible:

                                    sci_sendmsg SCI_GETSELECTIONSTART
                                    set local selStart = $(MSG_RESULT)

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