about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@wmii.de>2006-07-13 10:25:57 +0200
committerAnselm R. Garbe <garbeam@wmii.de>2006-07-13 10:25:57 +0200
commit3f942f9e798d4222116ae4c083d2482ddb1e972b (patch)
tree7fcba837c725e30fe6e687fa8d1074093fa74726
parent7e433694ffa59c5b47f216409d5fd2d68b77742e (diff)
downloaddwm-3f942f9e798d4222116ae4c083d2482ddb1e972b.tar.gz
removed obsolete stuff
-rw-r--r--mouse.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/mouse.c b/mouse.c
index ff81701..041ab03 100644
--- a/mouse.c
+++ b/mouse.c
@@ -1,6 +1,5 @@
 /*
  * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
- * (C)opyright MMVI Kris Maglione <fbsdaemon@gmail.com>
  * See LICENSE file for license details.
  */
 
@@ -17,10 +16,10 @@ void
 mresize(Client *c)
 {
 	XEvent ev;
-	int old_cx, old_cy;
+	int ocx, ocy;
 
-	old_cx = c->x;
-	old_cy = c->y;
+	ocx = c->x;
+	ocy = c->y;
 	if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
 				None, cursor[CurResize], CurrentTime) != GrabSuccess)
 		return;
@@ -34,10 +33,10 @@ mresize(Client *c)
 			break;
 		case MotionNotify:
 			XFlush(dpy);
-			c->w = abs(old_cx - ev.xmotion.x);
-			c->h = abs(old_cy - ev.xmotion.y);
-			c->x = (old_cx <= ev.xmotion.x) ? old_cx : old_cx - c->w;
-			c->y = (old_cy <= ev.xmotion.y) ? old_cy : old_cy - c->h;
+			c->w = abs(ocx - ev.xmotion.x);
+			c->h = abs(ocy - ev.xmotion.y);
+			c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
+			c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
 			resize(c);
 			break;
 		case ButtonRelease:
@@ -51,12 +50,12 @@ void
 mmove(Client *c)
 {
 	XEvent ev;
-	int x1, y1, old_cx, old_cy, di;
+	int x1, y1, ocx, ocy, di;
 	unsigned int dui;
 	Window dummy;
 
-	old_cx = c->x;
-	old_cy = c->y;
+	ocx = c->x;
+	ocy = c->y;
 	if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
 				None, cursor[CurMove], CurrentTime) != GrabSuccess)
 		return;
@@ -70,8 +69,8 @@ mmove(Client *c)
 			break;
 		case MotionNotify:
 			XFlush(dpy);
-			c->x = old_cx + (ev.xmotion.x - x1);
-			c->y = old_cy + (ev.xmotion.y - y1);
+			c->x = ocx + (ev.xmotion.x - x1);
+			c->y = ocy + (ev.xmotion.y - y1);
 			resize(c);
 			break;
 		case ButtonRelease:
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
// So far instructions can only contain linear lists of properties. Now we add
// support for more complex trees of properties in dilated reagents. This will
// come in handy later for expressing complex types, like "a dictionary from
// (address to array of charaters) to (list of numbers)".
//
// Type trees aren't as general as s-expressions even if they look like them:
// the first element of a type tree is always an atom, and it can never be
// dotted (right->right->right->...->right is always NULL).
//
// For now you can't use the simpler 'colon-based' representation inside type
// trees. Once you start typing parens, keep on typing parens.

void test_dilated_reagent_with_nested_brackets() {
  load(
      "def main [\n"
      "  {1: number, foo: (bar (baz quux))} <- copy 34\n"
      "]\n"
  );
  CHECK_TRACE_CONTENTS(
      "parse:   product: {1: \"number\", \"foo\": (\"bar\" (\"baz\" \"quux\"))}\n"
  );
}

:(before "End Parsing Dilated Reagent Property(value)")
value = parse_string_tree(value);
:(before "End Parsing Dilated Reagent Type Property(type_names)")
type_names = parse_string_tree(type_names);

:(code)
string_tree* parse_string_tree(string_tree* s) {
  assert(s->atom);
  if (!starts_with(s->value, "(")) return s;
  string_tree* result = parse_string_tree(s->value);
  delete s;
  return result;
}

string_tree* parse_string_tree(const string& s) {
  istringstream in(s);
  in >> std::noskipws;
  return parse_string_tree(in);
}

string_tree* parse_string_tree(istream& in) {
  skip_whitespace_but_not_newline(in);
  if (!has_data(in)) return NULL;
  if (in.peek() == ')') {
    in.get();
    return NULL;
  }
  if (in.peek() != '(') {
    string s = next_word(in);
    if (s.empty()) {
      assert(!has_data(in));
      raise << "incomplete string tree at end of file (0)\n" << end();
      return NULL;
    }
    string_tree* result = new string_tree(s);
    return result;
  }
  in.get();  // skip '('
  string_tree* result = NULL;
  string_tree** curr = &result;
  while (true) {
    skip_whitespace_but_not_newline(in);
    assert(has_data(in));
    if (in.peek() == ')') break;
    *curr = new string_tree(NULL, NULL);
    if (in.peek() == '(') {
      (*curr)->left = parse_string_tree(in);
    }
    else {
      string s = next_word(in);
      if (s.empty()) {
        assert(!has_data(in));
        raise << "incomplete string tree at end of file (1)\n" << end();
        return NULL;
      }
      (*curr)->left = new string_tree(s);
    }
    curr = &(*curr)->right;
  }
  in.get();  // skip ')'
  assert(*curr == NULL);
  return result;
}

void test_dilated_reagent_with_type_tree() {
  Hide_errors = true;  // 'map' isn't defined yet
  load(
      "def main [\n"
      "  {1: (foo (address array character) (bar number))} <- copy 34\n"
      "]\n"
      "container foo [\n"
      "]\n"
      "container bar [\n"
      "]\n"
  );
  CHECK_TRACE_CONTENTS(
      "parse:   product: {1: (\"foo\" (\"address\" \"array\" \"character\") (\"bar\" \"number\"))}\n"
  );
}

void test_dilated_empty_tree() {
  load(
      "def main [\n"
      "  {1: number, foo: ()} <- copy 34\n"
      "]\n"
  );
  CHECK_TRACE_CONTENTS(
      "parse:   product: {1: \"number\", \"foo\": ()}\n"
  );
}

void test_dilated_singleton_tree() {
  load(
      "def main [\n"
      "  {1: number, foo: (bar)} <- copy 34\n"
      "]\n"
  );
  CHECK_TRACE_CONTENTS(
      "parse:   product: {1: \"number\", \"foo\": (\"bar\")}\n"
  );
}