tcl-tclreadline/tcl-tclreadline-2.1.0-promp...

98 lines
3.3 KiB
Diff

Patch by Sergei Golovan <sgolovan@debian.org> and Chris Waters <xtifr@debian.org> for
tclreadline >= 2.1.0 which adds ::tclreadline::prompt2 command which allows to customize
secondary prompt. It removes garbage global variable prompt2, too. Removes tcl_prompt2
variable usage as well (the tclx uses this variable in commandloop command). And patches
startup code to no longer overwrite the global variables 'a', 'LINE' and 'result'. Other
variables seemed to be ok. For further information, please have a look to Debian bug IDs
#87050, #89650, #90060 and #92812.
--- tclreadline-2.1.0/tclreadlineSetup.tcl.in 2000-07-02 00:18:08.000000000 +0200
+++ tclreadline-2.1.0/tclreadlineSetup.tcl.in.prompt2 2010-04-06 01:50:59.000000000 +0200
@@ -136,7 +136,7 @@
::tclreadline::Init
}
- if {[catch {set a [::tclreadline::prompt1]}] && [info nameofexecutable] != ""} {
+ if {"" == [info procs ::tclreadline::prompt1] && [info nameofexecutable] != ""} {
namespace eval ::tclreadline {
variable prompt_string
@@ -171,6 +171,16 @@
# 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 ""}
@@ -263,22 +273,21 @@
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. \
@@ -294,19 +303,20 @@
# 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]
}
}