diff --git a/twander.py b/twander.py index 31fab43..7e9ba7c 100755 --- a/twander.py +++ b/twander.py @@ -4,7 +4,7 @@ PROGNAME = "twander" -RCSID = "$Id: twander.py,v 1.65 2002/11/19 10:21:23 tundra Exp $" +RCSID = "$Id: twander.py,v 1.66 2002/11/19 23:04:15 tundra Exp $" VERSION = RCSID.split()[2] @@ -44,7 +44,7 @@ CHANGEDIR = '' # Enter a new path DIRHOME = '' # Goto $HOME -DIRPREV = '' # Goto previous directory +DIRBACK = '' # Goto previous directory DIRSTART = '' # Goto starting directory DIRUP = '' # Go up one directory level @@ -128,6 +128,14 @@ REFRESHINT = 2000 # Interval (ms) for automatic refresh +# Note whether we're running on Unix or not + +if os.name == 'posix': + UNIX = TRUE +else: + UNIX = FALSE + + ##### # General Literals ##### @@ -177,6 +185,7 @@ # Warnings wCMDKEY = "Configuration File Entry For: \'%s\' Has No Command Key Defined." +wSYMBACK = " Symbolic Link %s Points Back To Own Directory" wWARN = "WARNING" @@ -397,7 +406,7 @@ self.DirList.bind(DIRHOME, KeyHomeDir) # Bind handler for "Previous Dir" - self.DirList.bind(DIRPREV, KeyPrevDir) + self.DirList.bind(DIRBACK, KeyBackDir) # Bind handler for "Starting Dir" self.DirList.bind(DIRSTART, KeyStartDir) @@ -465,20 +474,9 @@ def UpdateTitle(self, mainwin): - # Get current selection - selected = self.DirList.get(ACTIVE) - - # If there was a file selection append to title - if selected \ - and selected[0] == DIR_LDELIM \ - and selected[-1] == DIR_RDELIM: - - selected = "" - - # Update the titlebar mainwin.title(PROGNAME + " " + VERSION + " " + HOSTNAME + ": "+ - UI.CurrentDir + selected) + UI.CurrentDir) # End of method 'twanderUI.UpdateTitle()' @@ -567,7 +565,7 @@ # Event Handler: Move To Previous Directory ##### -def KeyPrevDir(event): +def KeyBackDir(event): # Move to last directory visited, if any - inhibit this from # being placed on the directory traversal stack @@ -578,7 +576,7 @@ else: pass -# End of 'KeyPrevDir()' +# End of 'KeyBackDir()' ##### @@ -675,6 +673,12 @@ # Strip off delimiters to get real name selected = selected[1:-1] + # If we're on Unix, don't follow symlinks pointing back to themselves + + if UNIX and os.path.samefile(UI.CurrentDir, UI.CurrentDir + selected): + WrnMsg(wSYMBACK % (UI.CurrentDir + selected)) + return + # We don't push this selection on the stack if # we are at root directory and user presses '..'