gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz ./Gzz.py gzz/media/impl/FakeTextSpan.java g...


From: Benja Fallenstein
Subject: [Gzz-commits] gzz ./Gzz.py gzz/media/impl/FakeTextSpan.java g...
Date: Wed, 01 Jan 2003 19:00:50 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Benja Fallenstein <address@hidden>      03/01/01 19:00:49

Modified files:
        .              : Gzz.py 
        gzz/media/impl : FakeTextSpan.java 
        gzz/modules/email: DefaultEmailInStorm.java 
        lava/gzz/client: PotionFallbackBinder.java 
        lava/gzz/potion: Call.java 
        lava/gzz/potion/potions: Types.java 
        lava/gzz/zzutil: Place.java 
        test/gzz/modules/email: TestDefaultEmailInStorm.java 
Added files:
        lava/gzz/potion/potions: ConstantExpression.java NewCell.java 

Log message:
        Make some initial potion bindings work (invoked through Gzz.py command 
line option)

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/Gzz.py.diff?tr1=1.57&tr2=1.58&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/media/impl/FakeTextSpan.java.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/modules/email/DefaultEmailInStorm.java.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/client/PotionFallbackBinder.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/potion/Call.java.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/potion/potions/ConstantExpression.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/potion/potions/NewCell.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/potion/potions/Types.java.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/zzutil/Place.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/test/gzz/modules/email/TestDefaultEmailInStorm.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: gzz/Gzz.py
diff -u gzz/Gzz.py:1.57 gzz/Gzz.py:1.58
--- gzz/Gzz.py:1.57     Sat Dec  7 17:09:20 2002
+++ gzz/Gzz.py  Wed Jan  1 19:00:49 2003
@@ -27,14 +27,14 @@
 
 # Flags that can be passed to Gzz.py
 # (prefix with '--' on the command line)
-flagset = ['multiline', 'double-size', 'triple-size', 'lollipop']
+flagset = ['multiline', 'double-size', 'triple-size', 'lollipop',
+           'python-bindings', 'potion-bindings']
 
 
 class Gzz(java.lang.Runnable):
     """The main Gzz client class."""
 
     transient = 0
-    bindings_type = 'java'
     flags = []
 
     def run(self):
@@ -82,8 +82,6 @@
                 gzz.control.commander.AwtCommander(globals())
             if o in ("-t", "--transient"):
                 self.transient = 1
-            if o in ("-p", "--python-bindings"):
-                self.bindings_type = 'python'
             if o[2:] in flagset:
                 self.flags.append(o[2:])
 
@@ -95,13 +93,24 @@
 
 
     def set_defaults(self):
-        if self.bindings_type == 'java':
-            self.binder = gzz.view.DefaultBinder()
-        else:
+        if 'python-bindings' in self.flags:
             print "Using Python bindings"
             import bindings
             self.binder = gzz.client.pythonbinder.PythonBinder(
                 bindings.normal_mode, bindings.edit_mode, bindings.search_mode)
+            
+        elif 'potion-bindings' in self.flags:
+            arr = gzz.client.PotionFallbackBinder.Arrow
+            bindings = java.util.HashMap()
+            bindings.put('Up', arr(1,1,-1))
+            bindings.put('Down', arr(1,1,1))
+            bindings.put('Left', arr(1,0,-1))
+            bindings.put('Right', arr(1,0,1))
+            newCell = gzz.potion.potions.NewCell();
+            bindings.put('n', gzz.potion.CommandCall(newCell, [None]))
+            self.binder = gzz.client.PotionFallbackBinder(bindings)
+        else:
+            self.binder = gzz.view.DefaultBinder()
         
         self.spanType = java.lang.System.getProperty("gzz.spanType")
         self.spaceType = java.lang.System.getProperty("gzz.spaceType")
Index: gzz/gzz/media/impl/FakeTextSpan.java
diff -u gzz/gzz/media/impl/FakeTextSpan.java:1.5 
gzz/gzz/media/impl/FakeTextSpan.java:1.6
--- gzz/gzz/media/impl/FakeTextSpan.java:1.5    Fri Aug  9 19:02:26 2002
+++ gzz/gzz/media/impl/FakeTextSpan.java        Wed Jan  1 19:00:49 2003
@@ -24,20 +24,27 @@
 package gzz.media.impl;
 import gzz.errors.*;
 import gzz.media.*;
+import gzz.util.*;
 
-/** An object that behaves like a text span but is not really stable media.
+/** An object that behaves like a text span but is not stored in a real Storm 
block.
  * Used for things like coordinates or other computer-generated rapidly 
changing
- * content.
+ * content. Must be atomic: if you give one piece away, you give
+ * the whole thing away. Must be short, because the whole thing
+ * is repeated whereever one piece goes. See PEG miniblocks--benja.
  */
 
 public class FakeTextSpan implements TextSpan, java.io.Serializable {
-public static final String rcsid = "$Id: FakeTextSpan.java,v 1.5 2002/08/09 
23:02:26 benja Exp $";
+public static final String rcsid = "$Id: FakeTextSpan.java,v 1.6 2003/01/02 
00:00:49 benja Exp $";
 
     String text;
+    FakeTextScrollBlock sb;
     transient char[] textarr;
-    transient FakeTextScrollBlock sb;
 
     public FakeTextSpan(String s) {
+       String id = URN5Namespace.instance.getStormDataBlockId();
+       id = id + "," + URIUtil.escapeUTF8(s);
+
+       sb = new FakeTextScrollBlock(/*s, id*/);
        this.text = s;
     }
 
@@ -67,8 +74,27 @@
     public String toString() { return "FAKESPAN "+text; }
     public boolean intersects(Span s) { return false; }
 
-    public class FakeTextScrollBlock implements TextScrollBlock {
-       public String getID() { return ""; }
+    protected class FakeTextScrollBlock implements TextScrollBlock {
+       /*
+       protected String str, id;
+
+       protected FakeTextScrollBlock(String id) {
+           if(!id.startsWith("storm:data:"))
+               throw IllegalArgumentException("Cannot handle URI: "+id);
+
+           // ignore everything between storm:data: and :[<mimetype>],<data>
+           int j = id.indexOf(',');
+           int i = id.lastIndexOf(':', j);
+           String type = str.substring(i+1, j);
+           if(!type.equals("") && !type.equals("text/plain;charset=UTF-8"))
+               throw IllegalArgumentException("Cannot handle content type: 
"+type);
+
+           this.str = URIUtil.unescapeUTF8(str.substring(j+1));
+           this.id = id;
+       }
+       */
+
+       public String getID() { return "" /*id*/; }
        public Span getCurrent() { return FakeTextSpan.this; }
        public boolean isFinalized() { return true; }
 
Index: gzz/gzz/modules/email/DefaultEmailInStorm.java
diff -u gzz/gzz/modules/email/DefaultEmailInStorm.java:1.9 
gzz/gzz/modules/email/DefaultEmailInStorm.java:1.10
--- gzz/gzz/modules/email/DefaultEmailInStorm.java:1.9  Sun Dec  8 09:50:04 2002
+++ gzz/gzz/modules/email/DefaultEmailInStorm.java      Wed Jan  1 19:00:49 2003
@@ -25,7 +25,9 @@
 
 import gzz.media.Enfilade1D;
 import gzz.mediaserver.*;
+import gzz.media.*;
 import gzz.media.impl.*;
+import java.io.IOException;
 import java.util.*;
 
 /** A representation of an email stored in Storm, as Xanalogical text.
@@ -40,12 +42,12 @@
     protected Enfilade1D date;
     protected Enfilade1D body;
 
-    public DefaultEmailInStorm(Mediaserver ms, Mediaserver.Id msid) {
+    public DefaultEmailInStorm(Mediaserver ms, Mediaserver.Id msid) throws 
IOException {
         Enfilade1D.Maker maker = new Enfilade1DImpl.Enfilade1DImplMaker();
        Mediaserver.Id bodyId = getBodyId(ms, msid);
        if(bodyId != null) {
-            PermanentTextScroll pts = new PermanentTextScroll(ms, bodyId);
-            body = maker.makeEnfilade(pts.getCurrent());
+           ScrollBlock block = ScrollBlockManager.getScrollBlock(ms, bodyId);
+           body = maker.makeEnfilade(block.getCurrent());
         } else {
             body = maker.makeEnfilade();
        }
Index: gzz/lava/gzz/client/PotionFallbackBinder.java
diff -u gzz/lava/gzz/client/PotionFallbackBinder.java:1.1 
gzz/lava/gzz/client/PotionFallbackBinder.java:1.2
--- gzz/lava/gzz/client/PotionFallbackBinder.java:1.1   Wed Jan  1 17:46:50 2003
+++ gzz/lava/gzz/client/PotionFallbackBinder.java       Wed Jan  1 19:00:49 2003
@@ -7,6 +7,8 @@
 import java.util.*;
 
 public class PotionFallbackBinder implements FallbackBinder {
+    public static boolean dbg = false;
+    private static void pa(String s) { System.out.println(s); }
 
     public CommandCall currentAction;
 
@@ -28,14 +30,19 @@
     public void setFallback(Fallback f) { fallback=f; }
 
     public void keystroke(String k, Fallback.Win win) {
+       if(dbg) pa("Key: "+k);
+
        Object binding = bindings.get(k);
+       if(dbg) pa("Binding: "+binding);
        if(binding == null)
            // no binding for this key
            return;
 
        else if(binding instanceof CommandCall) {
            currentAction = (CommandCall)binding;
+           if(dbg) pa("Replaced currentAction.");
            if(currentAction.isComplete()) {
+               if(dbg) pa("Execute: "+currentAction);
                Map context = getContext(fallback.windows[1]);
                currentAction.execute(context);
                currentAction = null;
@@ -43,22 +50,32 @@
        } else if(binding instanceof Arrow) {
            Arrow a = (Arrow)binding;
            Fallback.Win w = fallback.windows[a.win];
+           AbstractUpdateManager.prioritize(w.getScreen());
 
            if(currentAction == null) {
+               if(dbg) pa("Move.");
                Cell n = w.cursor.s(w.dims[a.axis], a.dir);
                if(n != null) w.cursor = n;
            } else {
                Map context = getContext(w);
                Type t = currentAction.getNextParam();
                FunctionExpression e = t.readDir(a.win, a.axis, a.dir, context);
-               if(e == null) return;
+               if(dbg) pa("Read direction: "+e);
+               if(e == null) {
+                   AbstractUpdateManager.chg();
+                   return;
+               }
                currentAction = (CommandCall)currentAction.setNextParam(e);
+               if(dbg) pa("Updated currentAction: "+currentAction);
                if(currentAction.isComplete()) {
+                   if(dbg) pa("Execute: "+currentAction);
                    currentAction.execute(context);
                    currentAction = null;
                }
            }
        }
+
+       AbstractUpdateManager.chg();
     }
 
     public Map getContext(Fallback.Win win) {
Index: gzz/lava/gzz/potion/Call.java
diff -u gzz/lava/gzz/potion/Call.java:1.5 gzz/lava/gzz/potion/Call.java:1.6
--- gzz/lava/gzz/potion/Call.java:1.5   Wed Jan  1 17:46:50 2003
+++ gzz/lava/gzz/potion/Call.java       Wed Jan  1 19:00:49 2003
@@ -86,7 +86,7 @@
        for(i++; i<params.length; i++)
            n[i] = params[i];
 
-       return newCall(params);
+       return newCall(n);
     }
 
     abstract protected Call newCall(FunctionExpression[] params);
@@ -96,5 +96,20 @@
        for(int i=0; i<params.length; i++)
            result[i] = params[i].evaluate(context);
        return result;
+    }
+
+    public String toString() {
+       StringBuffer buf = new StringBuffer(head.toString());
+       buf.append("[");
+       for(int i=0; i<params.length-1; i++) {
+           buf.append(params[i].toString());
+           buf.append(", ");
+       }
+
+       if(params.length > 0)
+           buf.append(params[params.length-1]);
+
+       buf.append("]");
+       return buf.toString();
     }
 }
Index: gzz/lava/gzz/potion/potions/Types.java
diff -u gzz/lava/gzz/potion/potions/Types.java:1.3 
gzz/lava/gzz/potion/potions/Types.java:1.4
--- gzz/lava/gzz/potion/potions/Types.java:1.3  Wed Jan  1 17:46:50 2003
+++ gzz/lava/gzz/potion/potions/Types.java      Wed Jan  1 19:00:49 2003
@@ -22,14 +22,27 @@
  */
 package gzz.potion.potions;
 import gzz.*;
+import gzz.view.*;
+import gzz.client.*;
 import gzz.potion.*;
+import gzz.zzutil.*;
 import gzz.vob.linebreaking.HChain;
 import java.util.*;
 
 public class Types {
     public static Type CELL = new SimpleType("which cell?");
     public static Type CONNECTION = new SimpleType("which connection?");
-    public static Type PLACE = new SimpleType("which place?");
+
+    public static Type PLACE = new SimpleType("where?") {
+           public FunctionExpression readDir(int win, int axis, int dir,
+                                             Map context) {
+               Fallback.Win w = (Fallback.Win)
+                   context.get(ViewContext.class);
+               
+               Place p = new Place(w.cursor, w.dims[axis], dir);
+               return new ConstantExpression(p, "XXX");
+           }
+       };
     
     public static class SimpleType implements Type {
        protected String question;
Index: gzz/lava/gzz/zzutil/Place.java
diff -u gzz/lava/gzz/zzutil/Place.java:1.1 gzz/lava/gzz/zzutil/Place.java:1.2
--- gzz/lava/gzz/zzutil/Place.java:1.1  Mon Nov 25 18:52:50 2002
+++ gzz/lava/gzz/zzutil/Place.java      Wed Jan  1 19:00:49 2003
@@ -1,14 +1,17 @@
+//(c):Ayse Cirakoglu and Benja Fallenstein
 package gzz.zzutil;
 import gzz.*;
 
 
-public class Place{
+public final class Place {
 
-        public Cell cell;
-
-        public Dim dim;
-        
-        public int dir;
+    public final Cell cell;
+    public final Dim dim;
+    public final int dir;
         
-
-}
\ No newline at end of file
+    public Place(Cell cell, Dim dim, int dir) {
+       this.cell = cell;
+       this.dim = dim;
+       this.dir = dir;
+    }
+}
Index: gzz/test/gzz/modules/email/TestDefaultEmailInStorm.java
diff -u gzz/test/gzz/modules/email/TestDefaultEmailInStorm.java:1.2 
gzz/test/gzz/modules/email/TestDefaultEmailInStorm.java:1.3
--- gzz/test/gzz/modules/email/TestDefaultEmailInStorm.java:1.2 Fri Nov 22 
07:41:29 2002
+++ gzz/test/gzz/modules/email/TestDefaultEmailInStorm.java     Wed Jan  1 
19:00:49 2003
@@ -1,9 +1,9 @@
 package gzz.modules.email;
 
-import gzz.mediaserver.*;
 import gzz.media.impl.*;
+import gzz.mediaserver.*;
+import java.io.*;
 import java.util.*;
-import gzz.modules.email.*;
 
 public class TestDefaultEmailInStorm {
 
@@ -19,7 +19,7 @@
     protected Mediaserver ms;
     Mediaserver.Id msid;
         
-    public TestDefaultEmailInStorm(Mediaserver ms, Mediaserver.Id msid) {
+    public TestDefaultEmailInStorm(Mediaserver ms, Mediaserver.Id msid) throws 
IOException {
        eis = new DefaultEmailInStorm(ms, msid);
         this.ms   = ms;
         this.msid = msid;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]