June 19, 2011

bijanbina bijanbina
Lab Rat
23 posts

new Suggestion for Code Folding

 

1. Partitioning Code
add something that start with

  1. Region"smt"
and end with
  1. endRegion
that the code between these tag can fold and display “smt” in the summery of the folded code.it’s very use full for access to your code faster!
2. Remember code folding
when a user save a code the fold state save and restore in next launch

8 replies

June 19, 2011

Andre Andre
Robot Herder
6417 posts

bijanbina, could you clarify your idea a bit? Do you want code folding on DevNet, or in Creator? Anyway, it is probably best to file a suggestion in Jira [bugreports.qt.nokia.com] for this.

June 19, 2011

bijanbina bijanbina
Lab Rat
23 posts

i want this feature add to QT Creator for code editing.
for example your code is:

  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void hello();
  6. void bye();
  7.  
  8. void hello()
  9. {
  10.     cout << "Hi" << endl;
  11. }
  12.  
  13. void bye()
  14. {
  15.     cout << "Good Bye" << endl;
  16. }
  17.  
  18. int main(int   argc, char *argv[])
  19. {
  20.     int i = 0;
  21.     hello()
  22.     cout << "argc is " << argc << endl;
  23.     for (i = 1;i<argc;i++)
  24.     {
  25.         cout << "the argumet number is " << i << " and the value is " << argv[i] << endl;
  26.     }
  27.     bye();
  28.     return 0;
  29. }

and then you change it to

  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. Region "Prototypes"
  6. void hello();
  7. void bye();
  8. endRegion
  9.  
  10. void hello()
  11. {
  12.     cout << "Hi" << endl;
  13. }
  14.  
  15. void bye()
  16. {
  17.     cout << "Good Bye" << endl;
  18. }
  19.  
  20. int main(int   argc, char *argv[])
  21. {
  22.     int i = 0;
  23.     hello()
  24.     cout << "argc is " << argc << endl;
  25.     for (i = 1;i<argc;i++)
  26.     {
  27.         cout << "the argumet number is " << i << " and the value is " << argv[i] << endl;
  28.     }
  29.     bye();
  30.     return 0;
  31. }

now you can fold your code like this

  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. ["Prototypes"]
  6.  
  7. void hello()
  8. {
  9.     cout << "Hi" << endl;
  10. }
  11.  
  12. void bye()
  13. {
  14.     cout << "Good Bye" << endl;
  15. }
  16.  
  17. int main(int   argc, char *argv[])
  18. {
  19.     int i = 0;
  20.     hello()
  21.     cout << "argc is " << argc << endl;
  22.     for (i = 1;i<argc;i++)
  23.     {
  24.         cout << "the argumet number is " << i << " and the value is " << argv[i] << endl;
  25.     }
  26.     bye();
  27.     return 0;
  28. }

June 19, 2011

Gerolf Gerolf
Robot Herder
3287 posts

So, you want it like MSVS does it (see MSDN [msdn.microsoft.com]) ) ?

  1. // pragma_directives_region.cpp
  2. #pragma region Region_1
  3. void Test() {}
  4. void Test2() {}
  5. void Test3() {}
  6. #pragma endregion Region_1
  7.  
  8. int main() {}

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

June 19, 2011

bijanbina bijanbina
Lab Rat
23 posts

yes it is actually i want

June 19, 2011

Andre Andre
Robot Herder
6417 posts

Such a thing, as long as it is not overused, might be useful, I guess.
One solution might be to define a macro Q_CODE_REGION (or something like that), and let Qt Creator’s code parser use that for code folding. For MSVC, it might expand to #pragma region, but AFAIK GCC does not have such a thing, so it should probably expand to nothing there.

June 19, 2011

bijanbina bijanbina
Lab Rat
23 posts

yes you can create a define in qt like

  1. #define Q_CODE_REGION //

and qt detect it for fold it’s no problem for gcc and other compiler

June 19, 2011

Andre Andre
Robot Herder
6417 posts

So… did you file that suggestion yet in Jira?

June 19, 2011

bijanbina bijanbina
Lab Rat
23 posts

yes you can find it here [bugreports.qt.nokia.com]

i just add my first post to it

 
  ‹‹ symbol(s) not found for architecture x86_64      Some C++ Keyword Not Detected ››

You must log in to post a reply. Not a member yet? Register here!