Author Topic: indentation guilds highlight  (Read 46982 times)

Offline blueshake

  • Regular
  • ***
  • Posts: 458
Re: indentation guilds highlight
« Reply #30 on: July 24, 2009, 07:50:16 am »
I just test the wxLIGHT_GREY
Code
control->StyleSetForeground(wxSCI_STYLE_INDENTGUIDE, *wxLIGHT_GREY);

@rhf
Is this the style you talk about?

[attachment deleted by admin]
« Last Edit: July 24, 2009, 07:53:33 am by blueshake »
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6035
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: indentation guilds highlight
« Reply #31 on: July 24, 2009, 02:08:19 pm »
I think He(rhf) would like "a dimmer indentation guide lines", I personally prefer the indentation guide line color = color of comment text.

But I don't know how to get that color value from predefined user color option. :(
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline blueshake

  • Regular
  • ***
  • Posts: 458
Re: indentation guilds highlight
« Reply #32 on: July 24, 2009, 03:47:57 pm »
maybe it is relative to mset.m_Colours in line 467 in editorcolourset.cpp.but I am not sure.
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline rhf

  • Multiple posting newcomer
  • *
  • Posts: 123
Re: indentation guilds highlight
« Reply #33 on: July 24, 2009, 04:39:04 pm »
@ollydbg and blueshake,

Following your suggestions, I added the following to sdk\editorcolourset.cpp in Line 463:
Code
 control->StyleSetForeground(wxSCI_STYLE_INDENTGUIDE, *wxLIGHT_GREY);

This worked beautifully, doing exactly what I wanted, and it even changes color when the braces are highlighted.

Well done and thanks,
Bob

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6035
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: indentation guilds highlight
« Reply #34 on: July 24, 2009, 04:57:14 pm »
hi, I have found a better way, that is: I can set the indentation guild line's color =C++ Comment color.
By default, it was a gray line.

You can add these code in

sdk\editorcolourset.cpp  line 506-509.

Code
        if (opt->name == _T("Comment (normal)") )
        {
            control->StyleSetForeground(wxSCI_STYLE_INDENTGUIDE,opt->fore);
        }

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline rhf

  • Multiple posting newcomer
  • *
  • Posts: 123
Re: indentation guilds highlight
« Reply #35 on: July 24, 2009, 10:50:31 pm »
You can add these code in
sdk\editorcolourset.cpp  line 506-509.
Code
        if (opt->name == _T("Comment (normal)") )
        {
            control->StyleSetForeground(wxSCI_STYLE_INDENTGUIDE,opt->fore);
        }
Very good, ollydbg, it is indeed a more general solution than using the fixed setting in my reply #33 above. Now if someone could just add "Indentation guideline" to the Configure editor Syntax highlighting list, everyone could use their own settings, and we would not have to use up one of the existing highlight options. I tried to do this but couldn't figure it out.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: indentation guilds highlight
« Reply #36 on: July 24, 2009, 11:13:12 pm »
Now if someone could just add "Indentation guideline" to the Configure editor Syntax highlighting list, everyone could use their own settings, and we would not have to use up one of the existing highlight options. I tried to do this but couldn't figure it out.

If I see it right the list is created from the lexer's content, so it can not easily be added to the list, without changing all lexers.

<Edit>
On the other hand that would be not such a hard work, because the style for the indendation guide already exists, so adding :
Code
				<Style name="Indendation guide"
index="37"
fg="55,55,55"/>
to sdk/resources/lexers/lexer_cpp.xml (and running update[.bat] afterwards to copy the changed file to the right place) makes the indendation guide's colour configurable at next start.
</Edit>

By the way the keyword "Comment (normal)" does not exist for all languages.

And the highlight-colour is always the same as used for matching braces:
Quote from: wxScintilla docu
void SetHighlightGuide (int column)
int GetHighlightGuide()


When brace highlighting occurs, the indentation guide corresponding to the braces may be highlighted with the brace highlighting style, wxSCI_STYLE_BRACELIGHT (34). Set column to 0 to cancel this highlight.
Quote from: sdk/wxscintilla/src/scintilla/src/Editor.cxx:2918
      pixmapIndentGuideHighlight->FillRectangle(rcIG, vs.styles[STYLE_BRACELIGHT].back.allocated);
      pixmapIndentGuideHighlight->PenColour(vs.styles[STYLE_BRACELIGHT].fore.allocated);

That means the highlight-style can never be different from the matching-braces highlight-style without patching scintillas-sources.
« Last Edit: July 24, 2009, 11:29:38 pm by jens »

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6035
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: indentation guilds highlight
« Reply #37 on: July 25, 2009, 03:18:33 am »


<Edit>
On the other hand that would be not such a hard work, because the style for the indendation guide already exists, so adding :
Code
				<Style name="Indendation guide"
index="37"
fg="55,55,55"/>
to sdk/resources/lexers/lexer_cpp.xml (and running update[.bat] afterwards to copy the changed file to the right place) makes the indentation guide's colour configurable at next start.

Really good  catch!
Thanks jens!!!
That also make its color configurable in Editor->Syntax highlighting dialog.

Edit
If I change indentation guide's colour, will it be saved in my "F:\cb_svn\src\output\share\CodeBlocks\lexers\lexer_cpp.xml" ?

It seems even I close CB, this xml file leaves unchanged. But the next time I run CB, the color do persist.


So, where does the customized color configuration be saved?
Thanks.

Edit2
Well, I find the answer myself. the customized color setting was saved in "default.conf". :D

Code
<editor>
<colour_sets>
               .........
<cc>
<style20>
<FORE>
<colour r="255" g="0" b="0" />
</FORE>
                ........

</colour_sets>
« Last Edit: July 25, 2009, 03:54:58 am by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline rhf

  • Multiple posting newcomer
  • *
  • Posts: 123
Re: indentation guilds highlight
« Reply #38 on: July 25, 2009, 03:39:02 pm »
Thanks to all of you guys! This is nice work.

By the way Jens, yesterday I tried exactly the same mod to lexer_cpp.xml that you suggest in your Reply #36 and nothing happened - because, Duh!, I never ran update.

I really like having control over the style of the guide that this gives me.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: indentation guilds highlight
« Reply #39 on: July 25, 2009, 04:06:30 pm »
Thanks to all of you guys! This is nice work.

By the way Jens, yesterday I tried exactly the same mod to lexer_cpp.xml that you suggest in your Reply #36 and nothing happened - because, Duh!, I never ran update.

I really like having control over the style of the guide that this gives me.

You should also be able to change the used lexer-xml directly.

On linux it's in /usr/share/codeblocks/lexers and on windows in <C::B-installation-directory>\share\CodeBlocks\lexers.

Or better create a subdirectory lexers in C::B's conf-dir copy the lexer-xml you want to change inside and change it (only tested on linux).

This has the advantage, that an update will not overwrite it, but of course the disadvantage that an update will not overwrite it
... even if some essentials have changed.

Offline rhf

  • Multiple posting newcomer
  • *
  • Posts: 123
Re: indentation guilds highlight
« Reply #40 on: July 25, 2009, 05:25:21 pm »
OK. Thanks, Jens.

Offline rhf

  • Multiple posting newcomer
  • *
  • Posts: 123
Re: indentation guilds highlight
« Reply #41 on: July 26, 2009, 05:55:13 pm »
Hi Jens,

Regarding your suggestion in Reply #36 above:

...  so adding :
Code
				<Style name="Indentation guide"
index="37"
fg="55,55,55"/>
to sdk/resources/lexers/lexer_cpp.xml (and running update[.bat] afterwards to copy the changed file to the right place) makes the indendation guide's colour configurable at next start.

I suppose it was obvious to everyone but me that this change to lexer_cpp.xml gives the user control over the guide syntax highlighting without any code changes at all to sdk\editorcolourset.cpp.  Since the Indentation guides checkbox has been added to Configure editor -> General settings in the trunk, it seems reasonable to add this change to the trunk as well.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6035
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: indentation guilds highlight
« Reply #42 on: July 28, 2009, 04:14:27 pm »
Quote
Since the Indentation guides checkbox has been added to Configure editor -> General settings in the trunk, it seems reasonable to add this change to the trunk as well.
I suggest this change should be added in trunk soon. :D
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: indentation guilds highlight
« Reply #43 on: July 28, 2009, 04:34:58 pm »
Quote
Since the Indentation guides checkbox has been added to Configure editor -> General settings in the trunk, it seems reasonable to add this change to the trunk as well.
I suggest this change should be added in trunk soon. :D

The indendation guide checkbox is there since a long time, so I don't see the relationship.
At the moment (wx)Scintilla uses the default foreground-color for the indendation-guide, so I don't think it's an absolute must to make the style configurable.
There might be other changes (or issues) with a higher priority.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6035
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: indentation guilds highlight
« Reply #44 on: July 28, 2009, 04:44:41 pm »
There might be other changes (or issues) with a higher priority.
Yes, other more important issues need to be fixed. You are a hard working dev!
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.