void put(String name, Box b, Object value) { put(b, value); }
static {
- //#repeat fillcolor/strokecolor
- specialBoxProperties.put("fillcolor", new SpecialBoxProperty() {
+ //#repeat fill/stroke fillcolor/strokecolor
+ specialBoxProperties.put("fill", new SpecialBoxProperty() {
public Object get(Box b) {
if ((b.fillcolor & 0xFF000000) == 0) return null;
String red = Integer.toHexString((b.fillcolor & 0x00FF0000) >> 16);
//#end
specialBoxProperties.put("color", new SpecialBoxProperty() {
- public Object get(Box b) { return b.get("fillcolor"); }
- public void put(Box b, Object value) { b.put("fillcolor", value); }
+ public Object get(Box b) { return b.get("fill"); }
+ public void put(Box b, Object value) { b.put("fill", value); }
});
specialBoxProperties.put("textcolor", new SpecialBoxProperty() {
- public Object get(Box b) { return b.get("strokecolor"); }
- public void put(Box b, Object value) { b.put("strokecolor", value); }
+ public Object get(Box b) { return b.get("stroke"); }
+ public void put(Box b, Object value) { b.put("stroke", value); }
});
specialBoxProperties.put("text", new SpecialBoxProperty() {
// Everything Else ////////////////////////////////////////////////////////////////////////////
private synchronized void connect() throws IOException {
+ if (originalUrl.equals("stdio:")) {
+ in = new BufferedInputStream(System.in);
+ return;
+ }
if (sock != null) {
if (in == null) in = new BufferedInputStream(sock.getInputStream());
return;
public void sendRequest(String contentType, String content) throws IOException {
- PrintWriter pw = new PrintWriter(new OutputStreamWriter(sock.getOutputStream()));
+ PrintWriter pw = new PrintWriter(new OutputStreamWriter(originalUrl.equals("stdio:") ? System.out : sock.getOutputStream()));
if (content != null) {
pw.print("POST " + path + " HTTP/1.1\r\n");
int contentLength = content.substring(0, 2).equals("\r\n") ?
if (url.startsWith("file:") && permitLocalFilesystem) return new File(url.substring(5));
if (url.startsWith("cab:")) return new CAB(stringToRes(url.substring(4)));
if (url.startsWith("data:")) return new ByteArray(Base64.decode(url.substring(5)));
+ if (url.startsWith("utf8:")) return new ByteArray(url.substring(5).getBytes());
throw new JS.Exn("invalid resource specifier " + url);
}
t.apply(b, callback, xwt);
}
- PerInstantiationScope pis = new PerInstantiationScope(b, xwt, parentPis);
+ PerInstantiationScope pis = new PerInstantiationScope(b, xwt, parentPis, staticScope);
for (int i=0; children != null && i<children.size(); i++) {
Box kid = new Box();
((Template)children.elementAt(i)).apply(kid, callback, xwt, pis);
private static class PerInstantiationScope extends JS.Scope {
XWT xwt = null;
PerInstantiationScope parentBoxPis = null;
+ JS.Scope myStatic = null;
void putDollar(String key, Box target) {
if (parentBoxPis != null) parentBoxPis.putDollar(key, target);
declare("$" + key);
put("$" + key, target);
}
- public PerInstantiationScope(Scope parentScope, XWT xwt, PerInstantiationScope parentBoxPis) {
+ public PerInstantiationScope(Scope parentScope, XWT xwt, PerInstantiationScope parentBoxPis, JS.Scope myStatic) {
super(parentScope);
this.parentBoxPis = parentBoxPis;
this.xwt = xwt;
+ this.myStatic = myStatic;
}
public boolean isTransparent() { return true; }
public boolean has(Object key) { return false; }
public void declare(String s) { super.declare(s); }
public Object get(Object key) {
if (key.equals("xwt")) return xwt;
+ if (key.equals("static")) return myStatic;
if (Box.SpecialBoxProperty.specialBoxProperties.get(key.toString()) != null) return getParentScope().get(key);
if (super.has(key)) return super.get(key);
Object ret = xwt.rr.get(key);
private Trap() { }
public Object perform() throws JS.Exn {
- if (f.getNumFormalArgs() > 0) return cascade();
- return f.call(new TrapArgs(this));
+ try {
+ if (f.getNumFormalArgs() > 0) return cascade();
+ return f.call(new TrapArgs(this));
+ } catch (Exception e) {
+ Log.log(this, "Exception thrown from within trap: " + e);
+ return null;
+ }
}
public void perform(Object val) throws JS.Exn {
- if (f.getNumFormalArgs() == 0) cascade(val);
- TrapArgs ta = new TrapArgs(this, val);
- Object ret = f.call(ta);
- if (ret != Boolean.FALSE && !ta.cascadeHappened) cascade(val);
+ try {
+ if (f.getNumFormalArgs() == 0) cascade(val);
+ TrapArgs ta = new TrapArgs(this, val);
+ Object ret = f.call(ta);
+ if (ret != Boolean.FALSE && !ta.cascadeHappened) cascade(val);
+ } catch (Exception e) {
+ Log.log(this, "Exception thrown from within trap: " + e);
+ }
}
public Object cascade() {
public Object get(Object name) {
if (name.equals("alt")) return Surface.alt ? Boolean.TRUE : Boolean.FALSE;
else if (name.equals("rr")) return rr;
+ else if (name.equals("box")) return new Box();
else if (name.equals("control")) return Surface.control ? Boolean.TRUE : Boolean.FALSE;
else if (name.equals("shift")) return Surface.shift ? Boolean.TRUE : Boolean.FALSE;
else if (name.equals("clipboard")) return Platform.getClipBoard();
return new SOAP(args.elementAt(0).toString(), "", args.elementAt(1).toString(), args.elementAt(2).toString());
else return null;
- } else if (method.equals("newBox")) {
- if (checkOnly) return Boolean.TRUE;
- return new Box();
-
} else if (method.equals("sleep")) {
if (checkOnly) return Boolean.TRUE;
if (args != null && (args.length() != 1 || args.elementAt(0) == null)) return null;