News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

New Folding Issue

Started by Vampyre_Dark, July 21, 2006, 03:32:11 AM

Previous topic - Next topic

Vampyre_Dark


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.  :?
C::B Wishlist
~BOYCOTT THE EVIL YELLOW BOXES~

PhyloGenesis

goto Editor options, the folding tab, and deselect the option to fold all on load
PhyloGenesis

"For every programmer, there is an equal and opposite programmer who can't stand to read the first programmers code." - Snook's first law of (game) programming

Vampyre_Dark

Quote from: PhyloGenesis on July 21, 2006, 09:46:19 AM
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.
C::B Wishlist
~BOYCOTT THE EVIL YELLOW BOXES~

PhyloGenesis

#3
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...
PhyloGenesis

"For every programmer, there is an equal and opposite programmer who can't stand to read the first programmers code." - Snook's first law of (game) programming

kidmosey

It might be tedious, but you could try updating all the structs to the following format:


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.
3 years until google knows more than god.

killerbot

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.

Vampyre_Dark

#6
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.
C::B Wishlist
~BOYCOTT THE EVIL YELLOW BOXES~

sethjackson

#7
Quote from: 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.

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.

Ceniza

The AStyle plugin has nothing to do with folding... or did I miss something? :?

sethjackson

Quote from: Ceniza on July 23, 2006, 02:48:24 AM
The AStyle plugin has nothing to do with folding... or did I miss something? :?

Why did I say that.  :oops:  :P

kidmosey

Quote from: Vampyre_Dark on July 22, 2006, 11:36:11 PM
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).


+ 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.
3 years until google knows more than god.

PhyloGenesis

#11
>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) Select
+ class CDolphin: public fish
  { // A dolphin class
-------------------------------------------------------
  };

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


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

"For every programmer, there is an equal and opposite programmer who can't stand to read the first programmers code." - Snook's first law of (game) programming

kidmosey

Quote from: PhyloGenesis on July 23, 2006, 09:28:20 AM
No, it should look like this (the line would go where the missing code is).

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

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


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

Quote from: PhyloGenesis on July 23, 2006, 09:28:20 AM
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.
3 years until google knows more than god.

sethjackson

Quote from: kidmosey on July 23, 2006, 10:19:02 AM
Quote from: PhyloGenesis on July 23, 2006, 09:28:20 AM
No, it should look like this (the line would go where the missing code is).

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

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


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

Quote from: PhyloGenesis on July 23, 2006, 09:28:20 AM
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.......

PhyloGenesis

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.
PhyloGenesis

"For every programmer, there is an equal and opposite programmer who can't stand to read the first programmers code." - Snook's first law of (game) programming