diff --git a/twander.py b/twander.py index 399c993..d7ff8f8 100755 --- a/twander.py +++ b/twander.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "twander" -RCSID = "$Id: twander.py,v 3.175 2005/01/25 22:28:49 tundra Exp $" +RCSID = "$Id: twander.py,v 3.176 2005/01/27 10:21:39 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -748,7 +748,7 @@ wUNDEFVBL = "Ignoring Line %s.\nUndefined Variable %s Referenced:\n\n%s" wVBLTOODEEP = "Ignoring Line %s.\nVariable Definition Nested Too Deeply:\n\n%s" wWARN = "WARNING" -wWILDCOMP = "Cannot Compile Wilcard Expression: %s" +wWILDCOMP = "Cannot Compile Wildcard Expression: %s" ##### @@ -2858,6 +2858,7 @@ ##### def KeySelWild(event, initial=""): + global UI # Ask the user for the wildcard pattern, using initial string, if any if initial: @@ -2896,15 +2897,18 @@ # ("..") is never considered when doing wildcard # matching. - matches = [] - for x in range(1,UI.DirList.size()): - if wild.match(UI.DirList.get(x)): - matches.append(x) + UI.FilterWildcard = wild + RefreshDirList() - # If anything matched, select it - if matches: - UI.SetSelection(matches, matches[0]) - +# matches = [] +# for x in range(1,UI.DirList.size()): +# if wild.match(UI.DirList.get(x)): +# matches.append(x) +# +# # If anything matched, select it +# if matches: +# UI.SetSelection(matches, matches[0]) + # Save the wildcard only if dynamic menus are enabled (MAXMENU > 0) # AND one of two conditions exist: # @@ -3411,6 +3415,9 @@ if NONAVIGATE and (newdir != STARTDIR): return + # Reset any active filtering + UI.FilterWildcard = None + # Transform double forward-slashes into a single # forward-slash. This keeps the Directory Stack # and Visited lists sane under Unix and prevents @@ -3545,8 +3552,6 @@ nominal = UI.OptionsNumeric["REFRESHINT"] - - # Check to see if SORTBYFIELD makes sense if SORTBYFIELD.lower() not in Name2Key.keys(): @@ -3697,7 +3702,27 @@ fList.append(fileinfo[index][0]) # Sorting logic ends here - + + # Filter through any filtering wildcard (if any). + + if UI.FilterWildcard: + for list in dList, fList: + + # Find the entries that don't match the wildcard. + # We have to store the entries we don't want and then + # remove them, because we cannot reliably remove items + # from a list while we are iterating over it. + + remove = [] + for x in list: + if not UI.FilterWildcard.match(x): + remove.append(x) + + # And remove those non-matching entries + + for x in remove: + list.remove(x) + # Now return results in their final form @@ -4792,9 +4817,12 @@ # Initialize storage for last manually entered selection wildcard UI.LastSelWildcard = "" -# And current location +# Initialize storage for current location UI.CurrentDir = "" +# Initialize storage for filtering wildcard +UI.FilterWildcard = None + # Initialize various menu data structures ClearHistory(None)