diff --git a/twander.py b/twander.py index 0512ca5..9923bfb 100755 --- a/twander.py +++ b/twander.py @@ -4,7 +4,7 @@ PROGNAME = "twander" -RCSID = "$Id: twander.py,v 1.58 2002/11/17 07:57:26 tundra Exp $" +RCSID = "$Id: twander.py,v 1.59 2002/11/17 09:06:50 tundra Exp $" VERSION = RCSID.split()[2] @@ -387,54 +387,54 @@ # General Program Commands # Bind handler for individual keystrokes - root.bind(KEYPRESS, KeystrokeHandler) + self.DirList.bind(KEYPRESS, KeystrokeHandler) # Bind handler for "Quit Program" - root.bind(QUITPROG, KeyQuitProg) + self.DirList.bind(QUITPROG, KeyQuitProg) # Bind handler of "Read Config File" - root.bind(READCONF, ParseConfFile) + self.DirList.bind(READCONF, ParseConfFile) # Directory Navigation # Bind handler for "Change Directory" - root.bind(CHANGEDIR, ChangeDir) + self.DirList.bind(CHANGEDIR, ChangeDir) # Bind handler for "Home Dir" - root.bind(DIRHOME, KeyHomeDir) + self.DirList.bind(DIRHOME, KeyHomeDir) # Bind handler for "Previous Dir" - root.bind(DIRPREV, KeyPrevDir) + self.DirList.bind(DIRPREV, KeyPrevDir) # Bind handler for "Starting Dir" - root.bind(DIRSTART, KeyStartDir) + self.DirList.bind(DIRSTART, KeyStartDir) # Bind handler for "Up Dir" - root.bind(DIRUP, KeyUpDir) + self.DirList.bind(DIRUP, KeyUpDir) # Selection Keys # Bind handler for "Next Item" - root.bind(SELNEXT, KeySelNext) + self.DirList.bind(SELNEXT, KeySelNext) # Bind handler for "Previous Item" - root.bind(SELPREV, KeySelPrev) + self.DirList.bind(SELPREV, KeySelPrev) # Bind handler for "First Item" - root.bind(SELFIRST, KeySelFirst) + self.DirList.bind(SELFIRST, KeySelFirst) # Bind handler for "Last Item" - root.bind(SELLAST, KeySelLast) + self.DirList.bind(SELLAST, KeySelLast) # Bind handler for "Item Select" - root.bind(SELKEY, DirListHandler) + self.DirList.bind(SELKEY, DirListHandler) - # We'll accept Single-Clicks as a selection + # Bind handler for "Mouse Select" self.DirList.bind(SELMOUSE, DirListHandler) - # Give the listbox focus so arrow keys work + # Give the listbox focus so it gets keystrokes self.DirList.focus() # End if method 'twanderUI.__init__()' @@ -460,7 +460,7 @@ def CurrentSelection(self): index = self.DirList.curselection() if index: - return self.DirList.get(index) + return self.DirList.get(index[-1]) else: return "" @@ -825,14 +825,21 @@ def RefreshDirList(*args): rm_list = [] - # Save current selection and active entry - number = 0 + # After we fiddle with things we want to + # restore the currently selected item as such. + # Ordinarily, the active entry and the + # selected entry are the same - We force that + # to be so at the end of this routine. + # + # However, in the case of the PgUp and + # PgDn keys, there may be multiple selections + # with yet another distinct active entry. In this + # case, the semantic we want is to choose + # the active item as the one selected. + # So ... we just need to save the active index. + active=UI.DirList.index(ACTIVE) - index = UI.DirList.curselection() - if index: - number = UI.DirList.index(index) - # Confirm that everything in the DirList widget # is still present in the directory. If not, # remove it from the widget. @@ -868,13 +875,12 @@ maxindex = UI.DirList.size() - 1 - if number > maxindex: - number = maxindex if active >maxindex: active = maxindex - UI.DirList.select_set(number) - UI.DirList.see(number) + UI.DirList.selection_clear(0, maxindex) + UI.DirList.select_set(active) + UI.DirList.see(active) UI.DirList.activate(active)