Revision: 44769
          http://brlcad.svn.sourceforge.net/brlcad/?rev=44769&view=rev
Author:   bhinesley
Date:     2011-06-07 01:41:02 +0000 (Tue, 07 Jun 2011)

Log Message:
-----------
This was an incremental step towards: 1) adding the man command to archer 2) 
creating a megawidget for the manual page browser, to eliminate code 
duplication among Archer and MGED. Progress already made on the actual 
megawidget will be added in a bit.

-Man command now works in Archer

-Changed the method of adding commands to the Manual Page Browser ToC from 
"insert end" to using -listvariable as recommended here: 
http://www.tkdocs.com/tutorial/morewidgets.html

-Archer.tcl: set menu item that called doarcherMan to execute man command 
directly.

-changed <Button-1> ToC selection binding to the much preferred 
<<ListboxSelect>>. Now, arrow keys work, click + dragging works, etc.

-Centering the window still isn't working right. Haven't figured that one out 
yet.

Modified Paths:
--------------
    brlcad/trunk/src/tclscripts/archer/Archer.tcl
    brlcad/trunk/src/tclscripts/archer/ArcherCore.tcl

Modified: brlcad/trunk/src/tclscripts/archer/Archer.tcl
===================================================================
--- brlcad/trunk/src/tclscripts/archer/Archer.tcl       2011-06-06 22:52:37 UTC 
(rev 44768)
+++ brlcad/trunk/src/tclscripts/archer/Archer.tcl       2011-06-07 01:41:02 UTC 
(rev 44769)
@@ -3272,6 +3272,7 @@
     global archer_help_data
     global manhtmlviewer
     global manhtml
+    global mancmds [list]
 
     itk_component add archerMan {
        ::iwidgets::dialog $itk_interior.archerMan \
@@ -3309,7 +3310,7 @@
        } {}
 
     itk_component add mantree {
-        ::tk::listbox $itk_component(archerManToC).mantree -bd 2 -width 16 
-exportselection false -yscroll "$itk_component(archerManS) set"
+        ::tk::listbox $itk_component(archerManToC).mantree -bd 2 -width 16 
-exportselection false -yscroll "$itk_component(archerManS) set" -listvariable 
mancmds
     } {}
 
     $itk_component(archerManS) configure -command "$itk_component(mantree) 
yview"
@@ -3323,21 +3324,16 @@
 
        # List of available help documents
        set cmdfiles [glob -directory [file join [bu_brlcad_data "html"] mann 
en] *.html ]
-       set cmds [list ]
        foreach cmdfile $cmdfiles {
            regexp {(.+/)(.+)(.html)} $cmdfile -> url cmdrootname htmlsuffix
            if {[string compare $cmdrootname "Introduction"]} {
-               set cmds [concat $cmds [list $cmdrootname]]
+               set mancmds [concat $mancmds [list $cmdrootname]]
            }
        }
-       set cmds [lsort $cmds]
-       foreach cmd $cmds {
-           $itk_component(mantree) insert end $cmd
-       }
+       set mancmds [lsort $mancmds]
 
        pack $itk_component(archerManToC) -side left -expand no -fill y
 
-
        # Main HTML window
 
        itk_component add archerManF {
@@ -3361,7 +3357,10 @@
 
        pack $itk_component(archerManF) -side left -expand yes -fill both
     }
-    bind $itk_component(mantree) <Button-1> {handle_select %W %y; 
Archer::get_html_man_data [%W get [%W curselection]]; Archer::html_man_display 
$manhtml}
+    bind $itk_component(mantree) <<ListboxSelect>> {
+        Archer::get_html_man_data [%W get [%W curselection]]
+        Archer::html_man_display $manhtml
+    }
 
     wm geometry $itk_component(archerMan) "800x600"
 }

Modified: brlcad/trunk/src/tclscripts/archer/ArcherCore.tcl
===================================================================
--- brlcad/trunk/src/tclscripts/archer/ArcherCore.tcl   2011-06-06 22:52:37 UTC 
(rev 44768)
+++ brlcad/trunk/src/tclscripts/archer/ArcherCore.tcl   2011-06-07 01:41:02 UTC 
(rev 44769)
@@ -193,6 +193,7 @@
        method make                {args}
        method make_bb             {args}
        method make_pnts           {args}
+       method man                 {args}
        method mater               {args}
        method mirror              {args}
        method move                {args}
@@ -443,7 +444,7 @@
                                           edmater erase erase_all ev exit 
facetize fracture \
                                           g group hide human i 
importFg4Section \
                                           in inside item kill killall killrefs 
killtree ls \
-                                          make make_bb make_pnts mater mirror 
move move_arb_edge move_arb_face \
+                                          make make_bb make_pnts man mater 
mirror move move_arb_edge move_arb_face \
                                           mv mvall nmg_collapse nmg_simplify \
                                           ocenter opendb orotate oscale 
otranslate p q packTree prefix protate pscale ptranslate \
                                           push put put_comb putmat pwd r 
rcodes red rfarb rm rmater \
@@ -5168,6 +5169,46 @@
     eval gedWrapper make_pnts 0 1 1 1 $args
 }
 
+::itcl::body ArcherCore::man {args} {
+    global mancmds
+
+    set len [llength $args]
+    if {$len != 0 && $len != 1} {
+       return "Usage: man cmdname"
+    }
+
+    if {$args != {}} {
+       set cmd $args
+        set manPage [file join [bu_brlcad_data html] mann en $cmd.html]
+
+        if {![file exists $manPage]} {
+            error "No man page found for $cmd"
+        } else {
+           set toc $itk_component(mantree)
+
+            # Deselect all
+           $toc selection clear 0 [$toc index end]
+
+           # Select the requested man page (shouldn't fail, since file exists)
+           set idx [lsearch -sorted -exact $mancmds $cmd]
+           if {$idx == -1} {
+               error "man page for $cmd was found, but there was problem 
loading it"
+           }
+           $toc selection set $idx
+           $toc activate $idx
+           $toc see $idx
+
+           # Open the man page browser and load the selected man page
+           $itk_component(archerMan) activate
+           event generate $itk_component(mantree) <<ListboxSelect>>
+
+        }
+    } else {
+       # Open the man page browser without loading a man page
+       $itk_component(archerMan) activate
+    }
+}
+
 ::itcl::body ArcherCore::mater {args} {
     eval gedWrapper mater 0 1 1 1 $args
 }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to