2010-05-09 20:11 UTC-0800 Pritpal Bedi ([hidden email])
% Changed: plugins are loaded on first call instead of
loading all plugins at startup. Now the overhead is negligible.
2010-05-09 17:21 UTC-0800 Pritpal Bedi ([hidden email])
+ Source and corresponding .hrb ( -gh ) plugin.
In practice .prg is never required for this purpose.
The source accompanying here is for demonstration purposes
which exposes elements to comprehend.
+ Image to be activated when "Line" selection mode is on.
+ Added ideplugin.prg
+ Added more keywords for syntax-highlighting.
+ Priliminary commit to handle plugins.
+ Implemented: a very simple yet powerful interface to hook plugins.
The idea got polished with Francesco Perillo's description of the thought.
Creating a hbIDE plugin
A .hrb ( compiled with -gh as the minimum ), i.e., savebackup.prg,
having two mandatory functions:
savebackup_INIT( ... ) -> TRUE/FALSE
savebackup_EXEC( oIde, ... ) -> xValue
savebackup_INIT() will be used to establish hand-shake and it must
return a logical indicating success or failure. Currently it is
called with "1.0" as version no but is scheduled to be enhanced
If hand-shake is successful, means, savebackup_INIT( ... ) returns
with TRUE, savebackup_EXEC( oIde, ... ) is called as per user
request. oIDE is sent as the first argument followed by user supplied
arguments. Within this function in .hrb, all action takes place.
User can write n number of functions withing the same source but
all other functions will always be STATIC ones.
The whole hbIDE object is passed with each execution and hence
user is having utmost control over what he wants to accomplish.
Location of the Plugin
All plugins ( .hrb ) must reside within "plugins" sub-folder from hbIDE.exe
location. The location is determined with return value of
hb_dirBase() + hb_osPathSeparator() + "plugins" + hb_osPathSeparator().
At startup hbIDE looks into "plugins" folder for all .hrb files.
It then tries to establish hand-shake with them. If successful, a
handle is retained in static array. When an execution request is
encountered, this static array is searched for and
savebackup_EXEC( oIDE, ... ) is called and return value is passed
back to the caller macro.
Executing Plugins in hbIDE
A public method ::execPlugin( cPlugin, ... ) is implemented under
"Keyboard Mappings". ::execPlugin is called with plugin name, which
essentially is the .hrb file name. So in demo example, it is
"savebackup". Final expression would be like :
::execPlugin( "savebackup", "saveas" )
Here "saveas" is the identifier which is used in this demo to invoke
STATIC FUNCTION savebackup_saveAs( oIde )
Author of plugin has to decide how and what he would like to pass
what and in how many. So simply build a macro to call a plugin
with parameters, that's it.
I am hopeful that you, brilliant programmers, with help extending hbIDE
to an amazing levels. Send your critics to the list to enrich this thought.