Author Topic: Highlighting the active folding block  (Read 2314 times)

Offline Ramzy2020

  • Single posting newcomer
  • *
  • Posts: 3
Highlighting the active folding block
« on: November 23, 2020, 09:06:35 pm »
Hi everyone,

I am looking for a way to add a highlighting color option for the active fold when the caret is inside it (i.e., to color the margin's folding line when the caret is inside the folding region). It is the red line on the left in the attached image (pasted from another editor that I am migrating from to Code:Blocks).

I searched a lot but could not find an option for it in Code::Blocks, or how to do it over the internet.

What I found is that it is a Scintilla option, which I believe is the same library that provides text editing functions to Code::Blocks. The following option controls the color in the previous editor: <WidgetStyle name="Fold active" styleID="0" fgColor="FF0000" />.

Can an option like this (WidgetStyle name="Fold active") be added to Code::Blocks in some way? Is this related to wxScintilla?

Thank you very much in advance!
« Last Edit: November 23, 2020, 09:12:23 pm by Ramzy2020 »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: Highlighting the active folding block
« Reply #1 on: November 23, 2020, 11:42:32 pm »
Quote
SCI_SETHIGHLIGHTGUIDE(position column)
SCI_GETHIGHLIGHTGUIDE → position
When brace highlighting occurs, the indentation guide corresponding to the braces may be highlighted with the brace highlighting style, STYLE_BRACELIGHT (34). Set column to 0 to cancel this highlight.

This is what we have and what we use: if you put your cursor on an open brace it will highlight the indent to the close brace.
Obviously this works only for languages with braces. :)
If you can make the feature you want in another scintilla based editor, I'll be happy to take a look and try to replicate it.

(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Ramzy2020

  • Single posting newcomer
  • *
  • Posts: 3
Re: Highlighting the active folding block
« Reply #2 on: November 24, 2020, 05:54:49 pm »
Hi oBFusCATed,

Thank you very much in advance. Yes I actually found the respective main patch used to push that into Scintilla. It is on the following website https://sourceforge.net/p/scintilla/feature-requests/765/?page=0

I actually admire how the guy insisted on adding the feature until it is implemented in Scintilla! Patch 14 should be the file to download. The Scintilla option is:

Code
SCI_MARKERENABLEHIGHLIGHT

The option to be added to the editor, I think, is: [editor:MarkerEnableHighlight(bool enabled) -- Enable/disable highlight for current folding block (smallest one that contains the caret)]. This can be found in Scintilla's API documentation here https://www.scintilla.org/PaneAPI.html

I also found the same option in wxWidgets here: https://docs.wxwidgets.org/trunk/classwx_styled_text_ctrl.html#aba8bda36ef191f934608aa4a4280ee44

I hope this helps more with the implementation. Thank you very much for your help with this!
« Last Edit: November 24, 2020, 05:57:55 pm by Ramzy2020 »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: Highlighting the active folding block
« Reply #3 on: November 24, 2020, 06:59:30 pm »
Good we have this event, so it would be easy thing to add. I suppose the hardest thing is to find where to put the option and how to name it. :)
Could you log this as feature request on https://sourceforge.net/p/codeblocks/tickets/ ?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Ramzy2020

  • Single posting newcomer
  • *
  • Posts: 3
Re: Highlighting the active folding block
« Reply #4 on: November 24, 2020, 08:09:23 pm »
Okay nice :) Thank you very much for taking this matter into your hands! I have opened a feature-request ticket #1038 as well.

If I may suggest, I think it can be added under Settings > Editor > Folding. It can also be named "Enable active fold highlighting".

Thanks again!

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: Highlighting the active folding block
« Reply #5 on: November 24, 2020, 08:56:38 pm »
I have not yet, hopefully I won't forget, currently doing something else.
If you don't hear from me in the next month or someone else doesn't step up, you can ping me.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]