The Elsbeth Editor and its Teacher Hypertools

What is Elsbeth?

Elsbeth is a full-fledged text editor, meant as a successor to Beth. Most of its
features are lifted straight from Beth. The main difference between Beth and
Elsbeth is that Elsbeth also provides several Teacher Hypertools to teach its
routines to other programs. For example, if you don't generally want to use
elsbeth, but you like its incremental-search facility, you can teach the search
facility to your favorite Tk text editor, or mail reader, or whatever.

Elsbeth's structure is as follows: At the core is a file browser called Els
(which you can run by itself) Els brings up a text window on each file you call,
and provides some simple parsing of command-line arguments, but once the file is
loaded, it provides no more features (except the ability to quit).

On top of els are the code provided by several Teacher Hypertools. For example,
the searcheth tool teaches widgets how to provide an interactive search/replace
facility. In fact, you can use searcheth to teach any Text, Entry, or Canvas
widget to search and replace text it contains. However, elsbeth is only
interested in the code to search through a Text widget, since that is what it
uses. So it loads some code provided by searcheth on top of els, and you then
have a bare-bones text editor with a search capability.

Add to this a set of editing commands, browsing, file I/O, and some other
goodies all provided by Teacher Hypertools, and you get a comprehensive editing
system.

Now, while one hypertool teaching stuff works rather quickly, Elsbeth uses code
from about twenty hypertools, and calling each hypertool to teach elsbeth its
tricks takes a long time. So instead of calling each hypertool each time you
start up elsbeth, a 'makebeth' program is provided. This program loads up each
hypertool, and puts its 'knowledge' into a file called aux/elsbeth.bindings. So
when you start up elsbeth, it reads this elsbeth.bindings file, and thereby
'gains the knowledge' of all the hypertools involved.


Special Features of Elsbeth:

Most of these are supplied as separate hypertools so you can teach these
features to other Tk applications.

	- Compatible with Tk 3.6 / Tcl 7.3
	- Global search/replace, for strings, globs, or regular expressions.
	- Unlimited undo, including undoing replace.
	- Optional horizontal and vertical grids.
	- Piped I/O to files or standard shell commands, with ability to read
	  output into text widget gradually, either standalone or with addinput
	- Execute wish/exec commands, with I/O with text widget.
	- Automatic completion of filenames, variable/array names,
	  Tcl commands and procedures, with optional listbox to display
	  possible endings to ambiguous completions.
	- Automatic expansion of file glob patterns, variable/array values,
	  and Tcl bracketed-command evaluation
	- Execute a function in all Elsbeth windows
	- Execute a function N times
	- Windowing functions for resize, move, raise, iconify
	- Switching between multiple Elsbeth windows from the keybaord.
	- Menus...each function has a corresponding menu item, plus menu
	  items to assist in the syntax of complex command options.
	- Parentheses balancing (also brackets, braces, angle brackets)
	- Simple modes for: Text, HTML, C, Lisp, Tcl


So how is it better than Beth?

Elsbeth is built using Beth's features, mostly, with a few enhancements. The
main difference is that Elsbeth can be run as one interpreter on multiple
windows, while Beth requires one window per interpreter. Elsbeth can also be run
as a one-window-per-interpreter system, like Beth, though it loses some
functionality.

Other than that, there are a lot of small enhancements (and bugfixes) that
Elsbeth provides over Beth, such as:

	- Search forward and backward for glob patterns and regular expressions
	- Search can be case-insensitive and/or incremental.
	- An automatic indexing facility
	- Starts up much faster
	- Can focus between text windows from keyboard (as opposed to Beth's
grab control hack)
	- Can put cursor in center of screen w/o using the mouse.
	- Can turn on/off parentheses balancing interactively. Ditto for various
bracket pairs.
	- Delete an indentation from a region of text.
	- File browsing capabilities...view directory, next file, previous file
	- Mail command
	- Mark commands for highlighting important regions of text.
	- Module for formatting HTML.


Installing Elsbeth

Except for Elsbeth, you can run any program right out of the box. If you try to
run elsbeth out of the box, it will simply run els. because it does not have
aux/elsbeth.bindings ready. To run elsbeth, first run the makebeth program and
press the 'Make Elsbeth' button. Then elsbeth will run with full functionality.


What are Teacher Hypertools?

See the file th.background for basic information about Teacher Hypertools.


Elsbeth Contents:

bin: 	All programs; not all are hypertools. All the hypertools provide their
own help documentation.

lib:	All code taught by hypertools.

aux: 	All code used by hypertools and elsbeth, but not taught to other
programs.


Teacher Hypertools Provided:

Nearly all of these are used by elsbeth, and all of them can teach things to
other programs.

browseth	Teach traversal, scrolling and selection commands to widgets
commandeth	Teach remote programs to prompt the user for wish or shell commands.
completh	Teach many different types of completion to textual widgets
cth		Teach text widgets to format C comments and functions	
edith		Teach basic text editing commands to widgets	
errorth		Teach text widgets about errors from C compilers	
filebrowseth	Turn text widgets into simple file/directory browsers	
fileth		Teach file I/O to widgets	
focuth		Teach keyboard focus switching between widgets	
gridth		Add row and column numbers to text, listbox and entry widgets	
historyth	Teach remote entries to remember their previous contents	
(This is not actually used by elsbeth, but it is used by the hypertools
to enhance their interfaces. You could also teach it to elsbeth if you wish)
htmlth		Teach text widgets to format HTML
iterath		Teach widgets to iterate commands many times at once.	
lispth		Teach text widgets to format Lisp comments and functions	
marketh 	Teach text widgets to highlight important regions of text
makebeth	Create Elsbeth (see above)
menutraverseth	Add Tk keyboard menubar traversal to a set of menus	
paragrath	Teach text widgets about paragraphs	
parenth		Teach widgets to help keep parentheses and other delimiters balanced	
resizeth	Teach widgets to shrink and expand themselves	
searcheth	Teach widgets to search for strings, glob patterns, or regular expressions	
taggeth		Add a menu of tags to a text widget	
tclth		Teach text widgets to format Tcl comments and procedures	
windowth	Teach programs to resize, move, raise, and iconify their windows	

th 	 	This is a 'catalog' program that lets you run any of the other
hypertools listed above, the easiest way to access the hypertools is to run this
program. To run it type "wish -f bin/th". Or change the first line in bin/th to
reflect the location of Wish on your system, and just type "bin/th".


Other programs available:

elsbeth 	The editor.
els 		A bare-bones text viewer, see above
rmth 		A wish and shell interpreter that uses Elsbeth's features.
thcolors 	A virtual color displayer, also uses elsbeth
thfonts 	A virtual font displayer, uses elsbeth
thterm 		A terminal emulator, based on Don Libes' tkterm from the Expect
distribution. Uses some hypertool features. (Requires expectk)
bsend 		A mail-sending program using elsbeth
bread 		A mail-reading program using elsbeth
bith 		A mail-notification program, loads up bread
These three programs were created to process my mail quickly and easily. (I use
mh on a Dec3100 running Ultrix4.3a.) I make no gaurentees regarding their
portability.


Some other noteworthy files:

aux/bindings.th/bindings 	This contains all the key and menu bindings 
taught by hypertools, in a single file for changeability. You can change the
bindings in this file, or you can change them individually in each hypertool, or
in makebeth.

aux/elsbeth.bindings.tcl 	This file contains the key and menu bindings
for elsbeth. It is created from aux/elsbeth.tmpl by bin/makebeth's 'Make
Elsbeth' feature. If this file doesn't exist, bin/elsbeth behaves like bin/els.

aux/elsbeth.help 		The help file for elsbeth; it is also created
by makebeth.

aux/rmth.help.txt 		Additional help file for rmth

aux/mh_profile 			Excerpt of my ~/.mh_profile, which links bread
and bsend to mh's repl, forw, comp, and show commands.


Elsbeth & Teacher Hypertools: Copyright (c) 1994  David Svoboda

Permission to use, copy, modify, and distribute this software is hereby granted,
provided that the above copyright line appears at least once in source code
taught by Teacher Hypertools, and in documentation relating to said code.
However, permission is not granted to modify the copyright insertion code.

This basically means: if a Teacher Hypertool sticks a copyright message in code
it teaches, and you copy that code to a file, leave the copyright message in.
And include it in your documentation. If it doesn't stick a copyright in code,
don't worry about it. Go ahead and fiddle around with the Teacher Hypertool
source code, and improve it (and drop me a line if you do, I'd be interested),
but don't change the code that inserts copyright notices.


Disclaimer

I don't see how its possible, but if this software crashes your system, destroys
your hard disk, posts to alt.flame asking for mail-bombs, etc. etc, I didn't do
it, man. :)


Bugs

Doubtless there will be bugs, or rather, 'features' you and I didn't count on.
The Tk error should complain of any errors that a bug causes. Keep in mind, that
the Tk error mechanism is also used to report errors from wish or exec commands
and I/O pipelines. So you could get a Tk error by telling Elseth to exec "rm
/usr" (unless you happen to be root :), but this is not a bug. Also some
commands will terminate abnormally, even if they do what you want. A good
example of this is diff, which will return nonzero status if any differences
occurred, which Tk will interpret as an error message. So you will get the
output you want, but there will be a Tk error message saying the process ended
abnormally. You might also get an error message if you interrupt a gradual
process. However, these are not bugs in Elsbeth.

If you get a reproduceable Tk error which you suspect is a bug in Elsbeth, check
the documentation in the hypertools to see if your bug is mentioned in its
documentation. For example, if you get an error message when pressing a close
parentheses, you might check the parenth hypertool's documetation (just run it
and press 'Help'). If your bug is mentioned there, I know about it, and either
considered it a feature, or too hard to fix. If you know of a fix, workaround,
or simply a better way of doing things, please tell me.

If you get a bug which is not covered in the hypertools documentation (or its
simply in the wrong one), please let me know. (If its merely covered by a
different hypertool, that's still a stylistic bug that I can fix by writing
better documentation :). Mail  me the contents of Tk's error stack trace, along
with what you were doing to invoke the error. Include the versions of Tk,Tcl,X
and your hardware and software platforms. If Tk does not report an error, but
Elsbeth does not do what you want, it could be a bug, or a feature. If you feel
strongly that this is a bug (it is not mentioned in the documentation, and you
cannot work around it, for example), send me a letter describing the problem.

There are many things that can be added to Elsbeth. (a few are mentioned in the
TODO file)  The best way to extend Elsbeth is by writing a Teacher Hypertool
teaching your new feature and include it in makebeth (which can be a simple or
complex job depending on the hypertool). Of course, a quick means of extension
is to write a script that first calls elsbeth and then adds your feature.
(Thcolors, thfonts, and rmth all do this), but then only elsbeth can use your
new feature. Putting it in a hypertool allows any program to use it. If you make
any popular hypertools or improvements, I would like to hear about them;


Elsbeth WWW Page

There is a WWW Page devoted to Elsbeth, located at:
http://www.ece.cmu.edu/afs/ece/usr/svoboda/www/elsbeth/homepage.html


Send questions and comments to David Svoboda <svoboda@ece.cmu.edu>.

Last modified: January 14,1995
