Scripting commands
Scripting is no good if all you can do is use the scripting language's builtin commands only. The host application (Code::Blocks) needs to expose parts of its internals to scripts, so scripts can use and control the host.
Code::Blocks has exposed a very large chunk of its SDK to scripts. This makes scripting in Code::Blocks nearly as powerful as native code (C++).
In this page all the exported constants, functions and classes are documented as a quick reference. For detailed documentation on each function/class, refer to the Code::Blocks SDK documentation.
NOTE: please remember that Squirrel is typeless. Data types mentioned below are only used for documentation purposes.
Application object
The application object is accessed through the variable named App. Currently bound functions are:
Return value | Name | Arguments | Remarks |
---|---|---|---|
void | RegisterScript | (char*,char*) or (wxString,wxString) | registers the script file (arg1) under a menu item (arg2).
e.g. App.RegisterScript("sample.script", "Scripts/Sample script"); |
Notes about the RegisterScript function:
The second argument (menu item) is a string containing two values separated by a slash (/). The first value (part before the slash) is the menu under which to add the menu item (which is the part after the slash).
If menu item starts with a dash (-), then a separator line is prepended in the menu before the menu item.
Global functions
Return value | Name | Arguments | Remarks |
---|---|---|---|
void | Log | wxString | logs to debug log |
int | Message | wxString,wxString,int | |
void | ShowMessage | wxString | |
void | ShowWarning | wxString | |
void | ShowError | wxString | |
void | ShowInfo | wxString | |
wxString | ReplaceMacros | wxString,bool | |
ProjectManager* | GetProjectManager | ||
EditorManager* | GetEditorManager | ||
ConfigManager* | GetConfigManager | ||
UserVariableManager* | GetUserVariableManager | ||
CompilerFactory* | GetCompilerFactory | ||
bool | IsNull | void* | |
wxString | _T | const char* | basically this is the wxString constructor |
ConfigManager
Return value | Name | Arguments | Remarks |
---|---|---|---|
int | Read | int,int | |
bool | Read | bool,bool | |
float | Read | float,float | |
wxString | Read | wxString,wxString | |
void | Write | int,int | |
void | Write | bool,bool | |
void | Write | float,float | |
void | Write | wxString,wxString[,bool] |
ProjectManager
Return value | Name | Arguments | Remarks |
---|---|---|---|
wxString | GetDefaultPath | ||
void | SetDefaultPath | wxString | |
cbProject* | GetActiveProject | ||
void | SetProject | cbProject* | |
bool | LoadWorkspace | wxString | |
bool | SaveWorkspace | ||
bool | SaveWorkspaceAs | wxString | |
bool | CloseWorkspace | ||
cbProject* | IsOpen | wxString | |
cbProject* | LoadProject | wxString,bool | |
bool | SaveProject | cbProject* | |
bool | SaveProjectAs | cbProject* | |
bool | SaveActiveProject | ||
bool | SaveActiveProjectAs | ||
bool | SaveAllProjects | ||
bool | CloseProject | cbProject*,bool,bool | |
bool | CloseActiveProject | bool | |
bool | CloseAllProjects | bool | |
cbProject* | NewProject | wxString | |
int | AddFileToProject | wxString,cbProject*,int | |
int | AskForBuildTargetIndex | cbProject* | |
void | RebuildTree |
EditorManager
Return value | Name | Arguments | Remarks |
---|---|---|---|
void | Configure | ||
cbEditor* | New | wxString | |
cbEditor* | Open | wxString | |
cbEditor* | IsBuiltinOpen | wxString | |
cbEditor* | GetBuiltinEditor | int | |
cbEditor* | GetBuiltinActiveEditor | ||
EditorBase* | GetActiveEditor | ||
void | ActivateNext | ||
void | ActivatePrevious | ||
bool | SwapActiveHeaderSource | ||
bool | CloseActive | bool | |
bool | Close | int,bool | |
bool | CloseAll | bool | |
bool | Save | int | |
bool | SaveActive | ||
bool | SaveAs | int | |
bool | SaveActiveAs | ||
bool | SaveAll | ||
int | ShowFindDialog | bool,bool |
UserVariableManager
Return value | Name | Arguments | Remarks |
---|---|---|---|
bool | Exists | wxString |
IO namespace
Return value | Name | Arguments | Remarks |
---|---|---|---|
bool | DirectoryExists | wxString | |
wxString | SelectDirectory | wxString,wxString,bool | |
bool | FileExists | wxString | |
wxString | SelectFile | wxString,wxString,wxString |
CompilerFactory
Return value | Name | Arguments | Remarks |
---|---|---|---|
bool | IsValidCompilerID | wxString | |
int | GetCompilerIndex | wxString | |
wxString | GetDefaultCompilerID | ||
bool | CompilerInheritsFrom |
wxString
Return value | Name | Arguments | Remarks |
---|---|---|---|
bool | operator+ | ||
bool | operator< | ||
bool | operator<= | ||
bool | operator>= | ||
bool | operator> | ||
int | Find | wxString | |
bool | Matches | wxString | |
void | AddChar | char | |
char | GetChar | int | |
bool | IsEmpty | ||
int | Length | ||
int | length | same as Length() | |
int | len | same as Length() | |
int | size | same as Length() | |
wxString | Lower | ||
wxString | LowerCase | same as Lower() | |
void | MakeLower | ||
wxString | Upper | ||
wxString | UpperCase | same as Upper() | |
void | MakeUpper | ||
wxString | Mid | int,int | |
void | Remove | int,int | |
void | RemoveLast | ||
int | Replace | wxString,wxString[,bool] | |
wxString | Right | int | |
wxString | AfterFirst | char | |
wxString | AfterLast | char | |
wxString | BeforeFirst | char | |
wxString | BeforeLast | char |
wxArrayString
Return value | Name | Arguments | Remarks |
---|---|---|---|
void | Add | wxString | |
void | Clear | ||
int | GetCount | ||
wxString | Item | int |
ProjectFile
Return value | Name | Arguments | Remarks |
---|---|---|---|
void | AddBuildTarget | wxString | |
void | RenameBuildTarget | wxString,wxString | |
void | RemoveBuildTarget | wxString | |
wxString | GetBaseName | ||
wxString | GetObjName | ||
void | SetObjName | wxString | |
cbProject* | GetParentProject | ||
wxString | relativeFilename | (variable) | |
wxString | relativeToCommonTopLevelPath | (variable) | |
bool | compile | (variable) | |
bool | link | (variable) | |
int | weight | (variable) | |
wxString | compilerVar | (variable) |
CompileOptionsBase
Return value | Name | Arguments | Remarks |
---|---|---|---|
void | SetLinkerOptions | wxArrayString | |
void | SetLinkLibs | wxArrayString | |
void | SetCompilerOptions | wxArrayString | |
void | SetIncludeDirs | wxArrayString | |
void | SetResourceIncludeDirs | wxArrayString | |
void | SetLibDirs | wxArrayString | |
void | SetCommandsBeforeBuild | wxArrayString | |
void | SetCommandsAfterBuild | wxArrayString | |
wxArrayString | GetLinkerOptions | ||
wxArrayString | GetLinkLibs | ||
wxArrayString | GetCompilerOptions | ||
wxArrayString | GetIncludeDirs | ||
wxArrayString | GetResourceIncludeDirs | ||
wxArrayString | GetLibDirs | ||
wxArrayString | GetCommandsBeforeBuild | ||
wxArrayString | GetCommandsAfterBuild | ||
bool | GetModified | ||
void | SetModified | bool | |
void | AddLinkerOption | wxString | |
void | AddLinkLib | wxString | |
void | AddCompilerOption | wxString | |
void | AddIncludeDir | wxString | |
void | AddResourceIncludeDir | wxString | |
void | AddLibDir | wxString | |
void | AddCommandsBeforeBuild | wxString | |
void | AddCommandsAfterBuild | wxString | |
void | RemoveLinkerOption | wxString | |
void | RemoveLinkLib | wxString | |
void | RemoveCompilerOption | wxString | |
void | RemoveIncludeDir | wxString | |
void | RemoveResourceIncludeDir | wxString | |
void | RemoveLibDir | wxString | |
void | RemoveCommandsBeforeBuild | wxString | |
void | RemoveCommandsAfterBuild | wxString | |
bool | GetAlwaysRunPostBuildSteps | ||
void | SetAlwaysRunPostBuildSteps | bool | |
bool | SetVar | wxString,wxString,bool | |
wxString | GetVar | wxString | |
bool | UnsetVar | wxString | |
void | UnsetAllVars |
CompileTargetBase
Extends CompileOptionsBase.
Return value | Name | Arguments | Remarks |
---|---|---|---|
wxString | GetFilename | ||
wxString | GetTitle | ||
void | SetTitle | wxString | |
void | SetOutputFilename | wxString | |
void | SetWorkingDir | wxString | |
void | SetObjectOutput | wxString | |
void | SetDepsOutput | wxString | |
OptionsRelation | GetOptionRelation | OptionsRelationType | |
void | SetOptionRelation | OptionsRelationType,OptionsRelation | |
wxString | GetWorkingDir | ||
wxString | GetObjectOutput | ||
wxString | GetDepsOutput | ||
wxString | GetOutputFilename | ||
wxString | SuggestOutputFilename | ||
wxString | GetExecutableFilename | ||
wxString | GetDynamicLibFilename | ||
wxString | GetDynamicLibDefFilename | ||
wxString | GetStaticLibFilename | ||
wxString | GetBasePath | ||
void | SetTargetType | TargetType | |
TargetType | GetTargetType | ||
wxString | GetExecutionParameters | ||
void | SetExecutionParameters | wxString | |
wxString | GetHostApplication | ||
void | SetHostApplication | wxString | |
void | SetCompilerID | wxString | |
wxString | GetCompilerID |
ProjectBuildTarget
Extends CompileTargetBase.
Return value | Name | Arguments | Remarks |
---|---|---|---|
cbProject* | GetParentProject | ||
wxString | GetFullTitle | ||
wxString | GetExternalDeps | ||
void | SetExternalDeps | wxString | |
void | SetAdditionalOutputFiles | wxString | |
wxString | GetAdditionalOutputFiles | ||
bool | GetIncludeInTargetAll | ||
void | SetIncludeInTargetAll | bool | |
bool | GetCreateDefFile | ||
void | SetCreateDefFile | bool | |
bool | GetCreateStaticLib | ||
void | SetCreateStaticLib | bool | |
bool | GetUseConsoleRunner | ||
void | SetUseConsoleRunner | bool |
cbProject
Extends CompileTargetBase.
Return value | Name | Arguments | Remarks |
---|---|---|---|
bool | GetModified | ||
void | SetModified | bool | |
wxString | GetMakefile | ||
void | SetMakefile | wxString | |
bool | IsMakefileCustom | ||
void | SetMakefileCustom | bool | |
bool | CloseAllFiles | bool | |
bool | SaveAllFiles | ||
bool | Save | ||
bool | SaveLayout | ||
bool | LoadLayout | ||
bool | ShowOptions | ||
wxString | GetCommonTopLevelPath | ||
int | GetFilesCount | ||
ProjectFile* | GetFile | int | |
ProjectFile* | GetFileByFilename | wxString,bool,bool | |
bool | RemoveFile | int | |
ProjectFile* | AddFile | int,wxString,bool,bool,int | |
int | GetBuildTargetsCount | ||
ProjectBuildTarget* | GetBuildTarget | int | |
ProjectBuildTarget* | AddBuildTarget | wxString | |
bool | RenameBuildTarget | int,wxString | |
ProjectBuildTarget* | DuplicateBuildTarget | int,wxString | |
bool | RemoveBuildTarget | int | |
bool | ExportTargetAsProject | int | |
void | SetActiveBuildTarget | int | |
int | GetActiveBuildTarget | ||
int | SelectTarget | int,bool | |
ProjectBuildTarget* | GetCurrentlyCompilingTarget | ||
void | SetCurrentlyCompilingTarget | ProjectBuildTarget* | |
PCHMode | GetModeForPCH | ||
void | SetModeForPCH | PCHMode |
EditorBase
Return value | Name | Arguments | Remarks |
---|---|---|---|
wxString | GetFilename | ||
void | SetFilename | wxString | |
wxString | GetShortName | ||
bool | GetModified | ||
void | SetModified | bool | |
wxString | GetTitle | ||
void | SetTitle | wxString | |
void | Activate | ||
bool | Close | ||
bool | Save | ||
bool | IsBuiltinEditor | ||
bool | ThereAreOthers | ||
void | GotoLine | int,bool | |
void | ToggleBreakpoint | int,bool | |
bool | HasBreakpoint | int | |
void | GotoNextBreakpoint | ||
void | GotoPreviousBreakpoint | ||
void | ToggleBookmark | int,bool | |
bool | HasBookmark | int | |
void | GotoNextBookmark | ||
void | GotoPreviousBookmark | ||
void | Undo | ||
void | Redo | ||
void | Cut | ||
void | Copy | ||
void | Paste | ||
bool | CanUndo | ||
bool | CanRedo | ||
bool | CanPaste | ||
bool | HasSelection |
cbEditor
Extends EditorBase.
Return value | Name | Arguments | Remarks |
---|---|---|---|
void | SetEditorTitle | wxString | |
ProjectFile* | GetProjectFile | ||
bool | SaveAs | ||
void | FoldAll | ||
void | UnfoldAll | ||
void | ToggleAllFolds | ||
void | FoldBlockFromLine | int | |
void | UnfoldBlockFromLine | int | |
void | ToggleFoldBlockFromLine | int | |
int | GetLineIndentInSpaces | int | |
wxString | GetLineIndentString | int | |
void | Touch | ||
bool | Reload | bool | |
void | bool,PrintColourMode,bool | ||
void | AutoComplete | ||
bool | AddBreakpoint | int,bool | |
bool | RemoveBreakpoint | int,bool | |
void | SetText | wxString | this is not present in cbEditor; included to help scripts edit text |
wxString | GetText | this is not present in cbEditor; included to help scripts edit text |
Constants
Constant | Type | Remarks |
---|---|---|
PLATFORM | int | this defines the platform Code::Blocks is currently running on. It is equal to only one of the following PLATFORM_* constants |
PLATFORM_MSW | int | All Windows platforms |
PLATFORM_GTK | int | All GTK platforms (Linux, BSD, Solaris, Darwin, etc.) |
PLATFORM_MAC | int | All Mac platforms |
PLATFORM_OS2 | int | OS/2 platform |
PLATFORM_X11 | int | All X11 platforms |
PLATFORM_UNKNOWN | int | Unknown platform. Please inform us if PLATFORM == PLATFORM_UNKNOWN so we can make this platform known too ;) |
Message dialog flags | ||
wxOK | int | Flag for Message() 's third argument (flags). |
wxYES_NO | int | -"- |
wxCANCEL | int | -"- |
wxICON_QUESTION | int | -"- |
wxICON_INFORMATION | int | -"- |
wxICON_WARNING | int | -"- |
wxICON_ERROR | int | -"- |
Message dialog return values | ||
wxID_OK | int | |
wxID_YES | int | |
wxID_NO | int | |
wxID_CANCEL | int | |
enum OptionsRelationType | ||
ortCompilerOptions | enum | |
ortLinkerOptions | enum | |
ortIncludeDirs | enum | |
ortLibDirs | enum | |
ortResDirs | enum | |
enum OptionsRelation | ||
orUseParentOptionsOnly | enum | |
orUseTargetOptionsOnly | enum | |
orPrependToParentOptions | enum | |
orAppendToParentOptions | enum | |
enum TargetType | ||
ttExecutable | enum | |
ttConsoleOnly | enum | |
ttStaticLib | enum | |
ttDynamicLib | enum | |
ttCommandsOnly | enum | |
enum MakeCommand | ||
mcClean | enum | |
mcDistClean | enum | |
mcBuild | enum | |
mcCompileFile | enum | |
enum PCHMode | ||
pchSourceDir | enum | |
pchObjectDir | enum | |
pchSourceFile | enum | |
enum PrintScope | ||
psSelection | enum | |
psActiveEditor | enum | |
psAllOpenEditors | enum | |
enum PrintColourMode | ||
pcmBlackAndWhite | enum | |
pcmColourOnWhite | enum | |
pcmInvertColours | enum | |
pcmAsIs | enum | |
enum TemplateOutputType | ||
wizProject | enum | TemplateOutputType::totProject |
wizTarget | enum | TemplateOutputType::totTarget |
wizFiles | enum | TemplateOutputType::totFiles |
wizCustom | enum | TemplateOutputType::totCustom |
Other constants | ||
wxFILE_SEP_PATH | wxString | Path separator. "\" for windows, "/" for all other platforms |
File extensions (e.g. "cbp") | ||
EXT_WORKSPACE | wxString | |
EXT_CODEBLOCKS | wxString | |
EXT_DEVCPP | wxString | |
EXT_MSVC6 | wxString | |
EXT_MSVC6_WORKSPACE | wxString | |
EXT_MSVC7 | wxString | |
EXT_MSVC7_WORKSPACE | wxString | |
EXT_D | wxString | |
EXT_F | wxString | |
EXT_F77 | wxString | |
EXT_F95 | wxString | |
EXT_CPP | wxString | |
EXT_C | wxString | |
EXT_CC | wxString | |
EXT_CXX | wxString | |
EXT_HPP | wxString | |
EXT_H | wxString | |
EXT_HH | wxString | |
EXT_HXX | wxString | |
EXT_OBJECT | wxString | |
EXT_XRCRESOURCE | wxString | |
EXT_STATICLIB | wxString | |
EXT_DYNAMICLIB | wxString | |
EXT_EXECUTABLE | wxString | |
EXT_RESOURCE | wxString | |
EXT_RESOURCEBIN | wxString | |
File extensions with leading dot (e.g. ".cbp") | ||
DOT_EXT_WORKSPACE | wxString | |
DOT_EXT_CODEBLOCKS | wxString | |
DOT_EXT_DEVCPP | wxString | |
DOT_EXT_MSVC6 | wxString | |
DOT_EXT_MSVC6_WORKSPACE | wxString | |
DOT_EXT_MSVC7 | wxString | |
DOT_EXT_MSVC7_WORKSPACE | wxString | |
DOT_EXT_D | wxString | |
DOT_EXT_F | wxString | |
DOT_EXT_F77 | wxString | |
DOT_EXT_F95 | wxString | |
DOT_EXT_CPP | wxString | |
DOT_EXT_C | wxString | |
DOT_EXT_CC | wxString | |
DOT_EXT_CXX | wxString | |
DOT_EXT_HPP | wxString | |
DOT_EXT_H | wxString | |
DOT_EXT_HH | wxString | |
DOT_EXT_HXX | wxString | |
DOT_EXT_OBJECT | wxString | |
DOT_EXT_XRCRESOURCE | wxString | |
DOT_EXT_STATICLIB | wxString | |
DOT_EXT_DYNAMICLIB | wxString | |
DOT_EXT_EXECUTABLE | wxString | |
DOT_EXT_RESOURCE | wxString | |
DOT_EXT_RESOURCEBIN | wxString |