Community
    • Login

    How to highlight the underlined squiggle words

    Scheduled Pinned Locked Moved General Discussion
    35 Posts 6 Posters 3.2k 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.
    • guy038G
      guy038
      last edited by guy038

      Hello, @mia-nguyen, @peterjones, @alan-kilborn, @ekopalypse, @michael-vincent and All,

      Two months ago, I asked Sergey Smushin ( aka @Predelnik ), the DSpellCheck’s author, for the following request :

      https://github.com/Predelnik/DSpellCheck/issues/201

      I saw that a commit, referencing that issue, has been added :

      https://github.com/Predelnik/DSpellCheck/commit/9b5e740ce4440669d6daf29ca98d77edd99d466c

      From the moment that any line containing a misspelled word can be bookmarked, it would be easy to gather all these lines for subsequent processes !


      @michael-vincent said :

      Now thinking this is an optimization in DSpellCheck for larger documents - only spell check the visible portions of a large document so the squigglys aren’t added to misspelled words off screen until those words are scrolled on screen which is why a top to bottom document search doesn’t turn up squigglies off screen.

      If so, may be, studying the commit, above, would give some hues about the way, used by @predelnik, to bookmark, in one go, all lines with misspelled words ?

      Just a non-coder thought ;-))

      BR

      guy038

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

        @Michael-Vincent

        I did a quick test and it seems that logic below works

        INDICATOR_TO_SEARCH = 31
        length = editor.getLength()
        start = editor.indicatorStart(INDICATOR_TO_SEARCH, -1)
        end = editor.indicatorEnd(INDICATOR_TO_SEARCH, -1)
        
        real_start = start if editor.indicatorValueAt(INDICATOR_TO_SEARCH, start) else end
        print(start, end, length, real_start)
        
        i = 100
        while real_start != length:
            i -= 1
            if i == 0:
                print('ahhh endless loop - breaking')
                break
            end = editor.indicatorEnd(INDICATOR_TO_SEARCH, real_start)
            print(editor.getTextRange(real_start, end))
            print()
            real_start = editor.indicatorEnd(INDICATOR_TO_SEARCH, end)
        
        Michael VincentM 1 Reply Last reply Reply Quote 1
        • EkopalypseE
          Ekopalypse
          last edited by

          Maybe it is a good idea to check if start != end before executing
          the while loop to see if there has been an indicator found at all
          and to prevent endless loops. :)

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

            @Ekopalypse said in How to highlight the underlined squiggle words:

            logic below works

            Thanks. Converted to PerlScript:

            #!perl
            
            use strict;
            use warnings;
            
            use Win32::Mechanize::NotepadPlusPlus ':main';
            my $npp = notepad();
            
            my $indicator = 19;
            my $length    = editor->getLength();
            my $start     = editor->indicatorStart( $indicator, -1 );
            my $end       = editor->indicatorEnd( $indicator, -1 );
            
            my $real_start;
            
            if ( editor->indicatorValueAt( $indicator, $start ) ) {
                $real_start = $start;
            } else {
                $real_start = $end;
            }
            
            print "$start, $end, $length, $real_start\n";
            
            my $i = 100;
            while ( $real_start != $length ) {
                $i -= 1;
                if ( $i == 0 ) {
                    print "ahhh endless loop - breaking\n";
                    last;
                }
                $end = editor->indicatorEnd( $indicator, $real_start );
                print editor->getTextRange( $real_start, $end ); 
                print "\n";
                $real_start = editor->indicatorEnd( $indicator, $end );
            }
            

            It “works” but same issue, only finding the squigglies on screen. If I scroll down to some new squigglies, it only finds those on screen again (i.e., not the previous ones that were on screen but are no longer). Becoming more convinced this is a DSpellCheck optimization - only squiggly-ing the misspellings on screen.

            Cheers.

            EkopalypseE 2 Replies Last reply Reply Quote 2
            • EkopalypseE
              Ekopalypse @Michael Vincent
              last edited by

              @Michael-Vincent

              hmm, did the test using the mark indicator from find dialog,
              which worked, maybe I should have used/installed dspell plugin.
              Sorry for the noise.

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

                @Ekopalypse said in How to highlight the underlined squiggle words:

                Sorry for the noise.

                No noise at all! In fact you pretty much confirmed it’s a DSpellCheck optimization . I was going to get around to writing a script to add indicators but didn’t know the Find => Mark could do that. Using the same long file I’ve been testing on, I Find => Mark a word I know recurs over 100 times throughout the file and all my scripts (2 previous and the one I converted from your Python example) found more than just those indicators on screen in view.

                Cheers.

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

                  I guess for a plugin like DSpellCheck it makes sense to do its work
                  only for the current screen but on the other side it might be possible
                  to do it in the background as well - but threading and scintilla and npp …
                  maybe an async method would be safer.

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

                    @Michael-Vincent said in How to highlight the underlined squiggle words:

                    Becoming more convinced this is a DSpellCheck optimization

                    I guess you are correct, as to this it checks only the visible area.

                    1 Reply Last reply Reply Quote 2
                    • Mia NguyenM
                      Mia Nguyen
                      last edited by

                      Hi @all ,
                      Me again another doubt. If the word is correct should be legitimate and I right clicked to add into Dictionary, it will be added into my own Npp only.
                      Is there anyway after all i extract the plug in and gave it for other people so they can use on their own Npp ?

                      PeterJonesP 1 Reply Last reply Reply Quote 0
                      • PeterJonesP
                        PeterJones @Mia Nguyen
                        last edited by

                        @Mia-Nguyen said in How to highlight the underlined squiggle words:

                        Hi @all ,
                        Is there anyway after all i extract the plug in and gave it for other people so they can use on their own Npp ?

                        Assuming your language is US-English, it puts it into %AppData%\Notepad++\Plugins\Config\Hunspell\en_US.usr … thus, I would assume that it goes into that same folder, but with the appropriate language code (for whatever spelling language you have selected) as the file basename, with .usr as the extension. So you could distribute that file, which the other users can then merge with their dictionary (assuming they’ve also added words).

                        Mia NguyenM 1 Reply Last reply Reply Quote 3
                        • Mia NguyenM
                          Mia Nguyen @PeterJones
                          last edited by

                          @PeterJones If i send them my .usr file. Can they use directly or have to do anything to merge?

                          PeterJonesP 1 Reply Last reply Reply Quote 0
                          • PeterJonesP
                            PeterJones @Mia Nguyen
                            last edited by

                            @Mia-Nguyen said in How to highlight the underlined squiggle words:

                            @PeterJones If i send them my .usr file. Can they use directly or have to do anything to merge?

                            If they didn’t have any custom words yet, or if you can guarantee that your .usr file has every custom word they’ve already added, then they can just use your file directly. But if they save your .usr file overtop of their old one, then any custom words they had before would be lost.

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

                              …any custom words they had before would be lost.

                              If the .usr file is in text format (don’t know, don’t use the spell-check plugin), perhaps the Compare plugin or a script to perform an automatic merge is called for. Just sayin.

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