diff --git a/twander.py b/twander.py index d87446c..e973b74 100755 --- a/twander.py +++ b/twander.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "twander" -RCSID = "$Id: twander.py,v 3.193 2005/02/03 11:24:55 tundra Exp $" +RCSID = "$Id: twander.py,v 3.194 2005/02/11 00:45:54 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -198,6 +198,7 @@ FILTERWILD = '' # Filter file list with wildcard SELWILD = '' # Select using wildcards TOGFILT = '' # Invert the filter wildcard logic +TOGHIDEDOT = '' # Toggle display of dotfiles ##### @@ -288,7 +289,9 @@ CMDSHELL = "" # No CMDSHELL processing DEBUGLEVEL = 0 # No debug output DEFAULTSEP = "==>" # Default separator in PROMPT and YES definitions +DOTFILE = '.' # Leading string of files suppressed by HIDEDOTFILES FORCEUNIXPATH = False # Force Unix path separators regardless of OS +HIDEDOTFILES = False # Suppress display of files begining with DOTFILE INVERTFILTER = False # Invert wildcard filtering logic MAXMENU = 32 # Maximum length of displayed menu MAXMENUBUF = 250 # Maximum size of internal menu buffer @@ -681,6 +684,7 @@ # Title-Bar Strings TTLAUTO = "Auto:" +TTLHIDEDOT = "HideDot:" TTLFILES = "Total Files:" TTLFILTER = "Filter:" TTLSIZE = "Total Size:" @@ -1006,10 +1010,16 @@ ##### # Check to see if a passed string matches/does not match the currently # active filtering wildcard. If there is no active wildcard, everything -# passes. +# passes. This routine also filters any "dotfiles" if the HIDEDOTFILES +# option is enabled. ##### -def FilterWildcardMatch(matchthis): +def FilterMatching(matchthis): + + # Check to see if dotfiles should be hidden + + if HIDEDOTFILES and matchthis.split()[-1].startswith(DOTFILE): + return False # Accomodate case-insensitive matching # But strict matching overrides this @@ -1021,7 +1031,7 @@ else: wc = UI.FilterWildcard[1] - # If there's not active filter, everything matches + # If there's no active filter, everything matches if not wc: matched = True @@ -1040,7 +1050,7 @@ return matched -# End of 'FilterWildcardMatch()' +# End of 'FilterMatching()' ##### # Pad A String With Spaces To Specified Width. @@ -1200,6 +1210,7 @@ "FILTERWILD":FILTERWILD, "SELWILD":SELWILD, "TOGFILT":TOGFILT, + "TOGHIDEDOT":TOGHIDEDOT } # Set all the program options to their default values @@ -2293,6 +2304,9 @@ # Bind handler for "Toggle Filter By Wildcard" self.DirList.bind(self.KeyBindings["TOGFILT"], KeyToggleFilter) + # Bind handler for "Toggle Dotfile Hiding" + self.DirList.bind(self.KeyBindings["TOGHIDEDOT"], KeyToggleHideDot) + # Give the listbox focus so it gets keystrokes self.DirList.focus() @@ -2462,9 +2476,11 @@ if INVERTFILTER: filterwc = "NOT " + filterwc filter = "%s %s" % (TTLFILTER, filterwc) + + hidedotfile = "%s %s" % (TTLHIDEDOT, YesOrNo[HIDEDOTFILES]) - mainwin.title("%s %s %s: %s %s %s %s %s %s %s%s %s %s" % - (PROGNAME, VERSION, FULLNAME, CurrentDir, filter, TTLFILES, + mainwin.title("%s %s %s: %s %s %s %s %s %s %s %s%s %s %s" % + (PROGNAME, VERSION, FULLNAME, CurrentDir, filter, hidedotfile, TTLFILES, str(self.DirList.size()), TTLSIZE, FileLength(self.TotalSize), sortedby, sepsort, TTLAUTO, autostate)) # Make sure the titlebar gets updated @@ -2774,6 +2790,21 @@ ##### +# Event Handler: Toggle Hiding Of Dotfiles +##### + +def KeyToggleHideDot(event): + global HIDEDOTFILES + + HIDEDOTFILES = not HIDEDOTFILES + RefreshDirList(event) + + return 'break' + +# End of 'KeyToggleHideDot()' + + +##### # Event Handler: Toggle Normalized Or Actual File Length Display ##### @@ -3923,7 +3954,7 @@ if UI.DetailsOn: matchthis = detail - if not FilterWildcardMatch(matchthis): + if not FilterMatching(matchthis): continue # Keep running tally of total files sizes @@ -4144,7 +4175,7 @@ if UI.DetailsOn: matchthis = entry - if not FilterWildcardMatch(matchthis): + if not FilterMatching(matchthis): continue # Keep running total of available space @@ -5101,6 +5132,7 @@ "AFTERCLEAR":AFTERCLEAR, "AUTOREFRESH":AUTOREFRESH, "FORCEUNIXPATH":FORCEUNIXPATH, + "HIDEDOTFILES":HIDEDOTFILES, "INVERTFILTER":INVERTFILTER, "NODETAILS":NODETAILS, "NONAVIGATE":NONAVIGATE, @@ -5121,7 +5153,7 @@ "MBCOLOR":MBCOLOR, "MFCOLOR":MFCOLOR, "MFNAME":MFNAME, "MFWT":MFWT, # Menu Font/Colors "HBCOLOR":HBCOLOR, "HFCOLOR":HFCOLOR, "HFNAME":HFNAME, "HFWT":HFWT, # Help Font/Colors "MBARCOL":MBARCOL, "QUOTECHAR":QUOTECHAR, "SORTBYFIELD":SORTBYFIELD, # Other - "STARTDIR":STARTDIR, "CMDSHELL":CMDSHELL, "DEFAULTSEP":DEFAULTSEP} + "STARTDIR":STARTDIR, "CMDSHELL":CMDSHELL, "DEFAULTSEP":DEFAULTSEP, "DOTFILE":DOTFILE} # Prepare storage for key bindings UI.KeyBindings = {}