Author Topic: New Folding Issue  (Read 13130 times)

Offline Vampyre_Dark

  • Regular
  • ***
  • Posts: 255
  • Hello!
    • Somewhere Over The Rainbow...
New Folding Issue
« 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.  :?
C::B Wishlist
~BOYCOTT THE EVIL YELLOW BOXES~

Offline PhyloGenesis

  • Multiple posting newcomer
  • *
  • Posts: 10
  • PhyloGenesis
Re: New Folding Issue
« Reply #1 on: July 21, 2006, 09:46:19 am »
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

Offline Vampyre_Dark

  • Regular
  • ***
  • Posts: 255
  • Hello!
    • Somewhere Over The Rainbow...
Re: New Folding Issue
« Reply #2 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.
C::B Wishlist
~BOYCOTT THE EVIL YELLOW BOXES~

Offline PhyloGenesis

  • Multiple posting newcomer
  • *
  • Posts: 10
  • PhyloGenesis
Re: New Folding Issue
« Reply #3 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...
« Last Edit: July 22, 2006, 12:07:00 am by PhyloGenesis »
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

Offline kidmosey

  • Multiple posting newcomer
  • *
  • Posts: 95
    • MUSITU International
Re: New Folding Issue
« Reply #4 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.
3 years until google knows more than god.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: New Folding Issue
« Reply #5 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.

Offline Vampyre_Dark

  • Regular
  • ***
  • Posts: 255
  • Hello!
    • Somewhere Over The Rainbow...
Re: New Folding Issue
« Reply #6 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.
« Last Edit: July 22, 2006, 11:39:46 pm by Vampyre_Dark »
C::B Wishlist
~BOYCOTT THE EVIL YELLOW BOXES~

sethjackson

  • Guest
Re: New Folding Issue
« Reply #7 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.
« Last Edit: July 23, 2006, 02:56:59 am by sethjackson »

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: New Folding Issue
« Reply #8 on: July 23, 2006, 02:48:24 am »
The AStyle plugin has nothing to do with folding... or did I miss something? :?

sethjackson

  • Guest
Re: New Folding Issue
« Reply #9 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

Offline kidmosey

  • Multiple posting newcomer
  • *
  • Posts: 95
    • MUSITU International
Re: New Folding Issue
« Reply #10 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.
3 years until google knows more than god.

Offline PhyloGenesis

  • Multiple posting newcomer
  • *
  • Posts: 10
  • PhyloGenesis
Re: New Folding Issue
« Reply #11 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.)
« Last Edit: July 23, 2006, 09:33:59 am by PhyloGenesis »
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

Offline kidmosey

  • Multiple posting newcomer
  • *
  • Posts: 95
    • MUSITU International
Re: New Folding Issue
« Reply #12 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.
3 years until google knows more than god.

sethjackson

  • Guest
Re: New Folding Issue
« Reply #13 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.......

Offline PhyloGenesis

  • Multiple posting newcomer
  • *
  • Posts: 10
  • PhyloGenesis
Re: New Folding Issue
« Reply #14 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.
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

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: New Folding Issue
« Reply #15 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


Offline jeancf

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: New Folding Issue
« Reply #16 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

Offline joubertdj

  • Multiple posting newcomer
  • *
  • Posts: 120
Re: New Folding Issue
« Reply #17 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...

Offline joubertdj

  • Multiple posting newcomer
  • *
  • Posts: 120
Re: New Folding Issue
« Reply #18 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
« Last Edit: December 14, 2006, 03:03:45 pm by joubertdj »

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: New Folding Issue
« Reply #19 on: December 14, 2006, 03:04:47 pm »
What is the 'language' that you 're referring to? Isn't cbEditor::GetLanguage( ) enough?
Be patient!
This bug will be fixed soon...

Offline joubertdj

  • Multiple posting newcomer
  • *
  • Posts: 120
Re: New Folding Issue
« Reply #20 on: December 14, 2006, 03:21:17 pm »
 :lol: That was actually what I was looking for... Hehehehe

Offline jeancf

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: New Folding Issue
« Reply #21 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