proc bind.text args { foreach w $args { bind $w "catch {%W insert cursor %A}" bind $w {focus %W} bind $w {%W insert cursor "\\"} bind $w {%W insert cursor "\{"} bind $w {%W insert cursor "\}"} bind $w {%W insert cursor "\["} bind $w {%W insert cursor "\]"} bind $w {%W insert cursor "\""} bind $w {%W insert cursor " "} bind $w {%W insert cursor "\n"} bind $w <2> {%W insert cursor [selection get]} bind $w {%W edit dnc} bind $w {%W edit dpc} bind $w {%W edit dpc} bind $w <1> {%W cursor @%x,%y; focus %W; %W select from @%x,%y} bind $w {%W select to @%x,%y} bind $w {%W select adjust @%x,%y} bind $w {%W select to @%x,%y} bind $w <3> {%W scan mark %x,%y} bind $w {%W scan dragto %x,%y} bind $w {%W edit bc} bind $w {%W edit fc} bind $w {%W edit pl} bind $w {%W edit nl} bind $w {%W edit bol} bind $w {%W edit bc} bind $w {} bind $w {%W edit dnc} bind $w {%W edit eol} bind $w {%W edit fc} bind $w {} bind $w {} bind $w {} bind $w {} bind $w {%W delete cursor eol} bind $w {} bind $w {} bind $w {%W edit nl} bind $w {} bind $w {%W edit pl} bind $w {} bind $w {} bind $w {} bind $w {} bind $w {} bind $w {%W insert cursor [selection get]} bind $w {} bind $w {} bind $w {} bind $w {} } } proc bind.text.readonly args { foreach w $args { bind $w <1> {%W cursor @%x,%y; focus %W; %W select from @%x,%y} bind $w {%W select to @%x,%y} bind $w {%W select adjust @%x,%y} bind $w {%W select to @%x,%y} bind $w <3> {%W scan mark %x,%y} bind $w {%W scan dragto %x,%y} } } frame .frame pack append . .frame {top expand} scrollbar .frame.vscrollbar -command ".frame.text viewline" -relief sunken scrollbar .hscrollbar -relief sunken -orient horizontal text .frame.text -height 25 -width 16 \ -scrollvcommand ".frame.vscrollbar set" \ -scrollhcommand ".hscrollbar set" pack append .frame \ .frame.vscrollbar {left expand filly} \ .frame.text {left expand} pack append . \ .hscrollbar {top expand fillx} update .frame.text configure -wrapmode word .frame.text insert 0 [exec cat tkText.c] bind.text .frame.text