diff --git a/twander.py b/twander.py index 545711a..be8293a 100755 --- a/twander.py +++ b/twander.py @@ -4,7 +4,7 @@ PROGNAME = "twander" -RCSID = "$Id: twander.py,v 1.42 2002/11/12 00:01:18 tundra Exp $" +RCSID = "$Id: twander.py,v 1.43 2002/11/12 01:07:03 tundra Exp $" VERSION = RCSID.split()[2] @@ -162,7 +162,7 @@ #----------------------------------------------------------# -CURSELECTION = 0 +INDEX = 0 FILESELECTED = "" LASTDIR = [] STARTDIR = "" @@ -203,7 +203,8 @@ # OSs like Win32 like to use '$' in file names which # sorts before "." - dList.insert(0, DIR_LDELIM + ".." + DIR_RDELIM) + if ROOTDIR != os.path.abspath(PSEP): + dList.insert(0, DIR_LDELIM + ".." + DIR_RDELIM) fList.sort() return dList + fList @@ -245,7 +246,6 @@ if save: LASTDIR.append(ROOTDIR) - # And select new directory to visit ROOTDIR = newdir @@ -365,9 +365,9 @@ ##### def ProcessSelection(): - global CURSELECTION, FILESELECTED, ROOTDIR + global INDEX, FILESELECTED, ROOTDIR - selected = UI.DirList.get(str(CURSELECTION)) + selected = UI.DirList.get(INDEX) # If selection is a directory, move there and list contents. # We examine this by checking the string for the directory @@ -404,8 +404,6 @@ else: FILESELECTED = os.path.join(ROOTDIR, selected) - UI.DirList.pack() - # End of 'Process Selection()' @@ -449,7 +447,7 @@ self.DirList.pack(side=LEFT, fill=BOTH, expand=1) # Bind the relevant widget event handlers - self.DirList.bind('', DirListHandler) + self.DirList.bind('', DirListHandler) # Bind the relevant root window handlers @@ -476,9 +474,6 @@ # key definitions in the configuration file root.bind('', KeystrokeHandler) - # Make sure the top level window has input focus - root.focus() - # End of class definition, 'twanderUI' @@ -487,9 +482,15 @@ ##### def DirListHandler(event): - global CURSELECTION + global INDEX - CURSELECTION = int(UI.DirList.nearest(event.y)) + # We use the 'nearest' method below to guarantee that INDEX will always + # a legitimate value - i.e., *Something* will always be selected. + # If we just used widget.get method this would not be the case + # whenever we rapidly clicked into a directory with only one entry (".."), + # because any click in a blank area of the screen would return (). + + INDEX = event.widget.nearest(event.y) ProcessSelection() # End of 'DirListHandler()' @@ -528,7 +529,7 @@ global LASTDIR # Move to last directory visited, if any - inhibit this from - # being place on the directory traversal stack + # being placed on the directory traversal stack if LASTDIR: LoadDirList(LASTDIR.pop(), save=FALSE) @@ -544,11 +545,10 @@ ##### def KeyDwn(event): - global CURSELECTION + global INDEX pass - # End of 'KeyDwn()' @@ -557,10 +557,10 @@ ##### def KeyUp(event): - global CURSELECTION + global INDEX - if CURSELECTION > 0: - CURSELECTION -= 1 + if int(INDEX[0]) > 0: + INDEX -= 1 ProcessSelection() # End of 'KeyDwn()'