Community
    • 登入

    Multi-cursor editing

    已排程 已置頂 已鎖定 已移動 Help wanted · · · – – – · · ·
    53 貼文 8 Posters 12.6k 瀏覽
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • astrosofistaA
      astrosofista @Alan Kilborn
      最後由 編輯

      @Alan-Kilborn

      Good to know, thank you :)

      1 條回覆 最後回覆 回覆 引用 2
      • astrosofistaA
        astrosofista @Ekopalypse
        最後由 編輯

        @Ekopalypse

        Thank you :)

        1 條回覆 最後回覆 回覆 引用 1
        • astrosofistaA
          astrosofista @astrosofista
          最後由 編輯

          @astrosofista said in Multi-cursor editing:

          @Ekopalypse said in Multi-cursor editing:

          Ooopppss - did not happen to me yet.
          Is it possible that a very, very large amount of data had to be selected?

          No, it wasn’t. It was late and I’m sorry but can’t exactly remember what was the selection to be made, surely the target were partial words. But don’t worry, maybe the issue had other causes. If I can reproduce it will let you know.

          Hi @Ekopalypse, All

          I think I found the mentioned issue. When a character as a comma (,) is selected —shown at the top of the posted imagen— the Python script works as expected, but things go weird when you select a period or a dot (.) and run the PS —at the bottom of the imagen—, as the multiselection now encompass all the characters of the document:

          7a7f19be-6d48-43ac-9f67-2a8aec81009d-imagen.png

          Hope this helps.

          Alan KilbornA 1 條回覆 最後回覆 回覆 引用 2
          • Alan KilbornA
            Alan Kilborn @astrosofista
            最後由 Alan Kilborn 編輯

            @astrosofista

            Apparently the script is treating the . as the regular expression for “any single character”. Thus, when the script is run with only a . character selected, you get a blinking (if so configured) caret at every position in the doc. This script modification corrects it:

            from Npp import editor
            first_line = editor.getFirstVisibleLine()
            editor.setSearchFlags(0)          # <---------- the new line
            editor.setTarget(0, editor.getTextLength())
            editor.multipleSelectAddEach()
            editor.rotateSelection()
            editor.setFirstVisibleLine(first_line)
            

            I’m not sure of the complete set of possible arguments to .setSearchFlags() – it is not documented so well in the P.S. docs–but I found these in the Notepad++ source code:

            #define SCFIND_NONE 0x0
            #define SCFIND_WHOLEWORD 0x2
            #define SCFIND_MATCHCASE 0x4
            #define SCFIND_WORDSTART 0x00100000
            #define SCFIND_REGEXP 0x00200000
            #define SCFIND_POSIX 0x00400000
            #define SCFIND_CXX11REGEX 0x00800000
            

            My modification to the script is using SCFIND_NONE.

            astrosofistaA 1 條回覆 最後回覆 回覆 引用 2
            • astrosofistaA
              astrosofista @Alan Kilborn
              最後由 編輯

              @Alan-Kilborn

              Definitively regex, or at least some of its functions are invoked in the original PS. I typed an \s at the end of the first paragraph —I mean the GNU License sample text—, then selected the backslash, run the script, then the s and the script… PS ignored single characters and only take into consideration whole words, so when I selected the first T, PS did nothing, but This was selected and PS correctly matched the other two instances of the word.

              Anyway, the script modification you provided solved the issue. A big thanks for your assistance and fast reply.

              Best Regards.

              1 條回覆 最後回覆 回覆 引用 2
              • EkopalypseE
                Ekopalypse
                最後由 編輯

                @astrosofista @Alan-Kilborn

                Thanks for testing and improving.
                I haven’t noticed it yet but it makes sense.
                The documentation for searchFlags is described here.

                Alan KilbornA astrosofistaA 2 條回覆 最後回覆 回覆 引用 2
                • Alan KilbornA
                  Alan Kilborn @Ekopalypse
                  最後由 編輯

                  @Ekopalypse said in Multi-cursor editing:

                  The documentation for searchFlags is described here.

                  Yes but that documentation falls flat when you need an actual number to pass to a function!

                  Is there some Python magic one can do to find these identifiers? What I mean is, if I do dir(MENUCOMMAND) in the P.S. console, I see:

                  >>> dir(MENUCOMMAND)
                  ['CLEAN_RECENT_FILE_LIST', 'EDIT_AUTOCOMPLETE', 'EDIT_AUTOCOMPLETE_CURRENTFILE', 'EDIT_AUTOCOMPLETE_PATH', 'EDIT_BEGINENDSELECT', ...
                  

                  Some similar way of finding these “SCFIND_” things?

                  EkopalypseE 1 條回覆 最後回覆 回覆 引用 0
                  • EkopalypseE
                    Ekopalypse @Alan Kilborn
                    最後由 編輯

                    @Alan-Kilborn

                    for readability you normally use FINDOPTION.NONE instead of the 0.
                    In order to get all values from such enum you can call its values method.
                    For example: FINDOPTION.values() would return

                    {0: Npp.FINDOPTION.NONE, 1048576: Npp.FINDOPTION.WORDSTART, 2: Npp.FINDOPTION.WHOLEWORD, 4: Npp.FINDOPTION.MATCHCASE, 2097152: Npp.FINDOPTION.REGEXP, 8388608: Npp.FINDOPTION.CXX11REGEX, 4194304: Npp.FINDOPTION.POSIX}
                    
                    
                    Alan KilbornA 2 條回覆 最後回覆 回覆 引用 2
                    • Alan KilbornA
                      Alan Kilborn @Ekopalypse
                      最後由 Alan Kilborn 編輯

                      @Ekopalypse said in Multi-cursor editing:

                      for readability you normally use FINDOPTION.NONE instead of the 0.

                      Yes, but you have to know that EXISTS first! :-)

                      To your point about “readability”…that’s why I was asking.
                      I would much rather NOT use the magic number of zero.

                      I didn’t see anything that logically links FINDOPTION to the SCFIND nomenclature. Maybe I missed the connection.

                      1 條回覆 最後回覆 回覆 引用 0
                      • Alan KilbornA
                        Alan Kilborn @Ekopalypse
                        最後由 Alan Kilborn 編輯

                        @Ekopalypse said in Multi-cursor editing:

                        For example: FINDOPTION.values() would return

                        Just a slight note for any future readers:

                        FINDOPTION.values() at the Pythonscript console yields:

                        >> FINDOPTION.values()
                        Traceback (most recent call last):
                          File "<console>", line 1, in <module>
                        TypeError: 'dict' object is not callable
                        

                        The proper thing to do is FINDOPTION.values (no parentheses).

                        1 條回覆 最後回覆 回覆 引用 2
                        • EkopalypseE
                          Ekopalypse
                          最後由 編輯

                          Ooopps - you are right, thx for reporting.
                          Seems I have wrapped it incorrectly with my python3 plugin.

                          Yes, not every enum has really the same, but most of the time similar, name as the normal c-headers have.
                          To get all the enums you can run globals() in the console or from a script.

                          Alan KilbornA 1 條回覆 最後回覆 回覆 引用 1
                          • Alan KilbornA
                            Alan Kilborn @Ekopalypse
                            最後由 編輯

                            @Ekopalypse said in Multi-cursor editing:

                            my python3 plugin.

                            gimme, Gimme, GIMME! :-)

                            1 條回覆 最後回覆 回覆 引用 2
                            • EkopalypseE
                              Ekopalypse
                              最後由 編輯

                              I’m sorry, but it’s still an alpha version.
                              As long as not all functions/methods work as described
                              you’re not really gonna enjoy it.
                              Had a nasty plugin crash yesterday because instead using
                              an signed integer I used an unsigned one. :-(

                              But there will be fewer and fewer open issues.
                              And since I was wrong with the release date several times,
                              I prefer not to give a forecast until when a beta version can be expected.

                              The actual situation, Corona, has one advantage - I have more time to work on PySnack (That’s what I want to call it).

                              1 條回覆 最後回覆 回覆 引用 3
                              • astrosofistaA
                                astrosofista @Ekopalypse
                                最後由 編輯

                                @Ekopalypse said in Multi-cursor editing:

                                Thanks for testing and improving.

                                Glad to be of help. Let me know if more tests are needed.

                                Best Regards.

                                1 條回覆 最後回覆 回覆 引用 1
                                • Michael VincentM
                                  Michael Vincent @dail
                                  最後由 編輯

                                  @dail said in Multi-cursor editing:

                                  I use BetterMultiSelection

                                  As do I - along with SurroundSelection and DoxyIt. Do you still support DoxyIt, I submitted a pull request a little while back.

                                  Cheers.

                                  dailD 1 條回覆 最後回覆 回覆 引用 0
                                  • dailD
                                    dail @Michael Vincent
                                    最後由 編輯

                                    @Michael-Vincent

                                    Personally I haven’t used DoxyIt in years. I wouldnt say it’s not supported, just my interest is quite lacking.

                                    In light of recent circumstances I find myself with copious amounts of free time currently, so I will make it a point to take a look at your PR soon.

                                    1 條回覆 最後回覆 回覆 引用 4
                                    • 第一個貼文
                                      最後的貼文
                                    The Community of users of the Notepad++ text editor.
                                    Powered by NodeBB | Contributors