diff options
author | Didier Raboud <odyx@debian.org> | 2017-11-28 16:59:36 +0100 |
---|---|---|
committer | Didier Raboud <odyx@debian.org> | 2017-11-28 16:59:36 +0100 |
commit | ba67de24f09cd22ab6f3ac3a0b89e3a62a1bfbc1 (patch) | |
tree | 83052b1c6912c4ba587206fff50787cc67be2ea0 /rlprompt.tcl |
Import jimtcl_0.77+dfsg0.orig.tar.xz
[dgit import orig jimtcl_0.77+dfsg0.orig.tar.xz]
Diffstat (limited to 'rlprompt.tcl')
-rw-r--r-- | rlprompt.tcl | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/rlprompt.tcl b/rlprompt.tcl new file mode 100644 index 0000000..cdd78d4 --- /dev/null +++ b/rlprompt.tcl @@ -0,0 +1,45 @@ +# Readline-based interactive shell for Jim +# Copyright(C) 2005 Salvatore Sanfilippo <antirez@invece.org> +# +# In order to automatically have readline-editing features +# put this in your $HOME/.jimrc +# +# if {$jim_interactive} { +# if {[catch {package require rlprompt}] == 0} { +# rlprompt.shell +# } +# } +package require readline + +proc rlprompt.shell {} { + puts "Readline shell loaded" + puts "Welcome to Jim [info version]!" + set prompt ". " + set buf "" + while 1 { + set line [readline.readline $prompt] + + if {[string length $line] == 0} { + continue + } + if {$buf eq ""} { + set buf $line + } else { + append buf \n $line + } + if {![info complete $buf]} { + set prompt "> " + continue + } + readline.addhistory $buf + + catch { + uplevel #0 $buf + } error + if {$error ne ""} { + puts $error + } + set buf "" + set prompt ". " + } +} |