| 1 |
2 |
tarookumic |
# FILE: header.tk
|
| 2 |
|
|
# This file is boilerplate TCL/TK function definitions for 'make xconfig'.
|
| 3 |
|
|
#
|
| 4 |
|
|
# CHANGES
|
| 5 |
|
|
# =======
|
| 6 |
|
|
#
|
| 7 |
|
|
# 8 January 1999, Michael Elizabeth Chastain,
|
| 8 |
|
|
# - Remove unused do_cmd function (part of the 2.0 sound support).
|
| 9 |
|
|
# - Arrange buttons in three columns for better screen fitting.
|
| 10 |
|
|
# - Add CONSTANT_Y, CONSTANT_M, CONSTANT_N for commands like:
|
| 11 |
|
|
# dep_tristate 'foo' CONFIG_FOO m
|
| 12 |
|
|
#
|
| 13 |
|
|
# 23 January 1999, Michael Elizabeth Chastain,
|
| 14 |
|
|
# - Shut vfix the hell up.
|
| 15 |
|
|
#
|
| 16 |
|
|
# 24 January 1999, Michael Elizabeth Chastain,
|
| 17 |
|
|
# - Improve the exit message (Jeff Ronne).
|
| 18 |
|
|
|
| 19 |
|
|
#
|
| 20 |
|
|
# This is a handy replacement for ".widget cget" that requires neither tk4
|
| 21 |
|
|
# nor additional source code uglification.
|
| 22 |
|
|
#
|
| 23 |
|
|
proc cget { w option } {
|
| 24 |
|
|
return "[lindex [$w configure $option] 4]"
|
| 25 |
|
|
}
|
| 26 |
|
|
|
| 27 |
|
|
#
|
| 28 |
|
|
# Function to compensate for broken config.in scripts like the sound driver,
|
| 29 |
|
|
# which make dependencies on variables that are never even conditionally
|
| 30 |
|
|
# defined.
|
| 31 |
|
|
#
|
| 32 |
|
|
proc vfix { var } {
|
| 33 |
|
|
global $var
|
| 34 |
|
|
if [ catch {eval concat $$var} ] {
|
| 35 |
|
|
set $var 4
|
| 36 |
|
|
}
|
| 37 |
|
|
}
|
| 38 |
|
|
|
| 39 |
|
|
#
|
| 40 |
|
|
# Constant values used by certain dep_tristate commands.
|
| 41 |
|
|
#
|
| 42 |
|
|
set CONSTANT_Y 1
|
| 43 |
|
|
set CONSTANT_M 2
|
| 44 |
|
|
set CONSTANT_N 0
|
| 45 |
|
|
set CONSTANT_E 4
|
| 46 |
|
|
|
| 47 |
|
|
#
|
| 48 |
|
|
# Create a "reference" object to steal colors from.
|
| 49 |
|
|
#
|
| 50 |
|
|
button .ref
|
| 51 |
|
|
|
| 52 |
|
|
#
|
| 53 |
|
|
# On monochrome displays, -disabledforeground is blank by default; that's
|
| 54 |
|
|
# bad. Fill it with -foreground instead.
|
| 55 |
|
|
#
|
| 56 |
|
|
if { [cget .ref -disabledforeground] == "" } {
|
| 57 |
|
|
.ref configure -disabledforeground [cget .ref -foreground]
|
| 58 |
|
|
}
|
| 59 |
|
|
|
| 60 |
|
|
|
| 61 |
|
|
#
|
| 62 |
|
|
# Define some macros we will need to parse the config.in file.
|
| 63 |
|
|
#
|
| 64 |
|
|
|
| 65 |
|
|
proc mainmenu_name { text } {
|
| 66 |
|
|
wm title . "$text"
|
| 67 |
|
|
}
|
| 68 |
|
|
|
| 69 |
|
|
proc menu_option { w menu_num text } {
|
| 70 |
|
|
global menus_per_column
|
| 71 |
|
|
global processed_top_level
|
| 72 |
|
|
set processed_top_level [expr $processed_top_level + 1]
|
| 73 |
|
|
if { $processed_top_level <= $menus_per_column } then {
|
| 74 |
|
|
set myframe left
|
| 75 |
|
|
} elseif { $processed_top_level <= [expr 2 * $menus_per_column] } then {
|
| 76 |
|
|
set myframe middle
|
| 77 |
|
|
} else {
|
| 78 |
|
|
set myframe right
|
| 79 |
|
|
}
|
| 80 |
|
|
button .f0.x$menu_num -anchor w -text "$text" \
|
| 81 |
|
|
-command "$w .$w \"$text\""
|
| 82 |
|
|
pack .f0.x$menu_num -pady 0 -side top -fill x -in .f0.$myframe
|
| 83 |
|
|
}
|
| 84 |
|
|
|
| 85 |
|
|
proc load_configfile { w title func } {
|
| 86 |
|
|
catch {destroy $w}
|
| 87 |
|
|
toplevel $w -class Dialog
|
| 88 |
|
|
global loadfile
|
| 89 |
|
|
frame $w.x
|
| 90 |
|
|
label $w.bm -bitmap questhead
|
| 91 |
|
|
pack $w.bm -pady 10 -side top -padx 10
|
| 92 |
|
|
label $w.x.l -text "Enter filename:" -relief raised
|
| 93 |
|
|
entry $w.x.x -width 35 -relief sunken -borderwidth 2 \
|
| 94 |
|
|
-textvariable loadfile
|
| 95 |
|
|
pack $w.x.l $w.x.x -anchor w -side left
|
| 96 |
|
|
pack $w.x -side top -pady 10
|
| 97 |
|
|
wm title $w "$title"
|
| 98 |
|
|
|
| 99 |
|
|
set oldFocus [focus]
|
| 100 |
|
|
frame $w.f
|
| 101 |
|
|
button $w.f.back -text "OK" -width 20 \
|
| 102 |
|
|
-command "destroy $w; focus $oldFocus;$func .fileio"
|
| 103 |
|
|
button $w.f.canc -text "Cancel" \
|
| 104 |
|
|
-width 20 -command "destroy $w; focus $oldFocus"
|
| 105 |
|
|
pack $w.f.back $w.f.canc -side left -pady 10 -padx 45
|
| 106 |
|
|
pack $w.f -pady 10 -side bottom -padx 10 -anchor w
|
| 107 |
|
|
focus $w
|
| 108 |
|
|
global winx; global winy
|
| 109 |
|
|
set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]
|
| 110 |
|
|
wm geometry $w +$winx+$winy
|
| 111 |
|
|
}
|
| 112 |
|
|
|
| 113 |
|
|
bind all {maybe_exit .maybe}
|
| 114 |
|
|
|
| 115 |
|
|
proc maybe_exit { w } {
|
| 116 |
|
|
catch {destroy $w}
|
| 117 |
|
|
toplevel $w -class Dialog
|
| 118 |
|
|
label $w.bm -bitmap questhead
|
| 119 |
|
|
pack $w.bm -pady 10 -side top -padx 10
|
| 120 |
|
|
message $w.m -width 400 -aspect 300 \
|
| 121 |
|
|
-text "Changes will be lost. Are you sure?" -relief flat
|
| 122 |
|
|
pack $w.m -pady 10 -side top -padx 10
|
| 123 |
|
|
wm title $w "Are you sure?"
|
| 124 |
|
|
|
| 125 |
|
|
set oldFocus [focus]
|
| 126 |
|
|
frame $w.f
|
| 127 |
|
|
button $w.f.back -text "OK" -width 20 \
|
| 128 |
|
|
-command "exit"
|
| 129 |
|
|
button $w.f.canc -text "Cancel" \
|
| 130 |
|
|
-width 20 -command "destroy $w; focus $oldFocus"
|
| 131 |
|
|
pack $w.f.back $w.f.canc -side left -pady 10 -padx 45
|
| 132 |
|
|
pack $w.f -pady 10 -side bottom -padx 10 -anchor w
|
| 133 |
|
|
bind $w "exit"
|
| 134 |
|
|
bind $w "destroy $w; focus $oldFocus"
|
| 135 |
|
|
focus $w
|
| 136 |
|
|
global winx; global winy
|
| 137 |
|
|
set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]
|
| 138 |
|
|
wm geometry $w +$winx+$winy
|
| 139 |
|
|
}
|
| 140 |
|
|
|
| 141 |
|
|
proc read_config_file { w } {
|
| 142 |
|
|
global loadfile
|
| 143 |
|
|
if { [string length $loadfile] != 0 && [file readable $loadfile] == 1 } then {
|
| 144 |
|
|
read_config $loadfile
|
| 145 |
|
|
} else {
|
| 146 |
|
|
catch {destroy $w}
|
| 147 |
|
|
toplevel $w -class Dialog
|
| 148 |
|
|
message $w.m -width 400 -aspect 300 -text \
|
| 149 |
|
|
"Unable to read file $loadfile" \
|
| 150 |
|
|
-relief raised
|
| 151 |
|
|
label $w.bm -bitmap error
|
| 152 |
|
|
pack $w.bm $w.m -pady 10 -side top -padx 10
|
| 153 |
|
|
wm title $w "Xconfig Internal Error"
|
| 154 |
|
|
|
| 155 |
|
|
set oldFocus [focus]
|
| 156 |
|
|
frame $w.f
|
| 157 |
|
|
button $w.f.back -text "Bummer" \
|
| 158 |
|
|
-width 10 -command "destroy $w; focus $oldFocus"
|
| 159 |
|
|
pack $w.f.back -side bottom -pady 10 -anchor s
|
| 160 |
|
|
pack $w.f -pady 10 -side top -padx 10 -anchor s
|
| 161 |
|
|
focus $w
|
| 162 |
|
|
global winx; global winy
|
| 163 |
|
|
set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]
|
| 164 |
|
|
wm geometry $w +$winx+$winy
|
| 165 |
|
|
}
|
| 166 |
|
|
}
|
| 167 |
|
|
|
| 168 |
|
|
proc write_config_file { w } {
|
| 169 |
|
|
global loadfile
|
| 170 |
|
|
if { [string length $loadfile] != 0
|
| 171 |
|
|
&& ([file writable $loadfile] == 1 || ([file exists $loadfile] == 0 && [file writable [file dirname $loadfile]] == 1)) } then {
|
| 172 |
|
|
writeconfig $loadfile .null
|
| 173 |
|
|
} else {
|
| 174 |
|
|
catch {destroy $w}
|
| 175 |
|
|
toplevel $w -class Dialog
|
| 176 |
|
|
message $w.m -width 400 -aspect 300 -text \
|
| 177 |
|
|
"Unable to write file $loadfile" \
|
| 178 |
|
|
-relief raised
|
| 179 |
|
|
label $w.bm -bitmap error
|
| 180 |
|
|
pack $w.bm $w.m -pady 10 -side top -padx 10
|
| 181 |
|
|
wm title $w "Xconfig Internal Error"
|
| 182 |
|
|
|
| 183 |
|
|
set oldFocus [focus]
|
| 184 |
|
|
frame $w.f
|
| 185 |
|
|
button $w.f.back -text "OK" \
|
| 186 |
|
|
-width 10 -command "destroy $w; focus $oldFocus"
|
| 187 |
|
|
pack $w.f.back -side bottom -pady 10 -anchor s
|
| 188 |
|
|
pack $w.f -pady 10 -side top -padx 10 -anchor s
|
| 189 |
|
|
focus $w
|
| 190 |
|
|
global winx; global winy
|
| 191 |
|
|
set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]
|
| 192 |
|
|
wm geometry $w +$winx+$winy
|
| 193 |
|
|
}
|
| 194 |
|
|
}
|
| 195 |
|
|
|
| 196 |
|
|
proc read_config { filename } {
|
| 197 |
|
|
set file1 [open $filename r]
|
| 198 |
|
|
clear_choices
|
| 199 |
|
|
while { [gets $file1 line] >= 0} {
|
| 200 |
|
|
if [regexp {([0-9A-Za-z_]+)=([ynm])} $line foo var value] {
|
| 201 |
|
|
if { $value == "y" } then { set cmd "global $var; set $var 1" }
|
| 202 |
|
|
if { $value == "n" } then { set cmd "global $var; set $var 0" }
|
| 203 |
|
|
if { $value == "m" } then { set cmd "global $var; set $var 2" }
|
| 204 |
|
|
eval $cmd
|
| 205 |
|
|
}
|
| 206 |
|
|
if [regexp {# ([0-9A-Za-z_]+) is not set} $line foo var] {
|
| 207 |
|
|
set cmd "global $var; set $var 0"
|
| 208 |
|
|
eval $cmd
|
| 209 |
|
|
}
|
| 210 |
|
|
if [regexp {([0-9A-Za-z_]+)=([0-9A-Fa-f]+)} $line foo var value] {
|
| 211 |
|
|
set cmd "global $var; set $var $value"
|
| 212 |
|
|
eval $cmd
|
| 213 |
|
|
}
|
| 214 |
|
|
if [regexp {([0-9A-Za-z_]+)="([^"]*)"} $line foo var value] {
|
| 215 |
|
|
set cmd "global $var; set $var \"$value\""
|
| 216 |
|
|
eval $cmd
|
| 217 |
|
|
}
|
| 218 |
|
|
}
|
| 219 |
|
|
close $file1
|
| 220 |
|
|
update_choices
|
| 221 |
|
|
update_mainmenu
|
| 222 |
|
|
}
|
| 223 |
|
|
proc write_comment { file1 file2 text } {
|
| 224 |
|
|
puts $file1 ""
|
| 225 |
|
|
puts $file1 "#"
|
| 226 |
|
|
puts $file1 "# $text"
|
| 227 |
|
|
puts $file1 "#"
|
| 228 |
|
|
puts $file2 "/*"
|
| 229 |
|
|
puts $file2 " * $text"
|
| 230 |
|
|
puts $file2 " */"
|
| 231 |
|
|
}
|
| 232 |
|
|
|
| 233 |
|
|
proc effective_dep { deplist } {
|
| 234 |
|
|
global CONFIG_MODULES
|
| 235 |
|
|
set depend 1
|
| 236 |
|
|
foreach i $deplist {
|
| 237 |
|
|
if {$i == 0} then {set depend 0}
|
| 238 |
|
|
if {$i == 2 && $depend == 1} then {set depend 2}
|
| 239 |
|
|
}
|
| 240 |
|
|
if {$depend == 2 && $CONFIG_MODULES == 0} then {set depend 0}
|
| 241 |
|
|
return $depend
|
| 242 |
|
|
}
|
| 243 |
|
|
|
| 244 |
|
|
proc sync_tristate { var dep } {
|
| 245 |
|
|
global CONFIG_MODULES
|
| 246 |
|
|
if {$dep == 0 && ($var == 1 || $var == 2)} then {
|
| 247 |
|
|
set var 0
|
| 248 |
|
|
} elseif {$dep == 2 && $var == 1} then {
|
| 249 |
|
|
set var 2
|
| 250 |
|
|
} elseif {$var == 2 && $CONFIG_MODULES == 0} then {
|
| 251 |
|
|
if {$dep == 1} then {set var 1} else {set var 0}
|
| 252 |
|
|
}
|
| 253 |
|
|
return $var
|
| 254 |
|
|
}
|
| 255 |
|
|
|
| 256 |
|
|
proc sync_bool { var dep modset } {
|
| 257 |
|
|
set var [sync_tristate $var $dep]
|
| 258 |
|
|
if {$dep == 2 && $var == 2} then {
|
| 259 |
|
|
set var $modset
|
| 260 |
|
|
}
|
| 261 |
|
|
return $var
|
| 262 |
|
|
}
|
| 263 |
|
|
|
| 264 |
|
|
proc write_tristate { file1 file2 varname variable deplist modset } {
|
| 265 |
|
|
set variable [sync_tristate $variable [effective_dep $deplist]]
|
| 266 |
|
|
if { $variable == 2 } \
|
| 267 |
|
|
then { set variable $modset }
|
| 268 |
|
|
if { $variable == 1 } \
|
| 269 |
|
|
then { puts $file1 "$varname=y"; \
|
| 270 |
|
|
puts $file2 "#define $varname 1" } \
|
| 271 |
|
|
elseif { $variable == 2 } \
|
| 272 |
|
|
then { puts $file1 "$varname=m"; \
|
| 273 |
|
|
puts $file2 "#undef $varname"; \
|
| 274 |
|
|
puts $file2 "#define ${varname}_MODULE 1" } \
|
| 275 |
|
|
elseif { $variable == 0 } \
|
| 276 |
|
|
then { puts $file1 "# $varname is not set"; \
|
| 277 |
|
|
puts $file2 "#undef $varname"} \
|
| 278 |
|
|
else { \
|
| 279 |
|
|
puts stdout "ERROR - Attempting to write value for unconfigured variable ($varname)." \
|
| 280 |
|
|
}
|
| 281 |
|
|
}
|
| 282 |
|
|
|
| 283 |
|
|
proc write_int { file1 file2 varname variable dep } {
|
| 284 |
|
|
if { $dep == 0 } \
|
| 285 |
|
|
then { puts $file1 "# $varname is not set"; \
|
| 286 |
|
|
puts $file2 "#undef $varname"} \
|
| 287 |
|
|
else {
|
| 288 |
|
|
puts $file1 "$varname=$variable"; \
|
| 289 |
|
|
puts $file2 "#define $varname ($variable)"; \
|
| 290 |
|
|
}
|
| 291 |
|
|
}
|
| 292 |
|
|
|
| 293 |
|
|
proc write_hex { file1 file2 varname variable dep } {
|
| 294 |
|
|
if { $dep == 0 } \
|
| 295 |
|
|
then { puts $file1 "# $varname is not set"; \
|
| 296 |
|
|
puts $file2 "#undef $varname"} \
|
| 297 |
|
|
else {
|
| 298 |
|
|
puts $file1 "$varname=$variable"; \
|
| 299 |
|
|
puts -nonewline $file2 "#define $varname 0x"; \
|
| 300 |
|
|
puts $file2 [exec echo $variable | sed s/^0\[xX\]//]; \
|
| 301 |
|
|
}
|
| 302 |
|
|
}
|
| 303 |
|
|
|
| 304 |
|
|
proc write_string { file1 file2 varname variable dep } {
|
| 305 |
|
|
if { $dep == 0 } \
|
| 306 |
|
|
then { puts $file1 "# $varname is not set"; \
|
| 307 |
|
|
puts $file2 "#undef $varname"} \
|
| 308 |
|
|
else {
|
| 309 |
|
|
puts $file1 "$varname=\"$variable\""; \
|
| 310 |
|
|
puts $file2 "#define $varname \"$variable\""; \
|
| 311 |
|
|
}
|
| 312 |
|
|
}
|
| 313 |
|
|
|
| 314 |
|
|
proc option_name {w mnum line text helpidx} {
|
| 315 |
|
|
button $w.x$line.l -text "$text" -relief groove -anchor w
|
| 316 |
|
|
$w.x$line.l configure -activefore [cget $w.x$line.l -fg] \
|
| 317 |
|
|
-activeback [cget $w.x$line.l -bg]
|
| 318 |
|
|
button $w.x$line.help -text "Help" -relief raised \
|
| 319 |
|
|
-command "dohelp .dohelp $helpidx .menu$mnum"
|
| 320 |
|
|
pack $w.x$line.help -side right -fill y
|
| 321 |
|
|
pack $w.x$line.l -side right -fill both -expand on
|
| 322 |
|
|
}
|
| 323 |
|
|
|
| 324 |
|
|
proc toggle_switch2 {w mnum line text variable} {
|
| 325 |
|
|
frame $w.x$line -relief sunken
|
| 326 |
|
|
radiobutton $w.x$line.y -text "y" -variable $variable -value 1 \
|
| 327 |
|
|
-relief groove -width 2 -command "update_active"
|
| 328 |
|
|
# radiobutton $w.x$line.m -text "-" -variable $variable -value 2 \
|
| 329 |
|
|
# -relief groove -width 2 -command "update_active"
|
| 330 |
|
|
radiobutton $w.x$line.n -text "n" -variable $variable -value 0 \
|
| 331 |
|
|
-relief groove -width 2 -command "update_active"
|
| 332 |
|
|
|
| 333 |
|
|
option_name $w $mnum $line $text $variable
|
| 334 |
|
|
|
| 335 |
|
|
pack $w.x$line.n $w.x$line.y -side right -fill y
|
| 336 |
|
|
}
|
| 337 |
|
|
|
| 338 |
|
|
proc toggle_switch3 {w mnum line text variable} {
|
| 339 |
|
|
frame $w.x$line -relief sunken
|
| 340 |
|
|
radiobutton $w.x$line.y -text "y" -variable $variable -value 1 \
|
| 341 |
|
|
-relief groove -width 2 -command "update_active"
|
| 342 |
|
|
radiobutton $w.x$line.m -text "m" -variable $variable -value 2 \
|
| 343 |
|
|
-relief groove -width 2 -command "update_active"
|
| 344 |
|
|
radiobutton $w.x$line.n -text "n" -variable $variable -value 0 \
|
| 345 |
|
|
-relief groove -width 2 -command "update_active"
|
| 346 |
|
|
|
| 347 |
|
|
option_name $w $mnum $line $text $variable
|
| 348 |
|
|
|
| 349 |
|
|
global CONFIG_MODULES
|
| 350 |
|
|
if {($CONFIG_MODULES == 0)} then {
|
| 351 |
|
|
$w.x$line.m configure -state disabled
|
| 352 |
|
|
}
|
| 353 |
|
|
pack $w.x$line.n $w.x$line.m $w.x$line.y -side right -fill y
|
| 354 |
|
|
}
|
| 355 |
|
|
|
| 356 |
|
|
proc bool {w mnum line text variable} {
|
| 357 |
|
|
toggle_switch2 $w $mnum $line $text $variable
|
| 358 |
|
|
# $w.x$line.m configure -state disabled
|
| 359 |
|
|
pack $w.x$line -anchor w -fill both -expand on
|
| 360 |
|
|
}
|
| 361 |
|
|
|
| 362 |
|
|
proc tristate {w mnum line text variable } {
|
| 363 |
|
|
toggle_switch3 $w $mnum $line $text $variable
|
| 364 |
|
|
pack $w.x$line -anchor w -fill both -expand on
|
| 365 |
|
|
}
|
| 366 |
|
|
|
| 367 |
|
|
proc dep_tristate {w mnum line text variable } {
|
| 368 |
|
|
tristate $w $mnum $line $text $variable
|
| 369 |
|
|
}
|
| 370 |
|
|
|
| 371 |
|
|
proc dep_bool {w mnum line text variable } {
|
| 372 |
|
|
bool $w $mnum $line $text $variable
|
| 373 |
|
|
}
|
| 374 |
|
|
|
| 375 |
|
|
proc int { w mnum line text variable } {
|
| 376 |
|
|
frame $w.x$line
|
| 377 |
|
|
entry $w.x$line.x -width 11 -relief sunken -borderwidth 2 \
|
| 378 |
|
|
-textvariable $variable
|
| 379 |
|
|
option_name $w $mnum $line $text $variable
|
| 380 |
|
|
pack $w.x$line.x -anchor w -side right -fill y
|
| 381 |
|
|
pack $w.x$line -anchor w -fill both -expand on
|
| 382 |
|
|
}
|
| 383 |
|
|
|
| 384 |
|
|
proc hex { w mnum line text variable } {
|
| 385 |
|
|
int $w $mnum $line $text $variable
|
| 386 |
|
|
}
|
| 387 |
|
|
|
| 388 |
|
|
proc istring { w mnum line text variable } {
|
| 389 |
|
|
frame $w.x$line
|
| 390 |
|
|
entry $w.x$line.x -width 18 -relief sunken -borderwidth 2 \
|
| 391 |
|
|
-textvariable $variable
|
| 392 |
|
|
option_name $w $mnum $line $text $variable
|
| 393 |
|
|
pack $w.x$line.x -anchor w -side right -fill y
|
| 394 |
|
|
pack $w.x$line -anchor w -fill both -expand on
|
| 395 |
|
|
}
|
| 396 |
|
|
|
| 397 |
|
|
proc minimenu { w mnum line text variable helpidx } {
|
| 398 |
|
|
frame $w.x$line
|
| 399 |
|
|
menubutton $w.x$line.x -textvariable $variable -menu \
|
| 400 |
|
|
$w.x$line.x.menu -relief raised \
|
| 401 |
|
|
-anchor w
|
| 402 |
|
|
option_name $w $mnum $line $text $helpidx
|
| 403 |
|
|
pack $w.x$line.x -anchor w -side right -fill y
|
| 404 |
|
|
pack $w.x$line -anchor w -fill both -expand on
|
| 405 |
|
|
}
|
| 406 |
|
|
|
| 407 |
|
|
proc menusplit {w m n} {
|
| 408 |
|
|
if { $n > 2 } then {
|
| 409 |
|
|
update idletasks
|
| 410 |
|
|
set menuoptsize [expr [$m yposition 2] - [$m yposition 1]]
|
| 411 |
|
|
set maxsize [winfo screenheight $w]
|
| 412 |
|
|
set splitpoint [expr $maxsize * 4 / 5 / $menuoptsize - 1]
|
| 413 |
|
|
for {set i [expr $splitpoint + 1]} {$i <= $n} {incr i $splitpoint} {
|
| 414 |
|
|
$m entryconfigure $i -columnbreak 1
|
| 415 |
|
|
}
|
| 416 |
|
|
}
|
| 417 |
|
|
}
|
| 418 |
|
|
|
| 419 |
|
|
proc menutitle {text menu w} {
|
| 420 |
|
|
wm title $w "$text"
|
| 421 |
|
|
}
|
| 422 |
|
|
|
| 423 |
|
|
proc submenu { w mnum line text subnum } {
|
| 424 |
|
|
frame $w.x$line
|
| 425 |
|
|
button $w.x$line.l -text "" -width 9 -relief groove
|
| 426 |
|
|
$w.x$line.l configure -activefore [cget $w.x$line.l -fg] \
|
| 427 |
|
|
-activeback [cget $w.x$line.l -bg] -state disabled
|
| 428 |
|
|
button $w.x$line.m -text "$text" -relief raised -anchor w \
|
| 429 |
|
|
-command "catch {destroy .menu$subnum}; menu$subnum .menu$subnum \"$text\""
|
| 430 |
|
|
pack $w.x$line.l -side left -fill both
|
| 431 |
|
|
pack $w.x$line.m -anchor w -side right -fill both -expand on
|
| 432 |
|
|
pack $w.x$line -anchor w -fill both -expand on
|
| 433 |
|
|
}
|
| 434 |
|
|
|
| 435 |
|
|
proc comment {w mnum line text } {
|
| 436 |
|
|
frame $w.x$line
|
| 437 |
|
|
button $w.x$line.l -text "" -width 15 -relief groove
|
| 438 |
|
|
$w.x$line.l configure -activefore [cget $w.x$line.l -fg] \
|
| 439 |
|
|
-activeback [cget $w.x$line.l -bg] -state disabled
|
| 440 |
|
|
button $w.x$line.m -text "$text" -relief groove -anchor w
|
| 441 |
|
|
$w.x$line.m configure -activefore [cget $w.x$line.m -fg] \
|
| 442 |
|
|
-activeback [cget $w.x$line.m -bg]
|
| 443 |
|
|
pack $w.x$line.l -side left -fill both
|
| 444 |
|
|
pack $w.x$line.m -anchor w -side right -fill both -expand on
|
| 445 |
|
|
pack $w.x$line -anchor w -fill both -expand on
|
| 446 |
|
|
}
|
| 447 |
|
|
|
| 448 |
|
|
proc dohelp {w var parent} {
|
| 449 |
|
|
catch {destroy $w}
|
| 450 |
|
|
toplevel $w -class Dialog
|
| 451 |
|
|
|
| 452 |
|
|
set filefound 0
|
| 453 |
|
|
set found 0
|
| 454 |
|
|
set lineno 0
|
| 455 |
|
|
|
| 456 |
|
|
if { [file readable config.help] == 1} then {
|
| 457 |
|
|
set filefound 1
|
| 458 |
|
|
# First escape sed regexp special characters in var:
|
| 459 |
|
|
set var [exec echo "$var" | sed s/\[\]\[\/.^$*\]/\\\\&/g]
|
| 460 |
|
|
# Now pick out right help text:
|
| 461 |
|
|
set message [exec sed -n "
|
| 462 |
|
|
/^$var\[ \]*\$/,\${
|
| 463 |
|
|
/^$var\[ \]*\$/c\\
|
| 464 |
|
|
${var}:\\
|
| 465 |
|
|
|
| 466 |
|
|
/^#/b
|
| 467 |
|
|
/^\[^ \]/q
|
| 468 |
|
|
s/^ //
|
| 469 |
|
|
/\]*\\)>/s//\\1/g
|
| 470 |
|
|
p
|
| 471 |
|
|
}
|
| 472 |
|
|
" config.help]
|
| 473 |
|
|
set found [expr [string length "$message"] > 0]
|
| 474 |
|
|
}
|
| 475 |
|
|
|
| 476 |
|
|
frame $w.f1
|
| 477 |
|
|
pack $w.f1 -fill both -expand on
|
| 478 |
|
|
|
| 479 |
|
|
# Do the OK button
|
| 480 |
|
|
#
|
| 481 |
|
|
set oldFocus [focus]
|
| 482 |
|
|
frame $w.f2
|
| 483 |
|
|
button $w.f2.ok -text "OK" \
|
| 484 |
|
|
-width 10 -command "destroy $w; catch {focus $oldFocus}"
|
| 485 |
|
|
pack $w.f2.ok -side bottom -pady 6 -anchor n
|
| 486 |
|
|
pack $w.f2 -side bottom -padx 10 -anchor s
|
| 487 |
|
|
|
| 488 |
|
|
scrollbar $w.f1.vscroll -command "$w.f1.canvas yview"
|
| 489 |
|
|
pack $w.f1.vscroll -side right -fill y
|
| 490 |
|
|
|
| 491 |
|
|
canvas $w.f1.canvas -relief flat -borderwidth 0 \
|
| 492 |
|
|
-yscrollcommand "$w.f1.vscroll set"
|
| 493 |
|
|
frame $w.f1.f
|
| 494 |
|
|
pack $w.f1.canvas -side right -fill y -expand on
|
| 495 |
|
|
|
| 496 |
|
|
if { $found == 0 } then {
|
| 497 |
|
|
if { $filefound == 0 } then {
|
| 498 |
|
|
message $w.f1.f.m -width 750 -aspect 300 -relief flat -text \
|
| 499 |
|
|
"No help available - unable to open file config.help."
|
| 500 |
|
|
} else {
|
| 501 |
|
|
message $w.f1.f.m -width 400 -aspect 300 -relief flat -text \
|
| 502 |
|
|
"No help available for $var"
|
| 503 |
|
|
}
|
| 504 |
|
|
label $w.f1.bm -bitmap error
|
| 505 |
|
|
wm title $w "RTFM"
|
| 506 |
|
|
} else {
|
| 507 |
|
|
text $w.f1.f.m -width 73 -relief flat -wrap word
|
| 508 |
|
|
$w.f1.f.m insert 0.0 $message
|
| 509 |
|
|
$w.f1.f.m conf -state disabled -height [$w.f1.f.m index end]
|
| 510 |
|
|
|
| 511 |
|
|
label $w.f1.bm -bitmap info
|
| 512 |
|
|
wm title $w "Configuration help"
|
| 513 |
|
|
}
|
| 514 |
|
|
pack $w.f1.f.m -side left
|
| 515 |
|
|
pack $w.f1.bm $w.f1.f -side left -padx 10
|
| 516 |
|
|
|
| 517 |
|
|
focus $w
|
| 518 |
|
|
set winx [expr [winfo x $parent]+20]
|
| 519 |
|
|
set winy [expr [winfo y $parent]+20]
|
| 520 |
|
|
wm geometry $w +$winx+$winy
|
| 521 |
|
|
set sizok [expr [winfo reqheight $w.f2.ok] + 12]
|
| 522 |
|
|
set maxy [expr [winfo screenheight .] * 3 / 4]
|
| 523 |
|
|
set canvtotal [winfo reqheight $w.f1.f.m]
|
| 524 |
|
|
if [expr $sizok + $canvtotal < $maxy] {
|
| 525 |
|
|
set sizy $canvtotal
|
| 526 |
|
|
} else {
|
| 527 |
|
|
set sizy [expr $maxy - $sizok]
|
| 528 |
|
|
}
|
| 529 |
|
|
$w.f1.canvas configure -height $sizy -width [winfo reqwidth $w.f1.f.m] \
|
| 530 |
|
|
-scrollregion "0 0 [winfo reqwidth $w.f1.f.m] \
|
| 531 |
|
|
[winfo reqheight $w.f1.f.m]"
|
| 532 |
|
|
$w.f1.canvas create window 0 0 -anchor nw -window $w.f1.f
|
| 533 |
|
|
update idletasks
|
| 534 |
|
|
|
| 535 |
|
|
set maxy [winfo screenheight .]
|
| 536 |
|
|
if [expr $sizok + $canvtotal < $maxy] {
|
| 537 |
|
|
set sizy [expr $sizok + $canvtotal]
|
| 538 |
|
|
} else {
|
| 539 |
|
|
set sizy $maxy
|
| 540 |
|
|
}
|
| 541 |
|
|
wm maxsize $w [winfo width $w] $sizy
|
| 542 |
|
|
}
|
| 543 |
|
|
|
| 544 |
|
|
bind all { catch {exec cp -f .config .config.old}; \
|
| 545 |
|
|
writeconfig .config config.h; wrapup .wrap }
|
| 546 |
|
|
|
| 547 |
|
|
proc wrapup {w } {
|
| 548 |
|
|
catch {destroy $w}
|
| 549 |
|
|
toplevel $w -class Dialog
|
| 550 |
|
|
|
| 551 |
|
|
global CONFIG_MODVERSIONS; vfix CONFIG_MODVERSIONS
|
| 552 |
|
|
message $w.m -width 460 -aspect 300 -relief raised -text \
|
| 553 |
|
|
"End of Core configuration. Next, \"build/scanconfig.pl .config\" will be run to create the VHDL configuration file (config.vhd)."
|
| 554 |
|
|
label $w.bm -bitmap info
|
| 555 |
|
|
pack $w.bm $w.m -pady 10 -side top -padx 10
|
| 556 |
|
|
wm title $w "Core build instructions"
|
| 557 |
|
|
|
| 558 |
|
|
set oldFocus [focus]
|
| 559 |
|
|
frame $w.f
|
| 560 |
|
|
button $w.f.back -text "OK" \
|
| 561 |
|
|
-width 10 -command "exit"
|
| 562 |
|
|
pack $w.f.back -side bottom -pady 10 -anchor s
|
| 563 |
|
|
pack $w.f -pady 10 -side top -padx 10 -anchor s
|
| 564 |
|
|
focus $w
|
| 565 |
|
|
bind $w "exit"
|
| 566 |
|
|
global winx; global winy
|
| 567 |
|
|
set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]
|
| 568 |
|
|
wm geometry $w +$winx+$winy
|
| 569 |
|
|
|
| 570 |
|
|
}
|
| 571 |
|
|
|
| 572 |
|
|
proc unregister_active {num} {
|
| 573 |
|
|
global active_menus
|
| 574 |
|
|
set index [lsearch -exact $active_menus $num]
|
| 575 |
|
|
if {$index != -1} then {set active_menus [lreplace $active_menus $index $index]}
|
| 576 |
|
|
}
|
| 577 |
|
|
|
| 578 |
|
|
proc update_active {} {
|
| 579 |
|
|
global active_menus total_menus
|
| 580 |
|
|
set max 0
|
| 581 |
|
|
if {[llength $active_menus] > 0} then {
|
| 582 |
|
|
set max [lindex $active_menus end]
|
| 583 |
|
|
update_define [toplevel_menu [lindex $active_menus 0]] $max 0
|
| 584 |
|
|
}
|
| 585 |
|
|
foreach i $active_menus {
|
| 586 |
|
|
if {[winfo exists .menu$i] == 0} then {
|
| 587 |
|
|
unregister_active $i
|
| 588 |
|
|
} else {
|
| 589 |
|
|
update_menu$i
|
| 590 |
|
|
}
|
| 591 |
|
|
}
|
| 592 |
|
|
update_define [expr $max + 1] $total_menus 1
|
| 593 |
|
|
update_mainmenu
|
| 594 |
|
|
}
|
| 595 |
|
|
|
| 596 |
|
|
proc configure_entry {w option items} {
|
| 597 |
|
|
foreach i $items {
|
| 598 |
|
|
$w.$i configure -state $option
|
| 599 |
|
|
}
|
| 600 |
|
|
}
|
| 601 |
|
|
|
| 602 |
|
|
proc validate_int {name val default} {
|
| 603 |
|
|
if {([exec echo $val | sed s/^-//g | tr -d \[:digit:\] ] != "")} then {
|
| 604 |
|
|
global $name; set $name $default
|
| 605 |
|
|
}
|
| 606 |
|
|
}
|
| 607 |
|
|
|
| 608 |
|
|
proc validate_hex {name val default} {
|
| 609 |
|
|
if {([exec echo $val | tr -d \[:xdigit:\] ] != "")} then {
|
| 610 |
|
|
global $name; set $name $default
|
| 611 |
|
|
}
|
| 612 |
|
|
}
|
| 613 |
|
|
|
| 614 |
|
|
proc update_define {first last allow_update} {
|
| 615 |
|
|
for {set i $first} {$i <= $last} {incr i} {
|
| 616 |
|
|
update_define_menu$i
|
| 617 |
|
|
if {$allow_update == 1} then update
|
| 618 |
|
|
}
|
| 619 |
|
|
}
|
| 620 |
|
|
|
| 621 |
|
|
#
|
| 622 |
|
|
# Next set up the particulars for the top level menu, and define a few
|
| 623 |
|
|
# buttons which we will stick down at the bottom.
|
| 624 |
|
|
#
|
| 625 |
|
|
|
| 626 |
|
|
frame .f0
|
| 627 |
|
|
frame .f0.left
|
| 628 |
|
|
frame .f0.middle
|
| 629 |
|
|
frame .f0.right
|
| 630 |
|
|
|
| 631 |
|
|
set active_menus [list]
|
| 632 |
|
|
set processed_top_level 0
|
| 633 |
|
|
set ARCH sparc
|