diff --git a/twander.py b/twander.py index 7cd1616..22e1fd8 100755 --- a/twander.py +++ b/twander.py @@ -4,7 +4,7 @@ PROGNAME = "twander" -RCSID = "$Id: twander.py,v 1.68 2002/11/21 01:05:08 tundra Exp $" +RCSID = "$Id: twander.py,v 1.69 2002/11/21 19:57:06 tundra Exp $" VERSION = RCSID.split()[2] @@ -137,8 +137,6 @@ # General Literals ##### -DIR_LDELIM = '[' # Directory left dsply. delimiter -DIR_RDELIM = ']' # Directory left dsply. delimiter PSEP = os.sep # Character separating path components @@ -504,14 +502,9 @@ # Otherwise, replace config tokens with actual file/dir names if cmd: - # Handle selections in form: /foo/bar/[....] - - cursel = UI.CurrentSelection() - if cursel[0] == DIR_LDELIM and cursel[-1] == DIR_RDELIM: - cursel = cursel[1:-1] + PSEP - # Replace runtime-determined tokens - cmd = cmd.replace(FILENAME, cursel) + + cmd = cmd.replace(FILENAME, UI.CurrentSelection()) cmd = cmd.replace(DIRNAME, UI.CurrentDir) # Actually execute the command @@ -542,6 +535,7 @@ newpath = askstring(pCHPATH, pENPATH) if newpath: LoadDirList(newpath) + SetSelection(0) UI.DirList.focus() # End of 'ChangeDir()' @@ -662,13 +656,8 @@ return # If selection is a directory, move there and list contents. - # We examine this by checking the string for the directory - # delimiter characters previously inserted in BuildDirList() - if selected[0] == DIR_LDELIM and selected[-1] == DIR_RDELIM: - - # Strip off delimiters to get real name - selected = selected[1:-1] + if os.path.isdir(os.path.join(UI.CurrentDir, selected)): # If we're on Unix, don't follow symlinks pointing back to themselves @@ -716,7 +705,6 @@ elif OSNAME == 'nt': os.startfile(os.path.join(os.path.abspath(UI.CurrentDir), selected)) - # Have to update the window title because selection changed UI.UpdateTitle(UIroot) @@ -796,8 +784,8 @@ # Walk the directory separate subdirs and files for file in os.listdir(currentdir): - if os.path.isdir(os.path.join(currentdir,file)): - dList.append(DIR_LDELIM + file + DIR_RDELIM) + if os.path.isdir(os.path.join(currentdir, file)): + dList.append(file + PSEP) else: fList.append(file) @@ -808,9 +796,15 @@ # OSs like Win32 like to use '$' in file names which # sorts before "." - dList.insert(0, DIR_LDELIM + ".." + DIR_RDELIM) + dList.insert(0, ".." + PSEP) fList.sort() + + # Go get details for everything in current directory + + for entry in (dList + fList): + UI.Details[entry] = os.stat(os.path.join(currentdir, entry)) + return dList + fList # End of 'BuildDirList()' @@ -824,8 +818,11 @@ # Save location & content of active item - active = UI.DirList.index(ACTIVE) - selected = UI.DirList.get(active) + selindex = UI.DirList.curselection() + if selindex: + selindex = int(selindex[-1]) + + selected = UI.CurrentSelection() # Save current scroll positions @@ -845,10 +842,10 @@ # If not, maintain same *position* in widget (set above). if selected in newlist: - active = newlist.index(selected) + selindex = newlist.index(selected) # Restore active item - SetSelection(active) + SetSelection(selindex) # Restore scroll positions @@ -975,6 +972,9 @@ # And current location UI.CurrentDir = "" +# And file details dictionary +UI.Details = {} + # Initialize the UI directory listing LoadDirList(STARTDIR)