1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-25 09:12:24 +00:00

Re-arrange the sums in the size tip code so as to ensure that we're always do

division on positive numbers, hence avoiding nasty problems of rounding
towards zero when I wanted rounding down.

[originally from svn r2443]
This commit is contained in:
Ben Harris 2003-01-04 00:48:13 +00:00
parent 7c40e3434d
commit e13dfa3562

View File

@ -1,4 +1,4 @@
/* $Id: macterm.c,v 1.32 2003/01/04 00:13:18 ben Exp $ */ /* $Id: macterm.c,v 1.33 2003/01/04 00:48:13 ben Exp $ */
/* /*
* Copyright (c) 1999 Simon Tatham * Copyright (c) 1999 Simon Tatham
* Copyright (c) 1999, 2002 Ben Harris * Copyright (c) 1999, 2002 Ben Harris
@ -792,7 +792,7 @@ void request_paste(void *frontend)
static struct { static struct {
Rect msgrect; Rect msgrect;
Point msgorigin; Point msgorigin;
Point startmouse; Point zeromouse;
Session *s; Session *s;
char oldmsg[20]; char oldmsg[20];
} growterm_state; } growterm_state;
@ -810,7 +810,9 @@ void mac_growterm(WindowPtr window, EventRecord *event) {
draghooksave = LMGetDragHook(); draghooksave = LMGetDragHook();
growterm_state.oldmsg[0] = '\0'; growterm_state.oldmsg[0] = '\0';
growterm_state.startmouse = event->where; growterm_state.zeromouse = event->where;
growterm_state.zeromouse.h -= s->term->cols * s->font_width;
growterm_state.zeromouse.v -= s->term->rows * s->font_height;
growterm_state.s = s; growterm_state.s = s;
GetPort(&portsave); GetPort(&portsave);
SetPort(s->window); SetPort(s->window);
@ -851,11 +853,9 @@ static pascal void mac_growtermdraghook(void)
int newrows, newcols; int newrows, newcols;
GetMouse(&mouse); GetMouse(&mouse);
newrows = (mouse.v - growterm_state.startmouse.v) / s->font_height + newrows = (mouse.v - growterm_state.zeromouse.v) / s->font_height;
s->term->rows;
if (newrows < 1) newrows = 1; if (newrows < 1) newrows = 1;
newcols = (mouse.h - growterm_state.startmouse.h) / s->font_width + newcols = (mouse.h - growterm_state.zeromouse.h) / s->font_width;
s->term->cols;
if (newcols < 1) newcols = 1; if (newcols < 1) newcols = 1;
sprintf(buf, "%dx%d", newcols, newrows); sprintf(buf, "%dx%d", newcols, newrows);
if (strcmp(buf, growterm_state.oldmsg) == 0) if (strcmp(buf, growterm_state.oldmsg) == 0)