Author Topic: "Smart" indent not working?  (Read 9764 times)

Offline Hnefi

  • Single posting newcomer
  • *
  • Posts: 6
"Smart" indent not working?
« on: June 02, 2009, 04:59:19 pm »
Heyall. Been using C::B at home for some time, now I'm trying to adapt it to our toolchain here at work, so I'm going through issues I have while I evaluate it before recommending it to my coworkers.

One issue I have is with smart indenting - it doesn't really seem to do anything. Consider the following steps:
1: Enter the incomplete function call "Foo(bar," into the editor.
2: Hit "enter".
3: Enter the second parameter and finish the function call: "rab);".

Expected output (indentation is 2 whitespaces):
Code
Foo(bar,
    rab);
Actual output:
Code
Foo(bar,
  rab);

Is there an easy fix for this? I'm running SVN revision 5617, on the wxfnb_to_wxaui branch.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: "Smart" indent not working?
« Reply #1 on: June 02, 2009, 08:14:12 pm »
Is there an easy fix for this?
There is nothing to fix as the indention is based on the indention guidelines which you setup to 2 spaces (or alike), obviously.

Hence you might want to try the AStyle plugin.
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 Hnefi

  • Single posting newcomer
  • *
  • Posts: 6
Re: "Smart" indent not working?
« Reply #2 on: June 03, 2009, 08:39:17 am »
Ah, but I'm using the AStyle plugin, with the guidelines I prefer. When I click the "Source Code Formatter (AStyle)" menu item, the whole file is formatted exactly the way I want it to be.

Unfortunately, that method doesn't work well because it adjusts the entire file - which is something I definitely do not want when I'm making changes in a branch of a huge source tree which I'm later expecting to merge with trunk.

Is there a way to make Smart Indentation mimic the behaviour of AStyle, or a way to apply AStyle to less than the entire file?

Thanks for your time.

Offline Hnefi

  • Single posting newcomer
  • *
  • Posts: 6
Re: "Smart" indent not working?
« Reply #3 on: June 03, 2009, 01:03:46 pm »
Hm, I've been looking into the possibility of patching this myself. Finding the appropriate function and manipulating it is no problem; the code for C::B is very well designed. However, it turns out that the functionality I want is significantly more complex than I realized. Emacs, for example, has a 1200-line elisp source file to deal with this particular issue. Not something I'll be able to replicate in an afternoon and it seems the current cbEditor contains no logic to make things easier.

So far, I think I'll stay content with my halfway solution patch to the problem; I have implemented the indentation rules I want, which is really nice, but it doesn't ignore strings and comments properly. However, if anyone happens to know of advanced indentation functionality implemented in other open source IDE's, please give me a holler. I'd be tempted to copy such a solution.
« Last Edit: June 03, 2009, 02:14:59 pm by Hnefi »