diff --git a/twander.py b/twander.py index 0112f8e..e3dd0e8 100755 --- a/twander.py +++ b/twander.py @@ -1,17 +1,17 @@ #!/usr/bin/env python # twander - Wander around the file system -# Copyright (c) 2002-2005 TundraWare Inc. All Rights Reserved. +# Copyright (c) 2002-2006 TundraWare Inc. All Rights Reserved. # For Updates See: http://www.tundraware.com/Software/twander # Program Information PROGNAME = "twander" -RCSID = "$Id: twander.py,v 3.195 2005/02/14 09:49:44 tundra Exp $" +RCSID = "$Id: twander.py,v 3.196 2006/12/11 09:21:19 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information -DATE = "2002-2005" +DATE = "2002-2006" CPRT = "(c)" OWNER = "TundraWare Inc." RIGHTS = "All Rights Reserved." @@ -695,7 +695,7 @@ # Convert Logical Values Into Yes/No String -YesOrNo = {True:"YES", False:"N0"} +YesOrNo = {True:"Y", False:"N"} # Menu Button Titles @@ -726,7 +726,6 @@ ABOUT = "%s %s\n\nCopyright %s %s\n%s\n\n%s\n\n%s" % (PROGNAME, VERSION, CPRT, DATE, OWNER, RIGHTS, WEBSITE) hABOUT = 'About' hCOMMANDS = 'Command Definitions' -hDIRSC = 'Directory Shortcuts' hINTVBLS = 'Internal Program Variables' hKEYS = 'Keyboard Assignments' hNONE = 'No %s Found.' @@ -819,7 +818,7 @@ dCMDTBL = hCOMMANDS dDIRSTK = "DIRECTORY STACK" dFALSE = "False" -dFUNCKEYS = hDIRSC +dFUNCKEYS = 'Directory Shortcuts' dHEADER = "twander Debug Dump Run On: %s\n" dHIST = "COMMAND HISTORY STACK" dINTVAR = hINTVBLS @@ -837,11 +836,12 @@ # Debug Formatting dCMDWIDTH = 20 +dCOLNUM = 3 +dCOLWIDTH = 50 dINTVARWIDTH = 12 dKEYWIDTH = 16 dOPTIONWIDTH = 16 dSCWIDTH = 6 -dTWOUPWIDTH = 50 dUSRVBLWIDTH = 20 # List of internal program variables to dump during debug sessions @@ -899,6 +899,64 @@ ##### +# Convert A Dictionary In A Multicolumn List Of Strings +##### + +def FormatMultiColumn(dict, numcols=dCOLNUM, lhswidth=dKEYWIDTH, colwidth=dCOLWIDTH): + + retval = [] + + # Get and sort list of keys + + keys = dict.keys() + keys.sort() + + # Make sure it is of proper length for multi-column output + + while len(keys) % numcols: + keys.append("") + + # Produce output + + k=0 + columnlen = len(keys)/numcols + while k != columnlen: + + # Produce output 'numcols' at a time + + entry = [] + for i in range(numcols): + + key = keys[k+(i*columnlen)] + if key: + val = dict[key] + else: + val = "" + entry.append(PadString(key, lhswidth) + val) + + # Turn it into a single string + + s="" + for x in entry: + s += PadString(x, colwidth) + + # And stuff it into the return object + + retval.append(s) + + # Point to the next tuple of entries + + k += 1 + + + # Return the results + + return retval + +# End of 'FormatMultiColumn()' + + +##### # Run A Command, Returning Status And Output # This Version Runs On Win32 Unlike commands.getstatusoutput() ##### @@ -1836,8 +1894,8 @@ (hCOMMANDS, UI.CmdDefs, GetCommandTable()), (hINTVBLS, UI.IntVbls, GetIntVars()), (hOPTVBLS, UI.OptVbls, GetOptions()), - (hKEYS, UI.Keys, GetKeyBindings()), - (hDIRSC, UI.DirSCs, GetDirShortcuts())): + (hKEYS, UI.Keys, FormatMultiColumn(UI.KeyBindings)), + ): mvbl.delete(0,END) @@ -4834,7 +4892,7 @@ if DEBUGLEVEL & DEBUGKEYS: # Keyboard Bindings - PrintDebug(dKEYBINDS, GetKeyBindings()) + PrintDebug(dKEYBINDS, FormatMultiColumn(UI.KeyBindings, numcols=1)) # Function Keys (Directory Shortcuts) PrintDebug(dFUNCKEYS, GetDirShortcuts()) @@ -5010,56 +5068,12 @@ ##### -# Return List Of Current Key Bindings -##### - -def GetKeyBindings(): - - debuginfo = [] - - # Get sorted list of all function names - kb = UI.KeyBindings.keys() - kb.sort() - - # Make sure it is of even length, so we can format 2-at-a-time - if len(kb) % 2: - kb.append("") - - # Now setup two lists - 1st and last half respectively - m = len(kb)/2 - l1 = kb[:m] - l2 = kb[m:] - - # Format the bindings for output, 2 per line - x = 0 - while(x < m): - - k1 = l1[x] - v1 = UI.KeyBindings[k1] - k2 = l2[x] - if k2: - v2 = UI.KeyBindings[k2] - else: - v2 = "" - - s1 = PadString(k1, dKEYWIDTH) + v1 - s2 = PadString(k2, dKEYWIDTH) + v2 - debuginfo.append(PadString(s1, dTWOUPWIDTH) + s2) - x += 1 - - debuginfo.sort() - return debuginfo - -# End of 'GetKeyBindings()' - - -##### # Return List Of User-Settable Options ##### def GetOptions(): - debuginfo = [] + options = {} for l,f in ((UI.OptionsBoolean, True), (UI.OptionsNumeric, False), (UI.OptionsString, False)): for v in l: @@ -5075,10 +5089,9 @@ else: s = str(value) - debuginfo.append(PadString(v, dOPTIONWIDTH) + (s or dNULL)) - - debuginfo.sort() - return debuginfo + options[v] = s + + return FormatMultiColumn(options, numcols=2) # End of 'GetOptions()'