- WaveSurfer Plug-in API
- Options to RegisterPlugin
- POD ERRORS

# WaveSurfer Plug-in API

WaveSurfer plug-ins are implemented in Tcl/Tk as a collection of procedures. During startup, the application will search certain system and user directories for plug-in scripts, and source them into the interpreter. The plugin script file must contain a call to the following procedure: wsurf::RegisterPlugin name ?option value? ... name is the name of the plug-in. Many of the options are used to associate event callbacks to procedures in the plug-in implementation. Note that the plug-in does not need to implement all callbacks, only the ones that are relevant to its functionality. It is advisable for all plug-ins to exist in their own namespace, with the same name as the plugin.

Most callbacks are invoked with the current widget as the first argument, and in the cases where the event refers to a pane, the pane window name will be the second argument.

# Options to RegisterPlugin

-description

  Specifies a textual description of the plugin's functionality. It will be displayed in plug-ins page of the preferences dialog.

-url

  Specify a home page URL for the plugin. It will be displayed in plug-ins page of the preferences dialog.

-addmenuentriesproc

  Specifies a callback procedure to be invoked when a context sensitive popup menu is created for a pane. This will allow the plug-in to add entries to the menu at the time it is posted. Callback syntax:

  `callback widget pane menu subMenu x y`

  menu refers to the window name of the popup menu widget, subMenu is an identifier of a sub-menu, can be create or an empty string. x and y refers to the coordinates where the menu button was pressed.

-applypropertiesproc

  Specifies a callback procedure to be invoked to apply the current values in the properties dialog. Callback syntax:

  `callback widget pane`

-copyproc

  Specifies a callback procedure to be invoked when a copy operation is performed in the widget. Callback syntax:

  `callback widget start end`

  start and <end> are given in seconds as floating point numbers.

-cursormovedproc

  Specifies a callback procedure to be invoked when the cursor is moved. Callback syntax:

  `callback widget pane time value`

  time is the cursor position along the time axis, in seconds. value is the cursor position along the value axis, in the pane's local units, see getBoundsProc. Both are given as floating point numbers.

-cutproc

  Specifies a callback procedure to be invoked when a cut operation is performed in the widget. Callback syntax:

  `callback widget start end`

  start and <end> are given in seconds as floating point numbers.

-getboundsproc

  When the a pane is redrawn, this callback is invoked to query the plugin for the extents of its contents. Callback syntax:

  `callback widget pane`

  The return value of the callback should be a list containing the time and value bounds for the plugin contents, as four elements: tmin vmin tmax vmax, where tmin and tmax are the minimum and maximum time, and vmin and vmax are the minimum and maximum values.

-getconfigurationproc

  Specifies a callback that invoked when the widget's current configuration is to be saved, to allow the plug-in to add its own configuration statements. Callback syntax:

  `callback widget pane`

  The callback is first invoked with pane as an empty string, which allows the plug-in to supply configuration statements for the entire widget, then it is invoked once for each pane in the widget. The return value of the callback should be a string containing new-line separated configuration statements for the plugin. Configuration statements are regular tcl-statements that will, when executed, recreate the current configuration of the widget. The configuration statements should refer to the current widget as `$widget` and to the pane as $<pane>. A typical configuration statement for myplugin might look something like:

  `$widget myplugin::addSomeFeature $pane -option1 value1 -option2 value2`

-getoptproc

  Specifies a callback procedure to be invoked the command line of the application is being parsed. This allows the plug-in to handle its own command line switches. Callback syntax:

  `callback arglistVar`

  arglistVar refers to a list variable name containing the command line, typically argv. The callback should remove all switches it wants to handle from arglistVar. This easiest done using the cmdline package in the Standard Tcl Library.

-openfileproc

  Specifies a callback procedure to be invoked when a file is to be opened, to allow the plug-in to handle the file. Callback syntax:

  `callback widget fileName`

  The callback should return a boolean value to indicate whether or not it handles the file. If a plug-in returns true, the application will not try to handle the file internally.

-panecreatedproc

  Specifies a callback procedure to be invoked when a new pane has been created in the widget. Callback syntax:

  `callback widget pane`

-panedeletedproc

  Specifies a callback procedure to be invoked when a pane is to be deleted in the widget. Callback syntax:

  `callback widget pane`

-pasteproc

  Specifies a callback procedure to be invoked when a paste operation is performed in the widget. Callback syntax:

  `callback widget start length`

  start and length are given in seconds as a floating point numbers.

-pauseproc

  Specifies a callback procedure to be invoked when playback has been paused in the widget. Callback syntax:

  `callback widget`

-playproc

  Specifies a callback procedure to be invoked when playback has been started in the widget. Callback syntax:

  `callback widget`

-printproc

  Specifies a callback procedure to be invoked when the widget is to be printed, to allow the plug-in to redraw its contents onto a canvas for printing. Callback syntax:

  `callback widget pane tempCanvas x y`

  tempCanvas is a temporary canvas used during printing. The plug-in is expected to re-draw the pane contents in this canvas at coordinate offset x,y.

-propertiespageproc

  Specifies a callback procedure to be invoked when the properties dialog is displayed. Callback syntax:

  `callback widget pane`

  The return value should be a list of the form {name displayproc name displayproc ...}. Each name/proc pair specifies one page in the properties dialog notebook widget. name is a text string that will be displayed on the notebook tab. displayproc should be a procedure that will be invoked to render the page. This procedure will be invoked as follows:

  `displayproc widget pane frame`

  Frame is the container frame of the notebook page, into which plugin widgets will be arranged.

-recordproc

  Specifies a callback procedure to be invoked when recording has been started in the widget. Callback syntax:

  `callback widget`

-redrawproc

  Specifies a callback procedure to be invoked when the contents of a pane are redrawn. All plug-ins that display graphics must implement this callback. Callback syntax:

  `callback widget pane`

-needsaveproc

  Specifies a callback procedure which is used to check whether there is unsaved information present in the pane. Callback syntax:

  `callback widget pane`

  The return value should be a boolean, indicating whether or not there is unsaved information in the pane.

-savefileproc

  Specifies a callback procedure to be invoked when a file is to be saved, to allow the plug-in to save the file. Callback syntax:

  `callback widget fileName`

  The callback should return a boolean value to indicate whether or not it saves the file. If a plug-in returns true, the application will not try to save the file internally.

-scrollproc

  Specifies a callback procedure to be invoked when the widget is scrolled along the time axis. Callback syntax:

  `callback widget pane`

-setselectionproc

  Specifies a callback procedure to be invoked when the selection has changed.

  `callback widget pane t0 t1`

  t0 and t1 are the start and end times for the new selection, given in seconds as floating point numbers.

-soundchangedproc

  Specifies a callback procedure to be invoked when the sound data has changed. This notifies a plug-in that the sound has been modified. Callback syntax:

  `callback widget flag`

  flag is a string describing the type of change.

-stopproc

  Specifies a callback procedure to be invoked when playback has been stopped in the widget. Callback syntax:

  `callback widget`

-undoproc

  Specifies a callback procedure to be invoked when an undo operation is performed in the widget, to allow the plugin to restore its data to the state it had before the last change. Callback syntax:

  `callback widget`

-widgetcreatedproc

  Specifies a callback procedure to be invoked upon creation of a new widget. Callback syntax:

  `callback widget`

-widgetdeletedproc

  Specifies a callback procedure to be invoked when a widget is to be deleted. Callback syntax:

  `callback widget`

# POD ERRORS

Hey! The above document had some coding errors, which are explained below:

Around line 11:

  =over without closing =back