Plugins

  Previous topic Next topic  

The concept of "Plugins" is quiet old and all the major tools provide some interface to hook third-party plugins to extend the domain of such tool. hbIDE also provides such interface. Below is the initial ChangeLog entry text which describes this protocol.

 


2010-05-09 20:11 UTC-0800 Pritpal Bedi ([hidden email])
* contrib/hbide/hbide.prg
* contrib/hbide/ideplugins.prg
% 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])
+ contrib/hbide/plugins
+ contrib/hbide/plugins/savebackup.hrb
+ contrib/hbide/plugins/savebackup.prg
+ 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.
 
+ contrib/hbide/resources/selectionline.png
+ Image to be activated when "Line" selection mode is on.
 
* contrib/hbqt/hbqt_hbqplaintextedit.cpp
 
* contrib/hbide/hbide.hbp
+ Added ideplugin.prg
 
* contrib/hbide/idethemes.prg
+ Added more keywords for syntax-highlighting.
 
* contrib/hbide/hbide.prg
* contrib/hbide/idedocks.prg
* contrib/hbide/ideedit.prg
* contrib/hbide/ideeditor.prg
+ contrib/hbide/ideplugins.prg
+ Priliminary commit to handle plugins.
 
* contrib/hbide/ideshortcuts.prg
 
+ 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:
 
1. hrb_file_name_without_extension_plus_underscrore_plus_INIT()
savebackup_INIT( ... ) -> TRUE/FALSE
2. hrb_file_name_without_extension_plus_underscrore_plus_EXEC()
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
in future.
 
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().
 
Loading Plugins
===============
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.
 
 

Page url: http://hbide.vouch.info/?plugins.htm