From 68d68b51b97b9892c46cdd5b65e40b4af8d20e0b Mon Sep 17 00:00:00 2001 From: moculus Date: Mon, 16 Jul 2007 22:43:11 +0000 Subject: [PATCH] --HG-- branch : pmacs2 --- code_examples/Reporting2.pm | 6 +++- lex3.py | 70 ++++++++++++++++++------------------- mode2.py | 43 ++++++++++++++++++++++- point2.py | 14 ++++++-- 4 files changed, 93 insertions(+), 40 deletions(-) diff --git a/code_examples/Reporting2.pm b/code_examples/Reporting2.pm index 14e2d19..b0a22a5 100644 --- a/code_examples/Reporting2.pm +++ b/code_examples/Reporting2.pm @@ -7,7 +7,11 @@ sub foo { unless 9 && 3; } -#@@:string:mode_sql.SqlGrammar +#@@:heredoc:mode_sql.SqlGrammar +my $s = < p.y: + newp = Point(p2.x, p2.y + ydelta) + elif ydelta == 0: + newp = Point(p2.x + xdelta, p2.y) + else: + newp = Point(p2.x, p2.y + ydelta) + ghist.setdefault(name, {}) + ghist[name][newp] = self.ghist[name][p2] + self.ghist = ghist def region_removed(self, p1, p2): if self.tabber is not None: self.tabber.region_removed(p1, p2) + if self.lexer and False: + ydelta = p2.y - p1.y + xdelta = p2.x - p1.x + ghist = {} + for name in self.ghist: + for p in self.ghist[name]: + if p < p1: + newp = p + elif p1 <= p and p < p2: + continue + elif ydelta == 0: + if p.y == p2.y: + newp = Point(p.x - xdelta, p.y) + else: + newp = p + else: + if p.y == p2.y: + newp = Point(p.x - xdelta, p.y - ydelta) + else: + newp = Point(p.x, p.y - ydelta) + ghist.setdefault(name, {}) + ghist[name][newp] = self.ghist[name][p] + self.ghist = ghist diff --git a/point2.py b/point2.py index 18e48a2..c011239 100644 --- a/point2.py +++ b/point2.py @@ -21,12 +21,22 @@ class Point(tuple): '''Returns a tuple (x,y)''' return tuple(self) def add(self, xdelta, ydelta): - '''Returns a new point, applying xdelta and ydelta''' + '''Returns a new point, adding xdelta and ydelta''' return Point(self[1] + xdelta, self[0] + ydelta) def vadd(self, xdelta, ydelta): - '''Returns a new point. If ydelta > 0, xdelta is absolute; otherwise, xdelta is relative''' + '''Returns a new point. If ydelta != 0, xdelta is absolute; otherwise, xdelta is relative''' assert xdelta >= 0 and ydelta >= 0, str((xdelta, ydelta)) if ydelta != 0: return Point(xdelta, self[0] + ydelta) else: return Point(self[1] + xdelta, self[0]) + #def sub(self, xdelta, ydelta): + # '''Returns a new point, subtracing xdelta and ydelta''' + # return Point(self[1] - xdelta, self[0] - ydelta) + #def vsub(self, xdelta, ydelta): + # '''Returns a new point. If ydelta != 0, xdelta is absolute; otherwise, xdelta is relative''' + # assert xdelta >= 0 and ydelta >= 0, str((xdelta, ydelta)) + # if ydelta != 0: + # return Point(self[1], self[0] - ydelta) + # else: + # return Point(self[1] - xdelta, self[0])