diff --git a/twander.py b/twander.py index ec14d50..3c8f4a9 100755 --- a/twander.py +++ b/twander.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "twander" -RCSID = "$Id: twander.py,v 3.111 2003/02/28 01:10:24 tundra Exp $" +RCSID = "$Id: twander.py,v 3.112 2003/02/28 19:46:26 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -303,7 +303,7 @@ SHOWDRIVES = '\\\\' # Logical directory name for Win32 Drive Lists STRICTMATCH = '#' # Tells wildcard system to enforce strict matching -# Sorting-Related Constants +# Sort Field Names fNONE = "None" fPERMISSIONS = "Permissions" @@ -314,6 +314,11 @@ fDATE = "Time" fNAME = "Name" +# 'Fake' sorting fields used to set SORTREVERSE and SORTSEPARATE + +fREVERSE = -1 +fSEPARATE = -2 + # Associate each legal field name with the corresponding sortkey field position # Note that fNONE indicates that no sorting is to be done, so there @@ -1627,8 +1632,8 @@ self.DirList.bind(self.KeyBindings["SORTBY5"], lambda event : KeySetSortParm(parm=fLENGTH)) self.DirList.bind(self.KeyBindings["SORTBY6"], lambda event : KeySetSortParm(parm=fDATE)) self.DirList.bind(self.KeyBindings["SORTBY7"], lambda event : KeySetSortParm(parm=fNAME)) - self.DirList.bind(self.KeyBindings["SORTREV"], lambda event : KeySetSortParm(parm=-1)) - self.DirList.bind(self.KeyBindings["SORTSEP"], lambda event : KeySetSortParm(parm=-2)) + self.DirList.bind(self.KeyBindings["SORTREV"], lambda event : KeySetSortParm(parm=fREVERSE)) + self.DirList.bind(self.KeyBindings["SORTSEP"], lambda event : KeySetSortParm(parm=fSEPARATE)) # Give the listbox focus so it gets keystrokes @@ -1703,7 +1708,7 @@ RefreshDirList() self.ElapsedTime = 0 else: - self.ElapsedTime = REFRESHINT * 3/4 + self.ElapsedTime = (REFRESHINT * 3)/4 # Setup next polling event self.DirList.after(POLLINT, self.poll) @@ -2616,10 +2621,10 @@ def KeySetSortParm(parm): global SORTBYFIELD, SORTREVERSE, SORTSEPARATE - if parm == -1: + if parm == fREVERSE: SORTREVERSE = not SORTREVERSE - elif parm == -2: + elif parm == fSEPARATE: SORTSEPARATE = not SORTSEPARATE else: @@ -2910,6 +2915,13 @@ detail, fields = FileDetails(file, currentdir) + + # Add trailing path separator to directory entries + + if detail[0] == ST_SPECIALS["04"]: + file += PSEP + detail += PSEP + # Decide whether we have to sort or not, act accordingly if SORTBYFIELD.lower() == fNONE.lower(): @@ -2932,19 +2944,18 @@ sortkey = fields[keyindex] if OSNAME == 'nt' and (SORTBYFIELD.lower() == fNAME.lower()): - sortkey = sortkey.lower + sortkey = sortkey.lower() # Keep track of the file name and its details, separating directories from files # Build corresponding key list for sorting - if detail[0] == ST_SPECIALS["04"]: + fileinfo.append((file, detail)) - fileinfo.append((file+PSEP, detail+PSEP)) + if detail[0] == ST_SPECIALS["04"]: dKeys.setdefault(sortkey, []).append(x) else: - fileinfo.append((file, detail)) fKeys.setdefault(sortkey, []).append(x)