aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Pike <robpike@gmail.com>2010-08-24 10:16:32 -0400
committerRuss Cox <rsc@swtch.com>2010-08-24 10:16:32 -0400
commita208917e7a935c019095acd1acd8165f08a54b7a (patch)
tree378b43ebb788aefc16a02af7fd6ab6fb64f9b0cd
parenta06877afa9b778570f599e0e8fa83347426fa0b9 (diff)
downloadplan9port-a208917e7a935c019095acd1acd8165f08a54b7a.tar.gz
plan9port-a208917e7a935c019095acd1acd8165f08a54b7a.tar.bz2
plan9port-a208917e7a935c019095acd1acd8165f08a54b7a.zip
acme: fix rounding in rows computation
R=rsc CC=codebot http://codereview.appspot.com/2007045
-rw-r--r--CONTRIBUTORS3
-rw-r--r--src/cmd/acme/rows.c9
2 files changed, 8 insertions, 4 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 21efdc2d..544ba99d 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -21,8 +21,9 @@ Mathieu Lonjaret <mathieu.lonjaret@gmail.com>
Michael Teichgräber <mt4swm@googlemail.com>
Michael Teichgräber <mt@ib.wmipf.de>
Nikolai Saoukh <nikolai.saoukh@gmail.com>
+Rob Pike <robpike@gmail.com>
Russ Cox <rsc@swtch.com>
Tim Newsham <tim.newsham@gmail.com>
Tony Lainson <t.lainson@gmail.com>
Venkatesh Srinivas <extrudedaluminiu@gmail.com>
-grai <t.lainson@gmail.com>
+
diff --git a/src/cmd/acme/rows.c b/src/cmd/acme/rows.c
index 36e244b4..c57a41b0 100644
--- a/src/cmd/acme/rows.c
+++ b/src/cmd/acme/rows.c
@@ -102,12 +102,14 @@ rowadd(Row *row, Column *c, int x)
void
rowresize(Row *row, Rectangle r)
{
- int i, dx, odx;
- Rectangle r1, r2;
+ int i, dx, odx, deltax;
+ Rectangle or, r1, r2;
Column *c;
dx = Dx(r);
odx = Dx(row->r);
+ or = row->r;
+ deltax = r.min.x - or.min.x;
row->r = r;
r1 = r;
r1.max.y = r1.min.y + font->height;
@@ -121,10 +123,11 @@ rowresize(Row *row, Rectangle r)
for(i=0; i<row->ncol; i++){
c = row->col[i];
r1.min.x = r1.max.x;
+ /* the test should not be necessary, but guarantee we don't lose a pixel */
if(i == row->ncol-1)
r1.max.x = r.max.x;
else
- r1.max.x = r1.min.x+Dx(c->r)*dx/odx;
+ r1.max.x = (c->r.max.x-or.min.x)*Dx(r)/Dx(or) + deltax;
if(i > 0){
r2 = r1;
r2.max.x = r2.min.x+Border;