diff --git a/twander.py b/twander.py index a0fff11..49c48d3 100755 --- a/twander.py +++ b/twander.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "twander" -RCSID = "$Id: twander.py,v 3.216 2007/01/08 20:40:11 tundra Exp $" +RCSID = "$Id: twander.py,v 3.217 2007/01/09 23:27:51 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -81,22 +81,24 @@ # General Program Commands -CLRHIST = '' # Clear Command History -FONTDECR = '' # Decrease Font Size -FONTINCR = '' # Increase Font Size -MOUSECTX = '' # Pop-up Command Menu -MOUSEDIR = '' # Pop-up Directory Menu -MOUSEHIST = '' # Pop-up History Menu -MOUSESC = '' # Pop-up Shortcut Menu -MOUSESORT = '' # Pop-up Sort Menu -KEYPRESS = '' # Any keypress (for commands) -QUITPROG = '' # Quit the program -READCONF = '' # Re-read the configuration file -REFRESH = '' # Refresh screen -TOGAUTO = '' # Toggle autorefreshing -TOGDETAIL = '' # Toggle detail view -TOGLENGTH = '' # Toggle length display between actual and normalized -TOGWIN32ALL = '' # Toggle win32all features, if available +CLRHIST = '' # Clear Command History +FONTDECR = '' # Decrease Font Size +FONTINCR = '' # Increase Font Size +MOUSECTX = '' # Pop-up Command Menu +MOUSEDIR = '' # Pop-up Directory Menu +MOUSEHIST = '' # Pop-up History Menu +MOUSESC = '' # Pop-up Shortcut Menu +MOUSESORT = '' # Pop-up Sort Menu +KEYPRESS = '' # Any keypress (for commands) +QUITPROG = '' # Quit the program +READCONF = '' # Re-read the configuration file +REFRESH = '' # Refresh screen +TOGAUTO = '' # Toggle autorefreshing +TOGDETAIL = '' # Toggle detail view +TOGLENGTH = '' # Toggle length display between actual and normalized +TOGSYMEXPAND = '' # Toggle symbolic link expansion +TOGSYMRESOLV = '' # Toggle absolute symbolic link resolution +TOGWIN32ALL = '' # Toggle win32all features, if available # Directory Navigation @@ -202,7 +204,6 @@ TOGFILT = '' # Invert the filter wildcard logic TOGHIDEDOT = '' # Toggle display of dotfiles - ##### # GUI Defaults ##### @@ -293,7 +294,6 @@ DEBUGLEVEL = 0 # No debug output DEFAULTSEP = "==>" # Default separator in PROMPT and YES definitions DOTFILE = '.' # Leading string of files suppressed by HIDEDOTFILES -EXPANDSYMLINKS = True # Expand symlink to show its target FORCEUNIXPATH = False # Force Unix path separators regardless of OS HIDEDOTFILES = False # Suppress display of files begining with DOTFILE INVERTFILTER = False # Invert wildcard filtering logic @@ -305,11 +305,12 @@ NONAVIGATE = False # True means that all directory navigation is prevented QUOTECHAR = '\"' # Character to use when quoting Built-In Variables REFRESHINT = 5000 # Interval (ms) for automatic refresh -RESOLVSYMLINKS = False # Show absolute path of symlink target SORTBYFIELD = "Name" # Field to use as sort key SORTREVERSE = False # Reverse specified sort order? SORTSEPARATE = True # Separate Directories and Files in sorted displays? SYMDIR = True # Sort symlinks pointing to directories as directories +SYMEXPAND = True # Expand symlink to show its target +SYMRESOLV = False # Show absolute path of symlink target USETHREADS = False # Use threads on Unix? USEWIN32ALL = True # Use win32all features if available? WARN = True # Warnings on? @@ -1219,6 +1220,8 @@ "TOGAUTO":TOGAUTO, "TOGDETAIL":TOGDETAIL, "TOGLENGTH":TOGLENGTH, + "TOGSYMEXPAND":TOGSYMEXPAND, + "TOGSYMRESOLV":TOGSYMRESOLV, "TOGWIN32ALL":TOGWIN32ALL, "CHANGEDIR":CHANGEDIR, "DIRHOME":DIRHOME, @@ -2252,7 +2255,14 @@ self.DirList.bind(self.KeyBindings["TOGDETAIL"], KeyToggleDetail) # Bind handler for "Toggle Length Display" - self.DirList.bind(self.KeyBindings["TOGLENGTH"], KeyToggleLength) + self.DirList.bind(self.KeyBindings["TOGLENGTH"],lambda event : KeyToggle(event, "ACTUALLENGTH")) + + # Bind handler for "Toggle Expand Symlinks" + self.DirList.bind(self.KeyBindings["TOGSYMEXPAND"],lambda event : KeyToggle(event, "SYMEXPAND")) + + # Bind handler for "Toggle Resolve Symlinks" + self.DirList.bind(self.KeyBindings["TOGSYMRESOLV"],lambda event : KeyToggle(event, "SYMRESOLV")) + # Bind handler for "Toggle win32all Features" self.DirList.bind(self.KeyBindings["TOGWIN32ALL"], KeyToggleWin32All) @@ -2433,7 +2443,7 @@ self.DirList.bind(self.KeyBindings["TOGFILT"], KeyToggleFilter) # Bind handler for "Toggle Dotfile Hiding" - self.DirList.bind(self.KeyBindings["TOGHIDEDOT"], KeyToggleHideDot) + self.DirList.bind(self.KeyBindings["TOGHIDEDOT"],lambda event : KeyToggle(event, "HIDEDOTFILES")) # Give the listbox focus so it gets keystrokes @@ -2866,6 +2876,19 @@ ##### +# Event Handler: Generic Option Toggle +##### + +def KeyToggle(event, option): + + exec("global %s; %s = not %s" % (option, option, option)) + RefreshDirList(event) + return 'break' + +# End of 'KeyToggle()' + + +##### # Event Handler: Toggle Autorefresh ##### @@ -2922,35 +2945,6 @@ ##### -# Event Handler: Toggle Hiding Of Dotfiles -##### - -def KeyToggleHideDot(event): - global HIDEDOTFILES - - HIDEDOTFILES = not HIDEDOTFILES - RefreshDirList(event) - - return 'break' - -# End of 'KeyToggleHideDot()' - - -##### -# Event Handler: Toggle Normalized Or Actual File Length Display -##### - -def KeyToggleLength(event): - global ACTUALLENGTH - - ACTUALLENGTH = not ACTUALLENGTH - RefreshDirList(event) - return 'break' - -# End of 'KeyToggleLength()' - - -##### # Event Handler: Toggle win32all Features, If Available ##### @@ -4280,7 +4274,7 @@ # If the user doesn't want symbolic link expansion, get # rid of it. - if not EXPANDSYMLINKS: + if not SYMEXPAND: for list, tail in ((fList, ""), (dList, PSEP)): for i in range(len(list)): list[i] = list[i].split(SYMPTR)[0] @@ -4697,7 +4691,7 @@ # Symlink targets can be displayed as defined (default) # or expanded to their absolute path string. - if RESOLVSYMLINKS: + if SYMRESOLV: f = os.path.realpath(currentdir + name) else: f = os.readlink(currentdir + name) @@ -5356,17 +5350,17 @@ "AFTERCLEAR":AFTERCLEAR, "AUTOREFRESH":AUTOREFRESH, "CMDMENUSORT":CMDMENUSORT, - "EXPANDSYMLINKS":EXPANDSYMLINKS, "FORCEUNIXPATH":FORCEUNIXPATH, "HIDEDOTFILES":HIDEDOTFILES, "INVERTFILTER":INVERTFILTER, "ISODATE":ISODATE, "NODETAILS":NODETAILS, "NONAVIGATE":NONAVIGATE, - "RESOLVSYMLINKS":RESOLVSYMLINKS, "SORTREVERSE":SORTREVERSE, "SORTSEPARATE":SORTSEPARATE, "SYMDIR":SYMDIR, + "SYMEXPAND":SYMEXPAND, + "SYMRESOLV":SYMRESOLV, "USETHREADS":USETHREADS, "USEWIN32ALL":USEWIN32ALL, "WARN":WARN,