ogden@nmsu.edu (Bill Ogden) (03/16/91)
I'd like to be able to write a filter like Fmt or Capitalize and have no trouble getting the selection, even deleting the selection, but how do I get the filtered text back to the textsw window? A compainion to the SELN_REQ_DELETE attribute (like perhaps SELN_REQ_INSERT) would be nice. Has anyone done this? Thanks. -- ogden@nmsu.edu Bill Ogden Computing Research Lab New Mexico State University Las Cruces, NM
openlook-request@openlook (03/19/91)
> I'd like to be able to write a filter like Fmt or Capitalize and > have no trouble getting the selection, even deleting the selection, > but how do I get the filtered text back to the textsw window? > A compainion to the SELN_REQ_DELETE attribute (like perhaps > SELN_REQ_INSERT) would be nice. Has anyone done this? How about using textsw_replace_bytes()? Frank G.
macq@miguel.llnl.gov (Don MacQueen) (03/19/91)
In article <OGDEN.91Mar15142937@aigyptos.nmsu.edu>, ogden@nmsu.edu (Bill Ogden) writes: |> I'd like to be able to write a filter like Fmt or Capitalize and |> have no trouble getting the selection, even deleting the selection, |> but how do I get the filtered text back to the textsw window? |> A compainion to the SELN_REQ_DELETE attribute (like perhaps |> SELN_REQ_INSERT) would be nice. Has anyone done this? |> Thanks. |> -- |> ogden@nmsu.edu |> Bill Ogden |> Computing Research Lab |> New Mexico State University |> Las Cruces, NM While we're (or more accurately you're) at it, will someone please tell a novice, namely me, what the heck these filters are? Are they C programs that read from stdin and write to stdout? Or what? I can't find out after spending an hour or so hitting the books. Because I would like to get an arbitrary key (such as F1 on Sparcstation IPC) to send a short text string as if I had typed it, in a cmdtool window. Easy in a shelltool. Thanks... -- -------------------- Don MacQueen macq@miguel.llnl.gov --------------------
ogden@nmsu.edu (Bill Ogden) (03/23/91)
>> I'd like to be able to write a filter like Fmt or Capitalize and >> have no trouble getting the selection, even deleting the selection, >> but how do I get the filtered text back to the textsw window? >> A compainion to the SELN_REQ_DELETE attribute (like perhaps >> SELN_REQ_INSERT) would be nice. Has anyone done this? > > How about using textsw_replace_bytes()? > > Frank G. Great idea if I could figure out how to get the handle to the textsw object. Since filters can be called from _any_ text window, I can't figure out how to get this handle. All I get back from the selection service is a handle to the "holder" which is not the same thing. Any ideas? -bill -- Bill Ogden Computing Research Lab Box 3CRL New Mexico State University Las Cruces, NM 88003 email: ogden@nmsu.edu
devil@techunix.BITNET (Gil Tene) (03/25/91)
Hello OpenPeople,
There have been some requests for info on textsw filters for the
extras menu. First, let me note that textedit(1) explians this
quite well, except for a few typos with file names.
In short, Filters are simple programs that get data in stdin and
put it out to stdout, modifying it if needed. textsw calls filters
giving them the current selection as input, and replacing it with
whatever they output. This means they can also be used as simple
"function key to string" bindings, if you don't wish to use xmodmap.
Filters in textsw can be bound to keys using the .textswrc file
in one's login dir. They can also be bound to the Extras menu
in one of several ways. The basic extras menu resides in
/usr/lib/.text_extras_menu. You can choose to modify this file
(yuck!), or you can set an environment variable or a .Xdefaults
entry to point to another file (see textedit(1)). An example
of binding keys to filters is given in /usr/lib/.textswrc,
this file is NOT used unless you have it in your home dir.
below is a simple filter program I use to indent mail in mailtool,
since I don't like the way mailtool does it.
Below that is my .textswrc file, binding the filter to F9 on my SLC
keyboard... When I wish to indent someone's mail, I paste it in,
select it all, press F9, and presto!
Have Fun.
-- Gil.
/home/devil/filters/rep_mail.c :
#include <stdio.h>
char in_line[1000];
main()
{
while(gets(in_line))
printf("> %s\n",in_line);
}
/home/devil/.textswrc :
# bind F9 to my rep_mail filter :
F9 FILTER
/home/devil/filters/rep_mail
--
--------------------------------------------------------------------
-- Gil Tene "Some days it just doesn't pay --
-- devil@techunix.technion.ac.il to go to sleep in the morning." --
--------------------------------------------------------------------
barnett@grymoire.crd.ge.com (Bruce Barnett) (03/25/91)
In article <9918@discus.technion.ac.il> devil@techunix.BITNET (Gil Tene) writes: > main() > { > while(gets(in_line)) > printf("> %s\n",in_line); > } Seems like a lot of extra work. Why not just have KEY_TOP(9) FILTER sed 's/^/> /' And add the following line to your .mailrc file: set indentprefix="> " -- Bruce G. Barnett uunet!crdgw1!barnett
km@mathcs.emory.edu (Ken Mandelberg) (03/26/91)
In article <9918@discus.technion.ac.il>, devil@techunix.BITNET (Gil Tene) writes: |> Hello OpenPeople, |> |> There have been some requests for info on textsw filters for the |> extras menu. First, let me note that textedit(1) explians this |> quite well, except for a few typos with file names. |> |> In short, Filters are simple programs that get data in stdin and |> put it out to stdout, modifying it if needed. textsw calls filters |> giving them the current selection as input, and replacing it with |> whatever they output. |> -------------------------------------------------------------------- The problem is that there are additional restrictions on textsw filters that are not documented. By experiment, I've found that if the filter itself creates a window during its execution, the original window loses track of the selection, and never replaces the text with the filters output. This makes it impossible to write an interactive filter, -- Ken Mandelberg | km@mathcs.emory.edu PREFERRED Emory University | {rutgers,gatech}!emory!km UUCP Dept of Math and CS | km@emory.bitnet NON-DOMAIN BITNET Atlanta, GA 30322 | Phone: Voice (404) 727-7963, FAX 727-5611
devil@techunix.BITNET (Gil Tene) (03/26/91)
In article <BARNETT.91Mar25102037@grymoire.crd.ge.com> barnett@crdgw1.ge.com wri tes: >In article <9918@discus.technion.ac.il> devil@techunix.BITNET (Gil Tene) writes : >> ... quote of my silly program to do mail indenting. > >Seems like a lot of extra work. Why not just have > >KEY_TOP(9) FILTER >sed 's/^/> /' > >And add the following line to your .mailrc file: >set indentprefix="> " Sure, both are better, but why do it the easy way ? :-) Actually, my posting came to answer a question about setting up filter programs to work with textsw applications, so I gave this as an EXAMPLE. I actually have several filters I use in my everyday netting. Some are much more complicated and do require some lexing, so a C program is useful. -- Gil. -- -------------------------------------------------------------------- -- Gil Tene "Some days it just doesn't pay -- -- devil@techunix.technion.ac.il to go to sleep in the morning." -- --------------------------------------------------------------------