Plugin API: Global objects

Globally available objects

Object Script

Methods

Method Returns Description
RegisterAction(Category, Caption, Shortcut, Function) none Register new item under Plugins menu, under additional submenu if Category is not empty.
Shortcut must be empty or specified in format [Shift+][Ctrl+][Alt+]Key (at least one of Shift/Ctrl/Alt must be specified). Example shortcut: Ctrl+Alt+B.
Function is reference to function with a single parameter that will be called when user clicks the menu item: Function(Sender).
Note that users will be allowed by menu and toolbar customization to place this action in any other menu or toolbar and reconfigure shortcuts.
RegisterDocumentAction(Category, Caption, Shortcut, Function) none The same as RegisterAction, but this action is only enabled if any document is open.
ConnectSignal(Signal, Function) none Connects function that needs to be called when specified signal is received. See signals reference.
ReadSetting(Name, DefaultVal) string Reads specified setting from properties.ini.
WriteSetting(Name, Value) none Writes specified setting to properties.ini.
CreateScriptableWebKit(Parent, Url, OnCreated) ScriptableChromium Creates WebKit control. OnCreated is reference to function(Sender, Browser). See WebKit form example.
CreateScriptableJsExecuter(DefaultUrl) ScriptableJsExecuter Creates JavaScript background executer. See ScriptableJsExecuter example.
Message(string) none Output message to Messages pane.
ClearMessages none Clear Messages pane.
HTTPGet(Url, OnComplete) ScriptableDownloadThr Downloads specified Url and calls referenced function OnComplete when download is finished: OnComplete(Downloaded_Data).
TimeOut(MilliSeconds, OnTimer) ScriptableTimer Calls referenced function OnTimer after specified time: OnTimer().

Properties

Property Type Description
Settings EditorSettings Access editor settings.
Status string Get/set application status bar message.
Path string Get plugin's folder path.
ProjectSettings ProjectSettings Get current project settings.
DpiScale float Get Windows DPI scale (1 = 100% Text Zoom). Use to scale any graphical elements created by plugin according to DPI scale.
IsDarkTheme bool Returns true if dark theme used for all GUI.

Object Editor, class ScriptableEditor

Object Editor represents currently active editor area. Editor areas in other document windows can be accessed via ScriptableDocumentWindow class.

Methods

Method Returns Description
SelectAll none Select all text.
BeginEditing none Enclose multiple text manipulation operations in BeginEditing...EndEditing to create a single unified Undo action.
EndEditing none See BeginEditing.
IsEditing bool Returns true if inside BeginEditing...EndEditing block.
Focus none Sets keyboard focus to editor.
TextPosToCursorPos(TextPos, &X, &Y) none Converts position in text (where Tab character is considered a single symbol) to cursor position (where Tab character can be any size as set in settings).
CursorPosToTextPos(X, Y, &TextPos) none Converts cursor position (where Tab character can be any size as set in settings) to position in text (where Tab character is considered a single symbol).
IsLineCollapsed(Y) bool Returns true if specified line is collapsible and is collapsed.
IsLineExpanded(Y) bool Returns true if specified line is collapsible and is expanded.
ToggleLineCollapse(Y) none Collapses or expands specified line, if the line is collapsible.
GetSelectionForUnixNewlines(&SelStart, &SelLen) none Returns what selection info for editor text would be if Unix style newlines (1 character) were used instead of Windows newlines (2 bytes).
ExecAutoCompleteNow(CharStr: string) none Trigger auto complete. CharStr allows specifying trigger character. Leave CharStr empty for emulating Ctrl+Space.

Properties

Property Type Description
Selection ScriptableEditorSelection Access editor's selection. See ScriptableEditorSelection reference.
SelText string Get/set selection text value.
Text string Get/set editor text.
LineCount integer Get number of text lines.
Modified bool Get/set whether editor text is modified (unsaved).
TopLine integer Get/set top visible editor's line. Changing this property will scroll editor.
LinesAsDisplayed[Y] string Get/set text line. When reading line, Tabs are converted to spaces.
Lines[Y] string Get/set text line.

Object Document, class ScriptableDocumentWindow

Object Document represents currently active document window (tab). Other document windows can be accessed via ScriptableDocumentWindows class.

Methods

Method Returns Description
Activate none Activate this document window.
Save(FileName) none If FileName is not empty then save as FileName, otherwise default save.
Close(NoSaving) none if NoSaving is true then close document without asking to save if modified, otherwise default close.

Properties

Property Type Description
Editor ScriptableEditor Access editor area of document window.
FileName string Get/set file name of document.
FtpFileName string Get/set file name of document if file is opened from FTP.
IsActive bool Returns true if document window is active.
PreviewTabIndex integer Get/set index of preview tab (Code Editor/Preview/Horizontal Split/Vertical Split).
DocType enum Get document type. Possible values: dtDefault, dtHTML, dtXML, dtCSS, dtJScript, dtVBScript, dtPerl, dtText, dtWML, dtPHP, dtASP, dtSQL, dtRuby, dtERuby, dtASPX, dtCS, dtSmarty, dtPython, dtApache, dtSass, dtLess.
CurrentCodeType enum Get current code type according to cursor position (e.g. in HTML files there can be multiple code types: HTML, CSS and JavaScript all in single file). Possible values: ltDefault, ltHTML, ltXML, ltCSS, ltJScript, ltWML, ltPHP, ltASP, ltRuby, ltSmarty, ltCS.
Encoding enum Get/set document encoding. Possible values: enAnsi, enUtf8, enUtf8NoBom, enUcs2.

Object Documents, class ScriptableDocumentWindows

Methods

Method Returns Description
NewDocument(Extension) none Create new tab with specified file extension (html, php, js etc).
OpenDocument(FileName) none Open specified file. If FileName is empty then Open Dialog is displayed.
TabByFileName(FileName) ScriptableDocumentWindow Returns reference to document window that contains specified file.

Properties

Property Type Description
Count integer Get number of open document windows (tabs).
Tab[i] ScriptableDocumentWindow Get i-th document window.

Class ScriptableEditorSelection

To manipulate selection you need to obtain current selection, change it and then assign changed selection back to editor. Sample:

var Sel = Editor.Selection; //obtain current selection
Sel.SelLength = 0;          //change selection properties
Editor.Selection = Sel;     //set selection to changed
There are a few gotchas. All selections obtained from a single editor reference the same object and changing one of them will change all of them. When changing selection you must manipulate either Line/Column properties or SelStart/Length properties. You can't mix them, e.g., setting SelStartLine and then SelLength won't work as expected.

Properties Type Description
SelStartLine integer Get/set line in which selection starts.
SelStartCol integer Get/set column in which selection starts. Note that it can be outside the text.
SelEndLine integer Get/set line in which selection ends.
SelEndCol integer Get/set column in which selection ends. Note that it can be outside the text.
SelStartColReal integer Get/set column in which selection starts in text units. Tabs are treated as a single position unit. Returned position is adjusted to not be outside the text.
SelEndColReal integer Get/set column in which selection starts in text units. See SelStartColReal for notes.
SelStart integer Get/set position of text in which selection starts in text units. Tabs are treated as a single position unit, Newlines are treated as two position units.
SelLength integer Get/set selection length in text units.

Class EditorSettings

Properties Type Description
TabSize integer Get Tab size setting.
TabsToSpaces bool Get whether Convert Tabs to spaces is ON.
BlockIndent integer Get Indent size setting.
TabIndent bool Get whether Use TAB key for indenting is ON.
AutoIndent bool Get whether Auto indent is ON.
CursorTraverse bool Get whether Constratin cursor to text if OFF.
LeaveTrailSpaces bool Get whether Remove trailing spaces and tabs if OFF.

Class ProjectSettings

Properties Type Description
SelectedProjectName string Get name of current project.
SelectedProjectRoot string Get root folder of current project.
SelectedProjectFileTypes string Get included file types of current project.
SelectedProjectExcludeFilters string Get exclude filters of current project as multi-line string.
SelectedProjectAssetsBrowseDir string Get folder to use as initial directory for file browse dialogs while this project is active.

Object Actions, class ScriptableActions

Provides access to all Rapid CSS actions that are triggered from menus, toolbars and keyboard shortcuts. These actions can be triggered from the script.

Methods

Method Returns Description
List array of string Obtain list of Rapid CSS actions. Returns internal action names that serve as parameters for other methods of this class.
GetCaption(Actn) string Get caption of action.
IsChecked(Actn) bool Get checked state of action.
SetChecked(Actn, Value) none Set checked state for action.
IsEnabled(Actn) bool Get enabled state of action.
SetEnabled(Actn, Value) none Set enabled state for action.
Execute(Actn) none Trigger action.
SetIcon(Actn, Icon) none Set default icon for action. Icon is TBitmap.

Object WeBuilder

Properties Type Description
Caption string Get/set title of main window of IDE.
BuildNumber integer Get IDE's version build number.
Version string Get IDE's version as text.

Class ScriptableDownloadThr

Do not delete objects of this type manually.

Class ScriptableTimer

Do not delete objects of this type manually. Use Kill method for that.

Methods

Method Returns Description
Kill none Stops the timer and deletes this object.

Class AutoCompleteLibrary

Used to customize PHP frameworks from plugins.

Methods

Method Returns Description
DeleteLibrary(LibraryName) none Delete framework.
AddPHPLibrary(LibraryName) none Add new PHP framework.
AddPHPEntry(LibraryName, ItemType, Name, Description, Inheritance, Scope, IsStatic, Arguments, ClassName, Returns) none Add auto-complete item (class, function, property etc) to PHP framework.

Object AutoComplete, Class ScriptableAutoComplete

Used to interact with auto-complete lists and hints. Generally this class is used when handling auto_complete signal. See examples.

Methods

Method Returns Description
Clear(Strings) none Clears auto-complete list.
AddItem(Strings, CodeWord, Txt) integer Add new entry to auto-complete list.
GetWordBeforeCursor(AdditionalChars) string Get word in editor just before text cursor. Word is considered anything consisting from aplhanumeric chars, but additional symbols can be specified in parameter.
Count(Strings) integer Get auto-complete list item count.
GetCodeWord(idx) string Get code word of auto-complete item by index.
GetFunctionData(LookupType, &Name, &ObjName, &ObjClass, &ObjSignature, &Param, &Start) none Parse and return information about code related to current cursor position. LookupType can be "JS", "PHP" or "RUBY".
FormatActiveParam(s, ParamNum) string Process function definition and make specified parameter bold for auto-complete hint.

Class ScriptableChromium

Methods

Method Returns Description
Subscribe(ChannelName, Method) none Referenced Method will be called when JavaScript sends data with specified channel name to IDE: Method(ChannelName, Data).
Data can be sent from WebKit source with following JavaScript code: WeBuilderData.Send(ChannelName, Data). Data returned by Method can be received by JavaScript caller.
Unsubscribe(ChannelName) none Unsubscribe from channel.
Send(Title, Data) none Send data to JavaScript. Data will be received if JavaScript has created global function WeBuilder_OnData as function(title, data)
SendWithCallback(Title, Data, Callback) none Same as Send() but Callback function will be executed after JavaScript has received the data. Callback is function(data) where data contains return value of WeBuilder_OnData function.
ExecuteJavaScript(js) none Evaluate JavaScript code in browser.
GetSource(Callback) none Request source code from browser and execute Callback function when source received. Callback is function(source).

Properties

Property Type Description
OnLoadEnd function Get/set OnLoadEnd event function. Property type is reference to function(Sender, Browser, Frame, HttpStatusCode, &Result).
OnStatusMessage function Get/set OnStatusMessage event function. Property type is reference to function(Sender, Browser, Value, StatusType, &Result).
OnConsoleMessage function Get/set OnConsoleMessage event function. Property type is reference to function(Sender, Browser, Message, Source, Line, &Result).
WebKit Chromium Get reference to Chromium object.
Status string Get last status message.
Url string Get/set URL.

Class ScriptableJsExecuter

Methods

Method Returns Description
ExecuteJavaScriptRequest(JavaScript, Channelname, Params, Callback) none Executes JavaScript in chromium engine and calls WeBuilder_OnData(Channelname, Params) function. Leave Channelname empty to generate it. To return data from Chromium to specified Callback function of plugin, use WeBuilderData.SendNative(channel, ReturnValue, ErrorMessage). Make sure that channel matches that sent during WeBuilder_OnData.
ExecuteJavaScriptFileRequest(FileName, Channelname, Params, Callback) none Same as ExecuteJavaScriptRequest but JavaScript code is read from file.
ExecuteJavaScriptSimple(JavaScript) none Executes JavaScript in chromium engine. Does not set up return channel or call WeBuilder_OnData.
ExecuteJavaScriptFileSimple(FileName) none Same as ExecuteJavaScriptSimple but JavaScript code is read from file.

Properties

Property Type Description
OnLoadEnd function Get/set OnLoadEnd event function. Property type is reference to function(Sender, Browser, Frame, HttpStatusCode, &Result).
OnStatusMessage function Get/set OnStatusMessage event function. Property type is reference to function(Sender, Browser, Value, StatusType, &Result).
OnConsoleMessage function Get/set OnConsoleMessage event function. Property type is reference to function(Sender, Browser, Message, Source, Line, &Result).
WebKitOSR Chromium Get reference to the invisible Chromium object.
Status string Get last status message.
Url string Get/set URL.
Ready bool Returns true if Chromium is initialized and ready to execute JavaScript.

Class Chromium

Methods

Method Returns Description
Load(url) none Start loading URL.
LoadString(str, url) none Load data from string. Url specifies document.location.href but it won't be loaded.

Class ScriptableJSON

Methods

Method Returns Description
Parse(JSONString) none Parses string to JSON object.
Stringify() none Generates JSON string.
SetValue(key, Value) none Sets key/value pair in JSON object.
GetValue(key) string/integer/bool Gets value from JSON object.
DeleteKey(key) none Delete key/value pair from JSON object.
HasKey(key) bool Returns true if key exists in JSON object.