Posted to tcl by jdc at Mon Dec 10 11:38:37 GMT 2007view raw

  1. package require Tk
  2.  
  3. text .t
  4.  
  5. rename .t .t::cmd
  6.  
  7. proc .t { cmd args } {
  8. switch -exact -- $cmd {
  9. pinsert {
  10. # inserted by program
  11. foreach {txt tags} $args {
  12. lappend tags "pinserted"
  13. eval .t::cmd insert $txt $tags
  14. }
  15. }
  16. insert {
  17. # inserted by user
  18. foreach {txt tags} $args {
  19. lappend tags "inserted"
  20. eval .t::cmd insert $txt $tags
  21. }
  22. }
  23. default {
  24. eval .t::cmd $cmd $args
  25. }
  26. }
  27. }
  28.  
  29. pack .t
  30. .t tag configure inserted -background red
  31. .t tag configure pinserted -background green