diff --git a/twander.py b/twander.py index 0f632b6..082318f 100755 --- a/twander.py +++ b/twander.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "twander" -RCSID = "$Id: twander.py,v 3.161 2005/01/21 21:04:42 tundra Exp $" +RCSID = "$Id: twander.py,v 3.162 2005/01/23 11:26:04 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -277,6 +277,7 @@ AUTOREFRESH = TRUE # Automatically refresh the directory display? CMDSHELL = "" # No CMDSHELL processing DEBUGLEVEL = 0 # No debug output +DEFAULTSEP = "==>" # Default separator in PROMPT and YES definitions FORCEUNIXPATH = FALSE # Force Unix path separators regardless of OS MAXMENU = 32 # Maximum length of displayed menu MAXMENUBUF = 250 # Maximum size of internal menu buffer @@ -642,99 +643,100 @@ # Title-Bar Strings -TTLAUTO = "Auto:" -TTLFILES = "Total Files:" -TTLSIZE = "Total Size:" -TTLSORTFLD = "Sort By:" -TTLSORTREV = "Rev:" -TTLSORTSEP = "Sep:" +TTLAUTO = "Auto:" +TTLFILES = "Total Files:" +TTLSIZE = "Total Size:" +TTLSORTFLD = "Sort By:" +TTLSORTREV = "Rev:" +TTLSORTSEP = "Sep:" # Convert Logical Values Into Yes/No String -YesOrNo = {TRUE:"YES", FALSE:"N0"} +YesOrNo = {TRUE:"YES", FALSE:"N0"} # Menu Button Titles -COMMANDMENU = 'Commands' # Title for Command Menu button -DIRMENU = 'Directories' # Title for Directory Menu button -HISTMENU = 'History' # Title for History Menu button -SCMENU = 'Shortcuts' # Title for Shortcut Menu button -SORTMENU = 'Sorting' # Title for Sort Menu button -WILDMENU = 'Wildcards' # Title for Wildcard Menu button -HELPMENU = 'Help' # Title for Help Menu button +COMMANDMENU = 'Commands' # Title for Command Menu button +DIRMENU = 'Directories' # Title for Directory Menu button +HISTMENU = 'History' # Title for History Menu button +SCMENU = 'Shortcuts' # Title for Shortcut Menu button +SORTMENU = 'Sorting' # Title for Sort Menu button +WILDMENU = 'Wildcards' # Title for Wildcard Menu button +HELPMENU = 'Help' # Title for Help Menu button # Sort Menu-Related # And their names - used in Sorting Menu -sSORTBY = "Sort By" -sREVERSE = "Reverse Sort" -sSEPARATE = "Separate Dirs/Files" +sSORTBY = "Sort By" +sREVERSE = "Reverse Sort" +sSEPARATE = "Separate Dirs/Files" # Help Menu-Related -WEBSITE = "Homepage:\n\nhttp://www.tundraware.com/Software/twander" -ABOUT = "%s %s\n\nCopyright %s %s\n%s\n\n%s\n\n%s" % (PROGNAME, VERSION, CPRT, DATE, OWNER, RIGHTS, WEBSITE) -hABOUT = 'About' -hCOMMANDS = 'Command Definitions' -hDIRSC = 'Directory Shortcuts' -hINTVBLS = 'Internal Program Variables' -hKEYS = 'Keyboard Assignments' -hNONE = 'No %s Found.' -hOPTVBLS = 'User-Settable Options' -hUSERVBLS = 'User-Defined Variables' +WEBSITE = "Homepage:\n\nhttp://www.tundraware.com/Software/twander" +ABOUT = "%s %s\n\nCopyright %s %s\n%s\n\n%s\n\n%s" % (PROGNAME, VERSION, CPRT, DATE, OWNER, RIGHTS, WEBSITE) +hABOUT = 'About' +hCOMMANDS = 'Command Definitions' +hDIRSC = 'Directory Shortcuts' +hINTVBLS = 'Internal Program Variables' +hKEYS = 'Keyboard Assignments' +hNONE = 'No %s Found.' +hOPTVBLS = 'User-Settable Options' +hUSERVBLS = 'User-Defined Variables' # Errors -eBADROOT = " %s Is Not A Directory" -eDIRRD = "Cannot Open Directory : %s --- Check Permissions." -eERROR = "ERROR" -eINITDIRBAD = "Cannot Open Starting Directory : %s - Check Permissions - ABORTING!." -eOPEN = "Cannot Open File: %s" -eTOOMANY = "You Can Only Specify One Starting Directory." +eBADROOT = " %s Is Not A Directory" +eDIRRD = "Cannot Open Directory : %s --- Check Permissions." +eERROR = "ERROR" +eINITDIRBAD = "Cannot Open Starting Directory : %s - Check Permissions - ABORTING!." +eOPEN = "Cannot Open File: %s" +eTOOMANY = "You Can Only Specify One Starting Directory." # Information -iNOSTAT = "Details Unavailable For This File ->" +iNOSTAT = "Details Unavailable For This File ->" # Prompts -pCHPATH = "Change Path" -pENCMD = "Enter Command To Run:" -pENPATH = "Enter New Path Desired:" -pENWILD = "Enter Selection Wildcard:" -pMANUALCMD = "Manual Command Entry" -pRUNCMD = "Run Command" -pWILDSEL = "Selection By Wildcard" +pCHPATH = "Change Path" +pENCMD = "Enter Command To Run:" +pENPATH = "Enter New Path Desired:" +pENWILD = "Enter Selection Wildcard:" +pMANUALCMD = "Manual Command Entry" +pRUNCMD = "Run Command" +pWILDSEL = "Selection By Wildcard" # Warnings -wBADCFGLINE = "Ignoring Line %s.\nBogus Configuration Entry:\n\n%s" -wBADDEBUG = "Ignoring Bogus Debug Level! - %s Is Not In Integer Or Hex Format." -wBADENDIF = "Ignoring Line %s!\nBogus End-Of-Block Statement:\n\n%s" -wBADENVVBL = "Ignoring Line %s.\nEnvironment Variable %s Not Set:\n\n%s" -wBADEXE = "Could Not Execute Command:\n\n%s" -wBADIF = "Ignoring Line %s.\nImproperly Formed Condition: \n\n%s" -wBADRHS = "Ignoring Line %s.\nOption Assignment Has Bad Righthand Side:\n\n%s" -wBADSCNUM = "Ignoring Line %s.\nShortcut Number Must Be From 1-12:\n\n%s" -wBADSORTFLD = "Don't Know How To Sort By: %s\n\nWill Sort By %s Instead." -wCONFOPEN = "Cannot Open Configuration File:\n%s" -wEXTRAENDIF = "Ignoring Line %s!\nNo Conditional Block To End:\n\n%s" -wLINKBACK = "%s Points Back To Own Directory" -wMISSENDIF = "Configuration File Is Missing %s " + CONDENDIF +" Statement(s)" -wNOCMDS = "Running With No Commands Defined!" -wNOREBIND = "Ignoring Line %s.\nCannot Rebind This Keyboard Or Mouse Button Combination:\n\n%s" -wREDEFVAR = "Ignoring Line %s.\nCannot Redefine Built-In Variable %s:\n\n%s" -wUNDEFVBL = "Ignoring Line %s.\nUndefined Variable %s Referenced:\n\n%s" -wVBLTOODEEP = "Ignoring Line %s.\nVariable Definition Nested Too Deeply:\n\n%s" -wWARN = "WARNING" -wWILDCOMP = "Cannot Compile Wilcard Expression: %s" +wBADCFGLINE = "Ignoring Line %s.\nBogus Configuration Entry:\n\n%s" +wBADDEBUG = "Ignoring Bogus Debug Level! - %s Is Not In Integer Or Hex Format." +wBADENDIF = "Ignoring Line %s!\nBogus End-Of-Block Statement:\n\n%s" +wBADENVVBL = "Ignoring Line %s.\nEnvironment Variable %s Not Set:\n\n%s" +wBADEXE = "Could Not Execute Command:\n\n%s" +wBADIF = "Ignoring Line %s.\nImproperly Formed Condition: \n\n%s" +wBADRHS = "Ignoring Line %s.\nOption Assignment Has Bad Righthand Side:\n\n%s" +wBADSCNUM = "Ignoring Line %s.\nShortcut Number Must Be From 1-12:\n\n%s" +wBADSORTFLD = "Don't Know How To Sort By: %s\n\nWill Sort By %s Instead." +wBADYESNODFLT = "Bad Default Argument For Yes/No Prompt: '%s'\nCommand '%s' Aborted" +wCONFOPEN = "Cannot Open Configuration File:\n%s" +wEXTRAENDIF = "Ignoring Line %s!\nNo Conditional Block To End:\n\n%s" +wLINKBACK = "%s Points Back To Own Directory" +wMISSENDIF = "Configuration File Is Missing %s " + CONDENDIF +" Statement(s)" +wNOCMDS = "Running With No Commands Defined!" +wNOREBIND = "Ignoring Line %s.\nCannot Rebind This Keyboard Or Mouse Button Combination:\n\n%s" +wREDEFVAR = "Ignoring Line %s.\nCannot Redefine Built-In Variable %s:\n\n%s" +wUNDEFVBL = "Ignoring Line %s.\nUndefined Variable %s Referenced:\n\n%s" +wVBLTOODEEP = "Ignoring Line %s.\nVariable Definition Nested Too Deeply:\n\n%s" +wWARN = "WARNING" +wWILDCOMP = "Cannot Compile Wilcard Expression: %s" ##### @@ -766,32 +768,32 @@ # Debug Strings -dCMD = "COMMAND" -dCMDTBL = hCOMMANDS -dDIRSTK = "DIRECTORY STACK" -dFALSE = "False" -dFUNCKEYS = hDIRSC -dHEADER = "twander Debug Dump Run On: %s\n" -dHIST = "COMMAND HISTORY STACK" -dINTVAR = hINTVBLS -dKEYBINDS = hKEYS -dMEM = "CONTENTS OF MEMORY %s" -dMEMALL = "CONTENTS OF ALL PROGRAM MEMORIES" -dNULL = "None" -dOPTVAR = hOPTVBLS -dSYMTBL = hUSERVBLS -dTRUE = "True" -dWILDSTK = "WILDCARD STACK" +dCMD = "COMMAND" +dCMDTBL = hCOMMANDS +dDIRSTK = "DIRECTORY STACK" +dFALSE = "False" +dFUNCKEYS = hDIRSC +dHEADER = "twander Debug Dump Run On: %s\n" +dHIST = "COMMAND HISTORY STACK" +dINTVAR = hINTVBLS +dKEYBINDS = hKEYS +dMEM = "CONTENTS OF MEMORY %s" +dMEMALL = "CONTENTS OF ALL PROGRAM MEMORIES" +dNULL = "None" +dOPTVAR = hOPTVBLS +dSYMTBL = hUSERVBLS +dTRUE = "True" +dWILDSTK = "WILDCARD STACK" # Debug Formatting -dCMDWIDTH = 20 -dINTVARWIDTH = 12 -dKEYWIDTH = 16 -dOPTIONWIDTH = 16 -dSCWIDTH = 6 -dTWOUPWIDTH = 50 -dUSRVBLWIDTH = 20 +dCMDWIDTH = 20 +dINTVARWIDTH = 12 +dKEYWIDTH = 16 +dOPTIONWIDTH = 16 +dSCWIDTH = 6 +dTWOUPWIDTH = 50 +dUSRVBLWIDTH = 20 # List of internal program variables to dump during debug sessions @@ -4012,13 +4014,36 @@ # First do any prompting required - for promptvar, handler, replace in ((YESNO, askyesno, FALSE), (PROMPT, askstring, TRUE)): + for promptvar, handler, defaultarg, replace in ((YESNO, askyesno, "default", FALSE), + (PROMPT, askstring, "initialvalue", TRUE)): for x in range(cmd.count(promptvar)): b = cmd.find(promptvar) e = cmd.find("]", b) prompt = cmd[b + len(promptvar):e] - val = handler(name, prompt) + + # Pickup default value, if any + + default = {} + prompt = prompt.split(DEFAULTSEP) + prompt.append("") + prompt, default[defaultarg] = prompt[0], prompt[1].lower().strip() + + # YESNO dialogs can only accept two arguments (we just made them case-insensitive above) + + if (promptvar == YESNO) and (default[defaultarg] not in ("yes", "no", "")): + + # Display an error + + WrnMsg(wBADYESNODFLT % (default[defaultarg], name)) + + # Force a return + val = "" + + # Everything OK - Run the dialog + + else: + val = handler(name, prompt, **default) # Make sure our program gets focus back UI.DirList.focus() @@ -4611,7 +4636,7 @@ "MBCOLOR":MBCOLOR, "MFCOLOR":MFCOLOR, "MFNAME":MFNAME, "MFWT":MFWT, # Menu Font/Colors "HBCOLOR":HBCOLOR, "HFCOLOR":HFCOLOR, "HFNAME":HFNAME, "HFWT":HFWT, # Help Font/Colors "MBARCOL":MBARCOL, "QUOTECHAR":QUOTECHAR, "SORTBYFIELD":SORTBYFIELD, # Other - "STARTDIR":STARTDIR, "CMDSHELL":CMDSHELL} + "STARTDIR":STARTDIR, "CMDSHELL":CMDSHELL, "DEFAULTSEP":DEFAULTSEP} # Prepare storage for key bindings UI.KeyBindings = {}