diff --git a/twander.py b/twander.py index 9d60527..e2f187d 100755 --- a/twander.py +++ b/twander.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "twander" -RCSID = "$Id: twander.py,v 2.69 2003/01/18 19:13:35 tundra Exp $" +RCSID = "$Id: twander.py,v 2.70 2003/01/19 02:41:22 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -206,6 +206,8 @@ AUTOREFRESH = TRUE # Automatically refresh the directory display DEBUGLEVEL = 0 # No debug output +MAXDIRBUF = 250 # Maximum size of UI.AllDirs +MAXHISTBUF = 250 # Maximum size of UI.CmdHist NODETAILS = FALSE # TRUE means details can never be displayed NONAVIGATE = FALSE # TRUE means that all directory navigation is prevented USETHREADS = TRUE # Use threads on Unix @@ -447,21 +449,16 @@ ##### uTable = [PROGNAME + " " + VERSION + " - %s\n" % COPYRIGHT, - "usage: " + PROGNAME + " [-bcdfhnqrstvwxy] [startdir] where,\n", + "usage: " + PROGNAME + " [-cdhqrstvwxy] [startdir] where,\n", " startdir name of directory in which to begin (default: current dir)", - " -b color background color (default: black)", " -c file name of configuration file (default: $HOME/." + PROGNAME + " or PROGDIR/." + PROGNAME + ")", " -d level set debugging level (default: 0, debugging off)", - " -f color foreground color (default: green)", " -h print this help information", - " -n name name of font to use (default: courier)", " -q quiet mode - no warnings (default: warnings on)", " -r turn off automatic content refreshing (default: refresh on)", - " -s size size of font to use (default: 12)", " -t no quoting when substituting Built-In Variables (default: quoting on)", " -v print detailed version information", - " -w wght weight/style of font to use (default: bold)", " -x width window width (default: 90)", " -y height window height (default: 25)", ] @@ -1350,7 +1347,7 @@ # Unrecognized - Ignore else: - return "break" + return parts = button.winfo_geometry().split('+') # Geometry returned as "WidthxHeight+X+Y" dims = parts[0].split('x') @@ -1904,7 +1901,7 @@ else: savecmd = newcmd - UpdateMenu(UI.HistBtn, UI.CmdHist, MAXHIST, KeyRunCommand, newentry=savecmd, fakeevent=TRUE) + UpdateMenu(UI.HistBtn, UI.CmdHist, MAXHIST, MAXHISTBUF, KeyRunCommand, newentry=savecmd, fakeevent=TRUE) # Dump Command History stack if requested @@ -2489,8 +2486,8 @@ # Make sure menus conform to max lengths (which may have changed). - UpdateMenu(UI.DirBtn, UI.AllDirs, MAXDIR, LoadDirList, sort=TRUE) - UpdateMenu(UI.HistBtn, UI.CmdHist, MAXHIST, KeyRunCommand, fakeevent=TRUE) + UpdateMenu(UI.DirBtn, UI.AllDirs, MAXDIR, MAXDIRBUF, LoadDirList, sort=TRUE) + UpdateMenu(UI.HistBtn, UI.CmdHist, MAXHIST, MAXHISTBUF, KeyRunCommand, fakeevent=TRUE) ##### # Initialize Help Menu with latest information @@ -2612,7 +2609,7 @@ # Now add the entry if we decided it was necessary. observing MAXDIR value. if addentry: - UpdateMenu(UI.DirBtn, UI.AllDirs, MAXDIR, LoadDirList, sort=TRUE, newentry=newdir) + UpdateMenu(UI.DirBtn, UI.AllDirs, MAXDIR, MAXDIRBUF, LoadDirList, sort=TRUE, newentry=newdir) # End of 'UpdateDirMenu()' @@ -2621,17 +2618,20 @@ # Generic Menu Update Routine ##### -def UpdateMenu(menubtn, datastore, max, func, sort=FALSE, newentry="", fakeevent=FALSE): +def UpdateMenu(menubtn, datastore, max, maxbuf, func, sort=FALSE, newentry="", fakeevent=FALSE): # First add the new data, if any, to the specified data storage stucture. if newentry: datastore.append(newentry) - # Now trim it to requested maximum length - this only changes how many - # entries are display on the menu - nothing is actually removed - # from the data storage for this menu. We also do not sort the - # actual data storage itself if sorting has been requested. + # Now trim it to requested maximum length. 'max' sets how + # many entries we see in the menu, and 'maxbuf' sets how large + # the actual storage buffer is allowed to get. + + datastore[:] = datastore[-maxbuf:] + + # We do not sort the data storage itself if sorting has been requested. # We sort the *copy*. That way we get the 'last _max_ items in # sorted order.' (If we sorted the master copy, we would lose # track of the order in which things were placed there.) @@ -2798,7 +2798,8 @@ "USETHREADS":USETHREADS, "WARN":WARN} UI.OptionsNumeric = {"DEBUGLEVEL":DEBUGLEVEL, "FSZ":FSZ, "HEIGHT":HEIGHT, "MAXDIR":MAXDIR, - "MAXHIST":MAXHIST, "MAXNESTING":MAXNESTING, "REFRESHINT":REFRESHINT, "WIDTH":WIDTH} + "MAXDIRBUF":MAXDIRBUF, "MAXHIST":MAXHIST, "MAXHISTBUF":MAXHISTBUF, + "MAXNESTING":MAXNESTING, "REFRESHINT":REFRESHINT, "WIDTH":WIDTH} UI.OptionsString = {"BCOLOR":BCOLOR, "FCOLOR":FCOLOR, "FNAME":FNAME, "FSZ":HFSZ, "FWT":FWT, # Main Font/Colors "MBCOLOR":MBCOLOR, "MFCOLOR":MFCOLOR, "MFNAME":MFNAME, "MFSZ":MFSZ, "MFWT":MFWT, # Menu Font/Colors @@ -2844,7 +2845,7 @@ OPTIONS = envopt.split() + OPTIONS try: - opts, args = getopt.getopt(OPTIONS, '-b:c:d:f:hn:qrs:tvw:x:y:') + opts, args = getopt.getopt(OPTIONS, '-c:d:hqrtvx:y:') except getopt.GetoptError: Usage() sys.exit(1) @@ -2879,26 +2880,16 @@ # Process the rest of the options, if any for opt, val in opts: - if opt == "-b": - BCOLOR = val if opt == "-d": DEBUGLEVEL = val if int(DEBUGLEVEL): print dHEADER % time.asctime() - if opt == "-f": - FCOLOR = val - if opt == "-n": - FNAME = val if opt == "-q": WARN = FALSE if opt == "-r": AUTOREFRESH = FALSE - if opt == "-s": - FSZ = val if opt == "-t": QUOTECHAR = "" - if opt == "-w": - FWT = val if opt == "-x": WIDTH = val if opt == "-y":