Author Topic: Word wrap and indentation  (Read 25162 times)

Offline carra

  • Multiple posting newcomer
  • *
  • Posts: 117
Word wrap and indentation
« 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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9702
Re: Word wrap and indentation
« Reply #1 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Word wrap and indentation
« Reply #2 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). 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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9702
Re: Word wrap and indentation
« Reply #3 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Word wrap and indentation
« Reply #4 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?

Offline carra

  • Multiple posting newcomer
  • *
  • Posts: 117
Re: Word wrap and indentation
« Reply #5 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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9702
Re: Word wrap and indentation
« Reply #6 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?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline carra

  • Multiple posting newcomer
  • *
  • Posts: 117
Re: Word wrap and indentation
« Reply #7 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.

Offline Freem

  • Almost regular
  • **
  • Posts: 219
Re: Word wrap and indentation
« Reply #8 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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9702
Re: Word wrap and indentation
« Reply #9 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...?!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ