Posted to tcl by aspect at Sun Dec 29 07:23:07 GMT 2013view raw

  1. proc ::repl {{type "readline"}} {
  2. # finally start the enhanced REPL
  3. switch -exact $type {
  4. "linenoise" {
  5. # package require Tclx
  6. # proc trapint {} {
  7. # global sigint
  8. # puts "SIGINT"
  9. # incr sigint
  10. # }
  11. # signal trap SIGINT trapint
  12.  
  13. package require linenoise
  14. while {1} {
  15. linenoise cmdloop -prompt1 {apply {{} {
  16. return "\033\[36mtclsh-[info patchlevel]\033\[0m \[\033\[34m[file tail [pwd]\033\[0m]\]\033\[31m % \033\[0m"
  17. }}} -prompt2 {apply {{} {
  18. return "[string repeat " " [string length "tclsh-[info patchlevel] \[[file tail [pwd]]\]"]]\033\[31m > \033\[0m"
  19. }}} -history yes
  20. }
  21. }
  22. "editline" {
  23. lappend ::auto_path /usr/local/share/eltcl
  24. package require eltclsh
  25. set ::el::prompt1 {subst -nov -noc "tclsh[info patchlevel] \[[pwd]\]% "}
  26. set ::el::prompt2 {list tclsh ...... >}
  27. interactive
  28. exit
  29. }
  30. "readline" {
  31. package require tclreadline
  32. ::tclreadline::Loop
  33. }
  34. "none" {
  35. }
  36. }
  37. }
  38.