• Login
Community
  • Login

Multi-cursor editing

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
53 Posts 8 Posters 8.6k 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.
  • E
    Ekopalypse @astrosofista
    last edited by Mar 30, 2020, 11:19 AM

    @astrosofista said in Multi-cursor editing:

    … almost all the time

    Ooopppss - did not happen to me yet.
    Is it possible that a very, very large amount of data had to be selected?
    I have done a small performance/stress test using this script to generate the test data.

    editor.appendText('This is a teest to see if it works\r\n'*100000)

    It took about 1 minute, on my PC, until all 100_000 instances were selected.
    For a test with 1000 instances, which in my opinion is still not
    a real world test - I mean, who has 1000 instances of the same word
    in their source code? - it actually selected it immediately.

    @guy038 , @Alan-Kilborn

    I ASSUME one of it, guess which one, is for the plugin admin,
    maybe a naming thing?? But of course, if both are the same then the
    non-plugin-admin version could have been deleted.

    Python27 should be loadable from within plugin directory.
    There was a change in npp source which allows plugins now to find
    their needed dlls within its directory.

    A 1 Reply Last reply Mar 30, 2020, 4:27 PM Reply Quote 2
    • G
      guy038
      last edited by guy038 Mar 30, 2020, 2:11 PM Mar 30, 2020, 12:07 PM

      Hello, @czmaniak, @alan-kilborn, @peterjones, @ekopalypse, @astrosofista,

      Regarding the Python problem, I deleted my Python install and re-installed the plugin with, unfortunately, the same result. My python27.dll library has version 2.7.17150.1013 and contains 2,649,600 bytes. But, never minds : it should be related to my old Win-XP laptop !!


      Now, Alan, assuming the text,below :

      123
      456789
      
      12 56498><717 5123 131
      21 78483><000 0456 235
      16 89410><575 5156 464
      97 89411><056 6045 454
      01 25822><644 8970 544
      
      123
      456789
      
      12 56498><717 5123 131
      21 78483><000 0456 235
      16 89410><575 5156 464
      97 89411><056 6045 454
      01 25822><644 8970 544
      
      123
      456789
      

      I did your test, without any plugin, involved :

      • I placed a caret, between the > and < chars inside the first block, so 5 ones, using the Ctrl key

      • Then, hitting 9 times on the Down arrow, only, I obtained exactly what you got !

      • Now, cancel any null selection

      • Create a normal column selection, between the > and < chars of the first block

      • Then, hitting 9 times on the Down arrow, only, anunique cursor was present on the 5th line of the second block


      • Now, enable the BetterMultiSelection plugin

      • Place a caret, between the > and < chars inside the first block, so 5 ones, using the Ctrl key

      • If you hit 9 times on the Down arrow, only, this time, the 5 carets are correctly located, between the > and < chars of the second block of five lines :-))

      • Cancel any null selection

      • Create a normal column selection, between the > and < chars of the first block

      • If you hit 9 times on the Down arrow, only, again, the 5 carets are correctly located, between the > and < chars of the second block of five lines :-))

      So, the @dail’s BetterMultiSelection plugin is definitively a must and should be installed and enabled every time ;-))


      IMPORTANT : To cancel any complicated number of selections, resulting of the use of the BetterMultiSelection plugin, simply hit the ESC key !

      Cheers,

      guy038

      E A 2 Replies Last reply Mar 30, 2020, 12:21 PM Reply Quote 1
      • E
        Ekopalypse @guy038
        last edited by Mar 30, 2020, 12:21 PM

        @guy038

        Ahh, yes - this was one of the reason to drop XP support as this
        API is not supported by XP.

        1 Reply Last reply Reply Quote 2
        • A
          astrosofista @Ekopalypse
          last edited by Mar 30, 2020, 4:27 PM

          @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.

          Best Regards

          A 1 Reply Last reply Apr 5, 2020, 12:14 AM Reply Quote 2
          • A
            astrosofista @guy038
            last edited by Mar 30, 2020, 6:38 PM

            @guy038, @alan-kilborn, All

            I tried to replicate your tests as long as I understood them, with just Notepad++ basic multiselection feature, that is, disabling the BMS plugin and without running Ekopalypse PS:

            Giphy

            In the first test I created a null selection column by pressing Shift + Alt + Down Arrow 5 times. As soon as I moved the caret down with an arrow key, the multiselection got lost. End of test.

            Second test. Created a null selection column pressing Cntrl + Click 5 times. Moved it down and arrived to line 14 with 5 cursors but misalignated. To resolve this unwanted result hit End and all the 5 cursors aligned at the end lines —or hit Home to get a similar output—. Then went up and got the same as before.

            Conclusion: It matters how the multiselection is created. I’m really puzzled.

            Best Regards

            E 1 Reply Last reply Mar 30, 2020, 7:30 PM Reply Quote 1
            • E
              Ekopalypse @astrosofista
              last edited by Mar 30, 2020, 7:30 PM

              @astrosofista

              scintilla knows and uses different selection modes .

              By using SHIFT+ALT+ARROWDOWN/UP you are creating a rectangular selection. By using CTRL+mouse_click you are creating the stream mode.

              A 1 Reply Last reply Mar 30, 2020, 8:40 PM Reply Quote 4
              • A
                astrosofista @Ekopalypse
                last edited by Mar 30, 2020, 8:40 PM

                @Ekopalypse

                -Thank you. I was unaware of these different modes of selection, considered them as an unique mode, without any difference.

                So the selection mode that is created by means of your Python plugin, for example, like in the gif animation you uploaded to this thread two days ago, seems to be a stream mode. Am I right?

                A E 2 Replies Last reply Mar 30, 2020, 8:53 PM Reply Quote 2
                • A
                  Alan Kilborn @astrosofista
                  last edited by Mar 30, 2020, 8:53 PM

                  @astrosofista said in Multi-cursor editing:

                  So the selection mode that is created by means of (PythonScript) plugin…seems to be a stream mode.

                  It’s not explicit in the Python code presented, but most of the P.S. functions that deal with creating selections assume you want stream mode. There are only a few functions that allow you to create column-block selections:

                  editor.setRectangularSelectionAnchor()
                  editor.setRectangularSelectionAnchorVirtualSpace()
                  editor.setRectangularSelectionCaret()
                  editor.setRectangularSelectionCaretVirtualSpace()
                  
                  A 1 Reply Last reply Mar 30, 2020, 10:28 PM Reply Quote 4
                  • E
                    Ekopalypse @astrosofista
                    last edited by Mar 30, 2020, 9:30 PM

                    @astrosofista said in Multi-cursor editing:

                    Am I right?

                    Yes. :-)

                    A 1 Reply Last reply Mar 30, 2020, 10:31 PM Reply Quote 1
                    • A
                      astrosofista @Alan Kilborn
                      last edited by Mar 30, 2020, 10:28 PM

                      @Alan-Kilborn

                      Good to know, thank you :)

                      1 Reply Last reply Reply Quote 2
                      • A
                        astrosofista @Ekopalypse
                        last edited by Mar 30, 2020, 10:31 PM

                        @Ekopalypse

                        Thank you :)

                        1 Reply Last reply Reply Quote 1
                        • A
                          astrosofista @astrosofista
                          last edited by Apr 5, 2020, 12:14 AM

                          @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.

                          A 1 Reply Last reply Apr 5, 2020, 2:22 AM Reply Quote 2
                          • A
                            Alan Kilborn @astrosofista
                            last edited by Alan Kilborn Apr 5, 2020, 2:23 AM Apr 5, 2020, 2:22 AM

                            @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.

                            A 1 Reply Last reply Apr 5, 2020, 3:57 AM Reply Quote 2
                            • A
                              astrosofista @Alan Kilborn
                              last edited by Apr 5, 2020, 3:57 AM

                              @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 Reply Last reply Reply Quote 2
                              • E
                                Ekopalypse
                                last edited by Apr 5, 2020, 9:45 AM

                                @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.

                                A A 2 Replies Last reply Apr 5, 2020, 12:01 PM Reply Quote 2
                                • A
                                  Alan Kilborn @Ekopalypse
                                  last edited by Apr 5, 2020, 12:01 PM

                                  @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?

                                  E 1 Reply Last reply Apr 5, 2020, 12:23 PM Reply Quote 0
                                  • E
                                    Ekopalypse @Alan Kilborn
                                    last edited by Apr 5, 2020, 12:23 PM

                                    @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}
                                    
                                    
                                    A 2 Replies Last reply Apr 5, 2020, 12:37 PM Reply Quote 2
                                    • A
                                      Alan Kilborn @Ekopalypse
                                      last edited by Alan Kilborn Apr 5, 2020, 12:38 PM Apr 5, 2020, 12:37 PM

                                      @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 Reply Last reply Reply Quote 0
                                      • A
                                        Alan Kilborn @Ekopalypse
                                        last edited by Alan Kilborn Apr 5, 2020, 12:47 PM Apr 5, 2020, 12:44 PM

                                        @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 Reply Last reply Reply Quote 2
                                        • E
                                          Ekopalypse
                                          last edited by Apr 5, 2020, 12:54 PM

                                          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.

                                          A 1 Reply Last reply Apr 5, 2020, 12:57 PM Reply Quote 1
                                          38 out of 53
                                          • First post
                                            38/53
                                            Last post
                                          The Community of users of the Notepad++ text editor.
                                          Powered by NodeBB | Contributors