Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Vampyre_Dark on July 21, 2006, 03:32:11 am

Title: New Folding Issue
Post by: Vampyre_Dark on July 21, 2006, 03:32:11 am

I'm looking through some code that has lots of

typedef struct
{
    int member;
}struct_name;

blocks in it. When it opens it all folds by default, and none of the struct names can be seen.  :?
Title: Re: New Folding Issue
Post by: PhyloGenesis on July 21, 2006, 09:46:19 am
goto Editor options, the folding tab, and deselect the option to fold all on load
Title: Re: New Folding Issue
Post by: Vampyre_Dark on July 21, 2006, 08:35:19 pm
goto Editor options, the folding tab, and deselect the option to fold all on load
  :lol: That's not the problem. I want everything to be folded. The problem is being unable to see what the structs are.
Title: Re: New Folding Issue
Post by: PhyloGenesis on July 22, 2006, 12:05:00 am
We'll I was going to put it in as a feature request that when they fold, they don't fold the closing bracket.
My reason was that when if statements are folded, it looks like the next statement (after the close) is part of the if, but your reason makes sense to.

Oh, and for me, even though I have the option on, nothing is folded when I open files...
Title: Re: New Folding Issue
Post by: kidmosey on July 22, 2006, 01:59:45 am
It might be tedious, but you could try updating all the structs to the following format:

Code
typedef struct _struct_name
{
    int member;
} struct_name;

That way, the struct has a name and the typedef has a name.  I believe this is the standard way of defining typedef structs, anyhow.
Title: Re: New Folding Issue
Post by: killerbot on July 22, 2006, 11:38:41 am
well it depends, that typedef stuff comes from C.

In the C++ world you don't do that:

struct MyStruct
{
  // ...
}

and you can use the struct

just like you do with a class :

class MyClass
{
}

In C++ in neither cases you need that typedef, so it is preferred NOT to use it.

The typedefs CAN have an added value if you use STL containers, because then they can hide the actual type (for the container and it's iterators, so you can easli switch them). But as far as those iterators will be concerned in TR1 the type will be determined automatically.
Title: Re: New Folding Issue
Post by: Vampyre_Dark on July 22, 2006, 11:36:11 pm
The code is not mine to change. I was looking through some example source files. Lots of code is written like this, wether it is right or wrong form is a matter of personal preference, and doesn't change the fact that it's an issue with the feature.

I also think like the above poster, that the last brace should be visible.
Title: Re: New Folding Issue
Post by: sethjackson on July 23, 2006, 02:33:51 am
The code is not mine to change. I was looking through some example source files. Lots of code is written like this, wether it is right or wrong form is a matter of personal preference, and doesn't change the fact that it's an issue with the feature.

I also think like the above poster, that the last brace should be visible.

Yup it's a bug. However I don't know how to fix. :P

Yeah I agree with PhyloGenesis. I get confused sometimes when I use the folding stuff.
Title: Re: New Folding Issue
Post by: Ceniza on July 23, 2006, 02:48:24 am
The AStyle plugin has nothing to do with folding... or did I miss something? :?
Title: Re: New Folding Issue
Post by: sethjackson on July 23, 2006, 02:56:40 am
The AStyle plugin has nothing to do with folding... or did I miss something? :?

Why did I say that.  :oops:  :P
Title: Re: New Folding Issue
Post by: kidmosey on July 23, 2006, 05:16:31 am
I also think like the above poster, that the last brace should be visible.

But then the fold could take upto 3 lines, two of which would usually be blank (except for braces).

Code
+ class CDolphin: public fish
  { // A dolphin class
  };
-------------------------------------------------------

+ struct TShark
  {
  };
-------------------------------------------------------

At first glance, they just look like empty declarations.  Personally, I think both braces should be left out.  At any rate, I'm not sure if this is a C::B issue or a scintilla issue.
Title: Re: New Folding Issue
Post by: PhyloGenesis on July 23, 2006, 09:28:20 am
>At first glance, they just look like empty declarations.

? No, it should look like this (the line would go where the missing code is).

Code: cpp
+ class CDolphin: public fish
  { // A dolphin class
-------------------------------------------------------
  };

+ struct TShark
  {
-------------------------------------------------------
  };

Where is the source code for the folding?  (I'll check it out.)
Title: Re: New Folding Issue
Post by: kidmosey on July 23, 2006, 10:19:02 am
No, it should look like this (the line would go where the missing code is).

Code: cpp
+ class CDolphin: public fish
  { // A dolphin class
-------------------------------------------------------
  };

+ struct TShark
  {
-------------------------------------------------------
  };

Ahhhh, okay... Yeah, that makes a bit more sense.

Where is the source code for the folding?  (I'll check it out.)

I did a quick search in SVN.

file: /src/sdk/cbeditor.cpp
line: 1290

I'd start there.
Title: Re: New Folding Issue
Post by: sethjackson on July 23, 2006, 02:30:24 pm
No, it should look like this (the line would go where the missing code is).

Code: cpp
+ class CDolphin: public fish
  { // A dolphin class
-------------------------------------------------------
  };

+ struct TShark
  {
-------------------------------------------------------
  };

Ahhhh, okay... Yeah, that makes a bit more sense.

Where is the source code for the folding?  (I'll check it out.)

I did a quick search in SVN.

file: /src/sdk/cbeditor.cpp
line: 1290

I'd start there.


You may want to check out the wxScintilla sources too.......
Title: Re: New Folding Issue
Post by: PhyloGenesis on July 24, 2006, 09:19:15 am
If any of the developers are willing:
To change the folding feature to not fold the closing brace simply


File: /src/sdk/cbeditor.cpp
Line: 1280-1284

change:
if (expand)
  m_pControl->ShowLines(line + 1, maxLine);
else
  m_pControl->HideLines(line + 1, maxLine);

to:  (just remove the " + 1")
if (expand)
  m_pControl->ShowLines(line, maxLine);
else
  m_pControl->HideLines(line, maxLine);


If there are residual problems, (such as the folder no longer finds the close brace) let me know, I'll do a more detailed check and get back on how to do it.
Title: Re: New Folding Issue
Post by: tiwag on July 24, 2006, 04:37:49 pm
If there are residual problems, (such as the folder no longer finds the close brace) let me know, I'll do a more detailed check and get back on how to do it.

try and debug it and then post a patch at berlios

Title: Re: New Folding Issue
Post by: jeancf on December 14, 2006, 11:12:46 am
I am using the latest nightly and folded code still shows only opening braces. Has this been implemented? Or is it an option that should be enabled somewhere maybe?

This is a really important feature for me as looking at the folded code with all these unclosed braces makes me very uncomfortable ;-) Seriously, keeping the closing brace visible when the code is folded would improve readability a lot.

Thanks,

/~jc
Title: Re: New Folding Issue
Post by: joubertdj on December 14, 2006, 12:52:48 pm
The trick is that at each where the "{" and "}" character is...
It has nothing to do with AStyle (I thought it did, but I was wrong)
Within the scintilla source directory is a file called LexCPP.cxx You will probably have to go and edit this file so that it will have an additional check clause if the "{" and "}" characters are alone on a line, then it should be the previous non-white line that needs to be the fold header...

 :lol:

{EDIT} This just means allot of coding and debugging...
Title: Re: New Folding Issue
Post by: joubertdj on December 14, 2006, 02:58:31 pm
 :oops: Okay so here is a silly question maybe... how do I identify the language that the current editor is handling regarding lexing and folding?

[EDIT] :oops: My Bad... found it ... duh
Title: Re: New Folding Issue
Post by: mandrav on December 14, 2006, 03:04:47 pm
What is the 'language' that you 're referring to? Isn't cbEditor::GetLanguage( ) enough?
Title: Re: New Folding Issue
Post by: joubertdj on December 14, 2006, 03:21:17 pm
 :lol: That was actually what I was looking for... Hehehehe
Title: Re: New Folding Issue
Post by: jeancf on April 10, 2007, 10:46:09 am
Hi,

I would really like to see this improved code folding implemented but I checked the latest nightly build and it is not. Do I need to post a bug for somebody to look at it?

/~jc