diff --git a/twander.py b/twander.py index 8b2fe03..f8c8016 100755 --- a/twander.py +++ b/twander.py @@ -4,7 +4,7 @@ # For Updates See: http://www.tundraware.com/Software/twander PROGNAME = "twander" -RCSID = "$Id: twander.py,v 1.98 2002/12/11 22:50:51 tundra Exp $" +RCSID = "$Id: twander.py,v 1.99 2002/12/12 16:49:44 tundra Exp $" VERSION = RCSID.split()[2] @@ -196,7 +196,9 @@ # General Literals ##### -PSEP = os.sep # Character separating path components +COMMANDMENU = 'Commands' # Title for Command Menu button +DIRMENU = 'Directories' # Title for Directory Menu button +PSEP = os.sep # Character separating path components ##### @@ -358,10 +360,13 @@ # Successful open of config file - Begin processing it - # Cleanout any old + # Cleanout any old configuration data UI.CmdTable = {} UI.SymTable = {} linenum = 0 + + # Initialize the command menu + UI.CmdBtn.menu.delete(0,END) # Process and massage the configuration file for line in cf.read().splitlines(): @@ -379,6 +384,9 @@ cf.close() + # Set the Command Menu Contents + UI.CmdBtn['menu'] = UI.CmdBtn.menu + # Dump tables if we're debugging if DEBUG: print "SYMBOL TABLE:\n" @@ -529,6 +537,7 @@ sys.exit(1) else: UI.CmdTable[cmdkey] = [cmdname, cmd] + UI.CmdBtn.menu.add_command(label=cmdname, command=lambda cmd=cmdkey: CommandMenuSelection(cmd)) else: ErrMsg(eBADCFGLINE % (num, line)) @@ -575,6 +584,23 @@ def __init__(self, root): + # Setup Menubar frame + + self.mBar = Frame(root, relief=RAISED, borderwidth=2) + self.mBar.pack(fill=X) + + # Setup the Command Menu + + self.CmdBtn = Menubutton(self.mBar, text=COMMANDMENU, underline=0) + self.CmdBtn.menu = Menu(self.CmdBtn) + self.CmdBtn.pack(side=LEFT, padx='2m') + + # Setup the Directory Menu + + self.DirBtn = Menubutton(self.mBar, text=DIRMENU, underline=0) + self.DirBtn.menu = Menu(self.DirBtn) + self.DirBtn.pack(side=LEFT, padx='2m') + # Setup the visual elements self.hSB = Scrollbar(root, orient=HORIZONTAL) @@ -1193,6 +1219,16 @@ # Also move the program context to the new directory os.chdir(newdir) + # Keep list of all unique directories visited in the Directory Menu + + if newdir not in UI.AllDirs: + UI.AllDirs.append(newdir) + UI.AllDirs.sort() + UI.DirBtn.menu.delete(0,END) + for dir in UI.AllDirs: + UI.DirBtn.menu.add_command(label=dir, command=lambda dir=dir: LoadDirList(dir)) + UI.DirBtn['menu'] = UI.DirBtn.menu + # And update the title to reflect changes UI.UpdateTitle(UIroot) @@ -1481,6 +1517,23 @@ # End of 'SetSelection()' +#---------------------- Menu Handlers ---------------------# + +##### +# Handle Command Menu Selections +##### + +def CommandMenuSelection(cmdkey): + + class event: + pass + + event.char = cmdkey + KeystrokeHandler(event) + +# End Of 'CommandMenuSelection()' + + #----------------------------------------------------------# # Program Entry Point # #----------------------------------------------------------# @@ -1570,6 +1623,9 @@ # Initialize directory stack UI.LastDir = [] +# Initialize list of all directories visited +UI.AllDirs = [] + # And current location UI.CurrentDir = ""