?? header.tk
字號:
# FILE: header.tk# This file is boilerplate TCL/TK function definitions for 'make xconfig'.## CHANGES# =======## 8 January 1999, Michael Elizabeth Chastain, <mec@shout.net># - Remove unused do_cmd function (part of the 2.0 sound support).# - Arrange buttons in three columns for better screen fitting.# - Add CONSTANT_Y, CONSTANT_M, CONSTANT_N for commands like:# dep_tristate 'foo' CONFIG_FOO m## 23 January 1999, Michael Elizabeth Chastain, <mec@shout.net># - Shut vfix the hell up.## 24 January 1999, Michael Elizabeth Chastain, <mec@shout.net># - Improve the exit message (Jeff Ronne).## This is a handy replacement for ".widget cget" that requires neither tk4# nor additional source code uglification.#proc cget { w option } { return "[lindex [$w configure $option] 4]"}## Function to compensate for broken config.in scripts like the sound driver,# which make dependencies on variables that are never even conditionally# defined.#proc vfix { var } { global $var if [ catch {eval concat $$var} ] { set $var 4 }}## Constant values used by certain dep_tristate commands.#set CONSTANT_Y 1set CONSTANT_M 2set CONSTANT_N 0set CONSTANT_E 4## Create a "reference" object to steal colors from.#button .ref## On monochrome displays, -disabledforeground is blank by default; that's# bad. Fill it with -foreground instead.#if { [cget .ref -disabledforeground] == "" } { .ref configure -disabledforeground [cget .ref -foreground]}## Define some macros we will need to parse the config.in file.#proc mainmenu_name { text } { wm title . "$text"}proc menu_option { w menu_num text } { global menus_per_column global processed_top_level set processed_top_level [expr $processed_top_level + 1] if { $processed_top_level <= $menus_per_column } then { set myframe left } elseif { $processed_top_level <= [expr 2 * $menus_per_column] } then { set myframe middle } else { set myframe right } button .f0.x$menu_num -anchor w -text "$text" \ -command "$w .$w \"$text\"" pack .f0.x$menu_num -pady 0 -side top -fill x -in .f0.$myframe}proc load_configfile { w title func } { catch {destroy $w} toplevel $w -class Dialog global loadfile frame $w.x label $w.bm -bitmap questhead pack $w.bm -pady 10 -side top -padx 10 label $w.x.l -text "Enter filename:" -relief raised entry $w.x.x -width 35 -relief sunken -borderwidth 2 \ -textvariable loadfile pack $w.x.l $w.x.x -anchor w -side left pack $w.x -side top -pady 10 wm title $w "$title" set oldFocus [focus] frame $w.f button $w.f.back -text "OK" -width 20 \ -command "destroy $w; focus $oldFocus;$func .fileio" button $w.f.canc -text "Cancel" \ -width 20 -command "destroy $w; focus $oldFocus" pack $w.f.back $w.f.canc -side left -pady 10 -padx 45 pack $w.f -pady 10 -side bottom -padx 10 -anchor w focus $w global winx; global winy set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30] wm geometry $w +$winx+$winy}bind all <Alt-q> {maybe_exit .maybe}proc maybe_exit { w } { catch {destroy $w} toplevel $w -class Dialog label $w.bm -bitmap questhead pack $w.bm -pady 10 -side top -padx 10 message $w.m -width 400 -aspect 300 \ -text "Changes will be lost. Are you sure?" -relief flat pack $w.m -pady 10 -side top -padx 10 wm title $w "Are you sure?" set oldFocus [focus] frame $w.f button $w.f.back -text "OK" -width 20 \ -command "exit" button $w.f.canc -text "Cancel" \ -width 20 -command "destroy $w; focus $oldFocus" pack $w.f.back $w.f.canc -side left -pady 10 -padx 45 pack $w.f -pady 10 -side bottom -padx 10 -anchor w bind $w <Return> "exit" bind $w <Escape> "destroy $w; focus $oldFocus" focus $w global winx; global winy set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30] wm geometry $w +$winx+$winy}proc read_config_file { w } { global loadfile if { [string length $loadfile] != 0 && [file readable $loadfile] == 1 } then { read_config $loadfile } else { catch {destroy $w} toplevel $w -class Dialog message $w.m -width 400 -aspect 300 -text \ "Unable to read file $loadfile" \ -relief raised label $w.bm -bitmap error pack $w.bm $w.m -pady 10 -side top -padx 10 wm title $w "Xconfig Internal Error" set oldFocus [focus] frame $w.f button $w.f.back -text "Bummer" \ -width 10 -command "destroy $w; focus $oldFocus" pack $w.f.back -side bottom -pady 10 -anchor s pack $w.f -pady 10 -side top -padx 10 -anchor s focus $w global winx; global winy set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30] wm geometry $w +$winx+$winy }}proc write_config_file { w } { global loadfile if { [string length $loadfile] != 0 && ([file writable $loadfile] == 1 || ([file exists $loadfile] == 0 && [file writable [file dirname $loadfile]] == 1)) } then { writeconfig $loadfile /dev/null } else { catch {destroy $w} toplevel $w -class Dialog message $w.m -width 400 -aspect 300 -text \ "Unable to write file $loadfile" \ -relief raised label $w.bm -bitmap error pack $w.bm $w.m -pady 10 -side top -padx 10 wm title $w "Xconfig Internal Error" set oldFocus [focus] frame $w.f button $w.f.back -text "OK" \ -width 10 -command "destroy $w; focus $oldFocus" pack $w.f.back -side bottom -pady 10 -anchor s pack $w.f -pady 10 -side top -padx 10 -anchor s focus $w global winx; global winy set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30] wm geometry $w +$winx+$winy }}proc read_config { filename } { set file1 [open $filename r] clear_choices while { [gets $file1 line] >= 0} { if [regexp {([0-9A-Za-z_]+)=([ynm])} $line foo var value] { if { $value == "y" } then { set cmd "global $var; set $var 1" } if { $value == "n" } then { set cmd "global $var; set $var 0" } if { $value == "m" } then { set cmd "global $var; set $var 2" } eval $cmd } if [regexp {# ([0-9A-Za-z_]+) is not set} $line foo var] { set cmd "global $var; set $var 0" eval $cmd } if [regexp {([0-9A-Za-z_]+)=([0-9A-Fa-f]+)} $line foo var value] { set cmd "global $var; set $var $value" eval $cmd } if [regexp {([0-9A-Za-z_]+)="([^"]*)"} $line foo var value] { set cmd "global $var; set $var \"$value\"" eval $cmd } } close $file1 update_choices update_mainmenu}proc write_comment { file1 file2 text } { puts $file1 "" puts $file1 "#" puts $file1 "# $text" puts $file1 "#" puts $file2 "/*" puts $file2 " * $text" puts $file2 " */"}proc effective_dep { deplist } { global CONFIG_MODULES set depend 1 foreach i $deplist { if {$i == 0} then {set depend 0} if {$i == 2 && $depend == 1} then {set depend 2} } if {$depend == 2 && $CONFIG_MODULES == 0} then {set depend 0} return $depend}proc sync_tristate { var dep } { global CONFIG_MODULES if {$dep == 0 && ($var == 1 || $var == 2)} then { set var 0 } elseif {$dep == 2 && $var == 1} then { set var 2 } elseif {$var == 2 && $CONFIG_MODULES == 0} then { if {$dep == 1} then {set var 1} else {set var 0} } return $var}proc sync_bool { var dep modset } { set var [sync_tristate $var $dep] if {$dep == 2 && $var == 2} then { set var $modset } return $var}proc write_tristate { file1 file2 varname variable deplist modset } { set variable [sync_tristate $variable [effective_dep $deplist]] if { $variable == 2 } \ then { set variable $modset } if { $variable == 1 } \ then { puts $file1 "$varname=y"; \ puts $file2 "#define $varname 1" } \ elseif { $variable == 2 } \ then { puts $file1 "$varname=m"; \ puts $file2 "#undef $varname"; \ puts $file2 "#define ${varname}_MODULE 1" } \ elseif { $variable == 0 } \ then { puts $file1 "# $varname is not set"; \ puts $file2 "#undef $varname"} \ else { \ puts stdout "ERROR - Attempting to write value for unconfigured variable ($varname)." \ }}proc write_int { file1 file2 varname variable dep } { if { $dep == 0 } \ then { puts $file1 "# $varname is not set"; \ puts $file2 "#undef $varname"} \ else { puts $file1 "$varname=$variable"; \ puts $file2 "#define $varname ($variable)"; \ }}proc write_hex { file1 file2 varname variable dep } { if { $dep == 0 } \ then { puts $file1 "# $varname is not set"; \ puts $file2 "#undef $varname"} \ else { puts $file1 "$varname=$variable"; \ puts -nonewline $file2 "#define $varname 0x"; \ puts $file2 [exec echo $variable | sed s/^0\[xX\]//]; \ }}proc write_string { file1 file2 varname variable dep } { if { $dep == 0 } \ then { puts $file1 "# $varname is not set"; \ puts $file2 "#undef $varname"} \ else { puts $file1 "$varname=\"$variable\""; \ puts $file2 "#define $varname \"$variable\""; \ }}proc option_name {w mnum line text helpidx} { button $w.x$line.l -text "$text" -relief groove -anchor w $w.x$line.l configure -activefore [cget $w.x$line.l -fg] \ -activeback [cget $w.x$line.l -bg] button $w.x$line.help -text "Help" -relief raised \ -command "dohelp .dohelp $helpidx .menu$mnum"
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -