1
// GCRunCommand.cs created with MonoDevelop
2
// User: dave at 12:54 AM 8/18/2007
4
// To change standard headers go to Edit->Preferences->Coding->Standard Headers
8
using System.Text.RegularExpressions;
13
public class DefineWordCommand : ICommand
16
const string wordPattern = @"^([^\W0-9_]+([ -][^\W0-9_]+)?)$";
20
public DefineWordCommand ()
22
wordRegex = new Regex (wordPattern, RegexOptions.Compiled);
26
get { return "Define"; }
29
public string Description {
30
get { return "Define a given word."; }
34
get { return "accessories-dictionary.png"; }
37
public Type[] SupportedTypes {
45
public Type[] SupportedModifierTypes {
49
public bool SupportsItem (IItem item) {
53
if (item is ITextItem) {
54
word = (item as ITextItem).Text;
58
return wordRegex.IsMatch (word);
63
public void Perform (IItem[] items, IItem[] modifierItems)
66
foreach (IItem item in items) {
67
if (item is ITextItem) {
68
word = (item as ITextItem).Text;
73
cmd = string.Format ("gnome-dictionary --look-up \"{0}\"", word);
75
System.Diagnostics.Process.Start (cmd);
76
} catch (Exception e) {
77
Console.WriteLine ("Failed to define word: \"{0}\"", e.Message);