X-Git-Url: https://git.distorted.org.uk/~mdw/anag/blobdiff_plain/7b468eed7bb2450cd8e85852c41bbb7d24bb6bb1..d9af4a2b674e5ab91df0f9af236283b617bb81c7:/AnagGUI.java diff --git a/AnagGUI.java b/AnagGUI.java index ccae591..ac4d279 100644 --- a/AnagGUI.java +++ b/AnagGUI.java @@ -1,6 +1,6 @@ /* -*-java-*- * - * $Id: AnagGUI.java,v 1.2 2001/02/07 09:10:04 mdw Exp $ + * $Id: AnagGUI.java,v 1.6 2003/11/29 23:38:37 mdw Exp $ * * Front-end GUI * @@ -29,6 +29,19 @@ /*----- Revision history --------------------------------------------------* * * $Log: AnagGUI.java,v $ + * Revision 1.6 2003/11/29 23:38:37 mdw + * Debianization. + * + * Revision 1.5 2002/08/11 12:58:09 mdw + * Added support for regular expression matching, if supported by the C + * library. + * + * Revision 1.4 2001/02/19 19:19:11 mdw + * Add `help' button. Lowercase input to the command. + * + * Revision 1.3 2001/02/16 21:46:10 mdw + * Use a BufferedReader, not a LineNumberReader. + * * Revision 1.2 2001/02/07 09:10:04 mdw * Add a settings panel (currently only allows the wordlist to be * changed). Move the buttons down the right-hand side of the list. Add a @@ -134,10 +147,10 @@ class AnagPanel extends Panel { void settings() { if (sb != null) sb.toFront(); else sb = new Settings(); } void listen(Process p) throws IOException { - LineNumberReader fout = - new LineNumberReader(new InputStreamReader(p.getInputStream())); - LineNumberReader ferr = - new LineNumberReader(new InputStreamReader(p.getErrorStream())); + BufferedReader fout = + new BufferedReader(new InputStreamReader(p.getInputStream())); + BufferedReader ferr = + new BufferedReader(new InputStreamReader(p.getErrorStream())); String l; Vector v = new Vector(); @@ -173,6 +186,15 @@ class AnagPanel extends Panel { } } + void help() { + try { + Process p = Runtime.getRuntime().exec("anag --help"); + listen(p); + } catch (IOException e) { + splat(e.toString()); + } + } + void getlist(String tag) { try { Vector v = new Vector(); @@ -181,7 +203,7 @@ class AnagPanel extends Panel { v.addElement("-file"); v.addElement(file); v.addElement(tag); - v.addElement(word.getText()); + v.addElement(word.getText().toLowerCase()); vv = new String[v.size()]; v.copyInto(vv); Process p = Runtime.getRuntime().exec(vv); @@ -197,7 +219,7 @@ class AnagPanel extends Panel { GridBagConstraints g = new GridBagConstraints(); Button b; - file = "/usr/dict/words"; + file = System.getProperty("anag.dictionary", "/usr/dict/words"); sb = null; g.gridx = g.gridy = GridBagConstraints.RELATIVE; @@ -243,6 +265,24 @@ class AnagPanel extends Panel { }); add(b, g); + b = new Button("Regular expression"); + b.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { getlist("-regexp"); } + }); + add(b, g); + + b = new Button("Perl regexp"); + b.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { getlist("-pcre"); } + }); + add(b, g); + + b = new Button("Monoalphabetic"); + b.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { getlist("-mono"); } + }); + add(b, g); + b = new Button("Trackword"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { getlist("-trackword"); } @@ -255,6 +295,12 @@ class AnagPanel extends Panel { }); add(b, g); + b = new Button("Help!"); + b.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { help(); } + }); + add(b, g); + b = new Button("Settings..."); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { settings(); } @@ -277,8 +323,8 @@ public class AnagGUI extends Applet { f.show(); } public AnagGUI() { super(); setLayout(new BorderLayout()); } - public void init() { add(new AnagPanel()); } - public void destroy() { removeAll(); } + public void init() { /*add(new AnagPanel());*/ main(null); } + public void destroy() { /*removeAll();*/ } }; /*----- That's all, folks -------------------------------------------------*/