Hi,
is it possible to add "variables" (global or project or whatever variables) to deafult code?
I want something like that:
"Variables":
Quote
@author = p7
@date= 01 Feb 2006
@project_name= Some project
@currdate= `date`
Default code with "variables"
Quote
**********************************************
Author: @author
Date: @date
Project: @project_name
Comments:
Last modification: @currdate
**********************************************
Default code in c/cpp/h file:
Quote
**********************************************
Author: p7
Date: 01 Feb 2006
Project: Some project
Comments:
Last modification: 04 Feb 2006
**********************************************
How to make it?
You mean you want CodeBlocks to automatically replace @author with your name whenever it saves a file? But keep the keyword when you open it? You should take a look at Subversion it offers similar functionality and seems to fit better with the source control system. Also @ could not be used for keywords because it conflicts with doxygen style comments.
Quote from: Game_Ender on February 04, 2006, 05:03:11 PM
You mean you want CodeBlocks to automatically replace @author with your name whenever it saves a file? But keep the keyword when you open it? You should take a look at Subversion it offers similar functionality and seems to fit better with the source control system. Also @ could not be used for keywords because it conflicts with doxygen style comments.
No, no. I want C::B to replace variables only with new files and only in "default code" placed at the top of c/cpp/h files.
KDevelop have dialog window for author, licenece, email and other things for "default code" when you create project.
I think something similar could be achieved using "default code" variables in C::B.
"@" is used as example it can be any character.
For example:
You have this "variable" set:
Quote@author = Game_Ender
You make new project "FooBar", then you open Settings->Editor->Default Code, and put:
Quote
/****************************
* Author: @author
* Project: @project_name
* File: @file_name
*
****************************/
And then for every new c/cpp/h file in project FooBar C::B puts:
Quote
/****************************
* Author: Game_Ender
* Project: FooBar
* File: FooBar.c / FooBar.h / whatever
*
****************************/
Sorry but my english isn't good, and i dont know how to explain it more clearly.
What you want is possible, and it is quite easy too (in principle). All you need to do is add one call to MacrosManager::ReplaceMacros(). This will replace $(ANY_VARIABLE).
In any case, you should add a config option to turn this behaviour on and off, otherwise it may interfere with code that contains something that looks like a variable (in which case this behaviour is not wanted).
Thanks, now i see :)
Quote from: thomas on February 04, 2006, 05:51:14 PM
In any case, you should add a config option to turn this behaviour on and off, otherwise it may interfere with code that contains something that looks like a variable (in which case this behaviour is not wanted).
Maybe it's not necesary, what about replacing only variables that have been defined, and left intact those who not?
Quote from: Takeshi Miya on February 04, 2006, 09:15:28 PMMaybe it's not necesary, what about replacing only variables that have been defined, and left intact those who not?
No
There are some things that deserve an option but doesn't deserve a gui. Let's see how...