• Login
Community
  • Login

[vi simulator] how to highlight a word

Scheduled Pinned Locked Moved Notepad++ & Plugin Development
55 Posts 5 Posters 61.3k 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.
  • C
    Claudia Frank @dail
    last edited by Dec 6, 2016, 6:23 PM

    @dail - thank you for clarification.

    Yes but indicators should only get removed when editor.indicatorClearRange() is called, and assuming the Python code is only ran 1 time, then editor.indicatorClearRange() should only ever be called once…even if it is running asynchronously.

    From my test

    it looks like that some found items were not colored instead of the previous are cleared as shown
    by Scotts gif. To be honest, I didn’t really test if the uncolored once are reported as found - I will do so.

    Cheers
    Claudia

    S 1 Reply Last reply Dec 6, 2016, 6:40 PM Reply Quote 0
    • S
      Scott Sumner @Claudia Frank
      last edited by Dec 6, 2016, 6:40 PM

      @Claudia-Frank

      At one point I had some code in there to count the "if"s so that I could make sure they were all found by the search function…and I always saw a consistent and correct count.

      C 1 Reply Last reply Dec 6, 2016, 7:15 PM Reply Quote 0
      • C
        Claudia Frank @Scott Sumner
        last edited by Dec 6, 2016, 7:15 PM

        @Scott-Sumner

        I can confirm, I run it 100 times and it always reported it correctly but there is another strange thing
        as soon as I put a print statement (which needs sys.stdout = console redirection) into the while loop I always get all "if"s colored. I even can now put the setIndicatorCurrent out of the loop.

        else:
            endPos = editor.getTextLength()
            temp = editor.findText(FINDOPTION.WHOLEWORD | FINDOPTION.MATCHCASE, 0, endPos, 'if')
            editor.setIndicatorCurrent(indicator)
            console.clear()
            while temp != None:
                print temp
                (s, e) = temp
                editor.indicatorFillRange(s, e - s)
                temp = editor.findText(FINDOPTION.WHOLEWORD | FINDOPTION.MATCHCASE, e, endPos, 'if')  
        print 'Done'
        

        First I thought about a timing issue but replacing the print statement with another time consuming action brings back the issue so … ???

        Cheers
        Claudia

        S 1 Reply Last reply Dec 6, 2016, 7:19 PM Reply Quote 0
        • S
          Scott Sumner @Claudia Frank
          last edited by Dec 6, 2016, 7:19 PM

          @Claudia-Frank

          Noticed that, too…sorry I didn’t mention it. :-)

          C 1 Reply Last reply Dec 6, 2016, 8:47 PM Reply Quote 0
          • C
            Claudia Frank @Scott Sumner
            last edited by Dec 6, 2016, 8:47 PM

            @Scott-Sumner, @dail

            I guess I found the reason. It’s basically what we already assumed. Npp is stepping in.
            During debugging I noticed, that sometime indicator was reset to value 29 (in such a case it was always 29),
            which, afaik, is used by smart highlighting.
            Albeit following code worked by 100 consecutive runs always, there is a potential risk that it fails again.

            endPos = editor.getTextLength()
            temp = editor.findText(FINDOPTION.WHOLEWORD | FINDOPTION.MATCHCASE, 0, endPos, 'if')
            editor.setIndicatorCurrent(indicator)
            while temp != None:
                (s, e) = temp
                editor.indicatorFillRange(s, e - s)
                if editor.getIndicatorCurrent() != indicator:
                    # print 'getIndicatorCurrent:{}'.format(editor.getIndicatorCurrent())
                    editor.setIndicatorCurrent(indicator)
                    editor.indicatorFillRange(s, e - s)
                temp = editor.findText(FINDOPTION.WHOLEWORD | FINDOPTION.MATCHCASE, e, endPos, 'if')
            

            Cheers
            Claudia

            1 Reply Last reply Reply Quote 0
            • C
              Claudia Frank
              last edited by Dec 6, 2016, 8:51 PM

              By the way, disabling smart highlighting doesn’t solve the issue because than another set indicator jumps in.

              Cheers
              Claudia

              1 Reply Last reply Reply Quote 0
              • D
                dail
                last edited by Dec 6, 2016, 11:45 PM

                another set indicator jumps in.

                Probably the xml tag highlighting.

                C 1 Reply Last reply Dec 7, 2016, 3:33 PM Reply Quote 0
                • C
                  Claudia Frank @dail
                  last edited by Dec 7, 2016, 3:33 PM

                  @dail

                  correct, if we disable smart and matching tags highlighting then it works as expected
                  but this, at least for me, isn’t desirable.

                  Cheers
                  Claudia

                  1 Reply Last reply Reply Quote 0
                  • D
                    dail
                    last edited by Dec 7, 2016, 3:37 PM

                    @Claudia-Frank

                    but this, at least for me, isn’t desirable

                    Oh I totally agree, it was just to prove it was caused by N++ :)

                    1 Reply Last reply Reply Quote 1
                    • J
                      Js jS
                      last edited by Jan 29, 2017, 9:34 PM

                      This post is deleted!
                      1 Reply Last reply Reply Quote 0
                      • J
                        Js jS
                        last edited by Js jS Jan 29, 2017, 9:43 PM Jan 29, 2017, 9:40 PM

                        run this with the “if” block on screen
                        and again with the “if” block off screen

                        same result on “normal text” file

                        the “if” block has to be added

                        gets flagged as spam if i include it

                        from timeit import default_timer as timer
                        
                        indicator = 12  # not sure what one is best to use but this works
                        editor.indicSetStyle       (indicator, INDICATORSTYLE.ROUNDBOX)
                        editor.indicSetAlpha       (indicator,  55)
                        editor.indicSetOutlineAlpha(indicator, 255)
                        
                        first =  726
                        last  = 2260 
                        
                        start = timer()
                        for s in range( first, last, 3):
                            a=s
                            editor.setIndicatorCurrent(indicator)
                            editor.indicatorFillRange(s, 2)
                        
                        end = timer()
                        console.write("4:\t%f\n" % (end - start))
                          
                        start = timer()
                        for s in range( first, last, 3):
                            a=s
                            editor.setIndicatorCurrent(indicator)
                            editor.indicatorClearRange(s, 2)
                        
                        end = timer()
                        console.write("5:\t%f\n" % (end - start))
                        
                        1 Reply Last reply Reply Quote 0
                        • J
                          Js jS
                          last edited by Js jS Jan 29, 2017, 9:55 PM Jan 29, 2017, 9:52 PM

                          forgot to mention …

                          open python console

                          turning off brace matching and smart highlighting makes no difference

                          npp 7.3.1 32 bit windows7 64bit

                          1 Reply Last reply Reply Quote 0
                          • J
                            Js jS
                            last edited by Jan 29, 2017, 10:11 PM

                            addendum:

                            moving the mouse during the script execution causes misses in highlighting

                            C S 2 Replies Last reply Jan 29, 2017, 10:58 PM Reply Quote 0
                            • C
                              Claudia Frank @Js jS
                              last edited by Jan 29, 2017, 10:58 PM

                              @Js-jS

                              for me it is hard to see to whom you want to address to.
                              May I ask you to add the name of the recipients to your post?
                              Concerning the post, I’m not quite sure what you try to impart.
                              Are you surprised about time differences?

                              Cheers
                              Claudia

                              1 Reply Last reply Reply Quote 0
                              • S
                                Scott Sumner @Js jS
                                last edited by Jan 30, 2017, 12:21 AM

                                @Js-jS

                                I, too, am confused about what you are trying to demonstrate here. I’m more inclined to try code out if there is also a clear description about what it is doing that is odd or interesting. After reading such a description, I can decide if I want to try the code out or not (if there is something about it that is interesting to me…). Anyway, we kind of beat to death the “highlighting IFs” situation a couple of months ago…not sure what new there is to take away from it.

                                1 Reply Last reply Reply Quote 0
                                • J
                                  Js jS
                                  last edited by Jan 30, 2017, 12:25 AM

                                  i was just adding my findings, in case anyone was still looking at this issue

                                  my knowledge is fairy limited, so i have not arrived to any real conclusion about the reason for the 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