Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Auto detect indent style

(1/3) > >>

Alpha:
I am working on providing the option for indentation style to be automatically detected and set.  Probably the most logical method would be to call my detection routine from cbEditor::InternalSetEditorStyleAfterFileOpen() (similar to how DetectLineEnds(cbStyledTextCtrl* control) is called).  There is a problem, however.  I want to call GetLineIndentString(), but cannot because it is not a static method.

Program design question: would it be preferred that I convert GetLineIndentString() to a static method?  Or add a static counterpart?  Or move it to cbStyledTextCtrl?  Or something else?

oBFusCATed:

--- Quote from: Alpha on March 01, 2013, 09:19:17 pm ---Program design question: would it be preferred that I convert GetLineIndentString() to a static method?  Or add a static counterpart?  Or move it to cbStyledTextCtrl?  Or something else?

--- End quote ---
If it doesn't access and class data, I'd vote for external/global function :)

Alpha:
It does not access class data (well not from cbEditor, it does use from cbStyledTextCtrl).  Of note, I believe the SmartIndent plugins (and maybe Abbreviations) use this function.

Alpha:
Detecting tabs vs. spaces is easy, however, detecting 2-space indentation vs 4-space indentation (or any other arbitrary number of spaces) is a little more difficult.

I plan to create a threshold to determine the indentation style (and fall back to defaults if it is indeterminate).  To tune this to greater accuracy, I need to collect statistics on samples of multiple styles of code.

If anyone could post samples/links to different styles of code, I can run this test on them.
If you have time to test yourself, apply the attached patch, and post the numbers printed in the Code::Blocks log (along with what the indentation style of the file(s) actually is).

oBFusCATed:

--- Quote from: Alpha on March 04, 2013, 04:51:30 pm ---If anyone could post samples/links to different styles of code, I can run this test on them.

--- End quote ---
Search github or code.google.com for examples, I suppose you can find all the possible styles know to man:)

Navigation

[0] Message Index

[#] Next page

Go to full version