Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: Vampyre_Dark on March 09, 2006, 11:29:22 pm

Title: Tools Help
Post by: Vampyre_Dark on March 09, 2006, 11:29:22 pm
I'd like to make a tool that could get me into my project folder quick. I can know how to get into a folder, I just have to type.. explorer ${PROJECT_DIR} as the command line. Problem is my projects look like this

Project Folder
/src
/obj
/folders with data files
Project.exe

So my project folder command brings me into Project Folder/src. Is there any way I can just navigate to just Project Folder?
Title: Re: Tools Help
Post by: thomas on March 09, 2006, 11:39:02 pm
cbProject::GetCommonTopLevelPath()
Title: Re: Tools Help
Post by: killerbot on March 09, 2006, 11:39:27 pm
what should ${PROJECT_DIR} return, the dir where the cbp file is located ??

or is ${PROJECT_DIR} not a variable.

Do I understand it is something you would register in the tools menu ??
Or are you writing code, then you can use Thomas' solution.
Title: Re: Tools Help
Post by: thomas on March 09, 2006, 11:52:55 pm
There is no other solution since the common toplevel path is not available as a variable, and a script would not know about the project structure...

But luckily, it is really easy. Make a plugin of type "Tool" and fill in something like this:
Code
virtual int Execute()
{
wxString x(_T("explorer ") + Manager::Get()->GetProjectManager()->GetActiveProject()->GetCommonTopLevelPath());
::wxExecute(x);
};

Compile and run, should do what you want.


EDIT: missing brace
Title: Re: Tools Help
Post by: TDragon on March 09, 2006, 11:55:48 pm
explorer ${PROJECT_DIR}..
?

Works for me.

EDIT: Accidentally threw an unneeded slash in there.
Title: Re: Tools Help
Post by: thomas on March 09, 2006, 11:57:59 pm
Well yes, this works for exactly one layout, but not for arbitrary layouts...
Title: Re: Tools Help
Post by: TDragon on March 10, 2006, 12:03:39 am
And takes marginally less time to implement. Plus, if all the files C::B ever sees are in the src subdirectory, that's what GetCommonTopLevelPath() will return, ne?
Title: Re: Tools Help
Post by: mandrav on March 10, 2006, 08:25:54 am
And takes marginally less time to implement. Plus, if all the files C::B ever sees are in the src subdirectory, that's what GetCommonTopLevelPath() will return, ne?

It will return what it says: the common top-level path for the project.
Example:


devel
    myproject_dir (<-- this will be returned by cbProject::GetCommonTopLevelPath())
        include
            a_file.h
        src
            a_file.cpp
            b_file.cpp
        projects
            codeblocks
                myproject.cbp (<-- this is your project file)
            visualXXX
                myproject.vcproj


And since it's trivial to be added as a macro, I think we will.
Title: Re: Tools Help
Post by: mandrav on March 10, 2006, 09:25:54 am
Quote from: SVN commit log
Added $PROJECT_TOPDIR macro. Aliases: $PROJECT_TOPDIRECTORY, $PROJECTTOPDIR and $PROJECTTOPDIRECTORY. Returns the project's common top-level path.
Title: Re: Tools Help
Post by: Vampyre_Dark on March 11, 2006, 08:10:50 am
Oops, sorry for the confusion, I should have been more specific in my original post. Anyways, you got the idea after a few posts. :lol: I figured there would be some kind of directory relative path code to make it work, like ./ .. ..\ or something like that.. I never learned those codes.

That new addition will be very helpful eventually, when a new release is made.