Author Topic: indentation guilds highlight  (Read 42464 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: indentation guilds highlight
« Reply #15 on: July 21, 2009, 04:00:24 pm »
This is because C::B removes the whites spaces at the end of the line, so this is not a new case...
Thanks for you explanation.
But can we learn from notepad++. they do a better job :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 rhf

  • Multiple posting newcomer
  • *
  • Posts: 123
Re: indentation guilds highlight
« Reply #16 on: July 21, 2009, 04:15:00 pm »

But can we learn from notepad++. they do a better job :D
[/quote]
@ollydbg
On my machine it appears that notepad++ does the same thing if the Edit option "Trim Trailing Space" is used.

Offline kisoft

  • Almost regular
  • **
  • Posts: 194
Re: indentation guilds highlight
« Reply #17 on: July 21, 2009, 04:16:13 pm »
Settings/Editor: uncheck "Strip trailing blanks".
OS: WinXPSP3
wxWidgets: 2.8.12
CodeBlocks: Master github cbMakefileGen plugin:
https://github.com/kisoft/cbmakefilegen

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: indentation guilds highlight
« Reply #18 on: July 21, 2009, 04:46:26 pm »
Thanks to rhf and kisoft.
Yes, if I unckeck "Trim Trailing Space", there's no difference after "save".

But it is still strange, seems NotePad++ can show quite well compare with CB.(Note, they open the same cpp file)

you can see my reply#10 and reply#12.
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 #19 on: July 21, 2009, 06:35:14 pm »
But it is still strange, seems NotePad++ can show quite well compare with CB.(Note, they open the same cpp file)
Yes, it appears to be a lighter shade and not as distracting - which I would prefer. Perhaps there is a font setting or something to set this.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: indentation guilds highlight
« Reply #20 on: July 23, 2009, 04:21:25 am »
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
Code
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:
Quote
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
Code
#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!!!



« Last Edit: July 23, 2009, 08:36:44 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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: indentation guilds highlight
« Reply #21 on: July 23, 2009, 08:24:47 am »
hi, this is the patch to get a continuous indentation guilds line.

Code
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.
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: 7255
Re: indentation guilds highlight
« Reply #22 on: July 23, 2009, 08:26:38 am »
Fixed in trunk (r5698) and (together with indendation-guide highlight) in cc-branch (r5699).

Thanks ollydbg.

By the way, if you quote from source-code, it would be nice to also know the filename and if possible the line in the file.

EDIT:

just the indendation-guide fix.
My changes and your post crossed each other.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: indentation guilds highlight
« Reply #23 on: July 23, 2009, 08:46:40 am »
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
Code
#define wxSTI_IV_NONE 0
#define wxSTI_IV_REAL 1
#define wxSTI_IV_LOOKFORWARD 2
#define wxSTI_IV_LOOKBOTH 3
:D
« Last Edit: July 23, 2009, 10:14:20 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 blueshake

  • Regular
  • ***
  • Posts: 459
Re: indentation guilds highlight
« Reply #24 on: July 23, 2009, 10:07:01 am »
nice work. :D
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 #25 on: July 23, 2009, 02:23:23 pm »
@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

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: indentation guilds highlight
« Reply #26 on: July 23, 2009, 02:36:43 pm »
Style STYLE_INDENTGUIDE  is used to specify the foreground and background colour of the indentation guides.
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: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: indentation guilds highlight
« Reply #27 on: July 23, 2009, 03:50:08 pm »
@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

Quote
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
Code
// 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

Code
// 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

Code
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?
« Last Edit: July 23, 2009, 04:00:06 pm 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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: indentation guilds highlight
« Reply #28 on: July 24, 2009, 07:32:27 am »
hi, add this statement will let the indentation guild line become green.

sdk\editorcolourset.cpp Line 463

Code
    control->StyleSetForeground(wxSCI_STYLE_INDENTGUIDE,wxColour(0xFF00));

But I still don't know how to use a predefined color... :(
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: 459
Re: indentation guilds highlight
« Reply #29 on: July 24, 2009, 07:47:14 am »
it works. :D
in this file gdicmn.h
Code
#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???
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?