Monoalphabetic match filter. Simplify the button list.
authormdw <mdw>
Mon, 15 Sep 2003 02:49:14 +0000 (02:49 +0000)
committermdw <mdw>
Mon, 15 Sep 2003 02:49:14 +0000 (02:49 +0000)
anag-gui.in

index 327164e..317f304 100644 (file)
@@ -176,19 +176,25 @@ frame .f-entry
 frame .f-list
 frame .f-buttons
 
-button .b-anagram -text "Anagram" -underline 0 \
-    -command { run-search "-anagram" $word }
-button .b-subgram -text "Subgram" -underline 0 \
-    -command { run-search "-subgram" $word }
-button .b-glob -text "Crossword" -underline 5 \
-    -command { run-search "-wildcard" $word }
-button .b-track -text "Trackword" -underline 0 \
-    -command { run-search "-trackword" $word }
-button .b-regexp -text "Regexp" -underline 0 \
-    -command { run-search "-regexp" $word }
+foreach {opt text mnem} {
+  anagram Anagram a
+  subgram Subgram s
+  wildcard Crossword w
+  trackword Trackword t
+  mono Monoalphabetic m
+  regexp "Regular expression" r
+} {
+  button .b-$opt -text $text \
+      -underline [string first $mnem [string tolower $text]] \
+      -command [concat [list run-search -$opt] \$word]
+  bind . <Alt-$mnem> [list tkButtonInvoke .b-$opt]
+  pack .b-$opt -in .f-buttons -fill x -padx 2 -pady 2
+}
 
 button .b-custom -text "Custom" -underline 0 \
     -command { run-search-v [wordlist $word] }
+bind . <Alt-c> { tkButtonInvoke .b-custom }
+pack .b-custom -in .f-buttons -fill x -padx 2 -pady 2
 
 listbox .list \
   -xscrollcommand { .f-list.xscroll set } \
@@ -204,9 +210,6 @@ grid .f-list.yscroll -row 0 -column 1 -sticky ns
 grid rowconfigure .f-list 0 -weight 1
 grid columnconfigure .f-list 0 -weight 1
 
-pack .b-custom .b-track .b-regexp .b-glob .b-subgram .b-anagram \
-    -in .f-buttons -fill x -padx 2 -pady 2
-
 pack .e-word -in .f-entry -expand yes -fill x -padx 2 -pady 2
 
 pack .f-entry -fill x
@@ -223,9 +226,3 @@ menu .menu.file
 focus .e-word
 bind .e-word <Return> { tkButtonInvoke .b-anagram }
 
-bind . <Alt-a> { tkButtonInvoke .b-anagram }
-bind . <Alt-t> { tkButtonInvoke .b-track }
-bind . <Alt-s> { tkButtonInvoke .b-subgram }
-bind . <Alt-w> { tkButtonInvoke .b-glob }
-bind . <Alt-r> { tkButtonInvoke .b-regexp }
-bind . <Alt-c> { tkButtonInvoke .b-custom }