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.
    • Mia NguyenM
      Mia Nguyen
      last edited by

      Thanks a lot @PeterJones @guy038
      That really highlighted the words. But I can not copy to excel keeping that highlight. It will be normal when i paste to Excel
      Do you know any way i can copy that ?
      Or another question, is there any way i can filter the rows with that highlighted word in NPP?
      Btw, my final purpose here is that i have an excel with some misspelling words inside that can not figure it out, so i copy it into NPP to highlight it out. And then i need to fix in excel finally.

      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:

        Thanks a lot @PeterJones @guy038
        That really highlighted the words. But I can not copy to excel keeping that highlight. It will be normal when i paste to Excel
        Do you know any way i can copy that ?

        It depends on which highlighting you mean. If you mean the normal syntax highlighting, you can use the NppExport plugin to Copy HTML to Clipboard or Copy All Formats to Clipboard; if you paste that into excel, you get the syntax highlighting. However, if you have a plugin like DSpellCheck, which puts squiggles under the misspelled words, you do not get that copied, even with Copy all formats…

        b3f59b14-3551-431b-bb30-6d788f9a47ca-image.png
        96e7d6b1-71e3-4643-bedb-e048dc34ef2b-image.png

        Or another question, is there any way i can filter the rows with that highlighted word in NPP?

        It depends on which highlighting you mean. If you mean the DSpellCheck squiggle highlighting, I don’t know of a way to filter on that. But Plugins > DSpellCheck > Find next misspelling will allow you to navigate between each misspelled word inside Notepad++

        Btw, my final purpose here is that i have an excel with some misspelling words inside that can not figure it out, so i copy it into NPP to highlight it out. And then i need to fix in excel finally.

        I think maybe “copy from Excel to Notepad++; use DSpellCheck to highlight and navigate the misspelled words and then fix them in Notepad++; then copy normally (not using NppExport plugin) and paste back into Excel” would be a possible sequence for you to try.

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

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

          DSpellCheck squiggle highlighting, I don’t know of a way to filter on that

          I did some playing with “PerlScript” but got a little farther with NppExec. It “seems” DSpellCheck uses indicator 19 for its squiggly lines (this is process of elimination, I looked at the DSpellCheck code and couldn’t find any of the Scintilla commands I’d expect would implement this).

          The following “works”:

          NPP_CONSOLE keep
          
          SET LOCAL INDICATOR = 19
          
          SCI_SENDMSG SCI_GETLENGTH
          SET LOCAL END = $(MSG_RESULT)
          
          SET LOCAL I = 0
          SET LOCAL INDICEND = 0
          // FOR
          :LOOP
          
              SCI_SENDMSG SCI_GOTOPOS $(I)
              
              SCI_SENDMSG SCI_INDICATOREND $(INDICATOR) $(I)
              IF "$(MSG_RESULT)"=="0" GOTO END
              
              SET LOCAL INDICSTART = $(MSG_RESULT)
              SCI_SENDMSG SCI_INDICATOREND $(INDICATOR) $(INDICSTART)
              SET LOCAL INDICEND = $(MSG_RESULT)
              
              SET LOCAL I = $(INDICEND)
              IF "$(I)"=="$(END)" GOTO END
          
              ECHO $(INDICSTART) - $(INDICEND)
          
              GOTO LOOP
          
          :END
          

          However, it only seems to get the next squiggly indicator if it’s visible on screen. So in a long document where you’d find a squiggly and then have to page down to find the next one, this script only finds the first. The Scintilla docs don’t describe this limitation so not sure why it’s working that way. Also, using the SCI_GETINDICATORVALUE and SCI_GETINDICATORCURRENT don’t return the value I’d expect for DSpellCheck indicators (which I discovered was 19).

          Obviously if this actually worked, you could use a the Scintilla multiple selection API to highlight the squigglies found as you iterate through the doc.

          Cheers.

          Michael VincentM 1 Reply Last reply Reply Quote 2
          • Michael VincentM
            Michael Vincent
            last edited by

            Also, DSpellCheck has:

            Plugins => DSpellCheck => Additional Actions => Copy All Misspelled Words to Clipboard

            Does that help?

            Cheers.

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

              It seems i can not filter the rows as function is excel. Sad though…lol
              Thanks guys anyway…

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

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

                However, it only seems to get the next squiggly indicator if it’s visible on screen

                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.

                Investigating more with “PerlScript”.

                Cheers.

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

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

                  Investigating more with “PerlScript”.

                  I give up. Using the script to “scroll” through the doc does find more squigglies, but not all of them. I’m pretty sure this is due to a DSpellCheck optimization as I alluded to in previous post. Need to put my own indicators on a large document and see if the SCI_INDICATORSTART/END API finds them all.

                  I tried 2 ways, with SCI_INDICATORSTART/END:

                  #!perl
                  
                  use strict;
                  use warnings;
                  
                  use Time::HiRes qw/sleep/;
                  use Win32::Mechanize::NotepadPlusPlus ':main';
                  
                  my $indicator = 19;
                  my $increment = 750;
                  my ( $indicStart, $indicEnd ) = ( 0, 0 );
                  my $loc = 0;
                  my $end = editor->getLength();
                  my $HELP = 0;
                  while ( $loc < $end ) {
                  
                      if ( not $loc % $increment ) {
                          editor->gotoPos( $loc );
                          sleep 0.5;
                      }
                  
                      $indicStart = editor->indicatorEnd( 19, $loc );
                      if ( $indicStart == 0 ) {
                          $HELP = 1;
                          next;
                      }
                      $indicEnd = editor->indicatorEnd( 19, $indicStart );
                  
                      if ( $indicEnd == $end ) {
                          $HELP = 1;
                          next;
                      }
                      $loc = $indicEnd;
                      print "$indicStart - $indicEnd\n";
                  } continue {
                      if ( $HELP ) {
                          $HELP = 0;
                          $loc = int( $loc / $increment +1 ) * $increment;
                          if ( $loc >= $end ) {
                              last;
                          }
                      }
                  }
                  

                  and with SCI_INDICATORVALUEAT:

                  #!perl
                  
                  use strict;
                  use warnings;
                  
                  use Time::HiRes qw/sleep/;
                  use Win32::Mechanize::NotepadPlusPlus ':main';
                  
                  my $indicator = 19;
                  
                  my $FOUND = 0;
                  for my $loc ( 0 .. editor->getLength() ) {
                  
                      if ( not $loc % 500 ) {
                          editor->gotoPos( $loc );
                          sleep 0.50;
                      }
                      my $iva = editor->indicatorValueAt( $indicator, $loc );
                      if ( $iva and not $FOUND ) {
                          print "$loc";
                          $FOUND = 1;
                      } elsif ( not $iva and $FOUND ) {
                          printf " - %i\n", $loc - 1;
                          $FOUND = 0;
                      }
                  }
                  

                  Cheers.

                  EkopalypseE 1 Reply Last reply Reply Quote 0
                  • 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