Hello :
I found that indentation guilds can not highlight in codeblock.So I did a little work for it .
Index: sdk/cbeditor.cpp
===================================================================
--- sdk/cbeditor.cpp (revision 5678)
+++ sdk/cbeditor.cpp (working copy)
@@ -2269,7 +2269,12 @@
ch == _T('}') || ch == _T(']') || ch == _T(')'))
{
if (newPos != wxSCI_INVALID_POSITION)
+ {
control->BraceHighlight(currPos, newPos);
+ int currColum = control->GetColumn(currPos);
+ int newColum = control->GetColumn(newPos);
+ control->SetHighlightGuide((currColum < newColum) ? currColum :newColum);
+ }
else
control->BraceBadLight(currPos);
}
[attachment deleted by admin]
I found the reason why the indent line will break.
First, if we check "show indent line" in the editor dialog. This function will be called.
src\sdk\wxscintilla\src\wxscintilla.cpp line 1301
void wxScintilla::SetIndentationGuides (int indentView)
{
SendMsg(SCI_SETINDENTATIONGUIDES, indentView, 0); //Set breakpoint here
}
So, I set a breakpoint there, and found the parameter indentView = 1.
Refer to the scintilla document:
SCI_SETINDENTATIONGUIDES(int indentView)
SCI_GETINDENTATIONGUIDES
Indentation guides are dotted vertical lines that appear within indentation white space every indent size columns. They make it easy to see which constructs line up especially when they extend over multiple pages. Style STYLE_INDENTGUIDE (37) is used to specify the foreground and background colour of the indentation guides.
There are 4 indentation guide views. SC_IV_NONE turns the feature off but the other 3 states determine how far the guides appear on empty lines.
SC_IV_NONE No indentation guides are shown.
SC_IV_REAL Indentation guides are shown inside real indentation white space.
SC_IV_LOOKFORWARD Indentation guides are shown beyond the actual indentation up to the level of the next non-empty line. If the previous non-empty line was a fold header then indentation guides are shown for one more level of indent than that line. This setting is good for Python.
SC_IV_LOOKBOTH Indentation guides are shown beyond the actual indentation up to the level of the next non-empty line or previous non-empty line whichever is the greater. This setting is good for most languages.
and
In the scr/sdk/wxscintilla/src/scintilla/include/Scintilla.h line 215
#define SC_IV_NONE 0
#define SC_IV_REAL 1
#define SC_IV_LOOKFORWARD 2
#define SC_IV_LOOKBOTH 3
So, the SC_IV_REAL will be used, which will cause a indentation line break.
So, I suggest that we can use:
SC_IV_LOOKFORWARD or SC_IV_LOOKBOTH.
By the way, I'd thank rhf for his help to find the reason!!!
hi, this is the patch to get a continuous indentation guilds line.
Index: cbeditor.cpp
===================================================================
--- cbeditor.cpp (revision 5697)
+++ cbeditor.cpp (working copy)
@@ -41,6 +41,8 @@
#include "encodingdetector.h"
#include "projectfileoptionsdlg.h"
+#include "wxscintilla/src/scintilla/include/Scintilla.h"
+
const wxString g_EditorModified = _T("*");
#define ERROR_MARKER 1
@@ -1081,7 +1083,7 @@
}
control->SetUseTabs(mgr->ReadBool(_T("/use_tab"), false));
- control->SetIndentationGuides(mgr->ReadBool(_T("/show_indent_guides"), false));
+ control->SetIndentationGuides(mgr->ReadBool(_T("/show_indent_guides"), false)!=false?SC_IV_LOOKBOTH:SC_IV_NONE);
control->SetTabIndents(mgr->ReadBool(_T("/tab_indents"), true));
control->SetBackSpaceUnIndents(mgr->ReadBool(_T("/backspace_unindents"), true));
control->SetWrapMode(mgr->ReadBool(_T("/word_wrap"), false));
@@ -2853,7 +2855,8 @@
cbStyledTextCtrl* control = GetControl();
int pos = control->PositionFromPoint(wxPoint(event.GetX(), event.GetY()));
int style = control->GetStyleAt(pos);
- NotifyPlugins(cbEVT_EDITOR_TOOLTIP, style, wxEmptyString, event.GetX(), event.GetY());
+ if(IsContextMenuOpened()==false)
+ NotifyPlugins(cbEVT_EDITOR_TOOLTIP, style, wxEmptyString, event.GetX(), event.GetY());
OnScintillaEvent(event);
}
Also, this patch disable the tooltip message if a context menu was opened.
Ok, I know, and I have modified my previous posts.
Your patch is better than mine, it can avoid include another header "Scintilla.h", because the indentation guilds type was also defined in "include\wxscintilla\include\wx\wxscintilla.h" Line 186
#define wxSTI_IV_NONE 0
#define wxSTI_IV_REAL 1
#define wxSTI_IV_LOOKFORWARD 2
#define wxSTI_IV_LOOKBOTH 3
:D
@ollydbg and jens.
Well done, guys!
I would still like to see dimmer indentation guide lines, similar to what notepad++ uses.
I think it involves the setting of STYLE_INDENTGUIDE, but I don't know how to do it.
Thanks again,
Bob
Firstly, you can find in the scintilla document
http://www.scintilla.org/ScintillaDoc.html#BuildingScintilla
Style definition
While the style setting messages mentioned above change the style numbers associated with text, these messages define how those style numbers are interpreted visually. There are 256 lexer styles that can be set, numbered 0 to STYLE_MAX (255). Unless you use SCI_SETSTYLEBITS to change the number of style bits, styles 0 to 31 are used to set the text attributes. There are also some predefined numbered styles starting at 32, The following STYLE_* constants are defined.
STYLE_INDENTGUIDE 37 This style sets the foreground and background colours used when drawing the indentation guides.
note: we are only interest in STYLE_INDENTGUIDE 37
Secondly, you can see the similar definition macros in, note: we are only interest in STYLE_INDENTGUIDE 37
include\wxscintilla\include\wx\wxscintilla.h line 131
// Styles in range 32..38 are predefined for parts of the UI and are not used as normal styles.
// Style 39 is for future use.
#define wxSCI_STYLE_DEFAULT 32
#define wxSCI_STYLE_LINENUMBER 33
#define wxSCI_STYLE_BRACELIGHT 34
#define wxSCI_STYLE_BRACEBAD 35
#define wxSCI_STYLE_CONTROLCHAR 36
#define wxSCI_STYLE_INDENTGUIDE 37
#define wxSCI_STYLE_CALLTIP 38
#define wxSCI_STYLE_LASTPREDEFINED 39
#define wxSCI_STYLE_MAX 255
So, in wxScintilla, they use wxSCI_STYLE_INDENTGUIDE.
Thirdly, I found the code in
sdk\wxscintilla\src\wxscintilla.cpp line 667
// Set the foreground colour of a style.
void wxScintilla::StyleSetForeground (int style, const wxColour& fore)
{
SendMsg(SCI_STYLESETFORE, style, wxColourAsLong(fore));
}
Forthly, I think you can do this in the function below:
sdk\editorcolourset.cpp line 434
void EditorColourSet::Apply(HighlightLanguage lang, cbStyledTextCtrl* control)
{
......
control->StyleSetForeground(wxSCI_STYLE_INDENTGUIDE, Dimmer color like comment text);
......
}
Finally, there is only one last question:
How can I get the "Dimmer color like comment text" value?
Any comments?
hi, add this statement will let the indentation guild line become green.
sdk\editorcolourset.cpp Line 463
control->StyleSetForeground(wxSCI_STYLE_INDENTGUIDE,wxColour(0xFF00));
But I still don't know how to use a predefined color... :(
it works. :D
in this file gdicmn.h
#define wxBLACK wxStockGDI::GetColour(wxStockGDI::COLOUR_BLACK)
#define wxBLUE wxStockGDI::GetColour(wxStockGDI::COLOUR_BLUE)
#define wxCYAN wxStockGDI::GetColour(wxStockGDI::COLOUR_CYAN)
#define wxGREEN wxStockGDI::GetColour(wxStockGDI::COLOUR_GREEN)
#define wxLIGHT_GREY wxStockGDI::GetColour(wxStockGDI::COLOUR_LIGHTGREY)
#define wxRED wxStockGDI::GetColour(wxStockGDI::COLOUR_RED)
#define wxWHITE wxStockGDI::GetColour(wxStockGDI::COLOUR_WHITE)
or add a option in setting???
I just test the wxLIGHT_GREY
control->StyleSetForeground(wxSCI_STYLE_INDENTGUIDE, *wxLIGHT_GREY);
@rhf
Is this the style you talk about?
[attachment deleted by admin]
@ollydbg and blueshake,
Following your suggestions, I added the following to sdk\editorcolourset.cpp in Line 463:
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
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.
if (opt->name == _T("Comment (normal)") )
{
control->StyleSetForeground(wxSCI_STYLE_INDENTGUIDE,opt->fore);
}
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 :
<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:
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.
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.
<Edit>
On the other hand that would be not such a hard work, because the style for the indendation guide already exists, so adding :
<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
<editor>
<colour_sets>
.........
<cc>
<style20>
<FORE>
<colour r="255" g="0" b="0" />
</FORE>
........
</colour_sets>