Manpower

Check-in [7de2e42581]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Further updates
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:7de2e42581e9c8c2c29e04a3419a6658b8885b63
User & Date: kevin 2019-08-18 02:01:57
Context
2019-08-20
12:47
More progress check-in: 1e0323ae61 user: kevin tags: trunk
2019-08-18
02:01
Further updates check-in: 7de2e42581 user: kevin tags: trunk
2019-08-16
12:41
Begin update to 7.0 check-in: 62fbdc81e8 user: kevin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to libs/manpower/manpower-main.tcl.

    20     20       py+1LIsJHiBAh+BgmiEAJQITgW6DgUQIAECH4JN8IPqYuNxUAOw==}
    21     21   image create photo downArrow -data {
    22     22       R0lGODlhDgAOAJEAANnZ2YCAgPz8/P///yH5BAEAAAAALAAAAAAOAA4AAAInhI+
    23     23       py+1I4ocQ/IgDEYIPgYJICUCE4F+YIBolEoKPEJKZmVJK6ZACADs=}
    24     24   image create photo noArrow -height 14 -width 14
    25     25   
    26     26   
           27  +#aem::installeventhandler CoKv sMan showManFromScript
           28  +#aem::installeventhandler GURL GURL showManURL
    27     29   #handle "get URL" event for man page
    28     30   proc showManURL {man} {
    29     31   
    30         -   global manitem
    31         -   set manitem [lindex [split $man "//"] 2]
    32         -   singleManPage
           32  +    global manitem
           33  +    set manitem [lindex [split $man "//"] 2]
           34  +    singleManPage
    33     35       
    34     36   }
    35     37   
    36     38   proc showManFromScript {man} {
    37     39   
    38     40       global manitem
    39     41       set manitem ""
................................................................................
    82     84   
    83     85   #draw the images
    84     86   proc makeImage {} {
    85     87   
    86     88       
    87     89       #create the images
    88     90       set imagedir [file join [file dirname [info script]] images]
    89         -	
    90         -     set imagefiles [glob -directory $imagedir *.tcl]
           91  +    
           92  +    set imagefiles [glob -directory $imagedir *.tcl]
    91     93       foreach item $imagefiles {
    92     94   	source $item
    93     95       }
    94     96   
    95     97       softwareupdate::setIcon icon-update
    96     98   
    97     99   }
................................................................................
   112    114       global copy_text
   113    115       global font_name
   114    116       global datadir
   115    117   
   116    118       set manitem ""
   117    119       set searchterm ""
   118    120       set manterm ""
   119         -   
          121  +    
   120    122   
   121    123       #set up menu
   122    124       menu .mb
   123    125   
   124    126       #apple menu
   125    127       menu .mb.apple
   126    128       .mb.apple add command -label "About Manpower" -command tkAboutDialog
................................................................................
   128    130       .mb.apple add command -label "Check for Updates" -command "softwareupdate::checkVersion $appname::name $appname::version"
   129    131       .mb.apple add separator
   130    132       .mb add cascade -label "Manpower" -menu .mb.apple
   131    133   
   132    134   
   133    135       #man page menu
   134    136       menu .mb.man
   135         -    .mb.man add command -label "Find Man Page" -command manSearch -accelerator "Command-F"
          137  +    .mb.man add command -label "Find Man Page" -command {.t.left.tree selection set Search} -accelerator "Command-F"
   136    138   
   137    139       menu .mb.man.save  
   138    140       .mb.man.save add command -label "Text" -command saveMan 
   139    141       .mb.man.save add command -label "HTML" -command saveHTML
   140    142       .mb.man.save add command -label "PDF" -command savePDF
   141    143   
   142    144       .mb.man add cascade -label "Save As" -menu .mb.man.save
................................................................................
   166    168       
   167    169       .mb add cascade -label "Help" -menu .mb.help
   168    170       
   169    171       . configure -menu .mb
   170    172   
   171    173       wm title . "Manpower"
   172    174       
   173         -    
   174         -    ttk::style configure Toolbutton -font {Iconic 22} 
   175    175   
   176    176       #create frame for toolbar
   177    177       pack [ttk::frame .tool] -side top -fill both -expand no
   178    178   
   179    179       #create toolbar
   180    180       pack [ttk::frame .tool.toolbar] -side top -fill both -expand no
   181    181   
................................................................................
   233    233       pack .bottomsep1 -side bottom -fill both -expand no -side bottom
   234    234   
   235    235       bind .tool.toolbar.frame.browser <ButtonRelease-1>  checkManSelection
   236    236   
   237    237   
   238    238       #additional bindings
   239    239       bind .tool.toolbar.frame.browser <Return> {singleManPage}
   240         -    bind .tool.toolbar.frame.entry <Return> {manSearch; writeState}
          240  +    bind .tool.toolbar.frame.entry <Return> {manSearch}
   241    241       
   242    242       ttk::frame .bottom
   243    243       pack .bottom -side bottom -fill both -expand no
   244    244   
   245    245       ttk::separator .bottomsep -orient vertical 
   246    246       pack .bottomsep -side bottom -fill both -expand no -side bottom
   247    247   
................................................................................
   262    262   	file-system xbm_folder_sans_16
   263    263   	other xbm_star_16
   264    264   	macro xbm_script_16
   265    265   	admin xbm_home_16
   266    266   	kernel xbm_refresh_16
   267    267       } 
   268    268       
   269         -    
   270         -    
   271    269       #lay out the tree widget
   272    270       ttk::treeview .middle.left.tree  -yscrollcommand [list .middle.left.scroll set] -show tree
   273    271       pack .middle.left.tree -fill both -side left -expand yes
   274         -	
   275         -	
   276         -	 #tree display for categories
          272  +    
          273  +    #tree display for categories
   277    274       ttk::treeview .t.left.tree -yscrollcommand [list .t.left.scroll set] -show tree
   278    275       
   279    276       pack .t.left.tree -fill both -side left -expand yes
   280    277   
   281    278       ttk::scrollbar .t.left.scroll -command [list .t.left.tree yview]
   282    279       pack .t.left.scroll -side right -fill y -expand no
   283    280   
   284    281       set entry1 [.middle.left.tree insert {} end -id All -value All -text "All" -image xbm_website_16]
   285    282       set entry2 [.middle.left.tree insert {} end -id Search -value Search -text "Search" -image xbm_search_16]
   286    283       set entry3 [ .middle.left.tree insert {} end -id Category -value Category -text "Category" -image xbm_category_16 ]
   287    284   
   288         -    
   289    285   
   290    286       set categoryman [list  users "1. User Commands" system "2. System Commands" library "3. Library Commands" special "4. Special" file-system "5. File Formats" other "6. Other" macro "7. Macros/Conventions" admin "8. Administrative" kernel "9. Kernel Commands" ]
   291    287   
   292    288       foreach {key value} $categoryman {
   293    289   	.middle.left.tree insert $entry3 end -id $key -value $key  -text $value -image $treelabel($key)
   294    290       }
   295    291   
   296    292   
   297         -    scrollbar .middle.left.scroll -command [list .middle.left.tree yview]
          293  +    ttk::scrollbar .middle.left.scroll -command [list .middle.left.tree yview]
   298    294       pack .middle.left.scroll -side right -fill y -expand no
   299    295   
   300         -    bind .middle.left.tree.c <KeyPress-Up> [list +event generate .middle.left.tree <<TreeSelect>>]
   301         -    bind .middle.left.tree.c <KeyPress-Down> [list +event generate .middle.left.tree <<TreeSelect>>]
          296  +    bind .middle.left.tree <<TreeviewSelect>> {setCat}
   302    297   
   303         -    bind .middle.left.tree <<TreeviewSelect>> {selectCat}
   304         -
   305         -    bind .middle.left.tree.c <MouseWheel> {%W yview scroll [expr {- (%D)}] units}
   306    298   
   307    299       .middle.left.tree opentree Category
   308    300   
   309    301       ttk::panedwindow .middle.right
   310    302       pack .middle.right -side right -fill both -expand yes
   311    303   
   312    304       ttk::frame .middle.right.upper
................................................................................
   317    309   
   318    310       ttk::frame .middle.right.upper.frame.row
   319    311       pack .middle.right.upper.frame.row -side right -fill y  -expand no
   320    312   
   321    313       ttk::label .middle.right.upper.frame.row.corner -style TablelistHeader.TLabel 
   322    314       pack .middle.right.upper.frame.row.corner -side top -fill x -expand no
   323    315   
   324         -    scrollbar .middle.right.upper.frame.row.vsb -orient vertical -command [list .middle.right.upper.frame.listbox yview]
          316  +    ttk::scrollbar .middle.right.upper.frame.row.vsb -orient vertical -command [list .middle.right.upper.frame.listbox yview]
   325    317       pack .middle.right.upper.frame.row.vsb -side bottom -fill y -expand 1
   326    318   
   327    319       #main data display
   328         -    tablelist::tablelist .middle.right.upper.frame.listbox -columns {"Man Page" "Description"} -show headings -yscrollcommand [list .middle.right.upper.frame.row.vsb set] -displaycolumns #all
   329         -	
          320  +    ttk::treeview .middle.right.upper.frame.listbox -columns {"Man Page" "Description"} -show headings -yscrollcommand [list .middle.right.upper.frame.row.vsb set] -displaycolumns #all
          321  +    
   330    322       pack .middle.right.upper.frame.listbox -side left -fill both -expand yes
   331    323       bind .middle.right.upper.frame.listbox <<TreeviewSelect>> {getManPage}
   332    324   
   333    325       foreach "item" $manlist {
   334    326   	.middle.right.upper.frame.listbox insert end $item
   335    327       }
   336    328   
   337    329   
   338    330       #menu for right-clicking
   339    331       menu .popup 
   340         -    .popup add command -label "Find Man Page" -command manSearch 
          332  +    .popup add command -label "Find Man Page" -command  {.t.left.tree selection set Search}  
   341    333       .popup add command -label "Print Man Page" -command  printFile
   342    334   
   343    335       bind [.middle.right.upper.frame.listbox bodypath] <Button-2> {tk_popup .popup %X %Y}
   344    336   
   345    337       #the rest of the display
   346    338       ttk::frame .middle.right.lower 
   347    339       pack .middle.right.lower -side bottom -fill both -expand true
   348    340   
   349    341   
   350    342       ttk::frame .middle.right.lower.right -height 100
   351    343       pack .middle.right.lower.right -side right -fill both -expand yes
   352    344   
   353    345       #output display--text
   354         -    text .middle.right.lower.right.log  -borderwidth .1 -relief sunken   -wrap word -highlightcolor SlateGray3 -yscrollcommand {.middle.right.lower.right.vsb set}  -bg white -state disabled
   355         -
   356         -    tclservices::registerservicewidget .middle.right.lower.right.log
   357         -    bind  .middle.right.lower.right.log <<Selection>> checkTextSelection 
          346  +    text .middle.right.lower.right.log  -borderwidth .1 -relief sunken -wrap word -highlightcolor SlateGray3 -yscrollcommand {.middle.right.lower.right.vsb set}  -state disabled
   358    347   
   359    348   
   360         -    scrollbar .middle.right.lower.right.vsb -command ".middle.right.lower.right.log yview" 
          349  +    ttk::scrollbar .middle.right.lower.right.vsb -command ".middle.right.lower.right.log yview" 
   361    350   
   362    351       pack .middle.right.lower.right.log -side left -fill both -expand yes
   363    352       pack .middle.right.lower.right.vsb -side right -fill y
   364    353   
   365    354       .middle.right.lower.right.log tag configure manref -foreground blue -underline on
   366    355   
   367    356       .middle.right.lower.right.log tag bind manref <Enter> {.middle.right.lower.right.log configure -cursor pointinghand}
................................................................................
   375    364       .middle add .middle.right
   376    365   
   377    366       toplevel .bookmarks
   378    367       tk::unsupported::MacWindowStyle style .bookmarks utility
   379    368       wm title .bookmarks "Bookmarks"
   380    369       
   381    370       #draw drawer window offscreen
   382         -    ttk::label .bookmarks.header -style TablelistHeader.TLabel -text "Bookmarks" -font {-size 12}
          371  +    ttk::label .bookmarks.header -text "Bookmarks" 
   383    372       pack .bookmarks.header -side top -fill both -expand yes
   384    373   
   385    374       ttk::frame .bookmarks.top
   386    375       pack .bookmarks.top -fill both -expand yes -side top
   387    376   
   388    377       ttk::frame .bookmarks.bottom -padding 2
   389    378       pack .bookmarks.bottom -fill both -expand no -side bottom
   390    379   
   391         -
   392         -    listbox .bookmarks.top.list -yscrollcommand [list .bookmarks.top.scrollbar set] -font {-size 12} -relief flat -bd 0 -selectbackground RoyalBlue1 -selectforeground white -height 30 -activestyle none
          380  +    listbox .bookmarks.top.list -yscrollcommand [list .bookmarks.top.ttk::scrollbar set] -font {-size 12} -relief flat -bd 0 -height 30 -activestyle none
   393    381       pack .bookmarks.top.list -side left -fill both -expand yes
   394    382   
   395    383   
   396         -    scrollbar .bookmarks.top.scrollbar -command [list .bookmarks.top.list yview]
   397         -    pack .bookmarks.top.scrollbar -side right -fill y -expand no
          384  +    ttk::scrollbar .bookmarks.top.ttk::scrollbar -command [list .bookmarks.top.list yview]
          385  +    pack .bookmarks.top.ttk::scrollbar -side right -fill y -expand no
   398    386   
   399         -    ttk::button .bookmarks.bottom.add -style Toolbutton -text \u2795 -takefocus 0 -command addBookMark
   400         -    ttk::button .bookmarks.bottom.delete -style Toolbutton -text \u2796 -takefocus 0 -command deleteBookMark
          387  +    ttk::button .bookmarks.bottom.add -style Toolbutton -text "+"	-takefocus 0 -command addBookMark
          388  +    ttk::button .bookmarks.bottom.delete -style Toolbutton -text "-" -takefocus 0 -command deleteBookMark
   401    389   
   402         -    DynamicHelp::register .bookmarks.bottom.add balloon "Add bookmark" 
   403         -    DynamicHelp::register  .bookmarks.bottom.delete balloon "Delete bookmark" 
   404         -    
          390  +    tooltip::tooltip .bookmarks.bottom.add  "Add bookmark" 
          391  +    tooltip::tooltip  .bookmarks.bottom.delete  "Delete bookmark" 
   405    392   
   406    393       bind .bookmarks.top.list <<ListboxSelect>> getManPagefromBookmark
   407    394   
   408    395       pack .bookmarks.bottom.add .bookmarks.bottom.delete -side left -fill both -expand no
   409    396   
   410    397       wm withdraw .bookmarks
   411    398       wm protocol .bookmarks WM_DELETE_WINDOW {wm withdraw .bookmarks}
   412    399   
   413    400       #other bindings
   414         -    bind all <Command-F> manSearch
   415         -    bind all <Command-f> manSearch
          401  +    bind all <Command-F> {.t.left.tree selection set Search} 
          402  +    bind all <Command-f>  {.t.left.tree selection set Search} 
   416    403       bind all <Command-P> printFile
   417    404       bind all <Command-p>  printFile
   418    405   
   419    406       bind . <Command-W> {wm state .  withdrawn}
   420    407       bind . <Command-w> {wm state .  withdrawn}
   421         -    wm protocol . WM_DELETE_WINDOW {wm withdraw .} 
          408  +    wm protocol . WM_DELETE_WINDOW {wm withdraw .}
          409  +
          410  +    .t.left.tree selection set All
   422    411   
   423    412   }
   424    413   
   425    414   ## Code to do the sorting of the tree contents when clicked on
   426    415   proc SortBy {tree col direction} {
   427    416   
   428    417       set tree .middle.right.upper.frame.listbox
................................................................................
   477    466   
   478    467   #get list of all man pages
   479    468   proc getAllMan {} {
   480    469   
   481    470       global manlist
   482    471       global cachedir
   483    472   
   484         -    puts "home is  $::env(HOME)"
   485         -
   486    473       set result [exec man -k \[a-zA-Z0-9\] > $cachedir/manpages 2>$cachedir/error]
   487    474   
   488    475       set fd [open $cachedir/manpages r]
   489    476       set basiclist [split [read $fd] \n]
   490    477       set displaylist [lrange $basiclist 0  end-1]
   491    478   
   492    479       #replace dash so we can split list more efficiently
................................................................................
   541    528   proc getManPage {} {
   542    529   
   543    530       global manitem
   544    531       global status
   545    532       global rmanpath
   546    533       global cachedir
   547    534   
   548         -    set item [lindex [.middle.right.upper.frame.listbox get [.middle.right.upper.frame.listbox curselection]] 0]
          535  +    set item [lindex [.middle.right.upper.frame.listbox item [.middle.right.upper.frame.listbox selection] -values] 0]
   549    536   
   550    537       #parse man page name from list
   551    538       set mansplit [split $item \(]
   552    539       set manitem [lindex $mansplit 0]
   553    540       set mansection [lindex [split [lindex $mansplit 1] \)] 0]
   554    541   
   555    542       
................................................................................
   573    560       .middle.right.lower.right.log configure -state disabled
   574    561   
   575    562       set status "Open man page: $manitem"
   576    563   }
   577    564   
   578    565   
   579    566   #get category for browsing--bound to single-click
   580         -proc setCat {node} {
          567  +proc setCat {} {
   581    568   
   582    569       global category 
   583    570       global manlist
   584    571   
   585         -    .middle.left.tree selection set $node
   586         -    
   587         -    if { $node == "Category"}  {
   588         -	return
   589         -    } 
   590         -    if {$node == "Search"} {
   591         -	manSearch
   592         -	return
   593         -    }
   594         -    if {$node == "All" } {
   595         -	refreshManList
   596         -	return
   597         -    }  else {
   598         -	manCat
   599         -    }
   600         -    
   601         -}
   602         -
   603         -#get selected node in tree; we use this because setCat takes a node name as arg, can't simply be called
   604         -proc selectCat {} {
   605         -    
   606         -    global manlist
   607         -    global mynode
   608         -
   609         -    set mynode [.middle.left.tree selection get]
   610         -    setCat $mynode
   611         -}
          572  +    set node [lindex [.middle.left.tree  item [.middle.left.tree selection] -values] 0]
          573  +    
          574  +    switch - $node  {
          575  +	"" {
          576  +	    return
          577  +	} "Category" {
          578  +	    return
          579  +	} "Search" {
          580  +	    manSearch
          581  +	    return
          582  +	} "All" {
          583  +	    refreshManList
          584  +	    return
          585  +	} default {
          586  +	    manCat
          587  +	}
          588  +    }
          589  +}
          590  +
   612    591   
   613    592   #search list of man pages for keyword
   614    593   proc manSearch {} {
   615    594       global manlist 
   616    595       global searchterm 
   617    596       global status
   618    597   
................................................................................
   806    785   
   807    786       set i [ .middle.right.lower.right.log  index @$xpos,$ypos]
   808    787       set range [ .middle.right.lower.right.log tag prevrange manref $i]
   809    788       set final [eval  .middle.right.lower.right.log get $range]
   810    789       set new [lindex [split $final \(] 0]
   811    790       set manitem $new
   812    791       singleManPage
   813         -    #  convertMan
   814    792   
   815    793       .middle.right.lower.right.log configure -cursor arrow
   816    794   }
   817    795   
   818    796   
   819    797   #print data to default printer
   820    798   proc printFile {} {
................................................................................
   938    916       set datadir [xplat::appconfig Manpower]
   939    917       set cachedir  [file join $::env(HOME) "Library" "Application Support" "Manpower" "Cache"]
   940    918   
   941    919       if {![file exists $cachedir]} {
   942    920   	file mkdir $cachedir
   943    921       }
   944    922   
   945         -	if {![file exists $datadir]} {
   946         -	    file mkdir $datadir
   947         -	} 
          923  +    if {![file exists $datadir]} {
          924  +	file mkdir $datadir
          925  +    } 
   948    926   
   949    927       set resourcedir [file join [softwareupdate::findCurrentInstallation] "Contents" "Resources"]
   950    928   
   951    929       getAllMan
   952    930       makeImage
   953    931       softwareupdate::setVersion $appname::name $appname::version
   954    932       machelp::setAppName $appname::name $appname::version
................................................................................
  1004    982       singleManPage
  1005    983   }
  1006    984   
  1007    985   
  1008    986   #custom "about" dialog
  1009    987   proc aboutWindow {} {
  1010    988   
  1011         - tk_messageBox -parent . -icon info -title "About Manpower" -message "Manpower: Man Page Viewer" -detail "Version 7.0\n(c)2019 WordTech Communications LLC"
          989  +    tk_messageBox -parent . -icon info -title "About Manpower" -message "Manpower: Man Page Viewer" -detail "Version 7.0\n(c)2019 WordTech Communications LLC"
  1012    990   
  1013    991   }
  1014    992   
  1015    993   #raise window if closed--dock click
  1016    994   proc ::tk::mac::ReopenApplication {} {
  1017    995   
  1018    996       if { [wm state .] == "withdrawn"} {