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 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755
|
#--------------------------------------------------
#
# manPreferences -- graphical interface to many values stored in startup file
#
#--------------------------------------------------
# would like to generalize construction, but can't spare the time
proc manPreferencesMake {{w0 ""}} {
global prefedit manx man bozo
# don't do global man here
set w .prefs
if {[winfo exists $w]||$w0==""} {return $w}
toplevel $w; wm resizable $w 0 0
wm geometry $w $prefedit(geom-prefs)
wm title $w "Preferences"
wm withdraw $w
set f [frame $w.pages]
foreach i {"Fonts" "Colors" "See" "Outline" "Database" "Icon" "Misc"} {
set il [string tolower $i]
radiobutton $f.$il -text $i -command manPreferences -variable manx(prefscreen) -value $il
pack $f.$il -side left -fill x -padx 4
}
frame $w.sep1 -height 2 -background $prefedit(guifg)
### fonts
set g [frame $w.[set group "fonts"]]
# fonts: gui, file, errors -- family, size
foreach {var txt} {gui Interface text "Text display" vol "Volume listings"
diffd "Text deleted from last version" diffc "Text changed from last version" diffa "Text added since last version"} {
lappend manx(vars-$group) $var-style
if [info exists $var-family] {lappend manx(vars-$group) $var-family}
lappend manx(vars-$group) $var-style
# $var-points -- diff[dca] don't have points
if [info exists $var-points] {lappend manx(vars-$group) $var-points}
set f [frame $g.font$var]
label $f.l -text $txt
[eval tk_optionMenu $f.style prefedit($var-style) $manx(styles)] configure -tearoff no
pack $f.l -side left -fill x
pack $f.style -side right -padx 2
if {![string match diff* $var]} {
[eval tk_optionMenu $f.family prefedit($var-family) $manx(fontfamilies)] configure -tearoff no
[eval tk_optionMenu $f.points prefedit($var-points) $manx(sizes)] configure -tearoff no
pack $f.points $f.family -after $f.style -side right -padx 2
lappend manx(vars-$group) $var-family $var-points
}
}
# set var fontpixels; set txt "Specify font as (see font(n))"
# lappend manx(vars-$group) $var-style
# set f [frame $g.$var]
# label $f.l -text $txt
# [eval tk_optionMenu $f.choice prefedit($var-t) $manx($var-t)] configure -tearoff no
# pack $f.l -side left -fill x
# pack $f.choice -side right -padx 2
pack $g.fontgui $g.fonttext $g.fontvol $g.fontdiffa $g.fontdiffc $g.fontdiffd -fill x -pady 3 -padx 4
if $manx(iswdiff) {pack forget $g.fontdiffc}
### colors
set g [frame $w.[set group "colors"]]
foreach {var txt} {gui "Interface" butt "Buttons" active "Active Regions" text "Text" selection "Selection"} {
lappend manx(vars-$group) ${var}fg ${var}bg
set f [frame $g.$var]
label $f.l -text $txt
foreach j {{fg "foreground"} {bg "background"}} {
foreach {jvar jtxt} $j break
if {$jvar=="fg"} {set jopp "bg"} {set jopp "fg"}
set mb $f.$var$jvar
[set m [eval tk_optionMenu $mb prefedit($var$jvar) $man(colors)]] configure -tearoff no
# when monochrome, keep foreground and background colors opposites!
if {$manx(mono)} {
foreach k $man(colors) {
set copp [lindex $prefedit(colors) [expr 1-[lsearch $prefedit(colors) $k]]]
$m entryconfigure $k -command "set prefedit($var$jopp) $copp; set prefedit($var$jvar) $k"
}
}
}
pack $f.l -side left -fill x
pack $f.${var}bg [label $f.${var}on -text "on"] $f.${var}fg -side right -padx 4
}
foreach {var fb txt} {manref f "Man page references" isearch b "Incremental search hits"
search b "Regexp search hits" highlight b "Highlights"} {
lappend manx(vars-$group) $var
set f [frame $g.$var]
label $f.l -text $txt
[set m [eval tk_optionMenu [set mb $f.$var] prefedit($var) $manx(highs)]] configure -tearoff no
foreach k $manx(highs) {
if {[lsearch $man(colors) $k]==-1} {set val $k} \
else {if {$fb=="f"} { set val "-foreground [list $k]"} { set val "-background [list $k]" } }
$m entryconfigure $k -command "set prefedit($var) [list $val]"
}
pack $f.l -side left -fill x
pack $mb -side right -padx 4
}
pack $g.text $g.gui $g.butt $g.active $g.selection $g.manref $g.isearch $g.search $g.highlight \
-fill x -expand yes -pady 3 -padx 4
### See
set g [frame $w.[set group "see"]]
foreach {var txt} {
headfoot "Header, footer, date at bottom"
maxpage "Page content only, except when menus active by Tab or mouse into region"
documentmap "Document map (adjacent to scrollbar)"
scrollbarside "Scrollbar side"
textboxmargin "Text box internal margin (in pixels)"
volcol "Width of columns in Volumes list"
high,vcontext "Back context for Highlights jump"
error-effect "Status line error/warning effect"
subvols "Subvolumes as submenus in Volumes"
apropostab "Tab stop in apropos list"
rebus "Rebus (Icons instead of words) for: file, TeX, ..."
# diffbar "Generate change bars"
} {
lappend manx(vars-$group) $var
set f [frame $g.$var]
label $f.l -text $txt
[set m [eval tk_optionMenu $f.high bozo($var) $manx(${var}-t)]] configure -tearoff no
set j 0
foreach mv $manx(${var}-v) {
$m entryconfigure $j -command "set prefedit($var) [list $mv]"
incr j
}
trace variable prefedit($var) w manPrefBozo
pack $f.l -side left -fill x
pack $f.high -side right
}
# $g.diffbar
pack $g.headfoot $g.maxpage $g.subvols $g.documentmap $g.high,vcontext $g.volcol $g.apropostab $g.rebus $g.scrollbarside $g.textboxmargin $g.error-effect \
-fill x -pady 3 -padx 4
### Outline
set g [frame $w.[set group "outline"]]
foreach {var txt} {
outline "Outlining state at page load"
manfill "Excerpt "
manfill-show ""
highlight-show "Highlights in collapsed outline visible"
# subsect-show "Subsection heads in collapsed visible"
options-show "Command line options in collapsed visible"
manref-show "Manual page references in collapsed visible"
search-show "Search hits in collapsed visible"
# outline-show "Texinfo outline headers visible down to"
search,bcontext "lines before, "
search,fcontext "after"
showsectmenu "Show Sections menu (obsolete with outlining)"
} {
lappend manx(vars-$group) $var
set f [frame $g.$var]
label $f.l -text $txt
[set m [eval tk_optionMenu $f.high bozo($var) $manx(${var}-t)]] configure -tearoff no
set j 0
foreach mv $manx(${var}-v) {
$m entryconfigure $j -command "set prefedit($var) [list $mv]"
incr j
}
trace variable prefedit($var) w manPrefBozo
pack $f.l -side left -fill x
pack $f.high -side right
}
pack $g.manfill-show -in $g.manfill -side right -padx 4
entry $g.manfill.e -width 40 -textvariable prefedit(manfill-sects) -relief sunken
pack $g.manfill.e -after $g.manfill.l -side left
foreach {var txt} {outlinebut "In outline \"all but\", show" autosearch "Automatically search for regexp"} {
lappend manx(vars-$group) $var
set f [frame $g.$var]
label $f.l -text $txt
entry $f.e -width 40 -textvariable prefedit($var) -relief sunken
pack $f.l -side left -fill x
pack $f.e -side right
}
# maybe add to autosearch: off, first letter, whole word
# package search hits back and forward context together
set f [frame $g.searchcontext]
pack [label $f.l -text "Search hits context"] -side left -fill x; lower $f
foreach var {search,fcontext search,bcontext} {
pack $g.$var.l -side right; pack $g.$var.high -side left
pack $g.$var -side right -fill none -in $f
}
pack $g.outline $g.outlinebut $g.manfill $g.highlight-show $g.options-show $g.manref-show $g.search-show $g.searchcontext $g.autosearch $g.showsectmenu \
# $g.outline-show
-fill x -pady 3 -padx 4
### icon-related
set g [frame $w.[set group "icon"]]
foreach {var txt} {iconify "Iconify on startup" } {
lappend manx(vars-$group) $var
set f [frame $g.$var]
label $f.l -text $txt
[set m [eval tk_optionMenu $f.high bozo($var) $manx(${var}-t)]] configure -tearoff no
set j 0
foreach mv $manx(${var}-v) {
$m entryconfigure $j -command "set prefedit($var) [list $mv]"
incr j
}
trace variable prefedit($var) w manPrefBozo
pack $f.l -side left -fill x
pack $f.high -side right
}
foreach {var txt} {iconname "Name when iconified"
iconbitmap "Path name of icon bitmap" iconmask "Path name of icon mask"
iconposition "Icon position (+|-)x(+|-)y"} {
lappend manx(vars-$group) $var
set f [frame $g.$var]
label $f.l -text $txt
entry $f.e -width 40 -textvariable prefedit($var) -relief sunken
pack $f.l -side left -fill x
pack $f.e -side right
}
set ring {iconname iconbitmap iconmask iconposition}; set ringl [llength $ring]
for {set i 0} {$i<$ringl} {incr i} {
set wig $g.[lindex $ring $i].e
foreach k {Tab Return} { bind $wig <KeyPress-$k> "focus $g.[lindex $ring [expr ($i+1)%$ringl]].e"; break }
bind $wig <Shift-KeyPress-Tab> "focus $g.[lindex $ring [expr ($i-1)%$ringl]].e; break"
}
# file completion for bitmap names
foreach wig {iconbitmap iconposition} {
set e $g.$wig.e
bind $e <KeyPress-Escape> "manFilecompleteLocal $e"
}
pack $g.iconify $g.iconname $g.iconbitmap $g.iconmask $g.iconposition \
-fill x -pady 3 -padx 4
### Miscellaneous
set g [frame $w.[set group "misc"]]
foreach {var txt} {
hyperclick "Mouse click to activate hyperlink"
incr,case "Incremental Search Case Sensitive"
regexp,case "Regexp and Glimpse Case Sensitive"
subsect "Parse man page subsections"
strictmotif "Strict Motif behavior"
# tables "Aggressive table parsing"
maxhistory "Maximum length of history list"
shortcuts-sort "Shortcuts list order"
# zaphy "Prevent hyphenation (good for searches)"
showrandom "Show \"random man page\" button"
} {
lappend manx(vars-$group) $var
set f [frame $g.$var]
label $f.l -text $txt
[set m [eval tk_optionMenu $f.high bozo($var) $manx(${var}-t)]] configure -tearoff no
set j 0
foreach mv $manx(${var}-v) {
$m entryconfigure $j -command "set prefedit($var) [list $mv]"
incr j
}
trace variable prefedit($var) w manPrefBozo
pack $f.l -side left -fill x
pack $f.high -side right
}
foreach {var txt} {printers "Printer list (space separated)"} {
lappend manx(vars-$group) $var
set f [frame $g.$var]
label $f.l -text $txt
entry $f.e -width 40 -textvariable prefedit($var) -relief sunken
pack $f.l -side left -fill x
pack $f.e -side right
}
pack $g.printers $g.hyperclick $g.incr,case $g.regexp,case $g.subsect $g.maxhistory $g.shortcuts-sort $g.showrandom $g.strictmotif \
# $g.zaphy
-fill x -pady 3 -padx 4
### Database
set g [frame $w.[set group "database"]]
foreach {var txt} {
nroffsave "Cache formatted (nroff'ed) pages"
columns "Width of man pages, in columns"
recentdays {"Recent" volume age, in days}
preferGNU "Prefer GNU versions of pages (e.g., od => god)"
indexglimpse "Glimpse indexing"
maxglimpse "Maximum Glimpse hits (per man hierarchy)"
maxglimpseexcerpt "Excerpt Glimpse hits if number of pages with hits less than"} {
lappend manx(vars-$group) $var
set f [frame $g.$var]
label $f.l -text $txt
[set m [eval tk_optionMenu $f.high bozo($var) $manx(${var}-t)]] configure -tearoff no
set j 0
foreach mv $manx(${var}-v) {
$m entryconfigure $j -command "set prefedit($var) [list $mv]"
incr j
}
trace variable prefedit($var) w manPrefBozo
pack $f.l -side left -fill x
pack $f.high -side right
}
foreach {var txt} {glimpsestrays "Distributed stray cats / unified index"
fsstnddir "Cache directory if .../catN unwritable"
# (useful if long lines)
texinfodir "Texinfo index directory"
# rfcdir "rfc-index.txt index directory"
} {
lappend manx(vars-$group) $var
set f [frame $g.$var]
label $f.l -text $txt
entry $f.e -width 40 -textvariable prefedit($var) -relief sunken
pack $f.l -side left -fill x
pack $f.e -side right
}
pack $g.nroffsave $g.columns $g.fsstnddir $g.recentdays $g.preferGNU \
$g.maxglimpse $g.maxglimpseexcerpt $g.indexglimpse $g.glimpsestrays $g.texinfodir \
-fill x -pady 3 -padx 4
if ![string match "*groff*/tmp/ll -*" $man(format)] {pack forget $g.columns}
# buttons
frame $w.bsep -relief sunken -height 2 -background $prefedit(guifg)
set f [frame $w.butts]
button $f.ok -text "OK" -padx 6 -command "grab release $w; wm withdraw $w; manPreferencesSet"
button $f.apply -text "Apply" -command "manPreferencesSet"
button $f.cancel -text "Cancel" -command "
grab release $w; wm withdraw $w
manPreferencesGet cancel; manPreferencesSet
"
button $f.default -text "Defaults" -command "manPreferencesGet default"
pack $f.ok $f.apply $f.default $f.cancel -side right -padx 4
pack $w.pages $w.sep1 $w.bsep $w.butts \
-side top -fill x -pady 3 -padx 4
return $w
}
proc manPrefBozo {array var op} {
global prefedit manx bozo
set bozo($var) [lindex $manx($var-t) [lsearch $manx($var-v) $prefedit($var)]]
}
proc manFilecompleteLocal {t} {
set line [$t get]
set fc [filecomplete $line]
set ll [llength $fc]
# no matches returns
if {!$ll} {
bell
return
}
# otherwise show longest valid name (longest common prefix determined by filecomplete)
$t delete 0 end
$t insert 0 [lfirst $fc]
$t icursor end
$t xview moveto 1
}
proc manPreferencesGet {{cmd "fill"}} {
global man manx default prefedit cancel curedit
# could use switch, except for command named default
if {$cmd=="fill"} {
foreach i [array names default] {set prefedit($i) [set curedit($i) [set cancel($i) $man($i)]]}
} elseif {$cmd=="default"} {
foreach i $manx(vars-$manx(prefscreen)) {set prefedit($i) $default($i)}
} elseif {$cmd=="cancel"} {
foreach i [array names default] {set prefedit($i) $cancel($i)}
} elseif {$cmd=="man"} {
foreach i [array names default] {set man($i) $prefedit($i)}
} elseif {$cmd=="curedit"} {
foreach i [array names default] {set curedit($i) $prefedit($i)}
}
}
set manx(prefscreen) "fonts"
set manx(oldprefscreen) ""
proc manPreferences {{screen ""}} {
global manx
# show right grouping
set w [manPreferencesMake bozo]
raise $w
if {$screen==""} {set screen $manx(prefscreen)} {set manx(prefscreen) $screen}
set prev $manx(oldprefscreen)
if {$screen!=$prev} {
if {$prev!=""} {
pack forget $w.$prev
# $w.pages.$prev configure -relief raised
}
pack $w.$screen -after $w.sep1 -fill x
# $w.pages.$screen configure -relief sunken
set manx(oldprefscreen) $screen
}
if ![winfo ismapped $w] {
manPreferencesGet fill
wm deiconify $w; grab set $w
}
}
proc manPresDefaultsSet {} {
global man
# fonts & colors
foreach {var txt} {gui "" butt "Button." butt "Menubutton." butt "Radiobutton." \
butt "Checkbutton." text "Text."} {
# {gui "Scrollbar."}} {
option add Tkman*${txt}Foreground $man(${var}fg) 61
option add Tkman*${txt}Background $man(${var}bg) 61
#puts "option add ...$txt... $man(${var}fg) on $man(${var}bg)"
}
option add Tkman*activeForeground $man(activefg) 61
option add Tkman*activeBackground $man(activebg) 61
option add Tkman*highlightBackground $man(activebg) 61
option add Tkman*selectColor $man(buttfg) 61
}
# reconfigure screen based on new preferences information
proc manPreferencesSet {} {
global man manx mani prefedit curedit default
set change 0
foreach i [array names default] {
if {$curedit($i)!=$prefedit($i)} {
set change 1
break
}
}
#puts "* manPreferencesSet, change=$change"
if !$change return
# random updates
set mani($prefedit(glimpsestrays),dirs) $mani($man(glimpsestrays),dirs)
# make temporary permanent
manPreferencesGet man
# manGeometry get -- done just before quit
# # # set keybindings--later
# fonts -- text, gui (main and preferences windows)
manPresDefaultsSet
eval font configure textpro [spec2font $man(text-family) $man(text-style) $man(text-points)]
#puts "set textpro to [font actual textpro]"
eval font configure gui [spec2font $man(gui-family) $man(gui-style) $man(gui-points)]
#puts "set gui to [font actual gui]"
eval font configure guisymbol [spec2font "symbol" $man(gui-style) $man(gui-points)]
eval font configure guimono [spec2font "courier" $man(gui-style) $man(gui-points)]
eval font configure textmono [spec2font "Courier" $man(text-style) $man(text-points)]
eval font configure peek [spec2font $man(text-family) italics $man(text-points) "s"]
# foreach f {diffa diffc diffd} {
# eval font configure $f [spec2font $man($f-family) $man($f-style) $man(text-points)]
# }
resetcolors
# bitmaps
foreach bitmap [image names] {
if {[string match "*Rebus" $bitmap] || $bitmap=="opened" || $bitmap=="closed"} { # face and icon always black on white
$bitmap configure -foreground $man(textfg) -background $man(textbg)
}
}
foreach i [list .occ .paths] {$i configure -selectcolor $man(guifg)}
manPreferencesSetGlobal
# manGeometry set
manPreferencesGet curedit
}
proc manPreferencesSetGlobal {} {
global man manx curedit tk_strictMotif
set tk_strictMotif $man(strictmotif)
# icon-related
# ... need to reference man() to get new values, but manx() has command line options
foreach i {iconname iconposition iconbitmap iconmask} {
if {$man($i)!=$curedit($i)} {set manx($i) $man($i)}
}
manShortcuts .man init
set manx(effcols) ""
if {[string match "*groff*$manx(longtmp) -*" $man(format)] && $man(columns)!=65} {set manx(effcols) "@$man(columns)"}
if {[[set m2 .occ.kill] index end]=="none" || $curedit(printers)!=$man(printers) } {
set plist [string trim $man(printers)]
# always put default printer in list
if [lsearch $plist $manx(printer)]==-1 { set plist [concat $manx(printer) $plist] }
#if {[llength $plist]==1} => always want level of indirection for printing
$m2 delete 0 end
foreach p $plist { $m2 add command -label $p -command "manPrint \$curwin $p" }
if ![llength $plist] { $m2 add command -label "(default)" -command "manPrint \$curwin" }
}
if {$curedit(subvols)!=$man(subvols)} {manMakeVolList 1}
# update text tags and other .man* bits
foreach w [lmatches ".man*" [winfo children .]] {manPreferencesSetMain $w}
}
proc manPreferencesSetMain {w} {
global man manx curedit
if ![string match ".man*" $w] return
if {[regexp $manx(posnregexp) $manx(iconposition) all x y]} {
wm iconposition $w $x $y
}
foreach i {iconbitmap iconmask iconwindow} {wm $i $w ""}
if {$manx(iconbitmap)=="(default)" || $manx(iconbitmap)=="default"} {
set iw ".iconwindow[string range $w 4 end]"
if ![winfo exists $iw] {
toplevel $iw; label $iw.l -image icon; pack $iw.l
# bug in ctwm doesn't deiconify if using icon window
# (default deiconify Button-1 in ctwm?)
bind $iw <Button-1> "wm deiconify $w"
}
wm iconwindow $w $iw
# iconwindows left hanging around whn close an instantiation, but no big deal
} else {
# everybody shares same icons
# (null string for name means no icon)
foreach i {iconbitmap iconmask} {
if {$manx($i)!=""} {
if [catch {wm $i $w @$manx($i)} info] {
puts stderr "Bad $i: $manx($i). Fix in Preferences/Icon."
# tk_dialog .dialog "BAD [string toupper $i]" "Bad $i: $manx($i). Fix in Preferences/Icon." "" 0 " OK "
}
}
}
}
# random bits
set t $w.show
pack $w.v -side $man(scrollbarside)
if $man(documentmap) { pack $w.cf -after $w.v -side $man(scrollbarside) -fill y } else { pack forget $w.cf }
if {$man(maxpage)} {
pack forget $w.info; pack forget $w.kind; pack forget $w.search
pack $w.top -before $w.vf -fill x
place $w.info -in $w.top -x 0 -y 0 -relwidth 1
place $w.kind -in $w.top -x 0 -y 0 -relwidth 1
lower $w.top; raise $w.info
bind $w.mantypein <FocusIn> "lower $w.info"
bind $w.info <Motion> "lower $w.info"
bind $t <Motion> "+if {%y>\[winfo height $t]-[winfo reqheight $w.search]} {place $w.search -x 0}"
place $w.search -in $t -x -[winfo width $t] -rely 1 -y -[winfo reqheight $w.search] -relwidth 1
bind $w.search.t <FocusIn> "place $w.search -in $t -x 0"
bind $w.search.t <FocusOut> "place $w.search -x -\[winfo width $t]"
} else {
pack forget $w.top; place forget $w.info; place forget $w.kind; place forget $w.search
bind $w.mantypein <FocusIn> {}; bind $w.search.t <FocusIn> {}; bind $w.search.t <FocusOut> {}
bind $t <Motion> {}; bind $w.info <Motion> {}
pack $w.info -before $w.vf -fill x
pack $w.kind -after $w.info -fill x -pady 3
pack $w.search -after $w.vf -fill x -pady 6
}
foreach f {diffa diffc diffd} {
$t tag configure $f -font [spec2font $man(text-family) $man($f-style) $man(text-points)]
}
# the scrollbar is an oddball
$w.v configure -troughcolor $man(guibg)
$w.v configure -background [expr {$man(buttbg)!=$man(guibg)?$man(buttbg):$man(guibg)}]
# text widget fonts and tags
$t configure -padx $man(textboxmargin) -pady $man(textboxmargin)
manManTabSet $w
# -tabs 0.2i -- tabs set to 5 spaces in current font
$t tag configure volume -font [spec2font $man(vol-family) $man(vol-style) $man(vol-points)] -tabs $man(volcol)
$t tag configure apropos -font [spec2font $man(vol-family) $man(vol-style) $man(vol-points)] -tabs $man(apropostab) -lmargin2 $man(apropostab)
$t tag configure sel -foreground $man(selectionfg) -background $man(selectionbg)
set man(highlight-meta) $man(highlight)
foreach v $manx(tags) {
#puts "$t => [winfo class $t]"
$t tag configure $v -font "" -foreground "" -background "" -underline no
set change ""; set newfont 0
set fam $man(text-family); set sty $man(text-style); set poi $man(text-points); set poi2 "m"
foreach g [subst $man($v)] {
switch -exact -- $g {
# normal should be plain
normal {}
underline {append change " -underline yes"}
reverse {append change " -foreground {$man(textbg)} -background {$man(textfg)}"}
italics { set sty $g; set newfont 1 }
bold -
bold-italics {
# aesthetically, among other text bold looks better when scaled down, for some reason
set sty $g; set poi2 "s"; set newfont 1
}
mono { set fam "Courier"; set newfont 1 }
symbol { set fam "Symbol"; set sty "normal"; set newfont 1 }
serif { set fam "Times"; set newfont 1 }
sanserif { set fam "Helvetica"; set newfont 1 }
small -
medium -
large {
set poi $g; set newfont 1
}
s -
m -
l {
set poi2 $g; set newfont 1
}
left -
right -
center {
append change " -justify $g"
}
default {
#puts "lsearch $g => [lsearch $manx(fontfamilies) [string tolower $g]]"
if {[lsearch $manx(fontfamilies) [string tolower $g]]!=-1} {set fam $g; set newfont 1
} else {append change " " [list $g]}
}
}
}
if {$newfont} {append change " -font \"[spec2font $fam $sty $poi $poi2]\""}
#puts "change $v = $change"
if {$change!=""} {
eval $t tag configure $v $change
if {$v=="highlight"} {catch {eval $w.high configure $change}}
# if {$v=="search"} {catch {eval $w.search.s configure $change}}
}
}
$t tag raise sel
$t tag configure sfirstvis -relief [expr {$man(search,bcontext)+$man(search,bcontext)>1?"raised":"flat"}]
if $man(showsectmenu) {pack $w.sections -before $w.high -side left -padx 4} else {pack forget $w.sections}
# set inx [lsearch $manx(outline-show-v) $man(outline-show)]
# foreach tag [lrange $manx(outline-show-v) 1 $inx] {$t tag configure $tag -elide 0}
# foreach tag [lrange $manx(outline-show-v) [expr $inx+1] end] {$t tag configure $tag -elide ""}
if $man(showrandom) {pack $w.random -before $w.vols -side left -padx 10} else {pack forget $w.random}
if {$curedit(hyperclick)!=$man(hyperclick)} {manHyper $w ""}
}
proc resetcolors {{w .}} {
global man curedit
set c [winfo class $w]
set g "gui"; if {$c=="Text"} {set g "text"} elseif {[string match "*utton" $c]} {set g "butt"}
#||$c=="Entry"
set foreground [set selector [set insertbackground $man(${g}fg)]]
set background $man(${g}bg)
set ofg $curedit(${g}fg)
set obg $curedit(${g}bg)
#puts "checking $w, class $c"
foreach i {foreground background insertbackground selectcolor} {
if ![catch {set color [$w cget -$i]}] {
if {$color==$ofg} {$w configure -$i $foreground} \
elseif {$color==$obg} {$w configure -$i $background}
}
}
set activeforeground $man(activefg)
set activebackground $man(activebg)
set highlightbackground $activebackground
foreach i {activeforeground activebackground highlightbackground} {
catch {$w configure -$i [set $i]}
}
# recurse
foreach c [winfo children $w] {
resetcolors $c
}
}
proc spec2font {{family "times"} {style "normal"} {points "medium"} {size "m"}} {
global man manx
#puts -nonewline "$family + $style + $points ( $size ) => "
set slant "roman"; set weight "normal"
switch -exact -- $style {
normal {}
bold {set weight "bold"}
italics {set slant "italic"}
bold-italics {set weight "bold"; set slant "italic"}
default {puts stderr "nonexistent style: $style"; exit 1}
}
# specify s,m,l within small,medium,large; or set absolute point size
if {[set pts [lsearch $manx(sizes) $points]]!=-1} {
set p "[lindex [lrange $manx(pts) $pts end] [lsearch {s m l} $size]]"
} else {set p $points}
# set font "-family [list $family] -size $man(fontpixels)$p -weight $weight -slant $slant"
set font "-family [list $family] -size $p -weight $weight -slant $slant"
#puts $font
return $font
}
|