]> gitweb.factorcode.org Git - factor.git/commitdiff
more plugin work
authorSlava Pestov <slava@factorcode.org>
Sat, 13 Nov 2004 23:24:46 +0000 (23:24 +0000)
committerSlava Pestov <slava@factorcode.org>
Sat, 13 Nov 2004 23:24:46 +0000 (23:24 +0000)
actions.xml
factor/jedit/EditWordDialog.java
factor/jedit/FactorPlugin.java
factor/jedit/WordPreview.java

index b120aabaf6d14b34c3c6a20c86c243a3599a6b0f..032edc4fefda2c16941baf61929618e3930d569d 100644 (file)
@@ -3,6 +3,12 @@
 <!DOCTYPE ACTIONS SYSTEM "actions.dtd">
 
 <ACTIONS>
+       <ACTION NAME="factor-listener">
+               <CODE>
+                       wm.addDockableWindow("console");
+                       wm.getDockableWindow("console").setShell("Factor");
+               </CODE>
+       </ACTION>
        <ACTION NAME="factor-restart">
                <CODE>
                        FactorPlugin.stopExternalInstance();
@@ -15,7 +21,7 @@
                        if(sel == null)
                                view.toolkit.beep();
                        else
-                               FactorPlugin.eval(view,sel);
+                               FactorPlugin.evalInListener(view,sel);
                </CODE>
        </ACTION>
        <ACTION NAME="factor-run-file">
@@ -35,7 +41,7 @@
                                view.toolkit.beep();
                        else
                        {
-                               FactorPlugin.eval(view,
+                               FactorPlugin.evalInListener(view,
                                        "\""
                                        + FactorReader.charsToEscapes(word)
                                        + "\" apropos.");
        </ACTION>
        <ACTION NAME="factor-see">
                <CODE>
-                       FactorPlugin.factorWordOperation(view,"see");
+                       FactorPlugin.factorWordOutputOp(view,"see");
                </CODE>
        </ACTION>
        <ACTION NAME="factor-edit">
                <CODE>
-                       FactorPlugin.factorWordOperation(view,"jedit");
+                       FactorPlugin.factorWordWireOp(view,"jedit");
                </CODE>
        </ACTION>
        <ACTION NAME="factor-edit-dialog">
@@ -60,7 +66,7 @@
        </ACTION>
        <ACTION NAME="factor-usages">
                <CODE>
-                       FactorPlugin.factorWordOperation(view,"usages.");
+                       FactorPlugin.factorWordOutputOp(view,"usages.");
                </CODE>
        </ACTION>
        <ACTION NAME="factor-insert-use">
index 49733068d0b1e64b61798b1f5a020f1a090040bd..231f8da61562388ec34ae4040f26055cbd6f88cc 100644 (file)
@@ -36,9 +36,11 @@ import javax.swing.text.Document;
 import javax.swing.*;
 import java.awt.event.*;
 import java.awt.*;
+import java.io.IOException;
 import java.util.List;
 import org.gjt.sp.jedit.gui.EnhancedDialog;
 import org.gjt.sp.jedit.*;
+import org.gjt.sp.util.Log;
 
 public class EditWordDialog extends WordListDialog
 {
@@ -80,8 +82,15 @@ public class EditWordDialog extends WordListDialog
                        return;
                }
 
-               String code = FactorPlugin.factorWord(word);
-               FactorPlugin.eval(view,code + " jedit");
+               try
+               {
+                       FactorPlugin.evalInWire(FactorPlugin.factorWord(word) + " jedit");
+               }
+               catch(IOException e)
+               {
+                       /* Don't care */
+                       Log.log(Log.ERROR,this,e);
+               }
                dispose();
        } //}}}
 
index 8ed881631355d4b64f9b8adbe5ba8c4a34bd1836..91c650a059e21e0cd4d44516d82a1e7dfc422f93 100644 (file)
@@ -158,8 +158,8 @@ public class FactorPlugin extends EditPlugin
                        "sidekick.SideKickParser","factor");
        } //}}}
        
-       //{{{ eval() method
-       public static void eval(View view, String cmd)
+       //{{{ evalInListener() method
+       public static void evalInListener(View view, String cmd)
        {
                DockableWindowManager wm = view.getDockableWindowManager();
                wm.addDockableWindow("console");
@@ -167,6 +167,12 @@ public class FactorPlugin extends EditPlugin
                console.run(Shell.getShell("Factor"),console,cmd);
        } //}}}
 
+       //{{{ evalInWire() method
+       public static void evalInWire(String cmd) throws IOException
+       {
+               getExternalInstance().eval(cmd);
+       } //}}}
+
        //{{{ factorWord() method
        /**
         * Build a Factor expression for pushing the selected word on the stack
@@ -202,17 +208,30 @@ public class FactorPlugin extends EditPlugin
                        return null;
        } //}}}
        
-       //{{{ factorWordOperation() method
+       //{{{ factorWordOutputOp() method
+       /**
+        * Apply a Factor word to the selected word.
+        */
+       public static void factorWordOutputOp(View view, String op)
+       {
+               String word = factorWord(view);
+               if(word == null)
+                       view.getToolkit().beep();
+               else
+                       evalInListener(view,word + " " + op);
+       } //}}}
+
+       //{{{ factorWordWireOp() method
        /**
         * Apply a Factor word to the selected word.
         */
-       public static void factorWordOperation(View view, String op)
+       public static void factorWordWireOp(View view, String op) throws IOException
        {
                String word = factorWord(view);
                if(word == null)
                        view.getToolkit().beep();
                else
-                       eval(view,word + " " + op);
+                       evalInWire(word + " " + op);
        } //}}}
 
        //{{{ getCompletions() method
index 8944d9115a8958949084b0f8fbdc06d557e3ab01..cf2c885c554a1c274c6b465aef55e76c0c010fa9 100644 (file)
@@ -81,8 +81,7 @@ public class WordPreview implements ActionListener, CaretListener
        {
                View view = textArea.getView();
 
-               SideKickParsedData data = SideKickParsedData
-                       .getParsedData(view);
+               SideKickParsedData data = SideKickParsedData.getParsedData(view);
                if(data instanceof FactorParsedData)
                {
                        int line = textArea.getCaretLine();