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

PATCH: (0.54) New command adjusts X and Y directions for contents viewing



I wanted to use d.contents and d.inside to manage contents lists for
nodes.  But using `x' and `y' every time was a pain; I needed to press
them three times each to avance from d.1 to d.inside and from d.2 to
d.contents.  So I added a new command to do it automatically, and I
added a new action node to the action menu to invoke the command.

The command is a perl function, `view_inside()'.  It accepts on
argument, which is a cursor/window number.  It then sets the X
direction in that window to `d.inside' and the Y direction to
`d.contents'.  I did not include a key binding for this function.

I can't make up my mind whether the existing inside/contents system is
a good idea or not.  Over the last couple of days I've made a lot of
notes about how contents lists can be managed, trying to get to the
bottom of this.

The general thrust of the notes is this: Dimensions need to have
semantics associated with them.  For example, if B is linked posward
from A in the d.contents dimension, B is deemed to be contained in A.
If the existing contents system is going to work at all, users must be
able to provide their own semantics for dimensions.  It should be easy
to provide a kitful of common semantics that can be assembled together
to make more complicated semantics.  An example of an item in the Kit:
You should be able to say that a certain dimension is symmetric, which
means that the meaning of the positive and the negative directions are
the same.

I'll write these notes up when I get a chance because I'm really
curious what Ted thinks about it; perhaps I'm not seeing the Big
Picture.

Here's the patch:

--- zigzag.054	Sun Oct 25 02:57:14 1998
+++ zigzag.view_inside	Sun Oct 25 19:59:25 1998
@@ -25,9 +25,15 @@
 # ===================== Change Log
 #
 # Inital zigzag implementation
-# $Id: zigzag,v 0.54 1998/10/08 03:56:21 xanni Exp $
+# $Id: zigzag,v 0.56 1998/10/25 18:47:15 mjd Exp $
 #
 # $Log: zigzag,v $
+# Revision 0.54.0.1  1998/10/25 18:47:15  mjd
+# Implement new function, `view_inside'.
+# Argument: Window/cursor number.
+# Effect:  Adjust X and Y directions in specified window to `d.inside'
+# and `d.contents', respectively.
+#
 # Revision 0.54  1998/10/08 03:56:21  xanni
 # Incorporate Gossamer's changes, fix $TEMP_FILE problem
 #
@@ -205,7 +211,7 @@
   return (
     0 =>        "Home",
       "0-d.1" =>	99,
-      "0+d.2" =>	30,
+      "0+d.2" =>	32,
       "0+d.cursor" =>	11,
     1 =>        "d.1",
       "1-d.1" =>	10,
@@ -270,8 +276,11 @@
       "20-d.1" =>	19,
    30 =>        "#Edit\natcursor_edit(1);",
       "30+d.1" =>	35,
-      "30-d.2" =>	0,
+      "30-d.2" =>	32,
       "30+d.2" =>	40,
+   32 =>        "#Containment\n#MJD 1998 10 25\nview_inside(1);",
+      "32+d.2" =>       30,
+      "32-d.2" =>        0,
    35 =>        "#Clone\natcursor_clone(1);",
       "35-d.1" =>	30,
    40 =>        "#L-ins\natcursor_insert(1, 'L');",
@@ -1654,6 +1663,36 @@
   }
 
   $ZZ{$curs} = substr($ZZ{$curs}, 0, 1) . $ZZ{$ZZ{"$index+d.2"}};
+  $Window_Dirty[$number] = $TRUE;
+}
+
+sub view_inside($) 
+# Rotate dimensions of given cursor so that X=d.inside and Y=d.contents
+# 1998 08 25 MJD (M-J. Dominus) mjd@xxxxxxxxx
+{
+  my $number = @_;
+  my $curs = &get_cursor($number);
+  my $dimension1 = $ZZ{"$CURSOR_HOME+d.1"}; # Dimension list is +d.1 from Cursor home
+  my $d;
+  my ($inside, $contents);
+  my $pass = 0;  # Prevent infinite loop on dimension list by counting passes
+  for ($d = $dimension1; !($inside && $contents) && $pass < 2; $d = $ZZ{"$d+d.2"}) {
+    $pass++ if $d == $dimension1;
+    if ($ZZ{$d} eq 'd.inside') {
+      $inside = $d;
+    } elsif ($ZZ{$d} eq 'd.contents') {
+      $contents = $d;
+    }
+  }
+
+  # Check here for $inside and $contents?
+  # Abort if either is undefined.
+
+  my $curs_x = $ZZ{"$curs+d.1"};
+  my $curs_y = $ZZ{"$curs_x+d.1"};
+
+  $ZZ{$curs_x} = '+' . $ZZ{$inside};
+  $ZZ{$curs_y} = '+' . $ZZ{$contents};
   $Window_Dirty[$number] = $TRUE;
 }