Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: carra on October 09, 2012, 04:07:23 pm

Title: Word wrap and indentation
Post by: carra on October 09, 2012, 04:07:23 pm
While I normally don't need to use word wrap, I have been surprised that it behaves differently in Code::Blocks than in some other editors, in my case Notepad++. Roughly, the wrapping schemes are these:

CODE::BLOCKS style
Code
namespace MyNames
{
    void Function()
    {
        if( Condition )
        {
            SomeVeryLongCall( param1,
param2 );
        }
    }
}

NOTEPAD++ style
Code
namespace MyNames
{
    void Function()
    {
        if( Condition )
        {
            SomeVeryLongCall( param1,
            param2 );
        }
    }
}

I'd like to hear your opinions on this. Mine is that, in the context of coding and other structured documents (like XML) indentation should be kept to not harm visual structure and readability. Or, at least, it would be nice to be able to choose it, if wxScintilla allows the option.
Title: Re: Word wrap and indentation
Post by: MortenMacFly on October 09, 2012, 04:21:03 pm
While I normally don't need to use word wrap, I have been surprised that it behaves differently in Code::Blocks than in some other editors
You can setup the wrapping behaviour in the editor options as desired.
Title: Re: Word wrap and indentation
Post by: dmoore on October 09, 2012, 04:31:27 pm
In scintilla you can control how word wrap is indented (this has no impact on the editor data, just how wrapped lines are displayed) using SCI_SETWRAPINDENTMODE (see here (http://www.scintilla.org/ScintillaDoc.html#SCI_SETWRAPINDENTMODE)). We don't currently support these options in C::B, so someone would need to make a patch. I don't have a strong opinion on whether indentation should be on by default or whether it should be the same for all languages.
Title: Re: Word wrap and indentation
Post by: MortenMacFly on October 09, 2012, 09:17:12 pm
SCI_SETWRAPINDENTMODE
OK - that's another story. What I meant was SmartIndent and alike. This is already implemented.
Title: Re: Word wrap and indentation
Post by: dmoore on October 09, 2012, 09:25:11 pm
The simplest fix would be to turn on SC_WRAPINDENT_SAME as the default for all editors. If noone objects, one of us could easily do this. An example of when this might (and I say might) be undesirable is for plain text mode. Other people might not like the feature, but I am not sure it is worth cluttering the settings with yet another option. Thoughts?
Title: Re: Word wrap and indentation
Post by: carra on October 09, 2012, 09:27:31 pm
I see, in wxScintilla the 2 styles I listed would correspond to setting the parameter as:

SCI_SETWRAPINDENTMODE = SC_WRAPINDENT_FIXED  (Code::Blocks)
SCI_SETWRAPINDENTMODE = SC_WRAPINDENT_SAME  (Notepad++)

There's even a third style I hadn't thought of, to make the wrapped part of the line have extra indent.
Title: Re: Word wrap and indentation
Post by: MortenMacFly on October 09, 2012, 09:33:55 pm
Other people might not like the feature, but I am not sure it is worth cluttering the settings with yet another option. Thoughts?
Well I see it exactly the opposite: Nobody complained so far, so the option we have currently seems to be OK for most people. This is the first complaint in that direction - this obviously means changing the default behaviour must become an option, don't you think?
Title: Re: Word wrap and indentation
Post by: carra on October 10, 2012, 12:43:32 am
I don't think many people will agree or complain. Actually I doubt most people use line wrap ever in C::B. I only turned it on today! after months of using C::B. And only because I was editing some non-C++ files.
Title: Re: Word wrap and indentation
Post by: Freem on October 11, 2012, 10:10:09 am
I guess many people use the right margin to avoid very long lines, and so code does not need to be wrapped often, because programmers do it manually (and smarter than any automated algorithm).
At least, I do, because I think it is easier to see function calls with many arguments when they are split on more than one lines with extra tabs.

About that feature, I do not really mind... if you really want to know what users think about that, why not make a poll? Will be easier for you to know user's opinions.
Title: Re: Word wrap and indentation
Post by: MortenMacFly on October 11, 2012, 11:28:24 am
if you really want to know what users think about that, why not make a poll?
True. Or simply provide a patch. It shouldn't be too hard to implement - you can see how its done with the other scintilla settings for the editors, even though it should be configurable (from my point of view, at least).

I could think of a selection of a combobox for the WRAPINDENTMODE (as dmoore said), in combination with a choice for the SETWRAPSTARTINDENT in case of the WRAPINDENTMODE "SC_WRAPINDENT_FIXED". The latter might even already be present...?!