Community
    • Login

    Disable brace highlight style in comments?

    Scheduled Pinned Locked Moved General Discussion
    3 Posts 2 Posters 2.3k 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.
    • albcntrA
      albcntr
      last edited by albcntr

      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

      Claudia FrankC 1 Reply Last reply Reply Quote 0
      • Claudia FrankC
        Claudia Frank @albcntr
        last edited by Claudia Frank

        @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

        1 Reply Last reply Reply Quote 0
        • albcntrA
          albcntr
          last edited by albcntr

          @Claudia-Frank

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

          Fondest wishes

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