Events - hakakou/optiperl GitHub Wiki
Events are triggered when the user does various actions in OptiPerl. When creating a plug-in using perl, simply adding a subroutine in the code with one of the names of the events below automatically calls it when specified.
The events are:
OnDocumentOpen(Path as String) as Boolean
Fires before opening a new script. If you use this subroutine, return true or false for whether optiperl should actually open the file specified.
example:
sub OnDocumentOpen {
$optiperl->OutputAddLine($_[0]);
#Returning 0 will cancel opening the file.
return 1;
}
OnDocumentClose(Path as String)
Fires right after closing a script.
example:
sub OnDocumentClose {
AddLog("Closed: $_[0]");
}
OnActiveDocumentChange
Fires right after a document is selected in the editor.
OnParseStart
Fires right before OptiPerl starts parsing the edited code for syntax highlighting.
OnParseEnd
Fires right after OptiPerl finishes parsing the code.
OnCanTerminate : Boolean
Called when the user wants to close OptiPerl. If you use this subroutine, return true or false for whether optiperl should be allowed to close.
OnKeyEvent(nVirtKey as Integer, lKeyData as Integer) as Boolean
Very low level key handler. Fires whenever the user presses a key and again after releasing it. The two parameters are the virtual-key code and keystroke-message information passed by Windows. If you use this subroutine, return true or false for whether optiperl should actually process the keystroke.
OnBeforeAction(Action as String) as Boolean
Fires before the user executes an action. See list of actions & shortcuts for more information. Returning 0 will cancel executing the action.
OnAfterAction(Action as String)
Fires after the execution of the action.