Here is a first version of the plugin (based on git head). As I only have a Windows machine, I can only provide a Windows version of the plugin... sorry
Of course, feedback is welcome. Moreover, as it is, the current API is enough for my own needs. But I can add all bindings you need to extends the current API.
To install it, you must extract the 7z content to your plugins directory.
This plugin provides a toolbar with 2 buttons :
- Show scripts : shows / hide a miniframe which contains all "on demand" script. Double clicking on a script runs it.
- Scripts settings : it show a dialog that allow you to add / remove scripts (on demand script or hooks scripts).
All scripts embed a global "codelite" variable, you can use to interract with codelite.
Here is the API :
codelite
- codelite.manager : gives you acces to the IManager
- codelite.Trace(str) : add a trace in the trace tab
- codelite:Bind(evendId, function) : This function is only usefull when creating a hook script. It binds the function to the current event. Currently, only the wxEVT_FILE_SAVED has been implemented.
IManager
- manager:GetActiveEditor() : return the current editor or nil
- manager:NewEditor() : Create a new editor, and returns it
- manager:GetWorkspace() : return the workspace or nil
IEditor
- editor:GetEditorText() : return the text of the editor
- editor:SetEditorText(str) : set the content of the editor
- editor:GetSelection() : return the current selection
- editor:ReplaceSelection(str) : replace the current selection with the given string
- editor:AppendText(str) : Append the given string at the end of the editor
- editor:GetCurrentPosition() : return the position of the caret
- editor:InsertText(int, str) : Insert text at the given position
Workspace
- workspace:GetActiveProjectName() : return the name of the active project
- workspace:GetProjectList() : return a table containing all project names
- worspace:FindProjectByName(str) : return the project named with the given string, or nil
Project
- project:GetName() : return the project name
- project:GetFiles() : return a table containing all file paths
Event
- event:GetString() : return the string, depending on the event context
Here is a "on demand" script which allow you to comment the current selection :
Code: Select all
editor = codelite.manager:GetActiveEditor()
if editor then
sel = editor:GetSelection()
if #sel > 0 then
text = "/* " .. sel .. " */"
editor:ReplaceSelection(text)
end
end
And here a hook script which trace each saved files
Code: Select all
local f = function(event)
codelite.Trace("FILE SAVED : " .. event:GetString())
end
codelite:Bind(wxEVT_FILE_SAVED, f)
You do not have the required permissions to view the files attached to this post.