]> gitweb.factorcode.org Git - factor.git/commitdiff
action menus work in listener
authorSlava Pestov <slava@factorcode.org>
Tue, 16 Nov 2004 03:06:01 +0000 (03:06 +0000)
committerSlava Pestov <slava@factorcode.org>
Tue, 16 Nov 2004 03:06:01 +0000 (03:06 +0000)
factor/jedit/ListenerAttributeSet.java

index 56f2ba4a931f8d3726ff0610c4f68520a954c31e..af595ae88e2f982cd830d06601338aa7a97a35ee 100644 (file)
 
 package factor.jedit;
 
+import console.*;
+import factor.Cons;
 import javax.swing.text.*;
+import javax.swing.Action;
 import java.awt.Color;
-import factor.Cons;
 
 public class ListenerAttributeSet extends SimpleAttributeSet
 {
@@ -63,6 +65,8 @@ public class ListenerAttributeSet extends SimpleAttributeSet
                        addAttribute(StyleConstants.FontFamily,value);
                else if("size".equals(key))
                        addAttribute(StyleConstants.FontSize,value);
+               else if("actions".equals(key))
+                       addAttribute(ConsolePane.Actions,createActionsMenu((Cons)value));
        } //}}}
        
        //{{{ toColor() method
@@ -73,4 +77,24 @@ public class ListenerAttributeSet extends SimpleAttributeSet
                Number b = (Number)color.next().next().car;
                return new Color(r.intValue(),g.intValue(),b.intValue());
        } //}}}
+       
+       //{{{ createActionsMenu() method
+       private Action[] createActionsMenu(Cons alist)
+       {
+               if(alist == null)
+                       return null;
+
+               int length = alist.length();
+               int i = 0;
+               Action[] actions = new Action[length];
+               while(alist != null)
+               {
+                       Cons pair = (Cons)alist.car;
+                       actions[i++] = new Console.EvalAction(
+                               (String)pair.car,(String)pair.cdr);
+                       alist = alist.next();
+               }
+               
+               return actions;
+       } //}}}
 }