Event Handler Uses
Application Events
event AppStart() event AppShutdown() event AppCommand(sCommand)
Document Events
event DocumentNew(sFile) event DocumentOpen(sFile) event DocumentClose(sFile) event DocumentSave(sFile) event DocumentSaveComplete(sFile) event DocumentChanged(sFile) event DocumentSelectionChanged(sFile)
Project Events
event ProjectOpen(sProject) event ProjectClose(sProject)
Statusbar Events
event StatusbarUpdate(sMessage)
Event Handler Uses
You can use event handlers for many things, but a few ideas are:
•
Monitor and log activity. For example, you can log actions to a log file, and later use that information to analyze what parts of a project have been edited.
•
Synchronize another program or file with actions inside Source Insight.
•
Alter the way that Source Insight works.
•
Perform post-processing of files before saving them.
•
Perform preprocessing of new files.
Adding Event Handlers to Source Insight
Event handlers are stored in macro source files. That is, they have the
.em
extension. You can mix event and macro functions in the same file. Once you write an event handler, you should add it to the current project.
You can add it to the Base project if you want the events to be handled regardless of the project. If Source
Insight cannot find a given event handler, it is ignored. Source Insight searches in your project, the project symbol path, and the Base project.
It's important to remember that you must add the
.em
file to a project, or Source Insight will not invoke the event handlers in that file. This is to prevent event handlers from accidentally running just by opening a .em file with an event function in it.
412 Source Insight 4 User Guide