4 # --------------------------------------------------------------------------
5 # Starting with Tcl 8.x, the BLT commands are stored in their own
6 # namespace called "blt". The idea is to prevent name clashes with
7 # Tcl commands and variables from other packages, such as a "table"
8 # command in two different packages.
10 # You can access the BLT commands in a couple of ways. You can prefix
11 # all the BLT commands with the namespace qualifier "blt::"
14 # blt::table . .g -resize both
16 # or you can import all the command into the global namespace.
18 # namespace import blt::*
20 # table . .g -resize both
22 # --------------------------------------------------------------------------
23 if { $tcl_version >= 8.0 } {
24 namespace import blt::*
25 namespace import -force blt::tile::*
27 source scripts/demo.tcl
29 set visual [winfo screenvisual .]
30 if { $visual == "staticgray" || $visual == "grayscale" } {
35 option add *top.background white
37 option add *htext.foreground navyblue
38 if { $tk_version >= 4.0 } {
39 set file1 ./images/clouds.gif
40 set file2 ./images/chalk.gif
41 image create photo bgTexture1 -file $file1
42 image create photo bgTexture2 -file $file2
43 # option add *htext.tile bgTexture1
44 option add *htext.foreground black
45 option add *htext.background white
46 option add *htext.selectBackground gold1
49 option add *highlightThickness 0
51 proc Blt_FindPattern { htext } {
53 wm title .search "Text search"
54 label .search.label1 -text "Enter Pattern"
55 entry .search.entry -relief sunken
56 button .search.clear -text "Clear" \
57 -command ".search.entry delete 0 end"
58 button .search.cancel -text "Cancel" \
59 -command "destroy .search; focus $htext"
60 button .search.search -text "Search" -command "Blt_Search&Move $htext"
61 bind .search.entry <Return> "Blt_Search&Move $htext"
63 .search.label1 0,0 -padx 4 \
64 .search.entry 0,1 -cspan 2 -pady 4 -padx 4 -reqwidth 3i \
65 .search.search 3,0 -reqwidth .75i -anchor w -padx 10 -pady 5 \
66 .search.clear 3,1 -reqwidth .75i -anchor center -padx 10 -pady 5 \
67 .search.cancel 3,2 -reqwidth .75i -anchor e -padx 10 -pady 5
69 bind .search <Visibility> { raise .search }
75 proc Blt_Search&Move { h } {
80 set pattern [.search.entry get]
81 if { [string compare $pattern $lastPattern] != 0 } {
83 set lastPattern $pattern
85 if { $pattern == "" } {
89 set indices [$h search $pattern $last end]
90 if { $indices == "" } {
93 set first [lindex $indices 0]
94 set last [lindex $indices 1]
95 $h selection range $first $last
101 # Create horizonatal and vertical scrollbars
102 scrollbar .vscroll -command { .htext yview } -orient vertical
103 scrollbar .hscroll -command { .htext xview } -orient horizontal
105 # Create the hypertext widget
106 htext .htext -file ./htext.txt \
107 -yscrollcommand { .vscroll set } \
108 -xscrollcommand { .hscroll set } \
109 -yscrollunits 10m -xscrollunits .25i \
114 .htext 0,0 -fill both \
115 .vscroll 0,1 -fill y \
118 table configure . r1 c1 -resize none
120 bind .htext <B1-Motion> {
124 %W select from @%x,%y
128 bind .htext <Shift-1> {
129 %W select word @%x,%y
131 bind .htext <Meta-1> {
132 %W select line @%x,%y
134 bind .htext <Control-1> {
135 puts stderr [%W select index @%x,%y]
138 bind .htext <B2-Motion> {
139 %W scan dragto @%x,%y
146 %W select adjust @%x,%y
149 bind .htext <Control-p> {
150 set line [%W gotoline]
154 set line [expr $line-1]
158 bind .htext <Control-n> {
159 set line [%W gotoline]
161 if { [%W gotoline $line.0] != $line } {
166 bind .htext <Control-v> {
167 %W yview [expr [%W yview]+10]
170 bind .htext <Meta-v> {
171 %W yview [expr [%W yview]-10]
174 bind .htext <Alt-v> {
175 %W yview [expr [%W yview]-10]
178 bind .htext <Any-q> {
181 bind .htext <Control-s> {