Skip to content

Fix smarthighlight#187

Closed
Cyrillev91 wants to merge 1 commit intonotepad-plus-plus:masterfrom
Cyrillev91:master
Closed

Fix smarthighlight#187
Cyrillev91 wants to merge 1 commit intonotepad-plus-plus:masterfrom
Cyrillev91:master

Conversation

@Cyrillev91
Copy link
Copy Markdown
Contributor

Hi,
With notepad++ it is possible to select the entire word when double click on word, all words selected are highlight (smart Highlight).
But code to select word by double click is not the same as smart highlight feature.
My commit Fix smarthighlight.

more explain :
http://sourceforge.net/p/notepad-plus/patches/652/

Cyrillev

because isQualifiedWord use hardcode and no SCI_GETWORDCHARS smarthighlight is not always OK.
This Fix use SCI_GETWORDCHARS.
@Cyrillev91 Cyrillev91 changed the title Change isQualifiedWord Fix smarthighlight Jun 12, 2015
@Cyrillev91
Copy link
Copy Markdown
Contributor Author

hi,
In npp you can select a word by double click.
A word contain only WordChars (A, B, ...Z, a, ..., z, and many other : use scintilla function SCI_GETWORDCHARS for complet list) not contain PunctuationChars (!"#$%&'()*+,-./:;<=>?@[]^`{|}~DEL) and not contain WhitespaceChar (SOH STX ETX EOT ENQ ACK BEL BS HT VT FF SO SI DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US SPACE)
To obtain list of char use scintilla function : SCI_GETWORDCHARS , SCI_GETPUNCTUATUATIONCHARS and GET_GETWHITHSPACE)

In smarthighlight the punctuationChar and WhiteSpaceChar are hardcode don't use SCI_GETxxxxxCHARS function) and forgets grave accent.

It is also possible to change the lists with setWordChars, setPunctuationChars or setWhiteChars (with Python script plugins for example)

This Fix #187 use scintilla function in smarthighlight function.
it 's OK with grave accent : http://sourceforge.net/p/notepad-plus/bugs/5339/
And it's OK if you use setWordChars to add or remove char.

Cyrillev91

@Cyrillev91
Copy link
Copy Markdown
Contributor Author

Test :
smarthighlight_test

@milipili milipili added the enhancement Proposed enhancements of existing features label Aug 7, 2015
@donho
Copy link
Copy Markdown
Member

donho commented Oct 4, 2015

@Cyrillev91 It's interesting your modification, but I don't see any change and advantage for an end-user. Care to elaborate it?

@donho donho added the accepted label Oct 15, 2015
@donho donho closed this in 037b41e Oct 15, 2015
@Eldaw
Copy link
Copy Markdown

Eldaw commented Oct 17, 2015

@Cyrillev91 Now that this has been merged into v6.8.4., how can I get the smart highlighting to work like in the last column of your test? Right now, the smart highlighting is still working like it always has, and if I select END-OF-FILE then it doesn't highlight other instances of END-OF-FILE.

@Cyrillev91
Copy link
Copy Markdown
Contributor Author

@Eldaw Hi,

  1. install python script : http://npppythonscript.sourceforge.net/
  2. create script with python script (plugings >> Python script >> New scrip) with :
def extendWordChar(args):
    word_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$-"
    for i in range(128,256):
        word_chars += chr(i)
    editor.setWordChars(word_chars)
notepad.callback(extendWordChar, [NOTIFICATION.BUFFERACTIVATED, NOTIFICATION.READY])
  1. save script
  2. run script
  3. close and re-open file or change active tab file
  4. now you can select by double-click "END-OF-FILE" and all "END-OF-FILE" are highlight

@donho thank you for adding my fix.
I use it with a specific language with function name or variable name allow "-" in name.
Example with MY-FUNCTION procedure or L-RES variable :

 011000 DEFINE, 'MY-FUNCTION', PROCEDURE                            $

        DECLARE, VARIABLE, 'L-RES'      IS INTEGER                  $


 011005 PERFORM, 'POWER-ON'                                         $

C-------------------------------------------------------------------$     

        PERFORM, 'TEST-XXXX'   RESULT ('L-RES')                     $

        IF, 'L-RES' EQ 0, THEN                                      $
            CALCULATE, 'FATAL' = TRUE                               $
            PERFORM, 'INIT-FAIL'                                    $
        END, IF                                                     $
 011505 PERFORM, 'POWER-OFF'                                        $
 011999 END, 'MY-FUNCTION'                                          $

Cyrillev
npp_smarthighlight

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String returned by SCI_GETWORDCHARS from scintilla is not null terminated, so check for strlen in isWordChar() below on listChar is dangerous

  • seen with MS Application Verifier on x64

@Cyrillev91
Copy link
Copy Markdown
Contributor Author

I agree with you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accepted enhancement Proposed enhancements of existing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants