diff --git a/twander.py b/twander.py index e58fe92..a9de5b8 100755 --- a/twander.py +++ b/twander.py @@ -4,7 +4,7 @@ # For Updates See: http://www.tundraware.com/Software/twander PROGNAME = "twander" -RCSID = "$Id: twander.py,v 2.65 2003/01/17 06:55:46 tundra Exp $" +RCSID = "$Id: twander.py,v 2.66 2003/01/17 20:58:49 tundra Exp $" VERSION = RCSID.split()[2] @@ -379,14 +379,12 @@ dINTVAR = "" dKEYBINDS = "" dNULL = "None" +dOPTVAR = "" dSYMTBL = "" # List of internal program variables to dump during debug sessions -DebugVars = ["RCSID", "OSNAME", "HOSTNAME", "OPTIONS", "STARTDIR", "HOME", "CONF", - "HEIGHT", "WIDTH", "BCOLOR", "FCOLOR", "FNAME", "FSZ", "FWT", - "MAXDIR", "MAXHIST", "MAXNESTING", "AUTOREFRESH", "DEBUGLEVEL", "WARN", "PSEP", - "QUOTECHAR", "POLLINT", "REFRESHINT", "NODETAILS", "NONAVIGATE"] +DebugVars = ["RCSID", "OSNAME", "HOSTNAME", "OPTIONS", "CONF", "HOME", "PSEP", "POLLINT"] ##### @@ -526,6 +524,15 @@ "MOUSESEL":MOUSESEL } + # Set all the program options to their default values + # This means that a configuration file reload can + # override the options set previously in the environment + # variable or on the command line. + + for x in (UI.OptionsBoolean, UI.OptionsNumeric, UI.OptionsString): + for o in x.keys(): + globals()[o] = x[o] + # Initialize the command menu UI.CmdBtn.menu.delete(0,END) @@ -687,7 +694,7 @@ # Process any option variables - elif name in UI.OptionsBoolean: + elif name in UI.OptionsBoolean.keys(): val = val.upper() if val == 'TRUE' or val == 'FALSE': globals()[name] = eval(val) # !!! Cheater's way to get to global variables. @@ -695,14 +702,14 @@ WrnMsg(wBADRHS % (num, line)) return - elif name in UI.OptionsNumeric: + elif name in UI.OptionsNumeric.keys(): try: globals()[name] = int(val) except: WrnMsg(wBADRHS % (num, line)) return - elif name in UI.OptionsString: + elif name in UI.OptionsString.keys(): # RHS cannot be null if not val: WrnMsg(wBADRHS % (num, line)) @@ -1393,8 +1400,6 @@ ##### def KeyRootDir(event): - global STARTDIR - LoadDirList(PSEP) # End of 'KeyRootDir()' @@ -1405,8 +1410,6 @@ ##### def KeyStartDir(event): - global STARTDIR - LoadDirList(STARTDIR) # End of 'KeyStartDir()' @@ -2544,10 +2547,19 @@ debuginfo = [] for v in DebugVars: - debuginfo.append(v + " " * (12-len(v)) + (str(eval(v)) or dNULL)) + debuginfo.append(v + " " * (12-len(v)) + (str(eval(v)) or dNULL)) PrintDebug(dINTVAR, debuginfo) + debuginfo = [] + for l in (UI.OptionsBoolean, UI.OptionsNumeric, UI.OptionsString): + for v in l: + debuginfo.append(v + " " * (12-len(v)) + (str(eval(v)) or dNULL)) + + debuginfo.sort() + PrintDebug(dOPTVAR, debuginfo) + + # If we just wanted debug output, quit now if int(DEBUGLEVEL) & DEBUGQUIT: sys.exit() @@ -2581,11 +2593,15 @@ UI.BuiltIns = {DIR:"", DSELECTION:"", DSELECTIONS:"", HASH:"", PROMPT:"", SELECTION:"", SELECTIONS:"", YESNO:""} -# Options which can be set in the configuration file +# Options (and their default values) which can be set in the configuration file -UI.OptionsBoolean = ["AUTOREFRESH", "NODETAILS", "NONAVIGATE", "WARN"] -UI.OptionsNumeric = ["DEBUGLEVEL", "FSZ", "HEIGHT", "MAXDIR", "MAXHIST", "MAXNESTING", "REFRESHINT", "WIDTH"] -UI.OptionsString = ["BCOLOR", "FCOLOR", "FNAME", "FWT", "QUOTECHAR", "STARTDIR"] +UI.OptionsBoolean = {"AUTOREFRESH":AUTOREFRESH, "NODETAILS":NODETAILS, "NONAVIGATE":NONAVIGATE, "WARN":WARN} + +UI.OptionsNumeric = {"DEBUGLEVEL":DEBUGLEVEL, "FSZ":FSZ, "HEIGHT":HEIGHT, "MAXDIR":MAXDIR, + "MAXHIST":MAXHIST, "MAXNESTING":MAXNESTING, "REFRESHINT":REFRESHINT, "WIDTH":WIDTH} + +UI.OptionsString = {"BCOLOR":BCOLOR, "FCOLOR":FCOLOR, "FNAME":FNAME, "FWT":FWT, "QUOTECHAR":QUOTECHAR, + "STARTDIR":STARTDIR} # Prepare storage for key bindings UI.KeyBindings = {} @@ -2686,9 +2702,9 @@ if opt == "-y": HEIGHT = val -# Figure out where to start -# Program can only have 0 or 1 arguments -# Make sure any startdir argument is legit +# Figure out where to start - Environment/Command Line overrides config +# file STARTDIR option. Program can only have 0 or 1 arguments. Make +# sure any startdir argument is legit if len(args) > 1: ErrMsg(eTOOMANY) @@ -2713,6 +2729,9 @@ ErrMsg(eBADROOT % STARTDIR) sys.exit(1) + # Save this value as the default for STARTDIR + UI.OptionsString["STARTDIR"] = STARTDIR + # Get starting directory into canonical form STARTDIR = os.path.abspath(STARTDIR)