Index: configure.in ================================================================== --- configure.in +++ configure.in @@ -120,36 +120,10 @@ Can't find tcl.h. Use --with-tcl-includes to specify the directory containing tcl.h on your system.]) else AC_MSG_RESULT($TCL_INCLUDE_DIR/tcl.h) fi - - -# --- -# check for the terminal library. -# --- - -AC_ARG_WITH(tlib-library, - [ --with-tlib-library=DIR - lib spec to tlib (e.g. '-L/usr/local/lib -lncurses')], - LIBS="$LIBS $withval", - for tlib in ncurses termlib termcap curses; do - brk=yes - AC_CHECK_LIB($tlib, tputs, , brk=no) - if test $brk = "yes"; then - HAVE_TLIB=yes - break - fi - done - if test "x" = "x$HAVE_TLIB"; then - AC_MSG_ERROR([ - no terminal library found. Please retry with the --with-tlib argument. - ]) - fi -) - - #-------------------------------------------------------------------- # Check for readline.h #-------------------------------------------------------------------- AC_ARG_WITH(readline-includes, Index: pkgIndex.tcl.in ================================================================== --- pkgIndex.tcl.in +++ pkgIndex.tcl.in @@ -1,6 +1,5 @@ -#!/usr/local/bin/tclsh # FILE: "/home/joze/src/tclreadline/pkgIndex.tcl.in" # LAST MODIFICATION: "Mit, 10 Jan 2001 06:29:33 +0100 (joze)" # (C) 1998 - 2001 by Johannes Zellner, # $Id$ # --- Index: tclreadline.c ================================================================== --- tclreadline.c +++ tclreadline.c @@ -47,12 +47,12 @@ #include "tclreadline.h" static const char* tclrl_library = TCLRL_LIBRARY; static const char* tclrl_version_str = TCLRL_VERSION_STR; static const char* tclrl_patchlevel_str = TCLRL_PATCHLEVEL_STR; -#define MALLOC(size) Tcl_Alloc((int) size) -#define FREE(ptr) if (ptr) { Tcl_Free((char*) ptr); ptr = 0; } +#define MALLOC(size) malloc((int) size) +#define FREE(ptr) if (ptr) { free((char*) ptr); ptr = 0; } enum { _CMD_SET = (1 << 0), _CMD_GET = (1 << 1) }; @@ -743,11 +743,11 @@ } Tcl_ResetResult(tclrl_interp); /* clear result space */ } if (!matches && tclrl_use_builtin_completer) { - matches = completion_matches(text, TclReadline0generator); + matches = rl_completion_matches(text, (rl_compentry_func_t *)TclReadline0generator); } return matches; } Index: tclreadline.n.in ================================================================== --- tclreadline.n.in +++ tclreadline.n.in @@ -71,11 +71,11 @@ For the functionality of the GNU readline you should refer to the readline's documentation. .PP The following list will give all commands, which are currently -implemented in the shared lib (e.g. libtclreadline@TCLREADLINE_VERSION@.so). +implemented in the shared lib (e.g. libtclreadline@VERSION@.so). Additional commands were introduced in a startup script \fBtclreadlineSetup.tcl\fP, which lives in the tclreadline installation directory. (typically something like /usr/local/lib/tclreadline ..) These commands are primarily for internal use and not documented here. @@ -143,11 +143,11 @@ \fBtclreadline::readline eof\fP returns the current eof script. .TP 5 \fB::tclreadline::readline initialize\fP \fIhistoryfile\fP initialize the tclreadline interface and read the history from -the \fIhistoryfile\fP. On succes an empty string is returned. +the \fIhistoryfile\fP. On success an empty string is returned. This command has to be called before any other tclreadline commands. .TP 5 \fB::tclreadline::readline read\fP \fIprompt\fP prints the \fIprompt\fP to stdout and enters the tclreadline event @@ -209,11 +209,11 @@ .TP 5 \fB::tclreadline::prompt1\fP a proc which is called by ::tclreadline::Loop and returns a string which will be displayed as the primary prompt. This prompt will be -something like "[info nameofexecutable] \[[pwd]\]" possibly fancy colored. +something like "[info nameofexecutable] \\[[pwd]\\]" possibly fancy colored. The default proc is defined on entering the ::tclreadline::Loop, if it is not already defined. So: If you define your own proc ::tclreadline::prompt1 before entering ::tclreadline::Loop, this proc is called each time the prompt is to be displayed. Example: @@ -230,10 +230,15 @@ Note that non-printable control characters as color control characters must be enclosed in literal ctrl-a / ctrl-b to tell readline the length of the printable prompt. See for example the variable `prompt_string' in the file tclreadlineSetup.tcl in your tclreadline installation directory. +.TP 5 +\fB::tclreadline::prompt2\fP +a proc which is called by ::tclreadline::Loop and returns a string +which will be displayed as the secondary prompt when interactively +prompting for continuation of an incomplete command. .\" .SH "EXAMPLES" .\" .SH "ENVIRONMENT VARIABLES" @@ -240,24 +245,24 @@ .SH "VARIABLES" \fItclreadline\fP defines the following variables in the namespace \fI::tclreadline\fP: -(for backwards compatiblity the global variables tclreadline_version, +(for backwards compatibility the global variables tclreadline_version, tclreadline_patchLevel and tclreadline_library are still present). .TP 5 \fBtclreadline::version\fP (read-only) -holds the version string "@TCLREADLINE_VERSION@". +holds the version string "@VERSION@". .TP 5 \fBtclreadline::patchLevel\fP (read-only) holds the patch level string "@PATCHLEVEL_STR@". .TP 5 \fBtclreadline::library\fP (read-only) -holds the library string "@TCLREADLINE_LIBRARY@". +holds the library string "@TCLRL_DIR@". .TP 5 \fBtclreadline::license\fP (read-only) holds a BSD license statement. Index: tclreadlineCompleter.tcl ================================================================== --- tclreadlineCompleter.tcl +++ tclreadlineCompleter.tcl @@ -623,11 +623,11 @@ } else { return 0 } } } - if {![catch [list set type [image type ${cmd}]]]} { + if {![catch {set type [image type $cmd]}]} { switch -- ${type} { photo { set result [PhotoObj ${text} ${start} ${end} ${line} ${pos}] return 1 } @@ -1458,11 +1458,11 @@ # make `alias' a fully qualified name. # this can raise an error, if alias is # no valid command. # - if {[catch [list set alias [namespace origin $alias]]]} { + if {[catch {set alias [namespace origin $alias]}]} { return "" } # strip leading ::'s. # @@ -3040,11 +3040,11 @@ # } proc complete(regsub) {text start end line pos mod} { set prev [PreviousWord ${start} ${line}] if {[llength ${prev}] && "--" != $prev && \ - ("-" == [string index ${prev} 0] || 1 == ${pos)}} { + ("-" == [string index ${prev} 0] || 1 == ${pos})} { set cmds [RemoveUsedOptions ${line} { -all -nocase --} {--}] if {[llength ${cmds}]} { return [string trim [CompleteFromList ${text} ${cmds}]] } @@ -3447,11 +3447,11 @@ } proc complete(switch) {text start end line pos mod} { set prev [PreviousWord ${start} ${line}] if {[llength ${prev}] && "--" != ${prev} && \ - ("-" == [string index ${prev} 0] || 1 == ${pos)}} { + ("-" == [string index ${prev} 0] || 1 == ${pos})} { set cmds [RemoveUsedOptions ${line} { -exact -glob -regexp --} {--}] if {[llength ${cmds}]} { return [string trim [CompleteFromList ${text} ${cmds}]] } Index: tclreadlineInit.tcl.in ================================================================== --- tclreadlineInit.tcl.in +++ tclreadlineInit.tcl.in @@ -1,6 +1,5 @@ -#!/usr/local/bin/tclsh # FILE: "/home/joze/src/tclreadline/tclreadlineInit.tcl.in" # LAST MODIFICATION: "Mit, 10 Jan 2001 06:29:33 +0100 (joze)" # (C) 1998 - 2001 by Johannes Zellner, # $Id$ # --- Index: tclreadlineSetup.tcl.in ================================================================== --- tclreadlineSetup.tcl.in +++ tclreadlineSetup.tcl.in @@ -1,6 +1,5 @@ -#!/usr/locanl/bin/tclsh # FILE: "/home/joze/src/tclreadline/tclreadlineSetup.tcl.in" # LAST MODIFICATION: "Mit, 10 Jan 2001 06:29:34 +0100 (joze)" # (C) 1998 - 2001 by Johannes Zellner, # $Id$ # --- @@ -134,11 +133,11 @@ if {"" == [info commands ::tclreadline::readline]} { ::tclreadline::Init } - if {[catch {set a [::tclreadline::prompt1]}] && [info nameofexecutable] != ""} { + if {"" == [info procs ::tclreadline::prompt1] && [info nameofexecutable] != ""} { namespace eval ::tclreadline { variable prompt_string set base [file tail [info nameofexecutable]] @@ -168,10 +167,20 @@ return "$prompt_string \[$pwd\]" } } # puts body=[info body ::tclreadline::prompt1] } + + if {"" == [info procs ::tclreadline::prompt2] && [info nameofexecutable] != ""} { + + if {"" == [info procs ::tclreadline::prompt2]} { + proc ::tclreadline::prompt2 {} { + return ">" + } + } + # puts body=[info body ::tclreadline::prompt2] + } if {"" == [info procs exit]} { catch {rename ::tclreadline::Exit ""} rename exit ::tclreadline::Exit @@ -261,26 +270,25 @@ uplevel #0 { while {1} { - if [info exists tcl_prompt2] { - set prompt2 $tcl_prompt2 - } else { - set prompt2 ">" - } - if {[catch { if {"" != [namespace eval ::tclreadline {info procs prompt1}]} { - set LINE [::tclreadline::readline read \ + set ::tclreadline::LINE [::tclreadline::readline read \ [::tclreadline::prompt1]] } else { - set LINE [::tclreadline::readline read %] + set ::tclreadline::LINE [::tclreadline::readline read %] } - while {![::tclreadline::readline complete $LINE]} { - append LINE "\n" - append LINE [tclreadline::readline read ${prompt2}] + while {![::tclreadline::readline complete $::tclreadline::LINE]} { + append ::tclreadline::LINE "\n" + if {"" != [namespace eval ::tclreadline {info procs prompt2}]} { + append ::tclreadline::LINE \ + [tclreadline::readline read [::tclreadline::prompt2]] + } else { + append ::tclreadline::LINE [tclreadline::readline read >] + } } } ::tclreadline::errorMsg]} { puts stderr [list tclreadline::Loop: error. \ $::tclreadline::errorMsg] continue @@ -292,23 +300,24 @@ # I decided to add only lines which are different from # the previous one to the history. This is different # from tcsh's behaviour, but I found it quite convenient # while using mshell on os9. # - if {[string length $LINE] && [history event 0] != $LINE} { - history add $LINE + if {[string length $::tclreadline::LINE] && \ + [history event 0] != $::tclreadline::LINE} { + history add $::tclreadline::LINE } if [catch { - set result [eval $LINE] - if {$result != "" && [tclreadline::Print]} { - puts $result + set ::tclreadline::result [eval $::tclreadline::LINE] + if {$::tclreadline::result != "" && [tclreadline::Print]} { + puts $::tclreadline::result } - set result "" + set ::tclreadline::result "" } ::tclreadline::errorMsg] { puts stderr $::tclreadline::errorMsg - puts stderr [list while evaluating $LINE] + puts stderr [list while evaluating $::tclreadline::LINE] } } } }