Difference between revisions of "Scripting commands"
Line 1,323: | Line 1,323: | ||
|- | |- | ||
| wxString || GetFirstValidBuildTargetName || bool || | | wxString || GetFirstValidBuildTargetName || bool || | ||
+ | |- | ||
+ | |||
+ | |- | ||
+ | | void || SetDefaultExecuteTarget || wxString || | ||
|- | |- | ||
Line 1,330: | Line 1,334: | ||
|- | |- | ||
− | | | + | | bool || SetActiveBuildTarget || wxString || |
|- | |- | ||
|- | |- | ||
− | | | + | | wxString || GetActiveBuildTarget || || |
|- | |- | ||
Revision as of 23:04, 11 January 2008
Scripting is no good if all you can do is use the scripting language's built-in 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.
NOTE: Please keep in mind that if a function has default parameters in C++ (which can be ommitted), you still have to type them for scripts (for e.g. exposed wxWidgets functionality). This means you *have* to use e.g. wxFileName.GetFullPath(wxPATH_NATIVE) instead of e.g only wxFileName.GetFullPath().
Application object
The application object is accessed through the variable named App. Currently it has no bound functions...
Global functions
Return value | Name | Arguments | Remarks |
---|---|---|---|
void | Log | wxString | logs to the application log |
void | LogDebug | wxString | logs to the debug log |
void | LogWarning | wxString | logs a warning |
void | LogError | wxString | logs an error |
int | Message | wxString,wxString,int | arg1=msg, arg2=caption, arg3=buttons; see API docs for cbMessageBox() |
void | ShowMessage | wxString | |
void | ShowWarning | wxString | |
void | ShowError | wxString | |
void | ShowInfo | wxString | |
wxString | ReplaceMacros | wxString,bool | |
ScriptingManager* | GetScriptingManager | ||
ProjectManager* | GetProjectManager | ||
EditorManager* | GetEditorManager | ||
ConfigManager* | GetConfigManager | ||
UserVariableManager* | GetUserVariableManager | ||
CompilerFactory* | GetCompilerFactory | ||
wxString | GetFolder | int | see API docs for ConfigManager::GetFolder() |
wxString | LocateDataFile | wxString, int | see API docs for ConfigManager::LocateDataFile() |
bool | InstallPlugin | wxString,bool, bool | Install a binary plugin |
void | Include | wxString | similar to C/C++ #include "name" |
bool | IsNull | void* | |
wxString | _T | const char* | basically this is the wxString constructor |
bool | wxLaunchDefaultBrowser | wxString | |
wxColour | wxGetColourFromUser | [wxColour] | |
long | wxGetNumberFromUser | wxString,wxString,wxString | |
wxString | wxGetPasswordFromUser | wxString,wxString,wxString | |
wxString | wxGetTextFromUser | wxString,wxString,wxString |
ScriptingManager
Return value | Name | Arguments | Remarks |
---|---|---|---|
bool | RegisterScriptMenu | wxString, wxString | registers the script file (arg1) under a menu item (arg2).
e.g. GetScriptingManager().RegisterScriptMenu(_T("sample.script"), _T("Scripts/Sample script")); |
Notes about the RegisterScriptMenu function:
- The second argument (menu item) is a string containing the full menu path to create the menu item. The path separator is a slash (/). For example, the string "Settings/Sample menu/Sample item" would create the menu path "Settings->Sample menu->Sample item".
- When each part of the path is evaluated, it is checked whether it starts with a number followed by a colon (:). If so then this is considered to be a menu index in the parent menu and the menu is inserted at that index instead of being appended to the menu. The number and colon are removed from the string.
- If the menu item starts with a dash (-), then a separator line is prepended in the menu before the menu item (e.g. "Scripts/-Sample script").
- For your convenience, all menu items created using this function have one extra functionality: if you keep the SHIFT key pressed while clicking on any of these "script menu items", instead of running the attached script, Code::Blocks will open it in the editor for you to view/edit :).
- Have a look at the startup script example.
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 | CreateDirectory | wxString,int | arg1=dir, arg2=permissions |
bool | RemoveDirectory | wxString | |
bool | CopyFile | wxString,wxString,bool | src,dest,overwrite |
bool | RenameFile | wxString,wxString | old,new |
bool | RemoveFile | wxString | |
bool | FileExists | wxString | |
wxString | SelectFile | wxString,wxString,wxString | |
bool | ReadFileContents | wxString,wxString | filename,contents |
bool | WriteFileContents | wxString,wxString | filename,contents |
int | Execute | wxString | |
wxString | ExecuteAndGetOutput | wxString |
Notes:
The namespaces are accesses by prepending it's name (e.g. "IO.") to the scripting function, e.g. "IO.DirectoryExists(...)". "::" is only used when declaring the members of the namespace.
The functions in bold are going through the scripts security layer so there is no guarantee calling them will succeed. You should always examine the return value...
There exists one constant too, named allowInsecureScripts, which allow you to test whether Code::Blocks was compiled with the functions going through the security layer.
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 |
NOTE: Is instantiated in a script using: local my_wxstring = ::wxString();
wxArrayString
Return value | Name | Arguments | Remarks |
---|---|---|---|
void | Add | wxString, size_t | arg1=string, arg2=number of copies to add |
void | Clear | ||
int | GetCount | ||
wxString | Item | int |
NOTE: Is instantiated in a script using: local my_wxarraystring = ::wxArrayString();
wxColour
Return value | Name | Arguments | Remarks |
---|---|---|---|
byte | Red | ||
byte | Green | ||
byte | Blue | ||
void | Set | byte,byte,byte |
NOTE: Is instantiated in a script using: local my_wxcolour = ::wxColour();
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 | GetCustomBuildCommand | wxString | |
void | SetCustomBuildCommand | wxString,wxString | |
bool | GetUseCustomBuildCommand | wxString | |
void | SetUseCustomBuildCommand | wxString,bool | |
wxFileName | file | (variable) | |
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 | AddPlatform | int | |
void | RemovePlatform | int | |
void | SetPlatforms | int | |
void | GetPlatforms | int | |
void | SupportsCurrentPlatform | int | |
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 | |
void | SetBuildScripts | wxArrayString | |
wxArrayString | GetBuildScripts | ||
void | AddBuildScript | wxString | |
void | RemoveBuildScript | wxString | |
bool | SetVar | wxString,wxString,bool | |
wxString | GetVar | wxString | |
bool | UnsetVar | wxString | |
void | UnsetAllVars |
CompileTargetBase
Extends CompileOptionsBase.
Return value | Name | Arguments | Remarks |
---|---|---|---|
void | SetTargetFilenameGenerationPolicy | enum, enum | |
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 | ||
wxString | GetMakeCommandFor | enum | |
void | SetMakeCommandFor | enum,wxString | |
bool | MakeCommandsModified |
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 | Display the project options dialog | |
wxString | GetCommonTopLevelPath | ||
int | GetFilesCount | Returns number of files in the project | |
ProjectFile* | GetFile | int | |
ProjectFile* | GetFileByFilename | wxString,bool,bool | See API docs for cbProject::GetFileByName |
bool | RemoveFile | int | |
ProjectFile* | AddFile | int,wxString,bool,bool,int | See API docs for cbProject::AddFile |
int | GetBuildTargetsCount | ||
ProjectBuildTarget* | GetBuildTarget | int | |
ProjectBuildTarget* | AddBuildTarget | wxString | |
bool | RenameBuildTarget | int,wxString | |
ProjectBuildTarget* | DuplicateBuildTarget | int,wxString | |
bool | RemoveBuildTarget | int | |
bool | ExportTargetAsProject | int | |
bool | BuildTargetValid | bool | |
wxString | GetFirstValidBuildTargetName | bool | |
void | SetDefaultExecuteTarget | wxString | |
wxString | GetDefaultExecuteTarget | wxString | |
bool | SetActiveBuildTarget | wxString | |
wxString | 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 | |
EXT_XML | wxString | |
EXT_SCRIPT | 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 | |
DOT_EXT_XML | wxString | |
DOT_EXT_SCRIPT | wxString |