Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: Vampyre_Dark on September 21, 2005, 05:56:58 am

Title: Idea
Post by: Vampyre_Dark on September 21, 2005, 05:56:58 am
I thought of this tonight after writing out a big source file full of functions I would need to declare in a header. I've always wanted this but never thought of the idea to actually have it has a feature. What if you could right click in the editor window and choose an option to grab the function names from that file into some kind of a buffer in the program, so you could then paste them somewhere else.
Title: Re: Idea
Post by: rickg22 on September 21, 2005, 07:40:41 am
Um, mind posting a more complete example? Maybe we can improve that idea...
Title: Re: Idea
Post by: mandrav on September 21, 2005, 08:57:15 am
Try this: right-click in the editor and select "Insert->Class method declaration/implementation"
Title: Re: Idea
Post by: fiammy on September 21, 2005, 09:59:52 am
I think Vampyre_Dark means it the other way. You write the source file, and in a way you 'generate' the header file from your already written source. Correct me if I'm wrong
Title: Re: Idea
Post by: Vampyre_Dark on September 21, 2005, 11:07:56 am
Sorry. I'm stupid that way sometimes. I'm bad at getting my ideas across most of the time. :) Basically, say I just wrote a CPP file full of functions to deal with direct input. Now I need to declare these functions in my main header (or any header, whatever) I have to start copying and pasting function names and remembering to put the ';' at the end. It's easy, and a no brainer, but when I have a bunch of functions, I find it very boring and tedious.

So what if I could right click, and use the context menu to grab all the function names? Like this out of my input.cpp

Code
//Input.cpp
void    InputAcquire(void);
bool    InputInit(HWND hWnd);
void    InputShutdown(void);
void    InputPoll(BYTE Keys[], int nSize, DIMOUSESTATE2 &Mouse);
vector3 CursorToVector(DIMOUSESTATE2 &Mouse);


Store it in a buffer, and then I can paste it where I need it.
Title: Re: Idea
Post by: grv575 on September 21, 2005, 04:26:52 pm
If you're going to parse function definitions, could we also get some way to list all the functions in the current file to one of the output windows and make that clickable so that it jumps to a specific function (like the compiler errors/warnings window).  Ultraedit has a view->functions toolbar which is similar.  Make it easier to jump to function definitions (I guess you could just fold everything using the editor, but this might be better).
Title: Re: Idea
Post by: mandrav on September 21, 2005, 06:21:37 pm
If you're going to parse function definitions, could we also get some way to list all the functions in the current file to one of the output windows and make that clickable so that it jumps to a specific function (like the compiler errors/warnings window).  Ultraedit has a view->functions toolbar which is similar.  Make it easier to jump to function definitions (I guess you could just fold everything using the editor, but this might be better).


Have you tried "Search->Go to function" (Ctrl-Alt-G) ?
Title: Re: Idea
Post by: Vampyre_Dark on September 21, 2005, 06:51:37 pm
Have you tried "Search->Go to function" (Ctrl-Alt-G) ?

That's not the same. And it's no different than using page up / page down. The idea is to grab them all in one command, at the same time. If you have goto function, then this shouldn't be a problem?

do
{
    FunctionFind(NEXT_WHATEVER);
    FunctionAddToBuffer();
}while whatever
Title: Re: Idea
Post by: mandrav on September 21, 2005, 06:56:52 pm
Have you tried "Search->Go to function" (Ctrl-Alt-G) ?

That's not the same. And it's no different than using page up / page down. The idea is to grab them all in one command, at the same time. If you have goto function, then this shouldn't be a problem?

do
{
 FunctionFind(NEXT_WHATEVER);
 FunctionAddToBuffer();
}while whatever

I was replying to grv575, as seen from the quote I used...
Title: Re: Idea
Post by: Vampyre_Dark on September 21, 2005, 07:32:47 pm
I was replying to grv575, as seen from the quote I used...
   :oops: Can I hold the talking stick now?
Title: Re: Idea
Post by: phlox81 on September 21, 2005, 08:08:28 pm
Once you start which such a feature, you never find an end  :lol:
For a similiar problem i startet to write my own Code Generator a few years ago,
first only planned to add set/get functions, to day its almost
a complete Classwizard (C++, java and php4).
Title: Re: Idea
Post by: mandrav on September 21, 2005, 08:21:57 pm
Once you start which such a feature, you never find an end :lol:
For a similiar problem i startet to write my own Code Generator a few years ago,
first only planned to add set/get functions, to day its almost
a complete Classwizard (C++, java and php4).

This sounds as a nice base for a plugin ;)
Title: Re: Idea
Post by: orefa on September 21, 2005, 08:40:25 pm
Usually I copy the implementation file and then delete the function bodies to produce the header. The task is similar to folding the body of the code for each function, only it deletes it completely. I don't know how folding is implemented or if it would lend itself to an adaptation of this kind.

A pattern-matching approach could be to search for a '{' and its matching '}' to delete all that and replace it with a semi-colon. It leaves a bit of redundant data to clean up, but a good part of the work is done.

And yes, this looks like a plug-in candidate.
Title: Re: Idea
Post by: mandrav on September 21, 2005, 09:01:50 pm
The code to get a list of functions in the current file, is already there (Ctrl-Alt-G uses it). It's just a matter of making it an option...
Please submit a feature request for it, or I 'll probably forget it. We 're currently busy preparing RC2.
Title: Re: Idea
Post by: phlox81 on September 21, 2005, 09:14:18 pm
Once you start which such a feature, you never find an end :lol:
For a similiar problem i startet to write my own Code Generator a few years ago,
first only planned to add set/get functions, to day its almost
a complete Classwizard (C++, java and php4).

This sounds as a nice base for a plugin ;)

If I had the time for it %)
Title: Re: Idea
Post by: mandrav on September 21, 2005, 09:23:48 pm
If you shared the code, I 'm sure someone would take the task of wrapping it up in a plugin ;)
Title: Re: Idea
Post by: phlox81 on September 21, 2005, 09:29:07 pm
If you shared the code, I 'm sure someone would take the task of wrapping it up in a plugin ;)

Its to old to share, and to messy  :lol:
Title: Re: Idea
Post by: Vampyre_Dark on September 21, 2005, 10:39:00 pm
Okay, it can be done. I'll wait until after the next stable to submit a request. I'm just wondering if you think it's a worthwhile idea?
Title: Re: Idea
Post by: mandrav on September 22, 2005, 12:07:59 am
Okay, it can be done. I'll wait until after the next stable to submit a request. I'm just wondering if you think it's a worthwhile idea?

Sure thing :)
Title: Re: Idea
Post by: grv575 on September 22, 2005, 11:16:44 pm
Oh last time I checked goto function, I had remembered it included more functions than those present in the active file (which would defeat some modularity).  Looking again though at a recent cvs, it looks fine.  Only thing that might be nice is if the window was dockable.
Title: Re: Idea
Post by: mandrav on September 22, 2005, 11:54:52 pm
Oh last time I checked goto function, I had remembered it included more functions than those present in the active file (which would defeat some modularity).  Looking again though at a recent cvs, it looks fine.  Only thing that might be nice is if the window was dockable.

I don't think it ever displayed more functions than those present. It doesn't use the parser's cache or something. Instead it parses the file on the fly, so it's not possible to show things that aren't there...