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

When include a file, auto add matching brackets

Started by Loaden, April 21, 2010, 06:11:09 PM

Previous topic - Next topic

Loaden

In the #include statement:
When entering the #include <xxxx.h| , auto add the ending matching bracket.

As we know, if include a file, like this:
#include "someheader.h

Then, the CC tip's will show "someheader.h" in the Tip Window.
But when we selected it, it's only change to:

#include "someheader.h // HERE, lose a " or >

If we apply this patch, it's can auto completion the matching brackets.
Like this:
#include "someheader.h"
OR
#include <someheader.h>

EDIT: fix, when type some char, it will failed.

[attachment deleted by admin]

Loaden


killerbot

Although I didn't try the patch out, this would indeed be nice. Question when the closing "> is added, I assume the cursor is behind it so I don't 'enter' the closing "> to the next line ?

I was wondering what you and others think of this (some of my personal irritations ;-) ).

I typically structure a project like this :

Project-Dir with the following subdirs :
* Project (contains the cbp file)
* src (contains *.cpp and .h[that don't need to be exported]
* inc (contains  *h[that are to be exported, typical use : when the project is a static lib or dll]

Use case 1 :
I am working on a file in the src dir, when I want to include a header file it gives them to me as "../src/header.h". This is correct but I like it to be normalized/reduced --> ../src is where I am at the moment, so I just want "header.h"

Use case 2 :
I added for example the inc directory of another component to the list of include/search directories.
I want to include in a source file in the src directory of my current project a header from that other component.
Not even 1 header file from the added include directory shows up. It would be nice those would pop up to.

Use case 3 :
In the ultimate case when I start an include with < , I would like to see the C/C++ headers too in the list.
I have type already so many times vector, string, iostream, .... ;-)

What do you guys think ?


Loaden

#3
About Use case 1 ~ 3:
Hi, killerbot, I need check the code, but now, i can't be sure it.
I will trying.

Loaden

Quote from: killerbot on May 02, 2010, 09:35:59 AM
Question when the closing "> is added, I assume the cursor is behind it so I don't 'enter' the closing "> to the next line ?
Yes, if completion the right brace, the caret is here:
#include <some.h>|

blueshake

QuoteUse case 3 :
In the ultimate case when I start an include with < , I would like to see the C/C++ headers too in the list.
I have type already so many times vector, string, iostream, .... Wink

I have a think for this for a long time , just not figure out a good way to implement it. :wink:
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

oBFusCATed

For 3: Is there a way to get all automatic include paths?

If there is we can scan this paths and cache the result, after some time we can scan again.
Another way is to hook the folders and wait for changes.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

killerbot

Quote from: oBFusCATed on May 02, 2010, 11:02:26 AM
For 3: Is there a way to get all automatic include paths?

If there is we can scan this paths and cache the result, after some time we can scan again.
Another way is to hook the folders and wait for changes.

For GCC we go hunt for them for the CC, otherwise even something like right clicking on include <string> to open the string header didn't work.

Loaden

Quote from: killerbot on May 02, 2010, 09:35:59 AM
Use case 1 :
I am working on a file in the src dir, when I want to include a header file it gives them to me as "../src/header.h". This is correct but I like it to be normalized/reduced --> ../src is where I am at the moment, so I just want "header.h"

Use case 2 :
I added for example the inc directory of another component to the list of include/search directories.
I want to include in a source file in the src directory of my current project a header from that other component.
Not even 1 header file from the added include directory shows up. It would be nice those would pop up to.
Hi, killerbot, I make a patch for do this.
Welcome for test.

The patch based cc branch.

killerbot

this sounds great, could you think you can have a patch for trunk ?

by the way : any idea when another merge round from cc_branch to trunk might happen ?

MortenMacFly

Quote from: Loaden on August 02, 2010, 11:14:02 AM
The patch based cc branch.
...and applied there.

Quote from: killerbot on August 02, 2010, 12:21:19 PM
by the way : any idea when another merge round from cc_branch to trunk might happen ?
Depends on how well we do testing of this branch. Everybody can contribute by doing so and making tests. Basically the CC branch is very well lined-up with trunk so you are not going to miss any features if you simply switch to this branch.

What about a second nightly? - One for trunk and one for the branch... probably not always... but from time-to-time?!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

Loaden

Quote from: killerbot on May 02, 2010, 09:35:59 AM
Use case 3 :
In the ultimate case when I start an include with < , I would like to see the C/C++ headers too in the list.
I have type already so many times vector, string, iostream, .... ;-)
support system headers now. :lol:
Based CC Branch too.
Sorry, I am not using trunk, but only cc branch.

killerbot

time to jump towards the cc branch for me then.

One question related to the branching. I would keep both branches on my laptop. And depending on what to use for the moment, I would issued the make install of the branch of interest.
Could there be any conflicts of each time make install on top of the previous one [by the way : what's the clean for make install ? is it make distclean ?]

killerbot

Quote from: Loaden on August 02, 2010, 07:01:49 PM
Quote from: killerbot on May 02, 2010, 09:35:59 AM
Use case 3 :
In the ultimate case when I start an include with < , I would like to see the C/C++ headers too in the list.
I have type already so many times vector, string, iostream, .... ;-)
support system headers now. :lol:
Based CC Branch too.
Sorry, I am not using trunk, but only cc branch.
@Martin : could you apply this one too to the cc branch ?

Jenna