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

Tools Help

Started by Vampyre_Dark, March 09, 2006, 11:29:22 PM

Previous topic - Next topic

Vampyre_Dark

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?
C::B Wishlist
~BOYCOTT THE EVIL YELLOW BOXES~

thomas

cbProject::GetCommonTopLevelPath()
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

killerbot

#2
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.

thomas

#3
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:
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
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

TDragon

#4
explorer ${PROJECT_DIR}..
?

Works for me.

EDIT: Accidentally threw an unneeded slash in there.
[url="https://jmeubank.github.io/tdm-gcc/"]https://jmeubank.github.io/tdm-gcc/[/url] - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

thomas

Well yes, this works for exactly one layout, but not for arbitrary layouts...
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

TDragon

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?
[url="https://jmeubank.github.io/tdm-gcc/"]https://jmeubank.github.io/tdm-gcc/[/url] - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

mandrav

Quote from: 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?

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.
Be patient!
This bug will be fixed soon...

mandrav

Quote from: SVN commit log
Added $PROJECT_TOPDIR macro. Aliases: $PROJECT_TOPDIRECTORY, $PROJECTTOPDIR and $PROJECTTOPDIRECTORY. Returns the project's common top-level path.
Be patient!
This bug will be fixed soon...

Vampyre_Dark

#9
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.
C::B Wishlist
~BOYCOTT THE EVIL YELLOW BOXES~