pcre.c, etc.: Support the PCRE2 library.
[anag] / anag-gui.in
index 327164e..45da707 100644 (file)
@@ -1,6 +1,31 @@
-#! /usr/bin/wish
-
-# --- Configuration ---
+#! @WISH@
+### -*-tcl-*-
+###
+### Graphical frontend for `anag'
+###
+### (c) 2002 Mark Wooding
+###
+
+###----- Licensing notice ---------------------------------------------------
+###
+### This file is part of Anag: a simple wordgame helper.
+###
+### Anag is free software; you can redistribute it and/or modify
+### it under the terms of the GNU General Public License as published by
+### the Free Software Foundation; either version 2 of the License, or
+### (at your option) any later version.
+###
+### Anag is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+### GNU General Public License for more details.
+###
+### You should have received a copy of the GNU General Public License
+### along with Anag; if not, write to the Free Software Foundation,
+### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+###--------------------------------------------------------------------------
+### Configuration.
 
 if {[info exists env(HOME)]} {
   set home $env(HOME)
@@ -13,7 +38,7 @@ if {[info exists env(HOME)]} {
   }
 }
 set conffile [list "/etc/anagrc" \
-                   [file join $home "anagrc"]]
+                 [file join $home "anagrc"]]
 if {[string compare "unix" $tcl_platform(platform)] == 0} {
   lappend conffile [file join $home ".anagrc"]
 }
@@ -38,7 +63,8 @@ foreach f $conffile {
   break
 }
 
-# --- Other setting up ---
+###--------------------------------------------------------------------------
+### Other setting up.
 
 if {[string compare "windows" $tcl_platform(platform)] == 0} {
   set exetypes {
@@ -49,7 +75,8 @@ if {[string compare "windows" $tcl_platform(platform)] == 0} {
   set exetypes {}
 }
 
-# --- Handy subroutines ---
+###--------------------------------------------------------------------------
+### Handy subroutines.
 
 proc wordlist {args} {
   set l {}
@@ -67,7 +94,8 @@ proc report {msg} {
       -title "Error from [wm title .]" -message $msg
 }
 
-# --- Options ---
+###--------------------------------------------------------------------------
+### Options.
 
 proc conf-copyout {} {
   global C C_tags
@@ -155,7 +183,8 @@ proc options {} {
   pack .opt.b -anchor e
 }
 
-# --- Run the command ---
+###--------------------------------------------------------------------------
+### Run the command.
 
 proc run-search {args} { run-search-v $args }
 proc run-search-v {v} {
@@ -169,26 +198,34 @@ proc run-search-v {v} {
   foreach i $l { .list insert end $i }
 }
 
-# --- Construct the main window ---
+###--------------------------------------------------------------------------
+### Construct the main window.
 
 wm title . "Anagram solver"
 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
+  pcre "Perl regexp" p
+} {
+  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 +241,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 +257,4 @@ 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 }
+###----- That's all, folks --------------------------------------------------