highliters function



  • Hi @Stefano-Riccardi,

    It seems I have mislead you a bit with my previous post, sorry for that.
    By “Scintilla” I meant not the SciTE editor but the internal Notepad++ editor engine.
    Unfortunately you (as a user) cannot configure this. It is not difficult from programmatic perspective as this configuration is already a part of the editor engine.
    That’s what I meant.

    Best Regards,
    Pavel



  • @Stefano-Riccardi and @pnedev,

    it actually is working when using space as the delimiter.
    If there is a need to specify more delimiter to be treaten as wordpart then
    you need to extend the Wordchars which can be done using python script plugin
    and a script like

    chars = editor.getWordChars() + “@#_()[]”
    editor.setWordChars(chars)

    Cheers
    Claudia



  • Thank you guys, I am very grateful.

    @Claudia-Frank I am not a programmer, but if you can tell me more information about the script I can try.
    If it is too difficult … peace :)



  • @Stefano-Riccardi

    it depends what exactly you want to achieve.
    Should every document which gets opened be extended with additional chars or
    is it just a few which maybe have in common the file extension or is it more like
    now there is a document which needs this situation?
    First thing you need to do is to install the python script plugin either by using plugin manager or,
    because it way already reported that it happens that installation failed, using the msi from the website.

    Then we need to write a script, which depends on your requirements.

    Cheers
    Claudia



  • @Claudia-Frank

    I would like that every document opened be extended with additional chars.

    I installed Pyithon plugin :)



  • @Stefano-Riccardi

    Having python script installed gives you two ways to execute the needed python script.
    Either by doing it manually or by letting it execute when python script starts.
    The latter is done by changing the configuration Plugins->Python Script->Configuration
    At the bottom there is a dropbox called Initialisation which has per default Lazy
    and needs to be changed to ATSTARTUP.
    This means when npp starts, a users startup.py gets executed as well.
    Let’s create this startup.py goto Plugins->Python Script->New Script and name it, well, startup.py.
    Put the code from below into it and save it. Restart npp.
    type something like test:test in a temporary file and double click on it -> if everything went ok, it should be highlighted completely.

    So, what does the script. It registers two callbacks, one which gets called when notepad starts (callback_READY)
    and one which gets called whenever you open/switch to a new tab (callback_BUFFERACTIVATED). In both cases the
    function extendWordChar will be called.

    additionalChars is the only place where you need to modify it to your needs.
    Currently only colon has been defined as an additional wordchar.
    If you wan’t for example ? and [ as well as ] to be added then change

    additionalChars = ':'
    

    to

    additionalChars = ':?[]'
    

    done.

    One word of warning, python is strict about tabbing, which means you
    need to indent code to make it run and in addition the tabs must be either
    a tab control char or spaces but not both mixed. In python community there is a silent
    agreement that spaces should be used but real tabs would work also.

    def extendWordChar():
        additionalChars = ':'
        chars = editor.getWordChars()
        if additionalChars not in chars:
            editor.setWordChars(chars + additionalChars)
    
    def callback_READY(args):
        extendWordChar()
        
    def callback_BUFFERACTIVATED(args):
        extendWordChar()
    
    notepad.clearCallbacks([NOTIFICATION.BUFFERACTIVATED ])
    notepad.callback(callback_BUFFERACTIVATED, [NOTIFICATION.BUFFERACTIVATED ])
    notepad.callback(callback_READY, [NOTIFICATION.READY ])
    

    Did I forget something? Most likely but if there is something you wanna know, let me know ;-)

    Cheers
    Claudia



  • Hello @Claudia-Frank ,
    I am very gratefull for your help ! sorry for delay but I was very busy.

    Anyway, I created Phyton script and I copied and pasted your script, I checked tabbing. I restarted NP++, at start a pop up warn “Exception: Unknown exception”, I push ok and I tested hilighters function unsuccesfully.

    Can you still help me ?
    thank you



  • Hello @Stefano-Riccardi,

    what you describe sounds like an incomplete installation of python script plugin.
    I assume you installed it by using plugin manager, didn’t you?
    May I ask you to use the msi instead?

    Cheers
    Claudia



  • ooh sorry yes I use Scrip manager. I try remove all and reinstall it using your link… I update you…



  • @Claudia-Frank I removed the old installation and I have installed Plugin manually and now run very well !! thank you very much you are super :)


Log in to reply