Index: tclreadline.c ================================================================== --- tclreadline.c +++ tclreadline.c @@ -1,10 +1,10 @@ /* ================================================================== - FILE: "/home/joze/src/tclreadline/tclreadline.c" - LAST MODIFICATION: "Wed Sep 15 01:00:43 1999 (joze)" + FILE: "/disk01/home/joze/src/tclreadline/tclreadline.c" + LAST MODIFICATION: "Thu Sep 16 15:43:29 1999 (joze)" (C) 1998, 1999 by Johannes Zellner, $Id$ --- tclreadline -- gnu readline for tcl @@ -189,15 +189,17 @@ Tcl_Obj** objv = (Tcl_Obj**) MALLOC((argc + 1) * sizeof(Tcl_Obj *)); static char *subCmds[] = { "read", "initialize", "write", "add", "complete", "customcompleter", "builtincompleter", "eofchar", + "reset-terminal", (char *) NULL }; enum SubCmdIdx { TCLRL_READ, TCLRL_INITIALIZE, TCLRL_WRITE, TCLRL_ADD, TCLRL_COMPLETE, - TCLRL_CUSTOMCOMPLETER, TCLRL_BUILTINCOMPLETER, TCLRL_EOFCHAR + TCLRL_CUSTOMCOMPLETER, TCLRL_BUILTINCOMPLETER, TCLRL_EOFCHAR, + TCLRL_RESET_TERMINAL }; Tcl_ResetResult(interp); /* clear the result space */ @@ -367,10 +369,22 @@ if (!blank_line(argv[2])) tclrl_eof_string = stripwhite(strdup(argv[2])); } Tcl_AppendResult(interp, tclrl_eof_string, (char*) NULL); break; + + case TCLRL_RESET_TERMINAL: + /* TODO: add this to the completer */ + if (argc > 3) { + Tcl_WrongNumArgs(interp, 2, objv, "?terminal-name?"); + return TCL_ERROR; + } else if (3 == argc) { + rl_reset_terminal(Tcl_GetString(objv[2])); + } else { + rl_cleanup_after_signal(); + } + break; default: goto BAD_COMMAND; /* NOTREACHED */ break; Index: tclreadline.n.in ================================================================== --- tclreadline.n.in +++ tclreadline.n.in @@ -1,10 +1,10 @@ .TH tclreadline n "@TCLREADLINE_VERSION@.@TCLREADLINE_PATCHLEVEL@" "Johannes Zellner" .\" (C) 1999 by Johannes Zellner -.\" FILE: "/diska/home/joze/src/tclreadline/tclreadline.n.in" -.\" LAST MODIFICATION: "Mon Aug 30 14:12:14 1999 (joze)" +.\" FILE: "/disk01/home/joze/src/tclreadline/tclreadline.n.in" +.\" LAST MODIFICATION: "Thu Sep 16 18:10:41 1999 (joze)" .\" (C) 1998, 1999 by Johannes Zellner, .\" $Id$ .\" --- .\" .\" tclreadline -- gnu readline for the tcl scripting language @@ -177,10 +177,16 @@ writes the history to the \fIhistoryfile\fP. This command is called automatically from the internal routine ::tclreadline::Exit. If the variable \fBtclreadline::historyLength\fP is non-negative, the historyfile will be truncated to hold only this number lines. +.TP 5 +\fB::tclreadline::readline reset-terminal\fP [\fIterminalName\fP] +w/o argument: reset the state of the terminal to what it was +before tclreadline was used. With argument: reinitialize readline's +idea of the terminal settings using terminalName as the terminal type. + .TP 5 \fB::tclreadline::Print\fP [\fIyes / no\fP] turns on or off the default behavior of tclsh to print the result of every command. This is turned on by default, so it will just behave as the tclsh w/o tclreadline. Turning off might be useful, when reading Index: tclreadlineCompleter.tcl ================================================================== --- tclreadlineCompleter.tcl +++ tclreadlineCompleter.tcl @@ -1,8 +1,8 @@ # -*- tclsh -*- # FILE: "/disk01/home/joze/src/tclreadline/tclreadlineCompleter.tcl" -# LAST MODIFICATION: "Thu Sep 16 02:53:18 1999 (joze)" +# LAST MODIFICATION: "Thu Sep 16 16:24:46 1999 (joze)" # (C) 1998, 1999 by Johannes Zellner, # $Id$ # --- # # tclreadline -- gnu readline for tcl @@ -982,11 +982,11 @@ # try to use $pos further ... # puts stderr |$line| # if {"." == [string index [string trim ${line}] 0]} { set alias WIDGET - set namespc "" + set namespc ""; # widgets are always in the global } else { # the double `lindex' strips {} or quotes. # the subst enables variables containing # command names. @@ -1037,11 +1037,15 @@ ::tclreadline::errorMsg] } { error [list error during evaluation of `complete(${cmd})'] } # puts stderr \nscript_result=|${script_result}| - return ${script_result} + if {[string length ${script_result}] || \ + "tclreadline_complete_unknown" == ${cmd} + } { + return ${script_result} + } } # set namespc ""; # no qualifiers for tclreadline_complete_unknown } # as we've reached here no valid specific completer @@ -2036,11 +2040,11 @@ } proc complete(lappend) {text start end line pos mod} { switch -- $pos { 1 { return [VarCompletion ${text}] } - default { return [DisplayHints ?value?] } + default { return [TryFromList ${text} ?value?] } } return "" } # the following routines are described in the @@ -2974,11 +2978,11 @@ proc tclreadline::complete(readline) {text start end line pos mod} { set cmd [Lindex $line 1] switch -- $pos { 1 { return [CompleteFromList ${text} { read initialize write add complete - customcompleter builtincompleter eofchar}] + customcompleter builtincompleter eofchar reset-terminal}] } 2 { switch -- $cmd { read {} initialize {} @@ -2986,10 +2990,17 @@ add { return [DisplayHints ] } completer { return [DisplayHints ] } customcompleter { return [DisplayHints ?scriptCompleter?] } builtincompleter { return [DisplayHints ?boolean?] } eofchar { return [DisplayHints ?script?] } + reset-terminal { + if {[info exists ::env(TERM)]} { + return [CompleteFromList ${text} $::env(TERM)] + } else { + return [DisplayHints ?terminalName?] + } + } } } } return "" } Index: tclreadlineSetup.tcl.in ================================================================== --- tclreadlineSetup.tcl.in +++ tclreadlineSetup.tcl.in @@ -1,8 +1,8 @@ #!/usr/locanl/bin/tclsh # FILE: "/disk01/home/joze/src/tclreadline/tclreadlineSetup.tcl.in" -# LAST MODIFICATION: "Wed Sep 15 15:23:30 1999 (joze)" +# LAST MODIFICATION: "Thu Sep 16 18:06:23 1999 (joze)" # (C) 1998, 1999 by Johannes Zellner, # $Id$ # --- # # tclreadline -- gnu readline for tcl @@ -136,11 +136,11 @@ return -code error "invalid command name \"$name\"" } namespace eval tclreadline { -namespace export Setup Glob Loop InitTclCmds InitTkCmds Print ls +namespace export Setup Loop InitTclCmds InitTkCmds Print ls proc ls {args} { if {[exec uname -s] == "Linux"} { eval exec ls --color -FC [Glob $args] } else { @@ -203,10 +203,12 @@ ::tclreadline::readline write \ [::tclreadline::HistoryFileGet] } ::tclreadline::errorMsg]} { puts stderr $::tclreadline::errorMsg } + + ::tclreadline::readline reset-terminal if [catch "eval ::tclreadline::Exit $args" message] { puts stderr "error:" puts stderr "$message" } @@ -247,10 +249,12 @@ proc HistoryFileGet {} { variable historyfile return $historyfile } +# obsolete +# proc Glob {string} { set commandstring "" foreach name $string { set replace [glob -nocomplain -- $name]