/usr/share/blt2.5/demos/htext1.tcl is in blt-demo 2.5.3+dfsg-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | #!/usr/bin/wish8.6
package require BLT
# --------------------------------------------------------------------------
# Starting with Tcl 8.x, the BLT commands are stored in their own
# namespace called "blt". The idea is to prevent name clashes with
# Tcl commands and variables from other packages, such as a "table"
# command in two different packages.
#
# You can access the BLT commands in a couple of ways. You can prefix
# all the BLT commands with the namespace qualifier "blt::"
#
# blt::graph .g
# blt::table . .g -resize both
#
# or you can import all the command into the global namespace.
#
# namespace import blt::*
# graph .g
# table . .g -resize both
#
# --------------------------------------------------------------------------
if { $tcl_version >= 8.0 } {
namespace import blt::*
namespace import -force blt::tile::*
}
source scripts/demo.tcl
set visual [winfo screenvisual .]
if { $visual == "staticgray" || $visual == "grayscale" } {
set activeBg black
set normalBg white
set bitmapFg black
set bitmapBg white
option add *top.background white
} else {
option add *htext.foreground navyblue
if { $tk_version >= 4.0 } {
set file1 ./images/clouds.gif
set file2 ./images/chalk.gif
image create photo bgTexture1 -file $file1
image create photo bgTexture2 -file $file2
# option add *htext.tile bgTexture1
option add *htext.foreground black
option add *htext.background white
option add *htext.selectBackground gold1
}
}
option add *highlightThickness 0
proc Blt_FindPattern { htext } {
toplevel .search
wm title .search "Text search"
label .search.label1 -text "Enter Pattern"
entry .search.entry -relief sunken
button .search.clear -text "Clear" \
-command ".search.entry delete 0 end"
button .search.cancel -text "Cancel" \
-command "destroy .search; focus $htext"
button .search.search -text "Search" -command "Blt_Search&Move $htext"
bind .search.entry <Return> "Blt_Search&Move $htext"
table .search \
.search.label1 0,0 -padx 4 \
.search.entry 0,1 -cspan 2 -pady 4 -padx 4 -reqwidth 3i \
.search.search 3,0 -reqwidth .75i -anchor w -padx 10 -pady 5 \
.search.clear 3,1 -reqwidth .75i -anchor center -padx 10 -pady 5 \
.search.cancel 3,2 -reqwidth .75i -anchor e -padx 10 -pady 5
focus .search.entry
bind .search <Visibility> { raise .search }
}
set last 0
set lastPattern {}
proc Blt_Search&Move { h } {
global last
global lastPattern
set pattern [.search.entry get]
if { [string compare $pattern $lastPattern] != 0 } {
set last 0
set lastPattern $pattern
}
if { $pattern == "" } {
return
}
set indices [$h search $pattern $last end]
if { $indices == "" } {
bell
} else {
set first [lindex $indices 0]
set last [lindex $indices 1]
$h selection range $first $last
$h gotoline $first
incr last
}
}
# Create horizonatal and vertical scrollbars
scrollbar .vscroll -command { .htext yview } -orient vertical
scrollbar .hscroll -command { .htext xview } -orient horizontal
# Create the hypertext widget
htext .htext -file ./htext.txt \
-yscrollcommand { .vscroll set } \
-xscrollcommand { .hscroll set } \
-yscrollunits 10m -xscrollunits .25i \
-height 6i
table . \
.htext 0,0 -fill both \
.vscroll 0,1 -fill y \
.hscroll 1,0 -fill x
table configure . r1 c1 -resize none
bind .htext <B1-Motion> {
%W select to @%x,%y
}
bind .htext <1> {
%W select from @%x,%y
%W select to @%x,%y
}
bind .htext <Shift-1> {
%W select word @%x,%y
}
bind .htext <Meta-1> {
%W select line @%x,%y
}
bind .htext <Control-1> {
puts stderr [%W select index @%x,%y]
}
bind .htext <B2-Motion> {
%W scan dragto @%x,%y
}
bind .htext <2> {
%W scan mark @%x,%y
}
bind .htext <3> {
%W select adjust @%x,%y
}
bind .htext <Control-p> {
set line [%W gotoline]
if { $line == 0 } {
bell
} else {
set line [expr $line-1]
%W gotoline $line.0
}
}
bind .htext <Control-n> {
set line [%W gotoline]
incr line
if { [%W gotoline $line.0] != $line } {
bell
}
}
bind .htext <Control-v> {
%W yview [expr [%W yview]+10]
}
bind .htext <Meta-v> {
%W yview [expr [%W yview]-10]
}
bind .htext <Alt-v> {
%W yview [expr [%W yview]-10]
}
bind .htext <Any-q> {
exit 0
}
bind .htext <Control-s> {
Blt_FindPattern %W
}
wm min . 0 0
focus .htext
|