diff --git a/twander.py b/twander.py index 558a23a..9852926 100755 --- a/twander.py +++ b/twander.py @@ -4,7 +4,7 @@ PROGNAME = "twander" -RCSID = "$Id: twander.py,v 1.87 2002/12/01 16:45:57 tundra Exp $" +RCSID = "$Id: twander.py,v 1.88 2002/12/01 22:16:10 tundra Exp $" VERSION = RCSID.split()[2] @@ -12,7 +12,6 @@ # Imports # #----------------------------------------------------------# -import commands import getopt import mutex import os @@ -54,9 +53,10 @@ # General Program Commands KEYPRESS = '' # Any keypress (for commands) -QUITPROG = '' # Quit the program +QUITPROG = '' # Quit the program READCONF = '' # Re-read the configuration file REFRESH = '' # Refresh screen +RUNCMD = '' # Run arbitrary user command TOGDETAIL = '' # Toggle detail view # Directory Navigation @@ -237,6 +237,9 @@ pCHPATH = "Change Path" pENPATH = "Enter New Path Desired:" +pRUNCMD = "Run Command" +pENCMD = "Enter Command To Run:" + # Warnings @@ -374,14 +377,12 @@ WrnMsg(wCMDKEY % fields[0]) key = fields[0] # Use whole word as index - # Found legit delimiter, so use it as - # dictionary index - mapped to lower case so - # command keys are case insensitive. + # Found legit delimiter, use it as dictionary index else: - key = fields[0][keypos+1].lower() + key = fields[0][keypos+1] if key in UI.rcfile: # This is a Python 2.2 or later idiom - ErrMsg(eDUPKEY % fields[0]) # Duplicate key found + ErrMsg(eDUPKEY % fields[0]) # Duplicate key found cf.close() sys.exit(1) @@ -469,13 +470,16 @@ # Bind handler for "Quit Program" self.DirList.bind(QUITPROG, KeyQuitProg) - # Bind handler of "Read Config File" + # Bind handler for "Read Config File" self.DirList.bind(READCONF, ParseConfFile) - # Bind handler of "Refresh Screen" + # Bind handler for "Refresh Screen" self.DirList.bind(REFRESH, RefreshDirList) - # Bind handler of "Toggle Detail" + # Bind handler for "Run Command" + self.DirList.bind(RUNCMD, KeyRunCommand) + + # Bind handler for "Toggle Detail" self.DirList.bind(TOGDETAIL, KeyToggleDetail) @@ -663,7 +667,7 @@ # get its associated string and # execute the command. - cmd = UI.rcfile.get(event.char.lower(), ["",""])[1] + cmd = UI.rcfile.get(event.char, ["",""])[1] # cmd == null means no matching command key - do nothing # Otherwise, replace config tokens with actual file/dir names @@ -697,6 +701,20 @@ ##### +# Event Handler: Run Command +#### + +def KeyRunCommand(event): + + cmd = askstring(pRUNCMD, pENCMD) + if cmd: + os.system(cmd) + UI.DirList.focus() + +# End of 'ChangeDir()' + + +##### # Event Handler: Toggle Detail View #####