Disable brace highlight style in comments?



  • Hi, I’m new in Notepad++ and I’ve spent time seeking information about this in many forums. Finally, I had signed up here and I decided to ask. Well, it’s possible to dissable de style option: Brace highlight style but only in comments?

    I’ve been reading too how I can change the foreground to white on Selected text only, and I did what Claudia Frank said, and it worked perfectly! (here the post: https://notepad-plus-plus.org/community/topic/11039/foreground-options-for-selected-text)

    I hope there is some way to do it like there, with some command from Python Script, or something. Thanks you very much.

    Greetings.

    Alberto



  • @albcntr

    in order to make this work we need to define that brace matching should use an indicator instead
    of a style and then enable/disable depending where we are.
    So something like

    editor.indicSetStyle(8,INDICATORSTYLE.HIDDEN)
    editor.indicSetFore(8,(0,0,0))
    editor.indicSetAlpha(8,0)
    editor.indicSetOutlineAlpha(8,0)
    editor.indicSetUnder(8,False)
    
    comment_style_id = 1
    
    def callback_UPDATEUI(args):
        cur_pos = editor.getCurrentPos()
        if editor.getStyleAt(cur_pos) == comment_style_id or editor.getStyleAt(cur_pos-1) == comment_style_id:
            editor.braceBadLightIndicator(True, 8)
            editor.braceHighlightIndicator(True, 8)
        else:
            editor.braceBadLightIndicator(False, 8)
            editor.braceHighlightIndicator(False, 8)
        
    editor.clearCallbacks([SCINTILLANOTIFICATION.UPDATEUI])
    editor.callbackSync(callback_UPDATEUI, [SCINTILLANOTIFICATION.UPDATEUI])
    

    You need to check which style_id for comments is used by your lexer and change
    comment_style_id = 1 accordingly. If you use the default theme, check in stylers.xml
    otherwise see in the xml of your used theme (under themes directory).

    Btw. instead of pasting this into the standard startup.py I would recommend you create
    the user startup.py, simply by going to Plugins->Python Script->New Script
    and name it startup.py.

    Cheers
    Claudia



  • @Claudia-Frank

    Thanks so much, it works perfectly! Just like what I wanted. Ty ty.

    Fondest wishes


Log in to reply