[comp.windows.x] wanted: filters in Athena Text widgets

jqj@rt-jqj.Stanford.EDU (JQ Johnson) (07/11/90)

I'm looking for a way from within the Athena Text widget to pass data
through an arbitrary Unix filter, analogous to the functionality of the
vi "!" command, emacs "filter-region" or SunView's text "Extras".
Before I go off and design/implement this for myself, has anyone
already done it?

Note that I envision filters that may potentially take a long time to run,
e.g. a spelling correcter that pops up a window; possibly as simple as:
	#! /bin/sh
	trap "rm -f /tmp/sp.$$"
	cat >/tmp/sp.$$; xterm -e ispell /tmp/sp.$$ && cat /tmp/sp.$$

I haven't given much thought to implementation, but 2 schemes
immediately occur to me.  One approach would be to subclass the text
widget under Unix to add an action that, when invoked, sent the current
selection to the clipboard then replaced it with the result of running
it through a filter specified as the action's argument.  This would
give static (translation table specified) filters, but not dynamic
specification of filters, though that could clearly be added with a
dialog box or something, perhaps in a program like xedit rather than in
the widget itself.

One alternative design would be to write a filter tool analogous to
xclipboard that allowed specification of the current filter, waited for
someone to assert ownership of a FILTER selection, fetched it and ran
it through its current filter, then made the result available for
pasting.  This suggests a user interface that is more complex for the
user but perhaps more general.  It has the disadvantage of being a
single service provider per display (if we allow long-processing
filters, it probably needs to be multithreaded), and of potential race
conditions (if two applications on the same display send to the filter
more-or-less simultaneously, we don't want one to get back the result
of filtering the other's selection!).

[aside and comment: ICCCM seems adequate for asynch messages, but not
as good for implementing RPC, multicast, or other interprocess
communications paradigms.  I guess you can't be all things to all
people...]

Comments, or alternative designs, anyone?
JQ Johnson                              voice: 415-723-3078
Manager, Special Projects               Internet: jqj@jessica.stanford.edu
Networking and Communications Systems
Pine Hall Rm 125-A 
Stanford University
Stanford, CA 94305-4122