X-based/elm-based mail browser using tk 
Author Message
 X-based/elm-based mail browser using tk

I've been following tk/tcl for some time, but just recently sat down to
actually *do* something with it.  The tk/tcl kit includes a simple file
browser, and as a learning exercise I hacked it up to become a mailbox
browser.  It brings up a list of your mail folders, you click on the
name, and it fires up an instance of elm on the indicated folder.

What, you're not an elm fan?  This should be useful for *any* mail
reading program.  Simple change the 'elm' command to the mailer of your

In the elm windows use your standard elm commands.  In the browse
windows do double-click to select a mailbox; do ^Q or ^C to exit the
browse windows.  You may want to set the "dirswitch" and "dir"
variables to match your personal usage.

Lest anyone jump up and down about given features: this was so
startlingly simple and functional that I and others am already using
it.  There's an hour of work tops in the thing, most of that reading
the manual page.  Probably 80% of the code is ripped off directly from
the tk sample file browser.

For those reading this in comp.mail.elm, tk/tcl is an X windows toolkit
and command processing language.  You can download the code from
sprite.berkeley.edu; the language is discussed in comp.lang.tcl, to
which this article is crossposted.


#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#               "End of shell archive."
# Contents:  tkelm

PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'tkelm' -a "${1}" != "-c" ; then
  echo shar: Will not clobber existing file \"'tkelm'\"
echo shar: Extracting \"'tkelm'\" \(1752 characters\)
sed "s/^X//" >'tkelm' <<'END_OF_FILE'
X#!/usr/local/bin/wish -f
X# This script generates a directory browser, which lists the working
X# directory and allows you to open files or subdirectories by
X# double-clicking.
X# Create a scrollbar on the right side of the main window and a listbox
X# on the left side.
X# These are the switches needed to generate a ls listing that prints
X# all files except . and .., and appends a "/" to directory names.  Your
X# mileage may vary.
Xset dirswitch "-AF"
X# The default location of your mail folder.  Elm's default is "Mail",
X# but many folks override this.
Xset dir ".mailbox"
Xscrollbar .scroll -command ".list yview"
Xlistbox .list -borderwidth 2 -yscroll ".scroll set" -relief raised -geometry 20x20
Xpack append . .scroll {right filly} .list {left expand fill}
X# The procedure below is invoked to open a browser on a given file;  if the
X# file is a directory then another instance of this program is invoked; if
X# the file is a regular file then the Mx editor is invoked to display
X# the file.
Xproc mailbrowse {dir file} {
X    if {[string compare $dir "."] != 0} {set file $dir/$file}
X    if [file isdirectory $file] {
X       exec mailbrowse $file &
X    } else {
X       if [file isfile $file] {
X           exec /usr/bin/X11/xterm -T $file -n $file -e elm -f $file &
X       } else {
X           puts stdout "\"$file\" isn't a directory or regular file"
X       }
X    }
X# Fill the listbox with a list of all the files in the directory (run
X# the "ls" command to get that information).
Xif $argc>0 {set dir [lindex $argv 0]}
Xforeach i [exec ls $dirswitch $dir] {
X    .list insert end $i
X# Set up bindings for the browser.
Xbind .list <Control-q> {destroy .}
Xbind .list <Control-c> {destroy .}
Xfocus .list
Xbind .list <Double-Button-1> {foreach i [selection get] {mailbrowse $dir $i}}
if test 1752 -ne `wc -c <'tkelm'`; then
    echo shar: \"'tkelm'\" unpacked with wrong size!
chmod +x 'tkelm'
# end of 'tkelm'
echo shar: End of shell archive.
exit 0
        "You can't get here from here."

Wed, 31 May 1995 12:55:37 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Announcing TKBROWSER-SIG: SIG on Building Tk-based Web Browsers

2. Announcing TKBROWSER-SIG: SIG on Building Tk-based Web Browsers

3. Tcl/Tk based www browser

4. tcl-plugin for a tcl/tk based browser...

5. Announcing TKBROWSER-SIG: SIG on Building Tk-based Web Browsers

6. tk based C++ class browser?

7. Using tk/tcl to put a windows-based front to old console applications

8. Help: Using curses-based line/column screen description with TK

9. Transition from Clipper DOS based to Windows based Programming language

10. LOGO-L> Base 10 to Base 3

11. C-based simulation faster than HDL-based simulation?

12. how to convert vhdl based ROM to verilog based ROM


Powered by phpBB® Forum Software