Check-in [447ba8e3d1]
Not logged in
Overview
Comment: sources Removed Files: tclreadlineSetup.tcl
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:447ba8e3d1fe619ec7979f8bc12b4caf150c6fca
User & Date: johannes@zellner.org on 1999-08-20 11:32:20
Other Links: manifest | tags
Context
1999-08-20
11:35
config.guess config.sub install-sh mkinstalldirs tcltags vimtags check-in: 3aa896e85d user: johannes@zellner.org tags: trunk
11:32
sources Removed Files: tclreadlineSetup.tcl check-in: 447ba8e3d1 user: johannes@zellner.org tags: trunk
09:44
*** empty log message *** check-in: 90883b7fdb user: johannes@zellner.org tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Modified sources from [404a74ebf6] to [4bb0513a62].

            1  +    GPL
     1      2       Makefile.in
            3  +    README
            4  +    TODO
     2      5       configure.in
            6  +    pkgIndex.tcl
            7  +    sample.tclshrc
            8  +    sources
     3      9       tclreadline.c
     4     10       tclreadline.h.in
           11  +    tclreadline.n.in
     5     12       tclreadlineConfig.sh.in
     6     13       tclreadlineInit.tcl.in
     7     14       tclreadlineSetup.tcl.in
     8         -    tclreadline.n.in
     9         -    sample.tclshrc

Deleted tclreadlineSetup.tcl version [ed16deb2b2].

     1         -#!/usr/local/bin/tclsh
     2         -# ==================================================================
     3         -# FILE: "/home/joze/tmp/tclreadline/tclreadlineSetup.tcl"
     4         -# LAST MODIFIED: "Mon Oct 05 15:15:42 1998 (joze)"
     5         -# (c) 1998 by Johannes Zellner
     6         -# Johannes.Zellner@physik.uni-karlsruhe.de
     7         -# $Id$
     8         -# ================================================================== 
     9         -
    10         -package provide tclreadline 1.0
    11         -
    12         -proc unknown args {
    13         -
    14         -    global auto_noexec auto_noload env unknown_pending tcl_interactive
    15         -    global errorCode errorInfo
    16         -
    17         -    # Save the values of errorCode and errorInfo variables, since they
    18         -    # may get modified if caught errors occur below.  The variables will
    19         -    # be restored just before re-executing the missing command.
    20         -
    21         -    set savedErrorCode $errorCode
    22         -    set savedErrorInfo $errorInfo
    23         -    set name [lindex $args 0]
    24         -    if ![info exists auto_noload] {
    25         -        #
    26         -        # Make sure we're not trying to load the same proc twice.
    27         -        #
    28         -        if [info exists unknown_pending($name)] {
    29         -            return -code error "self-referential recursion in \"unknown\" for command \"$name\"";
    30         -        }
    31         -        set unknown_pending($name) pending;
    32         -        set ret [catch {auto_load $name [uplevel 1 {namespace current}]} msg]
    33         -        unset unknown_pending($name);
    34         -        if {$ret != 0} {
    35         -            return -code $ret -errorcode $errorCode \
    36         -                "error while autoloading \"$name\": $msg"
    37         -        }
    38         -        if ![array size unknown_pending] {
    39         -            unset unknown_pending
    40         -        }
    41         -        if $msg {
    42         -            set errorCode $savedErrorCode
    43         -            set errorInfo $savedErrorInfo
    44         -            set code [catch {uplevel 1 $args} msg]
    45         -            if {$code ==  1} {
    46         -                #
    47         -                # Strip the last five lines off the error stack (they're
    48         -                # from the "uplevel" command).
    49         -                #
    50         -
    51         -                set new [split $errorInfo \n]
    52         -                set new [join [lrange $new 0 [expr [llength $new] - 6]] \n]
    53         -                return -code error -errorcode $errorCode \
    54         -                        -errorinfo $new $msg
    55         -            } else {
    56         -                return -code $code $msg
    57         -            }
    58         -        }
    59         -    }
    60         -
    61         -    # REMOVED THE [info script] TEST (joze, SEP 98)
    62         -    if {([info level] == 1) \
    63         -            && [info exists tcl_interactive] && $tcl_interactive} {
    64         -        if ![info exists auto_noexec] {
    65         -            set new [auto_execok $name]
    66         -            if {$new != ""} {
    67         -                set errorCode $savedErrorCode
    68         -                set errorInfo $savedErrorInfo
    69         -                set redir ""
    70         -                if {[info commands console] == ""} {
    71         -                    set redir ">&@stdout <@stdin"
    72         -                }
    73         -                # LOOK FOR GLOB STUFF IN $ARGS (joze, SEP 98)
    74         -                return [uplevel eval exec $redir $new \
    75         -                    [::tclreadline::Glob [lrange $args 1 end]]]
    76         -            }
    77         -        }
    78         -        set errorCode $savedErrorCode
    79         -        set errorInfo $savedErrorInfo
    80         -        if {$name == "!!"} {
    81         -            set newcmd [history event]
    82         -        } elseif {[regexp {^!(.+)$} $name dummy event]} {
    83         -            set newcmd [history event $event]
    84         -        } elseif {[regexp {^\^([^^]*)\^([^^]*)\^?$} $name dummy old new]} {
    85         -            set newcmd [history event -1]
    86         -            catch {regsub -all -- $old $newcmd $new newcmd}
    87         -        }
    88         -        if [info exists newcmd] {
    89         -            tclLog $newcmd
    90         -            history change $newcmd 0
    91         -            return [uplevel $newcmd]
    92         -        }
    93         -
    94         -        set ret [catch {set cmds [info commands $name*]} msg]
    95         -        if {[string compare $name "::"] == 0} {
    96         -            set name ""
    97         -        }
    98         -        if {$ret != 0} {
    99         -            return -code $ret -errorcode $errorCode \
   100         -                "error in unknown while checking if \"$name\" is a unique command abbreviation: $msg"
   101         -        }
   102         -        if {[llength $cmds] == 1} {
   103         -            return [uplevel [lreplace $args 0 0 $cmds]]
   104         -        }
   105         -        if {[llength $cmds] != 0} {
   106         -            if {$name == ""} {
   107         -                return -code error "empty command name \"\""
   108         -            } else {
   109         -                return -code error \
   110         -                        "ambiguous command name \"$name\": [lsort $cmds]"
   111         -            }
   112         -        }
   113         -    }
   114         -    return -code error "invalid command name \"$name\""
   115         -}
   116         -
   117         -namespace eval tclreadline:: {
   118         -    namespace export Setup Glob Loop InitCmds InitTclCmds InitTkCmds
   119         -}
   120         -
   121         -proc ::tclreadline::Setup {} {
   122         -
   123         -    uplevel #0 {
   124         -
   125         -
   126         -        if {[info exists tk_version]} {
   127         -            set readlinePrompt "\[0;94mwish$tk_version\[0m"
   128         -        } else {
   129         -            set readlinePrompt "\[0;91mtclsh$tcl_version\[0m"
   130         -        }
   131         -
   132         -        proc ls {args} {
   133         -            if {[exec uname -s] == "Linux"} {
   134         -                eval exec ls --color -FC [::tclreadline::Glob $args]
   135         -            } else {
   136         -                eval exec ls -FC [::tclreadline::Glob $args]
   137         -            }
   138         -        }
   139         -
   140         -        if {[info procs cd] == ""} {
   141         -            catch {rename ::tclreadline::Cd ""}
   142         -            rename cd ::tclreadline::Cd
   143         -            proc cd {args} {
   144         -                if {[catch {eval ::tclreadline::Cd $args} message]} {
   145         -                    puts stderr "$message"
   146         -                }
   147         -                ls
   148         -            }
   149         -        }
   150         -
   151         -        if {[info procs exit] == ""} {
   152         -
   153         -            catch {rename ::tclreadline::Exit ""}
   154         -            rename exit ::tclreadline::Exit
   155         -
   156         -            proc exit {args} {
   157         -
   158         -                catch {::tclreadline::readline write 
   159         -                    [::tclreadline::HistoryFileGet]}
   160         -
   161         -                if [catch "eval ::tclreadline::Exit $args" message] {
   162         -                    puts stderr "error:"
   163         -                    puts stderr "$message"
   164         -                }
   165         -                # NOTREACHED
   166         -            }
   167         -        }
   168         -
   169         -
   170         -
   171         -        global pi
   172         -        set pi 3.1415926535897931
   173         -        set tcl_precision 17
   174         -
   175         -
   176         -        global env
   177         -        variable historyfile
   178         -
   179         -        if {[info exists env(HOME)]} {
   180         -            set historyfile  $env(HOME)/.tclsh-history
   181         -            set env(INPUTRC) $env(HOME)/.tclsh-inputrc
   182         -        } else {
   183         -            set historyfile  .tclsh-history
   184         -        }
   185         -        set msg [::tclreadline::readline initialize $historyfile]
   186         -        if {$msg != ""} {
   187         -            puts stderr "$msg"
   188         -        }
   189         -
   190         -        ::tclreadline::InitCmds
   191         -    }
   192         -
   193         -    rename ::tclreadline::Setup ""
   194         -}
   195         -
   196         -proc ::tclreadline::HistoryFileGet {} {
   197         -    variable historyfile
   198         -    puts stderr "::tclreadline::HistoryFileGet: entered"
   199         -    return $historyfile
   200         -}
   201         -
   202         -proc ::tclreadline::Glob {string} {
   203         -
   204         -    set commandstring ""
   205         -    foreach name $string {
   206         -        set replace [glob -nocomplain -- $name]
   207         -        if {$replace == ""} {
   208         -            lappend commandstring $name
   209         -        } else {
   210         -            lappend commandstring $replace
   211         -        }
   212         -    }
   213         -    return $commandstring
   214         -}
   215         -
   216         -
   217         -
   218         -proc ::tclreadline::Loop {} {
   219         -
   220         -    ::tclreadline::Setup
   221         -
   222         -    uplevel #0 {
   223         -        while {1} {
   224         -            if {[catch {
   225         -                if {[info exists tk_version]} {
   226         -                    update
   227         -                }
   228         -                regsub $env(HOME) [pwd] "" prompt2
   229         -                set line [::tclreadline::readline read "$readlinePrompt \[$prompt2\]"]
   230         -                set result [eval $line]
   231         -                if {$result != ""} {
   232         -                    puts $result
   233         -                }
   234         -                set result ""
   235         -            } msg]} {
   236         -#                puts stderr $msg
   237         -            }
   238         -        }
   239         -    }
   240         -}
   241         -
   242         -
   243         -proc ::tclreadline::InitCmds {} {
   244         -    global tcl_version tk_version
   245         -    if {[info exists tcl_version]} {
   246         -        ::tclreadline::InitTclCmds
   247         -    }
   248         -    if {[info exists tk_version]} {
   249         -        ::tclreadline::InitTkCmds
   250         -    }
   251         -    rename tclreadline::InitCmds ""
   252         -}
   253         -
   254         -proc ::tclreadline::InitTclCmds {} {
   255         -::tclreadline::readline add "after option ?arg arg ...?"
   256         -::tclreadline::readline add "append varName ?value value ...?"
   257         -::tclreadline::readline add "array option arrayName ?arg ...?"
   258         -::tclreadline::readline add "binary option ?arg arg ...?"
   259         -::tclreadline::readline add "catch command ?varName?"
   260         -::tclreadline::readline add "clock option ?arg ...?"
   261         -::tclreadline::readline add "close channelId"
   262         -::tclreadline::readline add "eof channelId"
   263         -::tclreadline::readline add "error message ?errorInfo? ?errorCode?"
   264         -::tclreadline::readline add "eval arg ?arg ...?"
   265         -::tclreadline::readline add "exec ?switches? arg ?arg ...?"
   266         -::tclreadline::readline add "expr arg ?arg ...?"
   267         -::tclreadline::readline add "fblocked channelId"
   268         -::tclreadline::readline add "fconfigure channelId ?optionName? ?value? ?optionName value?..."
   269         -::tclreadline::readline add "fcopy input output ?-size size? ?-command callback?"
   270         -::tclreadline::readline add "file option ?arg ...?"
   271         -::tclreadline::readline add "fileevent channelId event ?script?"
   272         -::tclreadline::readline add "flush channelId"
   273         -::tclreadline::readline add "for start test next command"
   274         -::tclreadline::readline add "foreach varList list ?varList list ...? command"
   275         -::tclreadline::readline add "format formatString ?arg arg ...?"
   276         -::tclreadline::readline add "gets channelId ?varName?"
   277         -::tclreadline::readline add "glob ?switches? name ?name ...?"
   278         -::tclreadline::readline add "global varName ?varName ...?"
   279         -::tclreadline::readline add "incr varName ?increment?"
   280         -::tclreadline::readline add "info option ?arg arg ...?"
   281         -::tclreadline::readline add "interp cmd ?arg ...?"
   282         -::tclreadline::readline add "join list ?joinString?"
   283         -::tclreadline::readline add "lappend varName ?value value ...?"
   284         -::tclreadline::readline add "lindex list index"
   285         -::tclreadline::readline add "linsert list index element ?element ...?"
   286         -::tclreadline::readline add "llength list"
   287         -::tclreadline::readline add "load fileName ?packageName? ?interp?"
   288         -::tclreadline::readline add "lrange list first last"
   289         -::tclreadline::readline add "lreplace list first last ?element element ...?"
   290         -::tclreadline::readline add "lsearch ?mode? list pattern"
   291         -::tclreadline::readline add "lsort ?options? list"
   292         -::tclreadline::readline add "namespace subcommand ?arg ...?"
   293         -::tclreadline::readline add "open fileName ?access? ?permissions?"
   294         -::tclreadline::readline add "package option ?arg arg ...?"
   295         -::tclreadline::readline add "proc name args body"
   296         -::tclreadline::readline add "puts ?-nonewline? ?channelId? string"
   297         -::tclreadline::readline add "read ?-nonewline? channelId"
   298         -::tclreadline::readline add "regexp ?switches? exp string ?matchVar? ?subMatchVar subMatchVar ...?"
   299         -::tclreadline::readline add "regsub ?switches? exp string subSpec varName"
   300         -::tclreadline::readline add "rename oldName newName"
   301         -::tclreadline::readline add "scan string format ?varName varName ...?"
   302         -::tclreadline::readline add "seek channelId offset ?origin?"
   303         -::tclreadline::readline add "set varName ?newValue?"
   304         -::tclreadline::readline add "socket ?-myaddr addr? ?-myport myport? ?-async? host port"
   305         -::tclreadline::readline add "socket -server command ?-myaddr addr? port"
   306         -::tclreadline::readline add "source fileName"
   307         -::tclreadline::readline add "split string ?splitChars?"
   308         -::tclreadline::readline add "string option arg ?arg ...?"
   309         -::tclreadline::readline add "subst ?-nobackslashes? ?-nocommands? ?-novariables? string"
   310         -::tclreadline::readline add "switch ?switches? string pattern body ... ?default body?"
   311         -::tclreadline::readline add "tell channelId"
   312         -::tclreadline::readline add "time command ?count?"
   313         -::tclreadline::readline add "trace option \[arg arg ...\]"
   314         -::tclreadline::readline add "unset varName ?varName ...?"
   315         -::tclreadline::readline add "uplevel ?level? command ?arg ...?"
   316         -::tclreadline::readline add "upvar ?level? otherVar localVar ?otherVar localVar ...?"
   317         -::tclreadline::readline add "vwait name"
   318         -::tclreadline::readline add "while test command"
   319         -rename tclreadline::InitTclCmds ""
   320         -
   321         -}
   322         -
   323         -proc ::tclreadline::InitTkCmds {} {
   324         -::tclreadline::readline add "bind window ?pattern? ?command?"
   325         -::tclreadline::readline add "bindtags window ?tags?"
   326         -::tclreadline::readline add "button pathName ?options?"
   327         -::tclreadline::readline add "canvas pathName ?options?"
   328         -::tclreadline::readline add "checkbutton pathName ?options?"
   329         -::tclreadline::readline add "clipboard option ?arg arg ...?"
   330         -::tclreadline::readline add "entry pathName ?options?"
   331         -::tclreadline::readline add "event option ?arg1?"
   332         -::tclreadline::readline add "font option ?arg?"
   333         -::tclreadline::readline add "frame pathName ?options?"
   334         -::tclreadline::readline add "grab option ?arg arg ...?"
   335         -::tclreadline::readline add "grid option arg ?arg ...?"
   336         -::tclreadline::readline add "image option ?args?"
   337         -::tclreadline::readline add "label pathName ?options?"
   338         -::tclreadline::readline add "listbox pathName ?options?"
   339         -::tclreadline::readline add "lower window ?belowThis?"
   340         -::tclreadline::readline add "menu pathName ?options?"
   341         -::tclreadline::readline add "menubutton pathName ?options?"
   342         -::tclreadline::readline add "message pathName ?options?"
   343         -::tclreadline::readline add "option cmd arg ?arg ...?"
   344         -::tclreadline::readline add "pack option arg ?arg ...?"
   345         -::tclreadline::readline add "radiobutton pathName ?options?"
   346         -::tclreadline::readline add "raise window ?aboveThis?"
   347         -::tclreadline::readline add "scale pathName ?options?"
   348         -::tclreadline::readline add "scrollbar pathName ?options?"
   349         -::tclreadline::readline add "selection option ?arg arg ...?"
   350         -::tclreadline::readline add "send ?options? interpName arg ?arg ...?"
   351         -::tclreadline::readline add "text pathName ?options?"
   352         -::tclreadline::readline add "tk option ?arg?"
   353         -::tclreadline::readline add "tkwait variable|visibility|window name"
   354         -::tclreadline::readline add "toplevel pathName ?options?"
   355         -::tclreadline::readline add "winfo option ?arg?"
   356         -::tclreadline::readline add "wm option window ?arg ...?"
   357         -rename tclreadline::InitTkCmds ""
   358         -}
   359         -
   360         -
   361         -
   362         -
   363         -# ***** invalid command name "Tcl"
   364         -# ***** invalid command name "bgerror"
   365         -# ***** invalid command name "contents"
   366         -# ***** invalid command name "filename"
   367         -# ***** invalid command name "http"
   368         -# ***** wrong # args: no expression after "if" argument
   369         -# ***** invalid command name "library"
   370         -# ***** 4940
   371         -# ***** invalid command name "pkgMkIndex"
   372         -# ***** /home/joze
   373         -# ***** invalid command name "registry"
   374         -# ***** invalid command name "resource"
   375         -# ***** invalid command name "safe"
   376         -# ***** wrong # args: should be either:
   377         -# ***** invalid command name "tclvars"
   378         -# ***** invalid command name ""