The Plugins Methodology

Download the current version of my plugins interface definition, software and sample implementations
The most recent version of this Web page

Last updated by Omer Zak at 1999 February 6.

WARNING:
By sending unsolicited commercial/political/religious/MailPush E-mail messages (known also as "spam") to any E-mail address mentioned in this file, you irrevocably agree to pay the receipient US$500.- (plus any legal expenses incurred while trying to collect the amount due) per unsolicited commercial/political/religious/MailPush E-mail message - for the service of receiving your E-mail message.


Motivation for yet another interface

At present (as of January 1999), visual Hebrew is supported by several software packages running under GNU/Linux. Logical Hebrew is not supported. In order to allow Hebrew speakers to get weaned off Microsoft based software, logical Hebrew support has to be implemented in several text handling software running under GNU/Linux, such as: WYSIWYG word processors, graphical WWW browsers, text editors, X-Window widgets (such as Motif/Lesstif or Tk text widgets), ICQ client software, TeX, database.

In order to achieve the aforementioned goal, the following obstacles must be overcome:

  1. Software is developed by people from all over the world. Most of them neither know nor care about Hebrew or the BiDi rules.
  2. The BiDi algorithm (for converting logical Hebrew text into visual Hebrew for the purpose of rendering it) is still a moving target.
It is my belief that the best solution is to specify an interface, which will let people who develop and improve the BiDi algorithm (and similar algorithms for more exotic languages) work independently from people who develop text processing applications.

Such an interface has to meet the following requirements:

  1. Provide enough flexibility that an application writer would never have to know the details of an exotic language in order to allow his application to work seamlessly in that language, by means of the right plugin.
  2. Work with C, not C++ - to make it easier to integrate it into legacy software.
  3. Be helpful not only to Hebrew and Arabic speakers, but also to all the languages of the world - so that application writers will choose it as their contribution to I18N'ing their applications.
  4. Be very efficient - so that wordprocessors and WWW browsers won't slow down their text refreshes.
  5. Be configurable according to user's inputs (such as the ability to choose one of few BiDi algorithms).
  6. Allow different widgets in the same application to use different plugins (for example, one might want to use an X-Window application with two text widgets - one using Hebrew+BiDi, the other using Thai with its own rendering algorithm).

More possible benefits from adoption of the plugin methodology:


Why not to use CORBA or Portable Layout Services

I decided to use the dynamic linking loader feature (see man dlopen or read /usr/include/dlfcn.h for details). This interface standard originated from Solaris and was implemented also in Linux. An alternative to this feature is the CORBA, which I rejected due to the following reasons:
  1. We need only to dynamically link procedures to an application. The full power of CORBA is not needed. In particular, no data objects need to be passed to other processes.
  2. CORBA is not terribly fast.
  3. CORBA requires the user to install a CORBA server in his system.

Another interface, which is supposed to meet the same I18N needs as the proposed plugin interface, is the Portable Layout Services (PLS).

The PLS suffers from the following disadvantages:

  1. It appears that application developers must know something about the target language (Hebrew, Hangul (the Korean writing system), or whatever) in order to make their application compatible with it.
  2. It is complicated. Application writers (including widget developers) want to concentrate upon their application rather than deal with all those complicated text handling issues.

The proposed plugin interface, on the other hand, strives to encapsulate all language-specific knowledge. In order to make an application support a new language (or even use a different algorithm for an existing language), all one needs is to replace the plugin, or to supply different configuration parameters to the plugin.

By the way, the PLS and the proposed plugin interface are not really mutually exclusive! They expose different levels of abstraction to application developers.

It is possible to develop a plugin, which employs the proposed interface, and which implements the PLS. Such a plugin would relieve application developers from having to deal with all complexities of PLS.


The four levels of the plugin interface

The proposed plugin interface is, as far as I could determine, a novel concept. Therefore, the first few rounds of specifying it may not get everything right. Another hindrance is that I am not yet sufficiently familiar with the internal workings of text handling applications in order to be able to design an interface, which efficiently meets their needs. The only project, of which I am aware, and which specified their interface needs is the Mozilla project.

In order to allow for an iterative process of defining the interface details, I defined four levels of plugin interfaces, as follows:

So far, I worked out only the details of the level 0 plugin interface. The provided software package specifies and implements only this level.

I intend to define and implement also level 1, once I have access to more knowledge and experience about the actual performance of level 0 along with the real needs of applications.

However, I plan to leave to other people, who are more familiar than me with Eastern languages, to define levels 2 and 3 in detail.


Documentation of level 0 of the plugin interface

The plugin interface has two faces. One face interests the plugin writer. The other face interests the application developer.

The plugin writer is supposed to implement the following functions:

The application developer is supposed to allow the user to select a plugin and a configuration, independently for each text window (or widget) in the application. Such a selection is to be carried out by means of an application configuration file, or by means of a Xt-compatible resource file.

The application developer is supposed to provide the plugin with the following callback procedures:

The application developer is supposed to use the following functions:


Questions and Answers

How do you handle selection?
The plugin interface specs define a procedure called v2l_cursor_translation(), which receives "visual coordinates" of the mouse and/or cursor. It then computes the offset into the original string corresponding to the visual position on the string and returns it to the application. The application can then use this position for selecting a substring (by marking its beginning and ending).
If I take a text editor like pico, stuff a level 0 plugin in it and start writing Hebrew, what happens? Does pico consult plugin on every keypress?
Yes, every keypress, which modifies the text of your file.
How does the application know on which line the cursor is?
The application is supposed to keep track of the visual cursor position. The plugin provides for translation of the visual cursor position into the logical cursor position in the original text.
I am still confused. Can you please summarize for me the above points?
  1. The editing commands of the application operate only on the logical text.
  2. Cursor positioning commands of the application operate only on the visual text.
  3. After each cursor movement (by command or by mouse), the application does not compute itself the new cursor position in the logical text, but instead asks the plugin to compute this for it.
  4. After each text change, the application hands the modified text to the plugin and tells it where the text was modified. The plugin transforms as much text as needed to refresh the display, and not more than that. The plugin then (in principle) informs the application which lines on the display need to be refreshed due to the text change.

How to use and modify the provided software package

  1. Download the plugins0.0-001.tar.gz package.
  2. tar zxvf plugins0.0-001.tar.gz
  3. cd include
  4. Set the environment variable TEXT_RENDERING_PLUGIN_PATH to the current directory.
    In bash, the command is:
    TEXT_RENDERING_PLUGIN_PATH=`pwd`;export TEXT_RENDERING_PLUGIN_PATH
  5. The program plugfilter0 is a driver, which passes text from stdin to stdout via the selected plugin. The command to invoke it is:
    ./plugfilter0 plugin-name [plugin-configuration]
  6. The only plugin provided at present is null.so, which does no transformation to the text. It also receives no configuration information.
    Thus, the following command has the same functionality as cat: ./plugfilter0 null < input_file > output_file
  7. I built the binaries in a RedHat 5.1 based Linux system, with kernel version 2.0.36, gcc version 2.7.2.3, libc.so.6, libdl.so.2, and some other things.
    To rebuild the binaries, merely type make in the include subdirectory. The file Makefile takes care of all the rest (in RedHat 5.1 based Linux system).
Note:
The hardwired default for TEXT_RENDERING_PLUGIN_PATH is /usr/lib/plugins/textrendering. This is subject to change in the future, according to whatever decision the FSSTND maintainers will make.

My own ego trips


Copyright Notice

This document Copyright (C) 1999, all rights reserved.