diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt
index 411ca80376..b657ae4879 100644
--- a/TODO.FACTOR.txt
+++ b/TODO.FACTOR.txt
@@ -10,7 +10,6 @@
- multitasking
- review doc formatting with latex2html
- sidekick: error source not removed
-- array index out of bounds
[error] AWT-EventQueue-0: java.lang.NullPointerException
[error] AWT-EventQueue-0: at sidekick.SideKickParsedData.getTreePathForPosition(Unknown Source)
@@ -40,8 +39,11 @@
+ listener/plugin:
+- lineno/file for shuffle defs
+- balance needs USE:
+- input style after clicking link
+- completion: enter no good
- completion: don't show automatically
-- debug sidekick
- completion in the listener
- special completion for USE:/IN:
- fedit broken with listener
@@ -60,6 +62,8 @@
+ JVM compiler:
+- compiled stack traces broken
+- save classes to disk
- tail call optimization broken again
- don't compile inline words
- recursive words with code after ifte
@@ -71,7 +75,6 @@
+ misc:
-- compiled stack traces broken
- namespace clone drops static var bindings
- ditch map
- ditch expand
@@ -85,7 +88,6 @@
- log-client: fix for native
- if user clicks stop in browser, doesn't stop sending?
- log with date
-- log user agent
- add a socket timeout
- if a directory is requested and URL does not end with /, redirect
- return more header fields, like Content-Length, Last-Modified, and so on
diff --git a/actions.xml b/actions.xml
index 2526f13482..ab3a1339a8 100644
--- a/actions.xml
+++ b/actions.xml
@@ -40,7 +40,7 @@
- factorWordOperation(view,"USE: jedit jedit");
+ factorWordOperation(view,"jedit");
@@ -55,7 +55,7 @@
else
{
factorEval(view,
- "[ " + textArea.selectedText + " ] balance");
+ "[ " + textArea.selectedText + " ] balance .");
}
diff --git a/factor/FactorInterpreter.java b/factor/FactorInterpreter.java
index 406e8be54d..c266ab5cf5 100644
--- a/factor/FactorInterpreter.java
+++ b/factor/FactorInterpreter.java
@@ -35,7 +35,7 @@ import java.io.*;
public class FactorInterpreter implements FactorObject, Runnable
{
- public static final String VERSION = "0.63";
+ public static final String VERSION = "0.64";
// command line arguments are stored here.
public Cons args;
diff --git a/factor/jedit/factor.bsh b/factor/jedit/factor.bsh
new file mode 100644
index 0000000000..da21364190
--- /dev/null
+++ b/factor/jedit/factor.bsh
@@ -0,0 +1,32 @@
+factorEval(view,str)
+{
+ factor.jedit.FactorPlugin.eval(view,str);
+}
+
+/* Build a Factor expression for pushing the selected word on the stack */
+factorWord(view)
+{
+ textArea = view.textArea;
+ data = sidekick.SideKickParsedData.getParsedData(view);
+ if(data instanceof factor.jedit.FactorParsedData)
+ {
+ if(textArea.selectionCount == 0)
+ textArea.selectWord();
+ return "\""
+ + MiscUtilities.charsToEscapes(textArea.selectedText)
+ + "\" " + factor.FactorReader.unparseObject(data.use)
+ + " search";
+ }
+ else
+ return null;
+}
+
+/* Apply a Factor word to the selected word */
+factorWordOperation(view,op)
+{
+ word = factorWord(view);
+ if(word == null)
+ view.toolkit.beep();
+ else
+ factorEval(view,word + " " + op);
+}
diff --git a/factor/listener/FactorListener.java b/factor/listener/FactorListener.java
index 92fb88ac69..7e383e807b 100644
--- a/factor/listener/FactorListener.java
+++ b/factor/listener/FactorListener.java
@@ -49,6 +49,7 @@ public class FactorListener extends JTextPane
(Cursor.WAIT_CURSOR);
public static final Object Link = new Object();
+ public static final Object Actions = new Object();
private EventListenerList listenerList;
@@ -145,6 +146,7 @@ public class FactorListener extends JTextPane
try
{
StyledDocument doc = (StyledDocument)getDocument();
+ setCaretPosition(doc.getLength());
doc.insertString(doc.getLength(),eval + "\n",
getCharacterAttributes());
}
@@ -174,27 +176,77 @@ public class FactorListener extends JTextPane
}
} //}}}
- //{{{ getLinkAt() method
- private String getLinkAt(int pos)
+ //{{{ getAttributes() method
+ private AttributeSet getAttributes(int pos)
{
StyledDocument doc = (StyledDocument)getDocument();
Element e = doc.getCharacterElement(pos);
- AttributeSet a = e.getAttributes();
+ return e.getAttributes();
+ } //}}}
+
+ //{{{ getActions() method
+ private Cons getActions(int pos)
+ {
+ AttributeSet a = getAttributes(pos);
if(a == null)
return null;
else
- return (String)a.getAttribute(Link);
+ return (Cons)a.getAttribute(Actions);
+ } //}}}
+
+ //{{{ getActionsPopup() method
+ private JPopupMenu getActionsPopup(int pos)
+ {
+ Cons actions = getActions(pos);
+ if(actions == null)
+ return null;
+
+ JPopupMenu popup = new JPopupMenu();
+ while(actions != null)
+ {
+ Cons action = (Cons)actions.car;
+ JMenuItem item = new JMenuItem((String)action.cdr);
+ item.setActionCommand((String)action.car);
+ item.addActionListener(new EvalAction());
+ popup.add(item);
+ actions = actions.next();
+ }
+
+ return popup;
+ } //}}}
+
+ //{{{ showPopupMenu() method
+ private void showPopupMenu(int pos)
+ {
+ JPopupMenu actions = getActionsPopup(pos);
+ if(actions == null)
+ return;
+
+ try
+ {
+ StyledDocument doc = (StyledDocument)getDocument();
+ Element e = doc.getCharacterElement(pos);
+ Point pt = modelToView(e.getStartOffset())
+ .getLocation();
+ FontMetrics fm = getFontMetrics(getFont());
+
+ actions.show(this,pt.x,pt.y + fm.getHeight());
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ }
} //}}}
//{{{ MouseHandler class
class MouseHandler extends MouseInputAdapter
{
- public void mouseClicked(MouseEvent e)
+ public void mousePressed(MouseEvent e)
{
Point pt = new Point(e.getX(), e.getY());
int pos = viewToModel(pt);
if(pos >= 0)
- eval(getLinkAt(pos));
+ showPopupMenu(pos);
}
public void mouseMoved(MouseEvent e)
@@ -204,7 +256,7 @@ public class FactorListener extends JTextPane
if(pos >= 0)
{
Cursor cursor;
- if(getLinkAt(pos) != null)
+ if(getActions(pos) != null)
cursor = MoveCursor;
else
cursor = DefaultCursor;
@@ -215,12 +267,20 @@ public class FactorListener extends JTextPane
}
} //}}}
+ //{{{ EvalAction class
+ class EvalAction extends AbstractAction
+ {
+ public void actionPerformed(ActionEvent evt)
+ {
+ eval(evt.getActionCommand());
+ }
+ } //}}}
+
//{{{ EnterAction class
class EnterAction extends AbstractAction
{
public void actionPerformed(ActionEvent evt)
{
- setCaretPosition(getDocument().getLength());
replaceSelection("\n");
try
diff --git a/library/httpd/inspect-responder.factor b/library/httpd/inspect-responder.factor
index 47dd4e4dfb..f99a6e47ba 100644
--- a/library/httpd/inspect-responder.factor
+++ b/library/httpd/inspect-responder.factor
@@ -36,5 +36,5 @@ USE: httpd-responder
: inspect-responder ( argument -- )
serving-html dup [
- describe-object-path
+ describe-path
] simple-html-document ;
diff --git a/library/init.factor b/library/init.factor
index 472baf92bc..b9b58d236d 100644
--- a/library/init.factor
+++ b/library/init.factor
@@ -99,11 +99,13 @@ USE: words
"builtins"
"combinators"
"compiler"
+ "continuations"
"errors"
"debugger"
"hashtables"
"inspector"
"interpreter"
+ "jedit"
"kernel"
"lists"
"logic"
@@ -112,6 +114,7 @@ USE: words
"parser"
"prettyprint"
"stack"
+ "streams"
"stdio"
"strings"
"test"
diff --git a/library/inspector.factor b/library/inspector.factor
index f7a2268288..d65f304d88 100644
--- a/library/inspector.factor
+++ b/library/inspector.factor
@@ -109,8 +109,8 @@ USE: vectors
[ prettyprint ]
] cond ;
-: describe-object-path ( string -- )
- [
- dup "object-path" set
- "'" split global [ object-path ] bind describe
- ] with-scope ;
+: lookup ( str -- object )
+ global [ "'" split object-path ] bind ;
+
+: describe-path ( string -- )
+ [ dup "object-path" set lookup describe ] with-scope ;
diff --git a/library/platform/jvm/listener.factor b/library/platform/jvm/listener.factor
index c188f3e24c..b18ec29391 100644
--- a/library/platform/jvm/listener.factor
+++ b/library/platform/jvm/listener.factor
@@ -64,20 +64,30 @@ USE: unparser
"java.awt.Color"
jnew ;
-: link-key ( -- attr )
- "factor.listener.FactorListener" "Link" jvar-static-get
+: actions-key ( -- attr )
+ "factor.listener.FactorListener" "Actions" jvar-static-get
; inline
-: obj>listener-link ( obj -- link )
- #! Listener links are quotations.
- dup string? [
- ! Inspector link.
- unparse " describe-object-path" cat2
- ] when ;
+: actions ( -- list )
+ [
+ [ "describe-path" | "Describe" ]
+ [ "lookup" | "Push" ]
+ [ "lookup jedit" | "jEdit" ]
+ [ "lookup usages." | "Usages" ]
+ ] ;
+
+: ( path pair -- pair )
+ uncons >r " " swap cat3 r> cons ;
+
+: ( path -- alist )
+ unparse actions [ dupd ] inject nip ;
+
+: underline-attribute ( attribute-set -- )
+ t "Underline" swing-attribute+ ;
: link-attribute ( attribute-set target -- )
- [ dup t "Underline" swing-attribute+ ] dip
- obj>listener-link link-key attribute+ ;
+ over underline-attribute
+ actions-key attribute+ ;
: style>attribute-set ( -- attribute-set )