gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz ./Gzz.py lava/gzz/client/PotionFallbackBind...


From: Benja Fallenstein
Subject: [Gzz-commits] gzz ./Gzz.py lava/gzz/client/PotionFallbackBind...
Date: Mon, 06 Jan 2003 06:57:32 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Benja Fallenstein <address@hidden>      03/01/06 06:57:30

Modified files:
        .              : Gzz.py 
        lava/gzz/client: PotionFallbackBinder.java 
        lava/gzz/potion/potions: Clone.java PrefixOrOther.java 
                                 PrefixOrThis.java 
        lava/gzz/view  : PendingPotionDecorator.java 
Added files:
        lava/gzz/potion/potions: EventKey.java InsertChar.java 
                                 SwitchToNormalMode.java 
                                 SwitchToTextMode.java 
                                 TextCursorLeft.java 
                                 TextCursorRight.java ThisWindow.java 

Log message:
        Changes from Ayse

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/Gzz.py.diff?tr1=1.63&tr2=1.64&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/client/PotionFallbackBinder.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/potion/potions/EventKey.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/potion/potions/InsertChar.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/potion/potions/SwitchToNormalMode.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/potion/potions/SwitchToTextMode.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/potion/potions/TextCursorLeft.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/potion/potions/TextCursorRight.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/potion/potions/ThisWindow.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/potion/potions/Clone.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/potion/potions/PrefixOrOther.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/potion/potions/PrefixOrThis.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/view/PendingPotionDecorator.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: gzz/Gzz.py
diff -u gzz/Gzz.py:1.63 gzz/Gzz.py:1.64
--- gzz/Gzz.py:1.63     Sun Jan  5 06:33:08 2003
+++ gzz/Gzz.py  Mon Jan  6 06:57:29 2003
@@ -123,10 +123,13 @@
                 return m
 
             from gzz.potion.potions import NewCell, Connect, PrefixOrOther, \
-                                          Hop2, Put, PrefixOrRight, 
PrefixOrLeft, \
-                                          RightWindow, LeftWindow, Go, Clone, \
+                                          Hop2, Put, PrefixOrThis, Go, Clone, \
                                            ToggleMark, Quit, ChangeView, 
ChangeDim, \
-                                           Break, Delete, GoToOriginal
+                                           Break, Delete, GoToOriginal, 
ThisWindow, \
+                                          PrefixOrRight, PrefixOrLeft, 
EventKey, \
+                                          InsertChar, TextCursorLeft, \
+                                          TextCursorRight, SwitchToTextMode, \
+                                          SwitchToNormalMode
 
            def const(i):
                from gzz.potion.potions import ConstantExpression
@@ -142,14 +145,14 @@
                 'n': action([NewCell, None]),
                 '-': action([Connect, [PrefixOrOther], None]),
                'h': action([Hop2, None]),
-               'p': action([Put,[RightWindow], [PrefixOrLeft]]),
-                'P': action([Put,[LeftWindow], [PrefixOrRight]]),
+               'p': action([Put,[ThisWindow], [PrefixOrOther]], 1),
+                'P': action([Put,[ThisWindow], [PrefixOrOther]], 0),
                'g': action([Go, [PrefixOrOther]], 1),
                'G': action([Go, [PrefixOrOther]], 0),
                't': action([Clone,[PrefixOrRight], None]),
                 'T': action([Clone,[PrefixOrLeft], None]),
-               'm': action([ToggleMark, [RightWindow]]),
-               'M': action([ToggleMark, [LeftWindow]]),
+               'm': action([ToggleMark, [ThisWindow]], 1),
+               'M': action([ToggleMark, [ThisWindow]], 0),
                'q': action(call([Quit])),
                'Q': action(call([Quit])),
                'x': action(call([ChangeDim, const(0), const(1)])),
@@ -158,15 +161,32 @@
                'Alt-V': action(call([ChangeView, const(-1)])),
                 'b': action(call([Break, None])),
                 'B': action(call([Break, None])),
-                'Delete': action(call([Delete, [PrefixOrRight]])),
-                'Alt-Backspace': action(call([Delete, [PrefixOrRight]])),
-                'Shift-Delete': action(call([Delete, [PrefixOrLeft]])),
-                'Alt-Shift-Delete': action(call([Delete, [PrefixOrLeft]])),
-                'o': action(call([GoToOriginal, [RightWindow]]), 1),
-                'O': action(call([GoToOriginal, [LeftWindow]]), 0),
+                'Delete': action(call([Delete, [PrefixOrThis]])),
+                'Alt-Backspace': action(call([Delete, [PrefixOrThis]])),
+                'Shift-Delete': action(call([Delete, [PrefixOrThis]])),
+                'Alt-Shift-Delete': action(call([Delete, [PrefixOrThis]])),
+                'o': action(call([GoToOriginal, [ThisWindow]]), 1),
+                'O': action(call([GoToOriginal, [ThisWindow]]), 0),
+               'Tab': action(call([SwitchToTextMode])),
+               'Tabulator': action(([SwitchToTextMode])),
            }
 
-            self.binder = gzz.client.PotionFallbackBinder(map(bindings))
+           text_bindings = {
+               gzz.client.PotionFallbackBinder.CHAR_KEY:
+                           action(call([InsertChar, [EventKey]])),
+               'Left': action(call([TextCursorLeft])),
+               'Right': action(call([TextCursorRight])),
+               'Tab': action(call([SwitchToNormalMode])),
+               'Tabulator': action(([SwitchToNormalMode])),
+           }
+
+           bindings = map(bindings)
+           bindingsByMode = java.util.HashMap()
+           bindingsByMode.put(gzz.client.PotionFallbackBinder.NORMAL_MODE,
+                              bindings)
+           bindingsByMode.put("text mode", map(text_bindings))
+
+            self.binder = gzz.client.PotionFallbackBinder(bindingsByMode)
             self.decorators.append(gzz.view.PendingPotionDecorator())
         else:
             self.binder = gzz.view.DefaultBinder()
Index: gzz/lava/gzz/client/PotionFallbackBinder.java
diff -u gzz/lava/gzz/client/PotionFallbackBinder.java:1.4 
gzz/lava/gzz/client/PotionFallbackBinder.java:1.5
--- gzz/lava/gzz/client/PotionFallbackBinder.java:1.4   Sun Jan  5 05:41:05 2003
+++ gzz/lava/gzz/client/PotionFallbackBinder.java       Mon Jan  6 06:57:29 2003
@@ -13,8 +13,15 @@
     public CommandCall currentCommand;
     public int currentWin;
 
+    public static Object NORMAL_MODE = new Object();
+    public static Object CHAR_KEY = new Object();
+    public static Object ANY_KEY = new Object();
+
+    public static Object THE_KEY = new Object();
+
     protected Fallback fallback;
-    protected Map bindings;
+    protected Map bindingsByMode;
+    public Object mode = NORMAL_MODE;
 
     public Set markedCells = new HashSet();
 
@@ -35,8 +42,8 @@
        }
     }
 
-    public PotionFallbackBinder(Map bindings) {
-       this.bindings = bindings;
+    public PotionFallbackBinder(Map bindingsByMode) {
+       this.bindingsByMode = bindingsByMode;
     }
 
     public void setFallback(Fallback f) { fallback=f; }
@@ -44,7 +51,13 @@
     public void keystroke(String k, Fallback.Win win) {
        if(dbg) pa("Key: "+k);
 
+       Map bindings = (Map)bindingsByMode.get(mode);
        Object binding = bindings.get(k);
+       if(binding == null && k.length() == 1)
+           binding = bindings.get(CHAR_KEY);
+       if(binding == null)
+           binding = bindings.get(ANY_KEY);
+
        if(dbg) pa("Binding: "+binding);
        if(binding == null) {
            // no binding for this key: clear pending
@@ -57,7 +70,7 @@
            if(dbg) pa("Replaced currentCommand.");
            if(currentCommand.isComplete()) {
                if(dbg) pa("Execute: "+currentCommand);
-               Map context = getContext(fallback.windows[currentWin]);
+               Map context = getContext(fallback.windows[currentWin], k);
                currentCommand.execute(context);
                currentCommand = null;
            }
@@ -71,7 +84,7 @@
                Cell n = w.cursor.s(w.dims[a.axis], a.dir);
                if(n != null) w.cursor = n;
            } else {
-               Map context = getContext(w);
+               Map context = getContext(w, k);
                Type t = currentCommand.getNextParam();
                FunctionExpression e = t.readDir(a.win, a.axis, a.dir, context);
                if(dbg) pa("Read direction: "+e);
@@ -92,11 +105,12 @@
        AbstractUpdateManager.chg();
     }
 
-    public Map getContext(Fallback.Win win) {
+    public Map getContext(Fallback.Win win, String key) {
        Map context = new HashMap();
        context.put(Space.class, fallback.space);
        context.put(ViewContext.class, win);
        context.put(PotionFallbackBinder.class, this);
+       context.put(THE_KEY, key);
        return context;
     }
 
Index: gzz/lava/gzz/potion/potions/Clone.java
diff -u gzz/lava/gzz/potion/potions/Clone.java:1.2 
gzz/lava/gzz/potion/potions/Clone.java:1.3
--- gzz/lava/gzz/potion/potions/Clone.java:1.2  Mon Dec  2 20:01:58 2002
+++ gzz/lava/gzz/potion/potions/Clone.java      Mon Jan  6 06:57:29 2003
@@ -19,8 +19,7 @@
            Cell c = (Cell)i.next();
            for(Iterator j=params[1].iterator(); j.hasNext();) {
                Place p = (Place)j.next();
-               c.zzclone();
-               p.cell.insert(p.dim, p.dir, c); 
+               p.cell.insert(p.dim, p.dir, c.zzclone());
            }
        }
     }
Index: gzz/lava/gzz/potion/potions/PrefixOrOther.java
diff -u gzz/lava/gzz/potion/potions/PrefixOrOther.java:1.2 
gzz/lava/gzz/potion/potions/PrefixOrOther.java:1.3
--- gzz/lava/gzz/potion/potions/PrefixOrOther.java:1.2  Sun Jan  5 05:41:06 2003
+++ gzz/lava/gzz/potion/potions/PrefixOrOther.java      Mon Jan  6 06:57:30 2003
@@ -16,8 +16,6 @@
     }
 
     protected List getCells(Map context) {
-       System.out.println("PrefixOrOther.getCell");
-
        PotionFallbackBinder binder =
            (PotionFallbackBinder)context.get(PotionFallbackBinder.class);
 
Index: gzz/lava/gzz/potion/potions/PrefixOrThis.java
diff -u gzz/lava/gzz/potion/potions/PrefixOrThis.java:1.1 
gzz/lava/gzz/potion/potions/PrefixOrThis.java:1.2
--- gzz/lava/gzz/potion/potions/PrefixOrThis.java:1.1   Sat Jan  4 12:44:59 2003
+++ gzz/lava/gzz/potion/potions/PrefixOrThis.java       Mon Jan  6 06:57:30 2003
@@ -8,26 +8,13 @@
 import gzz.*;
 import gzz.potion.*;
 
-public class PrefixOrThis implements Function {
+public class PrefixOrThis extends PrefixOrOther {
 
     protected Cell getCell(Map context) {
-       System.out.println("PrefixOrThis.getCell");
-       Fallback.Win win = (Fallback.Win)context.get(ViewContext.class);
+        Fallback.Win win = (Fallback.Win)context.get(ViewContext.class);
        return win.cursor;
     }
-
-    public List evaluate(List[] params, Map context) {
-       return Collections.nCopies(1, getCell(context));
-    }
-    
     public String getString(Expression[] params, Map context) {
-       return "the cell in this window";
-    }
-       
-    public void render(Expression[] params,Map context, HChain into) {
-    }
-       
-    public Type[] getParams() {
-       return new Type[0];
+        return "the cell in this window";
     }
 }
Index: gzz/lava/gzz/view/PendingPotionDecorator.java
diff -u gzz/lava/gzz/view/PendingPotionDecorator.java:1.2 
gzz/lava/gzz/view/PendingPotionDecorator.java:1.3
--- gzz/lava/gzz/view/PendingPotionDecorator.java:1.2   Sun Jan  5 05:41:06 2003
+++ gzz/lava/gzz/view/PendingPotionDecorator.java       Mon Jan  6 06:57:30 2003
@@ -36,7 +36,7 @@
  *  potion op entered.
  */
 public class PendingPotionDecorator implements FallbackSceneDecorator {
-String rcsid = "$Id: PendingPotionDecorator.java,v 1.2 2003/01/05 10:41:06 
benja Exp $";
+String rcsid = "$Id: PendingPotionDecorator.java,v 1.3 2003/01/06 11:57:30 
benja Exp $";
     public static boolean dbg = false;
     private static void pa(String s) { System.err.println(s); }
 
@@ -59,7 +59,7 @@
        Dimension size = sc.getSize();
        HChain ch = new LinebreakableChain();
 
-       Map context = binder.getContext(win);
+       Map context = binder.getContext(win, null);
        String text = binder.currentCommand.getString(context);
        if(dbg) pa("Potion action text: "+text);
        ch.addBox(text(text));




reply via email to

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