action menus shown when listener links clicked
parent
5c00ef85dd
commit
f7b77cbba7
|
@ -10,7 +10,6 @@
|
||||||
- multitasking
|
- multitasking
|
||||||
- review doc formatting with latex2html
|
- review doc formatting with latex2html
|
||||||
- sidekick: error source not removed
|
- sidekick: error source not removed
|
||||||
- array index out of bounds
|
|
||||||
|
|
||||||
[error] AWT-EventQueue-0: java.lang.NullPointerException
|
[error] AWT-EventQueue-0: java.lang.NullPointerException
|
||||||
[error] AWT-EventQueue-0: at sidekick.SideKickParsedData.getTreePathForPosition(Unknown Source)
|
[error] AWT-EventQueue-0: at sidekick.SideKickParsedData.getTreePathForPosition(Unknown Source)
|
||||||
|
@ -40,8 +39,11 @@
|
||||||
|
|
||||||
+ listener/plugin:
|
+ listener/plugin:
|
||||||
|
|
||||||
|
- lineno/file for shuffle defs
|
||||||
|
- balance needs USE:
|
||||||
|
- input style after clicking link
|
||||||
|
- completion: enter no good
|
||||||
- completion: don't show automatically
|
- completion: don't show automatically
|
||||||
- debug sidekick
|
|
||||||
- completion in the listener
|
- completion in the listener
|
||||||
- special completion for USE:/IN:
|
- special completion for USE:/IN:
|
||||||
- fedit broken with listener
|
- fedit broken with listener
|
||||||
|
@ -60,6 +62,8 @@
|
||||||
|
|
||||||
+ JVM compiler:
|
+ JVM compiler:
|
||||||
|
|
||||||
|
- compiled stack traces broken
|
||||||
|
- save classes to disk
|
||||||
- tail call optimization broken again
|
- tail call optimization broken again
|
||||||
- don't compile inline words
|
- don't compile inline words
|
||||||
- recursive words with code after ifte
|
- recursive words with code after ifte
|
||||||
|
@ -71,7 +75,6 @@
|
||||||
|
|
||||||
+ misc:
|
+ misc:
|
||||||
|
|
||||||
- compiled stack traces broken
|
|
||||||
- namespace clone drops static var bindings
|
- namespace clone drops static var bindings
|
||||||
- ditch map
|
- ditch map
|
||||||
- ditch expand
|
- ditch expand
|
||||||
|
@ -85,7 +88,6 @@
|
||||||
- log-client: fix for native
|
- log-client: fix for native
|
||||||
- if user clicks stop in browser, doesn't stop sending?
|
- if user clicks stop in browser, doesn't stop sending?
|
||||||
- log with date
|
- log with date
|
||||||
- log user agent
|
|
||||||
- add a socket timeout
|
- add a socket timeout
|
||||||
- if a directory is requested and URL does not end with /, redirect
|
- if a directory is requested and URL does not end with /, redirect
|
||||||
- return more header fields, like Content-Length, Last-Modified, and so on
|
- return more header fields, like Content-Length, Last-Modified, and so on
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
</ACTION>
|
</ACTION>
|
||||||
<ACTION NAME="factor-edit">
|
<ACTION NAME="factor-edit">
|
||||||
<CODE>
|
<CODE>
|
||||||
factorWordOperation(view,"USE: jedit jedit");
|
factorWordOperation(view,"jedit");
|
||||||
</CODE>
|
</CODE>
|
||||||
</ACTION>
|
</ACTION>
|
||||||
<ACTION NAME="factor-usages">
|
<ACTION NAME="factor-usages">
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
factorEval(view,
|
factorEval(view,
|
||||||
"[ " + textArea.selectedText + " ] balance");
|
"[ " + textArea.selectedText + " ] balance .");
|
||||||
}
|
}
|
||||||
</CODE>
|
</CODE>
|
||||||
</ACTION>
|
</ACTION>
|
||||||
|
|
|
@ -35,7 +35,7 @@ import java.io.*;
|
||||||
|
|
||||||
public class FactorInterpreter implements FactorObject, Runnable
|
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.
|
// command line arguments are stored here.
|
||||||
public Cons args;
|
public Cons args;
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -49,6 +49,7 @@ public class FactorListener extends JTextPane
|
||||||
(Cursor.WAIT_CURSOR);
|
(Cursor.WAIT_CURSOR);
|
||||||
|
|
||||||
public static final Object Link = new Object();
|
public static final Object Link = new Object();
|
||||||
|
public static final Object Actions = new Object();
|
||||||
|
|
||||||
private EventListenerList listenerList;
|
private EventListenerList listenerList;
|
||||||
|
|
||||||
|
@ -145,6 +146,7 @@ public class FactorListener extends JTextPane
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
StyledDocument doc = (StyledDocument)getDocument();
|
StyledDocument doc = (StyledDocument)getDocument();
|
||||||
|
setCaretPosition(doc.getLength());
|
||||||
doc.insertString(doc.getLength(),eval + "\n",
|
doc.insertString(doc.getLength(),eval + "\n",
|
||||||
getCharacterAttributes());
|
getCharacterAttributes());
|
||||||
}
|
}
|
||||||
|
@ -174,27 +176,77 @@ public class FactorListener extends JTextPane
|
||||||
}
|
}
|
||||||
} //}}}
|
} //}}}
|
||||||
|
|
||||||
//{{{ getLinkAt() method
|
//{{{ getAttributes() method
|
||||||
private String getLinkAt(int pos)
|
private AttributeSet getAttributes(int pos)
|
||||||
{
|
{
|
||||||
StyledDocument doc = (StyledDocument)getDocument();
|
StyledDocument doc = (StyledDocument)getDocument();
|
||||||
Element e = doc.getCharacterElement(pos);
|
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)
|
if(a == null)
|
||||||
return null;
|
return null;
|
||||||
else
|
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
|
//{{{ MouseHandler class
|
||||||
class MouseHandler extends MouseInputAdapter
|
class MouseHandler extends MouseInputAdapter
|
||||||
{
|
{
|
||||||
public void mouseClicked(MouseEvent e)
|
public void mousePressed(MouseEvent e)
|
||||||
{
|
{
|
||||||
Point pt = new Point(e.getX(), e.getY());
|
Point pt = new Point(e.getX(), e.getY());
|
||||||
int pos = viewToModel(pt);
|
int pos = viewToModel(pt);
|
||||||
if(pos >= 0)
|
if(pos >= 0)
|
||||||
eval(getLinkAt(pos));
|
showPopupMenu(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseMoved(MouseEvent e)
|
public void mouseMoved(MouseEvent e)
|
||||||
|
@ -204,7 +256,7 @@ public class FactorListener extends JTextPane
|
||||||
if(pos >= 0)
|
if(pos >= 0)
|
||||||
{
|
{
|
||||||
Cursor cursor;
|
Cursor cursor;
|
||||||
if(getLinkAt(pos) != null)
|
if(getActions(pos) != null)
|
||||||
cursor = MoveCursor;
|
cursor = MoveCursor;
|
||||||
else
|
else
|
||||||
cursor = DefaultCursor;
|
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
|
//{{{ EnterAction class
|
||||||
class EnterAction extends AbstractAction
|
class EnterAction extends AbstractAction
|
||||||
{
|
{
|
||||||
public void actionPerformed(ActionEvent evt)
|
public void actionPerformed(ActionEvent evt)
|
||||||
{
|
{
|
||||||
setCaretPosition(getDocument().getLength());
|
|
||||||
replaceSelection("\n");
|
replaceSelection("\n");
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -36,5 +36,5 @@ USE: httpd-responder
|
||||||
|
|
||||||
: inspect-responder ( argument -- )
|
: inspect-responder ( argument -- )
|
||||||
serving-html dup [
|
serving-html dup [
|
||||||
describe-object-path
|
describe-path
|
||||||
] simple-html-document ;
|
] simple-html-document ;
|
||||||
|
|
|
@ -99,11 +99,13 @@ USE: words
|
||||||
"builtins"
|
"builtins"
|
||||||
"combinators"
|
"combinators"
|
||||||
"compiler"
|
"compiler"
|
||||||
|
"continuations"
|
||||||
"errors"
|
"errors"
|
||||||
"debugger"
|
"debugger"
|
||||||
"hashtables"
|
"hashtables"
|
||||||
"inspector"
|
"inspector"
|
||||||
"interpreter"
|
"interpreter"
|
||||||
|
"jedit"
|
||||||
"kernel"
|
"kernel"
|
||||||
"lists"
|
"lists"
|
||||||
"logic"
|
"logic"
|
||||||
|
@ -112,6 +114,7 @@ USE: words
|
||||||
"parser"
|
"parser"
|
||||||
"prettyprint"
|
"prettyprint"
|
||||||
"stack"
|
"stack"
|
||||||
|
"streams"
|
||||||
"stdio"
|
"stdio"
|
||||||
"strings"
|
"strings"
|
||||||
"test"
|
"test"
|
||||||
|
|
|
@ -109,8 +109,8 @@ USE: vectors
|
||||||
[ prettyprint ]
|
[ prettyprint ]
|
||||||
] cond ;
|
] cond ;
|
||||||
|
|
||||||
: describe-object-path ( string -- )
|
: lookup ( str -- object )
|
||||||
[
|
global [ "'" split object-path ] bind ;
|
||||||
dup "object-path" set
|
|
||||||
"'" split global [ object-path ] bind describe
|
: describe-path ( string -- )
|
||||||
] with-scope ;
|
[ dup "object-path" set lookup describe ] with-scope ;
|
||||||
|
|
|
@ -64,20 +64,30 @@ USE: unparser
|
||||||
"java.awt.Color"
|
"java.awt.Color"
|
||||||
jnew ;
|
jnew ;
|
||||||
|
|
||||||
: link-key ( -- attr )
|
: actions-key ( -- attr )
|
||||||
"factor.listener.FactorListener" "Link" jvar-static-get
|
"factor.listener.FactorListener" "Actions" jvar-static-get
|
||||||
; inline
|
; inline
|
||||||
|
|
||||||
: obj>listener-link ( obj -- link )
|
: actions ( -- list )
|
||||||
#! Listener links are quotations.
|
[
|
||||||
dup string? [
|
[ "describe-path" | "Describe" ]
|
||||||
! Inspector link.
|
[ "lookup" | "Push" ]
|
||||||
unparse " describe-object-path" cat2
|
[ "lookup jedit" | "jEdit" ]
|
||||||
] when ;
|
[ "lookup usages." | "Usages" ]
|
||||||
|
] ;
|
||||||
|
|
||||||
|
: <action-menu-item> ( path pair -- pair )
|
||||||
|
uncons >r " " swap cat3 r> cons ;
|
||||||
|
|
||||||
|
: <actions-menu> ( path -- alist )
|
||||||
|
unparse actions [ dupd <action-menu-item> ] inject nip ;
|
||||||
|
|
||||||
|
: underline-attribute ( attribute-set -- )
|
||||||
|
t "Underline" swing-attribute+ ;
|
||||||
|
|
||||||
: link-attribute ( attribute-set target -- )
|
: link-attribute ( attribute-set target -- )
|
||||||
[ dup t "Underline" swing-attribute+ ] dip
|
over underline-attribute
|
||||||
obj>listener-link link-key attribute+ ;
|
<actions-menu> actions-key attribute+ ;
|
||||||
|
|
||||||
: style>attribute-set ( -- attribute-set )
|
: style>attribute-set ( -- attribute-set )
|
||||||
<attribute-set>
|
<attribute-set>
|
||||||
|
|
Loading…
Reference in New Issue