Posted to tcl by jdc at Mon Dec 10 11:38:37 GMT 2007view raw
- package require Tk
- text .t
- rename .t .t::cmd
- proc .t { cmd args } {
- switch -exact -- $cmd {
- pinsert {
- # inserted by program
- foreach {txt tags} $args {
- lappend tags "pinserted"
- eval .t::cmd insert $txt $tags
- }
- }
- insert {
- # inserted by user
- foreach {txt tags} $args {
- lappend tags "inserted"
- eval .t::cmd insert $txt $tags
- }
- }
- default {
- eval .t::cmd $cmd $args
- }
- }
- }
- pack .t
- .t tag configure inserted -background red
- .t tag configure pinserted -background green