STDWIN 0.9.6 patches, part 2/5
Guido van Rossum
guido at cwi.nl
Fri Jun 7 23:32:00 AEST 1991
Archive-name: stdwin0.9.6/patch2
*** 0.9.5/Packs/textedit/editwin.c Mon Oct 22 13:36:35 1990
--- stdwin/Packs/textedit/editwin.c Tue May 28 22:57:27 1991
***************
*** 63,73 ****
--- 63,77 ----
{
EDITWIN *ew= ALLOC(EDITWIN);
int width, height;
+ int hbar, vbar;
int i;
if (ew == NULL)
return NULL;
+ wgetdefscrollbars(&hbar, &vbar);
+ wsetdefscrollbars(0, 1);
ew->win= wopen(filename==NULL ? "Untitled" : filename, ewdrawproc);
+ wsetdefscrollbars(hbar, vbar);
if (ew->win == NULL) {
FREE(ew);
return NULL;
***************
*** 335,340 ****
--- 339,348 ----
}
break;
+ case WE_CLOSE:
+ closed= ewclose(ew);
+ break;
+
case WE_COMMAND:
if (e->u.command == WC_CLOSE) {
closed= ewclose(ew);
***************
*** 345,351 ****
e->u.command == WC_TAB ||
e->u.command == WC_BACKSPACE)
change= TRUE;
! goto def;
case WE_MOUSE_DOWN:
/* Edit the coordinates slightly so teevent always
--- 353,359 ----
e->u.command == WC_TAB ||
e->u.command == WC_BACKSPACE)
change= TRUE;
! goto def; /* Go pass it on to teevent */
case WE_MOUSE_DOWN:
/* Edit the coordinates slightly so teevent always
*** 0.9.5/Packs/textedit/text.h Thu Oct 18 14:00:07 1990
--- stdwin/Packs/textedit/text.h Tue May 28 22:57:58 1991
***************
*** 22,28 ****
struct _textedit {
/* Drawing environment */
WINDOW *win;
! coord left, top, right, bottom;
hcoord width; /* == right-left */
TEXTATTR attr; /* Text attributes */
vcoord vspace; /* Vertical spacing (line height) */
--- 22,28 ----
struct _textedit {
/* Drawing environment */
WINDOW *win;
! coord left, top, right, bottom; /* Text area */
hcoord width; /* == right-left */
TEXTATTR attr; /* Text attributes */
vcoord vspace; /* Vertical spacing (line height) */
***************
*** 55,61 ****
coord opt_h, opt_v; /* Caret position in window */
hcoord opt_avail; /* White pixels at end of line */
hcoord opt_end; /* End of line or next tab stop */
!
/* NB: aim, opt_h, opt_v are in window coordinates,
i.e., tp->left or tp->top has already been added */
};
--- 55,65 ----
coord opt_h, opt_v; /* Caret position in window */
hcoord opt_avail; /* White pixels at end of line */
hcoord opt_end; /* End of line or next tab stop */
!
! /* View restriction */
! coord vleft, vtop, vright, vbottom; /* View area */
! tbool viewing; /* TRUE to enable view */
!
/* NB: aim, opt_h, opt_v are in window coordinates,
i.e., tp->left or tp->top has already been added */
};
*** 0.9.5/Packs/textedit/textedit.c Thu Feb 21 10:53:57 1991
--- stdwin/Packs/textedit/textedit.c Tue May 28 23:18:47 1991
***************
*** 30,35 ****
--- 30,67 ----
teinsert(tp, cbuf, 1);
}
+ /* Interfaces for wchange and wscroll that clip to the viewing rectangle */
+
+ static void
+ techange(tp, left, top, right, bottom)
+ TEXTEDIT *tp;
+ int left, top, right, bottom;
+ {
+ if (tp->viewing) {
+ CLIPMIN(left, tp->vleft);
+ CLIPMIN(top, tp->vtop);
+ CLIPMAX(right, tp->vright);
+ CLIPMAX(bottom, tp->vbottom);
+ }
+ wchange(tp->win, left, top, right, bottom);
+ }
+
+ static void
+ tescroll(tp, left, top, right, bottom, dh, dv)
+ TEXTEDIT *tp;
+ int left, top, right, bottom;
+ int dh, dv;
+ {
+ if (tp->viewing) {
+ CLIPMIN(left, tp->vleft);
+ CLIPMIN(top, tp->vtop);
+ CLIPMAX(right, tp->vright);
+ CLIPMAX(bottom, tp->vbottom);
+ }
+ wscroll(tp->win, left, top, right, bottom, dh, dv);
+ /* XXX Should call wchange for bits scrolled in from outside view? */
+ }
+
/* Optimization for the common case insert char.
Assumes text measurement is additive. */
***************
*** 110,128 ****
tp->opt_avail -= w;
if (tp->active)
wnocaret(tp->win);
! wscroll(tp->win,
tp->opt_h, tp->opt_v,
tp->opt_end, tp->opt_v + tp->vspace,
w, 0);
wbegindrawing(tp->win);
wdrawchar(tp->opt_h, tp->opt_v, c);
wenddrawing(tp->win);
tp->opt_h += w;
if (tp->active) {
! wsetcaret(tp->win, tp->opt_h, tp->opt_v);
! wshow(tp->win,
! tp->opt_h, tp->opt_v,
! tp->opt_h, tp->opt_v + tp->vspace);
}
tp->aim= tp->opt_h;
--- 142,170 ----
tp->opt_avail -= w;
if (tp->active)
wnocaret(tp->win);
! tescroll(tp,
tp->opt_h, tp->opt_v,
tp->opt_end, tp->opt_v + tp->vspace,
w, 0);
wbegindrawing(tp->win);
+ if (tp->viewing)
+ wcliprect(tp->vleft, tp->vtop, tp->vright, tp->vbottom);
wdrawchar(tp->opt_h, tp->opt_v, c);
wenddrawing(tp->win);
tp->opt_h += w;
if (tp->active) {
! if (!tp->viewing ||
! tp->vleft <= tp->opt_h &&
! tp->opt_h <= tp->vright &&
! tp->vtop <= tp->opt_v &&
! tp->opt_v + tp->vspace <= tp->vbottom) {
! wsetcaret(tp->win, tp->opt_h, tp->opt_v);
! wshow(tp->win,
! tp->opt_h, tp->opt_v,
! tp->opt_h, tp->opt_v + tp->vspace);
! }
! else
! wnocaret(tp->win);
}
tp->aim= tp->opt_h;
***************
*** 205,217 ****
lineno k= chlast;
if (shift > 0)
k -= shift;
! wscroll(tp->win,
tp->left, tp->top + k*tp->vspace,
tp->right, tp->top + tp->nlines*tp->vspace,
0, shift*tp->vspace);
}
! wchange(tp->win,
tp->left, tp->top + chfirst*tp->vspace,
tp->right, tp->top + chlast*tp->vspace);
}
--- 247,259 ----
lineno k= chlast;
if (shift > 0)
k -= shift;
! tescroll(tp,
tp->left, tp->top + k*tp->vspace,
tp->right, tp->top + tp->nlines*tp->vspace,
0, shift*tp->vspace);
}
! techange(tp,
tp->left, tp->top + chfirst*tp->vspace,
tp->right, tp->top + chlast*tp->vspace);
}
***************
*** 219,225 ****
tp->nlines= i+1;
newbottom= tp->top + tp->vspace*tp->nlines;
if (newbottom < tp->bottom)
! wchange(tp->win,
tp->left, newbottom, tp->right, tp->bottom);
tp->bottom= newbottom;
tp->aim= UNDEF;
--- 261,267 ----
tp->nlines= i+1;
newbottom= tp->top + tp->vspace*tp->nlines;
if (newbottom < tp->bottom)
! techange(tp,
tp->left, newbottom, tp->right, tp->bottom);
tp->bottom= newbottom;
tp->aim= UNDEF;
***************
*** 367,379 ****
case WE_MOUSE_DOWN:
{
int h= e->u.where.h, v= e->u.where.v;
! if (h >= tp->left && h <= tp->right &&
! v >= tp->top && v <= tp->bottom)
! teclicknew(tp, h, v,
! e->u.where.button == 2,
! e->u.where.clicks > 1);
! else
! return FALSE;
}
break;
--- 409,428 ----
case WE_MOUSE_DOWN:
{
int h= e->u.where.h, v= e->u.where.v;
! if (tp->viewing) {
! if (h < tp->vleft || h > tp->vright ||
! v < tp->vtop || v > tp->vbottom)
! return FALSE;
! }
! else {
! if (h < tp->left || h > tp->right ||
! v < tp->top || v > tp->bottom)
! return FALSE;
! }
! teclicknew(tp, h, v,
! e->u.where.button == 3 ||
! (e->u.where.mask & WM_SHIFT),
! e->u.where.clicks > 1);
}
break;
***************
*** 644,649 ****
--- 693,717 ----
}
void
+ tesetview(tp, left, top, right, bottom)
+ TEXTEDIT *tp;
+ int left, top, right, bottom;
+ {
+ tp->viewing= TRUE;
+ tp->vleft= left;
+ tp->vtop= top;
+ tp->vright= right;
+ tp->vbottom= bottom;
+ }
+
+ void
+ tenoview(tp)
+ TEXTEDIT *tp;
+ {
+ tp->viewing= FALSE;
+ }
+
+ void
tesetfocus(tp, foc1, foc2)
TEXTEDIT *tp;
focpos foc1, foc2;
***************
*** 712,718 ****
if (buf == NULL || buflen < 0)
return;
if (drawing)
! wchange(tp->win, tp->left, tp->top, tp->right, tp->bottom);
free(tp->buf);
tp->buf= buf;
tp->buflen= buflen;
--- 780,786 ----
if (buf == NULL || buflen < 0)
return;
if (drawing)
! techange(tp, tp->left, tp->top, tp->right, tp->bottom);
free(tp->buf);
tp->buf= buf;
tp->buflen= buflen;
***************
*** 721,727 ****
terecompute(tp, 0, tp->buflen);
if (drawing) {
tp->drawing= TRUE;
! wchange(tp->win, tp->left, tp->top, tp->right, tp->bottom);
}
}
--- 789,795 ----
terecompute(tp, 0, tp->buflen);
if (drawing) {
tp->drawing= TRUE;
! techange(tp, tp->left, tp->top, tp->right, tp->bottom);
}
}
*** 0.9.5/Packs/textedit/textlow.c Mon Oct 22 13:37:36 1990
--- stdwin/Packs/textedit/textlow.c Tue May 28 23:19:12 1991
***************
*** 1,5 ****
--- 1,7 ----
/* Text Edit, low-level routines */
+ /* XXX Should make return-less functions void */
+
/* CONVENTION:
routines beginning with te... have a first parameter 'tp';
routines beginning with z... don't, or are macros that
***************
*** 199,204 ****
--- 201,208 ----
tp->top= top;
tp->right= right;
tp->width= right-left;
+
+ tp->viewing= FALSE;
wgettextattr(&saveattr);
if (win != NULL) {
***************
*** 247,253 ****
tedestroy(tp)
register TEXTEDIT *tp;
{
! wchange(tp->win, tp->left, tp->top, tp->right, tp->bottom);
tefree(tp);
}
--- 251,260 ----
tedestroy(tp)
register TEXTEDIT *tp;
{
! if (tp->viewing)
! wchange(tp->win, tp->vleft, tp->vtop, tp->vright, tp->vbottom);
! else
! wchange(tp->win, tp->left, tp->top, tp->right, tp->bottom);
tefree(tp);
}
***************
*** 294,299 ****
--- 301,308 ----
{
if (tp->active && !tp->hilite && tp->foclen > 0) {
wbegindrawing(tp->win);
+ if (tp->viewing)
+ wcliprect(tp->vleft, tp->vtop, tp->vright, tp->vbottom);
teinvertfocus(tp);
wenddrawing(tp->win);
tp->hilite= TRUE;
***************
*** 305,310 ****
--- 314,321 ----
{
if (tp->hilite) {
wbegindrawing(tp->win);
+ if (tp->viewing)
+ wcliprect(tp->vleft, tp->vtop, tp->vright, tp->vbottom);
teinvertfocus(tp);
wenddrawing(tp->win);
tp->hilite= FALSE;
***************
*** 327,332 ****
--- 338,345 ----
{
if (tp->hilite) {
wbegindrawing(tp->win);
+ if (tp->viewing)
+ wcliprect(tp->vleft, tp->vtop, tp->vright, tp->vbottom);
if (f1 == tp->foc)
teinvert(tp, zfocend, f2);
else if (f2 == zfocend)
***************
*** 379,385 ****
tedrawnew(tp, tp->left, tp->top, tp->right, tp->bottom);
}
- /*ARGSUSED*/
void
tedrawnew(tp, left, top, right, bottom)
register TEXTEDIT *tp;
--- 392,397 ----
***************
*** 386,392 ****
--- 398,415 ----
coord left, top, right, bottom;
{
lineno ifirst, ilast, i;
+
+ /* Clip given area to view */
+ if (tp->viewing) {
+ CLIPMIN(left, tp->vleft);
+ CLIPMIN(top, tp->vtop);
+ CLIPMAX(right, tp->vright);
+ CLIPMAX(bottom, tp->vbottom);
+ }
+ /* Restrict drawing to intersection of view and given area */
+ wcliprect(left, top, right, bottom);
+
/* Compute first, last line to be drawn */
ifirst= (top - tp->top)/tp->vspace;
if (ifirst < 0)
***************
*** 408,413 ****
--- 431,439 ----
}
if (tp->hilite)
teinvertfocus(tp);
+
+ /* Reset the clip rectangle */
+ wnoclip();
}
/* Move the gap to a new position */
***************
*** 522,527 ****
--- 548,569 ----
tp->start[i]= zgapend;
}
+ /* Interface for wshow that clips to the viewing rectangle */
+
+ static void
+ teshow(tp, left, top, right, bottom)
+ TEXTEDIT *tp;
+ int left, top, right, bottom;
+ {
+ if (tp->viewing) {
+ CLIPMIN(left, tp->vleft);
+ CLIPMIN(top, tp->vtop);
+ CLIPMAX(right, tp->vright);
+ CLIPMAX(bottom, tp->vbottom);
+ }
+ wshow(tp->win, left, top, right, bottom);
+ }
+
/* Set the caret at the new focus position,
or display the focus highlighting, if applicable.
Also call wshow() of the focus.
***************
*** 539,545 ****
tewhichpoint(tp, tp->foc, &h, &v);
if (tp->foclen == 0) {
! wsetcaret(tp->win, h, v);
hlast= h;
vlast= v;
}
--- 581,594 ----
tewhichpoint(tp, tp->foc, &h, &v);
if (tp->foclen == 0) {
! if (!tp->viewing ||
! tp->vleft <= h && h <= tp->vright &&
! tp->vtop <= v && v + tp->vspace <= tp->vbottom) {
! wsetcaret(tp->win, h, v);
! }
! else {
! wnocaret(tp->win);
! }
hlast= h;
vlast= v;
}
***************
*** 548,554 ****
wnocaret(tp->win);
teshowfocus(tp);
}
! wshow(tp->win, h, v, hlast, vlast + tp->vspace);
}
/* Coordinate transformations.
--- 597,603 ----
wnocaret(tp->win);
teshowfocus(tp);
}
! teshow(tp, h, v, hlast, vlast + tp->vspace);
}
/* Coordinate transformations.
*** 0.9.5/Packs/vt/vt.c Mon Oct 22 15:06:06 1990
--- stdwin/Packs/vt/vt.c Tue May 14 13:16:40 1991
***************
*** 15,20 ****
--- 15,21 ----
int left, int top, int right, int bottom));
STATIC void vtdraw _ARGS((VT *vt, int r1, int c1, int r2, int c2));
STATIC void vtchrange _ARGS((VT *vt, int r1, int c1, int r2, int c2));
+ STATIC bool slowcirculate _ARGS((VT *vt, int r1, int r2, int n));
/* Administration for vtfind */
*** 0.9.5/Packs/vt/vtvtrm.c Mon Oct 22 15:46:08 1990
--- stdwin/Packs/vt/vtvtrm.c Tue May 14 13:17:29 1991
***************
*** 7,12 ****
--- 7,13 ----
One other thing: you'll have to call wdone() when you really exit. */
/* XXX This has never been tested... */
+ /* XXX The interfaces to trmputdata and trmsense should change !!! */
#include "vtimpl.h"
#include "vtrm.h"
***************
*** 30,36 ****
*rows_return= 24;
*cols_return= 80;
*flags_return=
! HAS_STANDOUT | CAN_SCROLL | CAN_SENSE;
return TE_OK;
}
--- 31,37 ----
*rows_return= 24;
*cols_return= 80;
*flags_return=
! HAS_STANDOUT | CAN_SCROLL;
return TE_OK;
}
***************
*** 39,44 ****
--- 40,46 ----
active= FALSE;
}
+ /* XXX Need interface change */
trmputdata(row, col, data)
int row, col;
char *data;
***************
*** 130,135 ****
--- 132,138 ----
}
}
+ /* XXX Need interface change */
int
trmsense(row_return, col_return)
int *row_return, *col_return;
*** 0.9.5/Ports/alfa/draw.c Tue Jan 8 13:03:32 1991
--- stdwin/Ports/alfa/draw.c Sun May 12 13:54:10 1991
***************
*** 3,8 ****
--- 3,9 ----
#include "alfa.h"
static char *textline[MAXLINES];
+ static char *modeline[MAXLINES];
static short textlen[MAXLINES];
static char texttouched[MAXLINES];
***************
*** 112,117 ****
--- 113,119 ----
for (i= top; i < bottom; ++i)
uptodate[i] = FALSE;
#else
+ /* XXX This code was never fixed to update the mode array */
char *p;
if(dv==0)
***************
*** 238,255 ****
wbegindrawing(win)
WINDOW *win;
{
! int i;
if (draw_win != NULL)
wenddrawing(draw_win); /* Finish previous job */
! /* Auto-initialization of the textline array.
The other arrays needn't be initialized,
since they are preset to zero. */
for (i= win->top; i < win->bottom; ++i) {
if (textline[i] == NULL)
textline[i]= malloc((unsigned) (columns+1));
! /*uptodate[i]= FALSE;*/
}
draw_saveattr= wattr;
--- 240,262 ----
wbegindrawing(win)
WINDOW *win;
{
! int i, j;
if (draw_win != NULL)
wenddrawing(draw_win); /* Finish previous job */
! /* Auto-initialization of the textline and modeline array.
The other arrays needn't be initialized,
since they are preset to zero. */
+ /* XXX Crash if malloc() fails! */
for (i= win->top; i < win->bottom; ++i) {
if (textline[i] == NULL)
textline[i]= malloc((unsigned) (columns+1));
! if (modeline[i] == NULL) {
! modeline[i]= malloc((unsigned) columns);
! for (j = 0; j < columns; j++)
! modeline[i][j] = PLAIN;
! }
}
draw_saveattr= wattr;
***************
*** 271,277 ****
if (texttouched[i]) {
texttouched[i]= FALSE;
textline[i][textlen[i]]= EOS;
! trmputdata(i, i, 0, textline[i]);
}
}
--- 278,284 ----
if (texttouched[i]) {
texttouched[i]= FALSE;
textline[i][textlen[i]]= EOS;
! trmputdata(i, i, 0, textline[i], modeline[i]);
}
}
***************
*** 292,307 ****
int k;
for (k= 0; k < space/2 - 1; ++k)
! buf[k]= '-'|mask;
! buf[k++]= ' '|mask;
while (k < columns && *title != EOS)
! buf[k++]= *title++|mask;
if (k < columns)
! buf[k++]= ' '|mask;
while (k < columns)
! buf[k++]= '-'|mask;
buf[k]= EOS;
! trmputdata(titline, titline, 0, buf);
uptodate[titline]= TRUE;
}
--- 299,323 ----
int k;
for (k= 0; k < space/2 - 1; ++k)
! buf[k]= '-';
! buf[k++]= ' ';
while (k < columns && *title != EOS)
! buf[k++]= *title++;
if (k < columns)
! buf[k++]= ' ';
while (k < columns)
! buf[k++]= '-';
buf[k]= EOS;
! if (win == front) {
! char mode[256];
! int i;
! for (i = 0; i < k; i++)
! mode[i] = STANDOUT;
! trmputdata(titline, titline, 0, buf, mode);
! }
! else {
! trmputdata(titline, titline, 0, buf, (char *)0);
! }
uptodate[titline]= TRUE;
}
***************
*** 312,319 ****
int len;
{
int k;
! int mask= (wattr.style == 0) ? 0 : 0200;
char *text;
WINDOW *win= draw_win;
if (len < 0)
--- 328,336 ----
int len;
{
int k;
! int flag= (wattr.style == 0) ? PLAIN : STANDOUT;
char *text;
+ char *mode;
WINDOW *win= draw_win;
if (len < 0)
***************
*** 322,333 ****
if (v < win->top || v >= win->bottom || h >= columns || len == 0)
return;
text= textline[v];
k= textlen[v];
! while (k < h)
! text[k++]= ' ';
while (len > 0) {
#define APPC(c) \
! if (h >= 0) text[h]= (c) | mask; if (++h >= columns) break
unsigned char c= *str++;
--len;
if (c < ' ') {
--- 339,353 ----
if (v < win->top || v >= win->bottom || h >= columns || len == 0)
return;
text= textline[v];
+ mode= modeline[v];
k= textlen[v];
! for (; k < h; k++) {
! text[k]= ' ';
! mode[k]= PLAIN;
! }
while (len > 0) {
#define APPC(c) \
! if (h >= 0) {text[h]= (c); mode[h]= flag;} if (++h >= columns) break
unsigned char c= *str++;
--len;
if (c < ' ') {
***************
*** 407,412 ****
--- 427,448 ----
/*ARGSUSED*/
void
+ wfillcircle(h, v, radius)
+ int h, v;
+ int radius;
+ {
+ }
+
+ /*ARGSUSED*/
+ void
+ wxorcircle(h, v, radius)
+ int h, v;
+ int radius;
+ {
+ }
+
+ /*ARGSUSED*/
+ void
wdrawelarc(h, v, radh, radv, ang1, ang2)
int h, v;
int radh, radv;
***************
*** 416,421 ****
--- 452,475 ----
/*ARGSUSED*/
void
+ wfillelarc(h, v, radh, radv, ang1, ang2)
+ int h, v;
+ int radh, radv;
+ int ang1, ang2;
+ {
+ }
+
+ /*ARGSUSED*/
+ void
+ wxorelarc(h, v, radh, radv, ang1, ang2)
+ int h, v;
+ int radh, radv;
+ int ang1, ang2;
+ {
+ }
+
+ /*ARGSUSED*/
+ void
wdrawbox(left, top, right, bottom)
int left, top, right, bottom;
{
***************
*** 459,472 ****
for (v= top; v < bottom; ++v) {
int k= textlen[v];
char *text= textline[v];
if (k < right) {
do {
! text[k++]= ' ';
} while (k < right);
textlen[v]= k;
}
! for (k= left; k < right; ++k)
! text[k] ^= 0200;
texttouched[v]= TRUE;
}
}
--- 513,533 ----
for (v= top; v < bottom; ++v) {
int k= textlen[v];
char *text= textline[v];
+ char *mode= modeline[v];
if (k < right) {
do {
! text[k]= ' ';
! mode[k]= PLAIN;
! k++;
} while (k < right);
textlen[v]= k;
}
! for (k= left; k < right; ++k) {
! if (mode[k] != PLAIN)
! mode[k]= PLAIN;
! else
! mode[k]= STANDOUT;
! }
texttouched[v]= TRUE;
}
}
***************
*** 494,503 ****
for (v= top; v < bottom; ++v) {
int k= textlen[v];
char *text= textline[v];
if (k > right)
k= right;
! while (--k >= left)
text[k]= ' ';
texttouched[v]= TRUE;
}
}
--- 555,567 ----
for (v= top; v < bottom; ++v) {
int k= textlen[v];
char *text= textline[v];
+ char *mode= modeline[v];
if (k > right)
k= right;
! while (--k >= left) {
text[k]= ' ';
+ mode[k]= PLAIN;
+ }
texttouched[v]= TRUE;
}
}
***************
*** 504,509 ****
--- 568,597 ----
/*ARGSUSED*/
void
+ wdrawpoly(n, points)
+ int n;
+ POINT *points;
+ {
+ }
+
+ /*ARGSUSED*/
+ void
+ wfillpoly(n, points)
+ int n;
+ POINT *points;
+ {
+ }
+
+ /*ARGSUSED*/
+ void
+ wxorpoly(n, points)
+ int n;
+ POINT *points;
+ {
+ }
+
+ /*ARGSUSED*/
+ void
wcliprect(left, top, right, bottom)
int left, top, right, bottom;
{
***************
*** 515,518 ****
--- 603,654 ----
wnoclip()
{
/* XXX not implemented */
+ }
+
+ /*ARGSUSED*/
+ void
+ wsetfont(fontname)
+ char *fontname;
+ {
+ }
+
+ /*ARGSUSED*/
+ void
+ wsetsize(size)
+ int size;
+ {
+ }
+
+ /*ARGSUSED*/
+ COLOR
+ wfetchcolor(colorname)
+ char *colorname;
+ {
+ return 0;
+ }
+
+ /*ARGSUSED*/
+ void
+ wsetfgcolor(color)
+ COLOR color;
+ {
+ }
+
+ COLOR
+ wgetfgcolor()
+ {
+ return 0;
+ }
+
+ /*ARGSUSED*/
+ void
+ wsetbgcolor(color)
+ COLOR color;
+ {
+ }
+
+ COLOR
+ wgetbgcolor()
+ {
+ return 0;
}
*** 0.9.5/Ports/alfa/event.c Thu Oct 18 13:58:28 1990
--- stdwin/Ports/alfa/event.c Tue May 28 18:35:41 1991
***************
*** 223,228 ****
--- 223,230 ----
}
if (ep->window == NULL && front != syswin)
ep->window= front;
+ if (ep->type == WE_COMMAND && ep->u.command == WC_CLOSE)
+ ep->type= WE_CLOSE; /* Too hard to do earlier... */
lasttype= ep->type;
return ep->type != WE_NULL;
}
*** 0.9.5/Ports/alfa/menu.c Mon Oct 29 09:58:17 1990
--- stdwin/Ports/alfa/menu.c Tue Apr 16 16:20:02 1991
***************
*** 497,503 ****
if (lowest < lines)
uptodate[lowest]= FALSE;
}
! trmputdata(i+1, lowest, 0, "");
leftblank= left;
trmsync(curitem+1, mp->left);
}
--- 497,503 ----
if (lowest < lines)
uptodate[lowest]= FALSE;
}
! trmputdata(i+1, lowest, 0, "", (char *)0);
leftblank= left;
trmsync(curitem+1, mp->left);
}
***************
*** 559,566 ****
items on the first menu (after the sysmenu) weren't removed
from the screen. I haven't tried to fix this in a more
efficient manner. */
! trmputdata(line, line, 0, "");
! trmputdata(line, line, leftblank, buf);
uptodate[line]= FALSE;
}
--- 559,566 ----
items on the first menu (after the sysmenu) weren't removed
from the screen. I haven't tried to fix this in a more
efficient manner. */
! trmputdata(line, line, 0, "", (char *)0);
! trmputdata(line, line, leftblank, buf, (char *)0);
uptodate[line]= FALSE;
}
*** 0.9.5/Ports/alfa/stdwin.c Sun Oct 21 12:51:10 1990
--- stdwin/Ports/alfa/stdwin.c Tue Apr 16 16:21:10 1991
***************
*** 16,37 ****
int lines, columns;
! /* Initialization call.
! Should be called only once, before any others.
! Will exit when the initialization fails. */
!
void
! winit()
{
! winitargs((int*)NULL, (char***)NULL);
}
/*ARGSUSED*/
void
! winitargs(pargc, pargv)
int *pargc;
char ***pargv;
{
int flags;
int err;
--- 16,46 ----
int lines, columns;
! /*ARGSUSED*/
void
! winitargs(pargc, pargv)
! int *pargc;
! char ***pargv;
{
! wargs(pargc, pargv);
! winit();
}
/*ARGSUSED*/
void
! wargs(pargc, pargv)
int *pargc;
char ***pargv;
{
+ }
+
+ /* Initialization call.
+ Should be called only once, before any others.
+ Will exit when the initialization fails. */
+
+ void
+ winit()
+ {
int flags;
int err;
***************
*** 59,65 ****
gettckeydefs();
if (lines > MAXLINES)
lines= MAXLINES;
! trmputdata(0, lines-1, 0, "");
initsyswin();
_winitmenus();
}
--- 68,74 ----
gettckeydefs();
if (lines > MAXLINES)
lines= MAXLINES;
! trmputdata(0, lines-1, 0, "", (char *)0);
initsyswin();
_winitmenus();
}
***************
*** 73,79 ****
{
if (lines > 0) {
/* Move cursor to last screen line. */
! trmputdata(lines-1, lines-1, 0, "");
trmsync(lines-1, 0);
}
lines= 0;
--- 82,88 ----
{
if (lines > 0) {
/* Move cursor to last screen line. */
! trmputdata(lines-1, lines-1, 0, "", (char *)0);
trmsync(lines-1, 0);
}
lines= 0;
***************
*** 292,297 ****
--- 301,334 ----
{
}
+ /*ARGSUSED*/
+ void
+ wsetdefscrollbars(width, height)
+ int width, height;
+ {
+ }
+
+ void
+ wgetdefwinpos(ph, pv)
+ int *ph, *pv;
+ {
+ *ph = *pv = 0;
+ }
+
+ void
+ wgetdefwinsize(ph, pv)
+ int *ph, *pv;
+ {
+ *ph = *pv = 0;
+ }
+
+ void
+ wgetdefscrollbars(ph, pv)
+ int *ph, *pv;
+ {
+ *ph = *pv = 0;
+ }
+
/* Make a window the active window. */
void
***************
*** 362,368 ****
uptodate[i]= FALSE;
_wreshuffle();
trmundefined();
! trmputdata(0, lines-1, 0, "");
}
/* Temporarily restore cooked tty mode. */
--- 399,405 ----
uptodate[i]= FALSE;
_wreshuffle();
trmundefined();
! trmputdata(0, lines-1, 0, "", (char *)0);
}
/* Temporarily restore cooked tty mode. */
***************
*** 369,375 ****
_wcooked()
{
! trmputdata(lines-1, lines-1, 0, "");
trmsync(lines-1, 0);
trmend();
}
--- 406,412 ----
_wcooked()
{
! trmputdata(lines-1, lines-1, 0, "", (char *)0);
trmsync(lines-1, 0);
trmend();
}
*** 0.9.5/Ports/alfa/syswin.c Thu Oct 18 13:58:31 1990
--- stdwin/Ports/alfa/syswin.c Tue Apr 16 16:21:35 1991
***************
*** 346,355 ****
while(Butt[y-1]) {
if(y==Curr) sprintf(buf, "%c %s", META('o'), Butt[y-1]);
else sprintf(buf, "o %s", Butt[y-1]);
! trmputdata(y, y, 0, buf);
++y;
}
! trmputdata(y,y,0,"");
}
/* additional EuroMath WM routine, called after returning from an
--- 346,355 ----
while(Butt[y-1]) {
if(y==Curr) sprintf(buf, "%c %s", META('o'), Butt[y-1]);
else sprintf(buf, "o %s", Butt[y-1]);
! trmputdata(y, y, 0, buf, (char *)0);
++y;
}
! trmputdata(y,y,0,"",(char *)0);
}
/* additional EuroMath WM routine, called after returning from an
*** 0.9.5/Ports/mac/about.c Thu Feb 28 12:48:31 1991
--- stdwin/Ports/mac/about.c Tue Mar 26 11:08:03 1991
***************
*** 16,23 ****
Also see your THINK C licence.
*/
char *about_message=
! "STDWIN version 0.9.5 (using THINK C 4.0)\r\r\
! Copyright \251 1988, 1989, 1990 Stichting Mathematisch Centrum, \
Amsterdam\r\
Written by Guido van Rossum (guido at cwi.nl)\r\
CWI, dept. AA, P.O.B. 4079\r1009 AB Amsterdam, The Netherlands\r\r\
--- 16,23 ----
Also see your THINK C licence.
*/
char *about_message=
! "STDWIN version 0.9.5a (using THINK C 4.0)\r\r\
! Copyright \251 1988, 1989, 1990, 1991 Stichting Mathematisch Centrum, \
Amsterdam\r\
Written by Guido van Rossum (guido at cwi.nl)\r\
CWI, dept. AA, P.O.B. 4079\r1009 AB Amsterdam, The Netherlands\r\r\
*** /dev/null Fri Jun 7 14:31:40 1991
--- stdwin/Ports/mac/color.c Tue Apr 9 20:01:40 1991
***************
*** 0 ****
--- 1,44 ----
+ /* MAC STDWIN -- COLOR HANDLING. */
+
+ #include "macwin.h"
+
+ /* Provisional color encoding:
+ - low 16 bits: a color as specified in <QuickDraw.h>
+ - high 16 bits: a shade factor, 0 -> full, 128 -> 50%
+ See also draw.c
+ */
+
+ static struct colorentry {
+ char *name;
+ long color;
+ } colorlist[] = {
+ {"black", blackColor},
+ {"white", whiteColor},
+ {"red", redColor},
+ {"green", greenColor},
+ {"blue", blueColor},
+ {"cyan", cyanColor},
+ {"magenta", magentaColor},
+ {"yellow", yellowColor},
+ {"gray25", blackColor + (192L << 16)},
+ {"gray50", blackColor + (128L << 16)},
+ {"gray75", blackColor + (64L << 16)},
+ {"foreground", blackColor},
+ {"background", whiteColor},
+ {NULL, 0} /* Sentinel */
+ };
+
+ long
+ wfetchcolor(colorname)
+ char *colorname;
+ {
+ struct colorentry *p;
+
+ for (p = colorlist; p->name != NULL; p++) {
+ if (strcmp(p->name, colorname) == 0)
+ return p->color;
+ }
+
+ dprintf("wmakecolor: unknown color '%s'", colorname);
+ return blackColor;
+ }
*** 0.9.5/Ports/mac/cursor.c Tue Feb 19 10:46:44 1991
--- stdwin/Ports/mac/cursor.c Tue Mar 26 10:37:15 1991
***************
*** 31,43 ****
h = GetCursor(plusCursor);
else if (strcmp(name, "watch") == 0)
h = GetCursor(watchCursor);
else if (strcmp(name, "arrow") == 0) {
! /* The arrow is not a resource but a quickdraw global.
! Fake a handle with a static variable. */
static CursPtr arrowptr;
arrowptr = &QD(arrow);
h = &arrowptr;
}
else if (strcmp(name, "hand") == 0) {
/* The hand is hardcoded below */
h = &handcursorptr;
--- 31,46 ----
h = GetCursor(plusCursor);
else if (strcmp(name, "watch") == 0)
h = GetCursor(watchCursor);
+ #if 0
else if (strcmp(name, "arrow") == 0) {
! /* The arrow is only a quickdraw global,
! which we can't use.
! Should have it as a static variable... */
static CursPtr arrowptr;
arrowptr = &QD(arrow);
h = &arrowptr;
}
+ #endif
else if (strcmp(name, "hand") == 0) {
/* The hand is hardcoded below */
h = &handcursorptr;
***************
*** 63,69 ****
void
set_arrow()
{
- /*XXX SetCursor(&QD(arrow)); */
InitCursor();
}
--- 66,71 ----
*** 0.9.5/Ports/mac/dialog.c Wed Nov 7 23:35:19 1990
--- stdwin/Ports/mac/dialog.c Tue Mar 26 11:09:12 1991
***************
*** 60,65 ****
--- 60,69 ----
def= buf;
SFPutFile(PASSPOINT corner, PSTRING(prompt),
#ifdef THINK_C /* XXX ??? */
+ /* XXX I think PSTRING returns a pointer to a static buffer
+ so there can be only one call to PSTRING in an arg list.
+ Maybe I forgot that when I found this code didn't work.
+ Should fix it better! */
CtoPstr(def),
#else
PSTRING(def),
*** 0.9.5/Ports/mac/draw.c Tue Feb 19 10:46:48 1991
--- stdwin/Ports/mac/draw.c Sun Apr 7 16:56:25 1991
***************
*** 8,14 ****
text measuring;
text drawing;
coordinate conversion tools;
! ordinary drawing.
XXX Should be split, only things used between w{begin,end}drawing
belong here.
--- 8,15 ----
text measuring;
text drawing;
coordinate conversion tools;
! ordinary drawing;
! color stuff.
XXX Should be split, only things used between w{begin,end}drawing
belong here.
***************
*** 33,38 ****
--- 34,43 ----
#include <Fonts.h>
#endif
+ COLOR _w_fgcolor = blackColor;
+ COLOR _w_bgcolor = whiteColor;
+ static COLOR save_fgcolor, save_bgcolor;
+
static WINDOW *drawing;
static TEXTATTR drawsaveattr;
static int baseline;
***************
*** 44,49 ****
--- 49,62 ----
STATIC void setwattr _ARGS((TEXTATTR *attr));
STATIC void getfinfo _ARGS((void));
+ /* Patterns -- can't use the QuickDraw globals (sigh) */
+
+ static Pattern pat0 = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+ static Pattern pat25 = {0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44};
+ static Pattern pat50 = {0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa};
+ static Pattern pat75 = {0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd};
+ static Pattern pat100 = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+
void
wchange(win, left, top, right, bottom)
WINDOW *win;
***************
*** 110,116 ****
--- 123,135 ----
DisposeRgn(ur);
}
+ /* ScrollRect seems to work only in normal mode */
+ ForeColor(blackColor);
+ BackColor(whiteColor);
ScrollRect(pr, dh, dv, rgn);
+ ForeColor((short)win->fgcolor);
+ BackColor((short)win->bgcolor);
+
InvalRgn(rgn);
DisposeRgn(rgn);
***************
*** 131,137 ****
rmcaret(win);
BeginUpdate(win->w);
EraseRect(&win->w->portRect);
! DrawGrowIcon(win->w);
DrawControls(win->w);
getwinrect(win, pr);
RectRgn(rgn, pr);
--- 150,156 ----
rmcaret(win);
BeginUpdate(win->w);
EraseRect(&win->w->portRect);
! _wgrowicon(win);
DrawControls(win->w);
getwinrect(win, pr);
RectRgn(rgn, pr);
***************
*** 184,189 ****
--- 203,215 ----
PenNormal();
wgettextattr(&drawsaveattr);
wsettextattr(&win->attr);
+
+ save_fgcolor = _w_fgcolor;
+ save_bgcolor = _w_bgcolor;
+ _w_fgcolor = win->fgcolor;
+ _w_bgcolor = win->bgcolor;
+ _w_usefgcolor(_w_fgcolor);
+ _w_usebgcolor(_w_bgcolor);
}
void
***************
*** 200,205 ****
--- 226,237 ----
dprintf("warning: wenddrawing ignored for wrong window");
return;
}
+
+ _w_fgcolor = save_fgcolor;
+ _w_bgcolor = save_bgcolor;
+ _w_usefgcolor(win->fgcolor);
+ _w_usebgcolor(win->bgcolor);
+
SetOrigin(0, 0);
SetRect(&r, -32000, -32000, 32000, 32000);
ClipRect(&r);
***************
*** 509,516 ****
Rect *pr;
{
*pr= win->w->portRect;
! pr->right -= BAR;
! pr->bottom -= BAR;
}
/* ACTUAL DRAW ROUTINES. */
--- 541,550 ----
Rect *pr;
{
*pr= win->w->portRect;
! if (win->vbar != NULL)
! pr->right -= BAR;
! if (win->hbar != NULL)
! pr->bottom -= BAR;
}
/* ACTUAL DRAW ROUTINES. */
***************
*** 568,574 ****
Rect r;
SetRect(&r, left, top, right, bottom);
! FillRect(&r, QD(black));
}
void
--- 602,608 ----
Rect r;
SetRect(&r, left, top, right, bottom);
! FillRect(&r, drawing->w->pnPat);
}
void
***************
*** 577,593 ****
int perc;
{
Rect r;
! unsigned char *p; /* really Pattern * or PatPtr */
perc= (perc + 12)/25;
CLIPMIN(perc, 0);
switch (perc) {
! case 0: p= &QD(white)[0]; break;
! case 1: p= &QD(ltGray)[0]; break;
! case 2: p= &QD(gray)[0]; break;
! case 3: p= &QD(dkGray)[0]; break;
! default: p= &QD(black)[0]; break;
}
SetRect(&r, left, top, right, bottom);
--- 611,627 ----
int perc;
{
Rect r;
! PatPtr p;
perc= (perc + 12)/25;
CLIPMIN(perc, 0);
switch (perc) {
! case 0: p = &pat0; break;
! case 1: p = &pat25; break;
! case 2: p = &pat50; break;
! case 3: p = &pat75; break;
! default: p = &pat100; break;
}
SetRect(&r, left, top, right, bottom);
***************
*** 602,608 ****
{
Rect r;
- /* XXX Isn't there an off-by-one error here? */
SetRect(&r, h-radius, v-radius, h+radius, v+radius);
FrameOval(&r);
}
--- 636,641 ----
***************
*** 615,623 ****
wdrawelarc(h, v, hrad, vrad, ang1, ang2)
{
Rect r;
- /* XXX Does this work? No off-by-one errors? */
SetRect(&r, h-hrad, v-vrad, h+hrad, v+vrad);
! FrameArc(&r, 90-ang1, ang1-ang2); /* ??? */
}
/* CLIPPING */
--- 648,655 ----
wdrawelarc(h, v, hrad, vrad, ang1, ang2)
{
Rect r;
SetRect(&r, h-hrad, v-vrad, h+hrad, v+vrad);
! FrameArc(&r, 90-ang1, ang1-ang2);
}
/* CLIPPING */
***************
*** 640,643 ****
--- 672,738 ----
Rect r;
getwinrect(drawing, &r);
ClipRect(&r);
+ }
+
+ /* COLOR */
+
+ COLOR
+ wgetfgcolor()
+ {
+ return _w_fgcolor;
+ }
+
+ COLOR
+ wgetbgcolor()
+ {
+ return _w_bgcolor;
+ }
+
+ void
+ wsetfgcolor(color)
+ COLOR color;
+ {
+ _w_fgcolor = color;
+ if (drawing)
+ _w_usefgcolor(color);
+ }
+
+ void
+ wsetbgcolor(color)
+ COLOR color;
+ {
+ _w_bgcolor = color;
+ if (drawing)
+ _w_usebgcolor(color);
+ }
+
+ void
+ _w_usefgcolor(color)
+ COLOR color;
+ {
+ ForeColor((short)color);
+ switch (((color >> 16) + 32) / 64) {
+ case 0:
+ PenPat(pat100);
+ break;
+ case 1:
+ PenPat(pat75);
+ break;
+ case 2:
+ PenPat(pat50);
+ break;
+ case 3:
+ PenPat(pat25);
+ break;
+ case 4:
+ PenPat(pat0);
+ break;
+ }
+ }
+
+ void
+ _w_usebgcolor(color)
+ COLOR color;
+ {
+ BackColor((short)color);
}
*** 0.9.5/Ports/mac/event.c Tue Feb 19 10:46:53 1991
--- stdwin/Ports/mac/event.c Tue May 28 22:23:56 1991
***************
*** 9,15 ****
--- 9,18 ----
#endif
#ifdef THINK_C
#include <EventMgr.h>
+ #ifndef THINK_C_3_0
+ #include <console.h> /* See do_update */
#endif
+ #endif
void (*_w_idle_proc)(); /* Function to call in idle loop */
***************
*** 83,88 ****
--- 86,99 ----
if (active == NULL)
set_arrow();
+ else if (active->w != FrontWindow()) {
+ /* Somehow we missed a deactivation event.
+ Fake one now. */
+ ep->type= WE_DEACTIVATE;
+ ep->window= active;
+ deactivate();
+ return;
+ }
ep->type= WE_NULL;
ep->window= NULL;
***************
*** 206,212 ****
win= whichwin((WindowPtr) e.message);
if (win == NULL) {
! /* dprintf("update evt for alien window"); */
return;
}
_wupdate(win, &r);
--- 217,239 ----
win= whichwin((WindowPtr) e.message);
if (win == NULL) {
! /* Update event for a window not created by STDWIN
! (not a Desk Accessory -- these are taken care of
! by GetNextEvent or at some other secret place.)
! This is is problem: if we ignore it, it will come
! back forever, so we'll never be idle again. */
! #ifdef THINK_C
! #ifndef THINK_C_3_0
! /* Most likely, under THINK C 4.0, it is the console
! window. We can force the window to repaint itself
! by calling any console function. A rather harmless
! one is cgetxy. Use stderr as the one least likely
! to be redirected. */
! int x, y;
! if (stderr->window)
! cgetxy(&x, &y, stderr);
! #endif
! #endif
return;
}
_wupdate(win, &r);
***************
*** 227,239 ****
WindowPtr w;
int code= FindWindow(PASSPOINT e.where, &w);
- /* XXX This doesn't look incredibly necessary:
- if (active != NULL) {
- SetPort(active->win);
- rmcaret(active);
- }
- */
-
if (code != inContent && code != inSysWindow)
set_arrow();
switch (code) {
--- 254,259 ----
***************
*** 273,289 ****
do_key(ep)
EVENT *ep;
{
! char c= e.message & charCodeMask;
- /* XXX shouldn't mess at all with non-stdwin windows */
-
if (e.modifiers & cmdKey) {
if (c == '.') {
ep->type= WE_COMMAND;
ep->u.command= WC_CANCEL;
}
! else
! _wdo_menu(ep, MenuKey(c));
}
else {
ep->type= WE_COMMAND;
--- 293,317 ----
do_key(ep)
EVENT *ep;
{
! int c= e.message & charCodeMask;
if (e.modifiers & cmdKey) {
if (c == '.') {
ep->type= WE_COMMAND;
ep->u.command= WC_CANCEL;
}
! else {
! long menu_item= MenuKey(c);
! if (HiWord(menu_item) != 0) {
! _wdo_menu(ep, menu_item);
! }
! else {
! ep->type= WE_KEY;
! ep->u.key.code= c;
! ep->u.key.mask= WM_META;
! /* Should filter out arrow keys? */
! }
! }
}
else {
ep->type= WE_COMMAND;
***************
*** 350,356 ****
return;
/* If we get here we've missed a
deactivate event... */
! dprintf("activate without deactivate");
#endif
}
activate(win);
--- 378,384 ----
return;
/* If we get here we've missed a
deactivate event... */
! /* dprintf("activate without deactivate"); */
#endif
}
activate(win);
***************
*** 381,387 ****
rmcaret(active);
hidescrollbars(active);
rmlocalmenus(active);
! DrawGrowIcon(active->w);
active= NULL;
set_arrow();
}
--- 409,415 ----
rmcaret(active);
hidescrollbars(active);
rmlocalmenus(active);
! _wgrowicon(active);
active= NULL;
set_arrow();
}
***************
*** 492,524 ****
{
Rect r;
long reply;
! /* XXX shouldn't mess at all with non-stdwin windows */
! /* Set minimal window size */
! r.left= LSLOP + MIN_WIDTH + RSLOP + BAR;
! r.top= MIN_HEIGHT + BAR;
! /* The max size is derived from the document size.
! If there is no document size, it is unlimited.
! (There is nothing wrong with windows larger than
! the screen, really.) */
! r.right = r.bottom = 0x7fff;
! {
! /* Max size restriction based on doc size, if specified */
! WINDOW *win = whichwin(w);
! int docwidth = win->docwidth;
! int docheight = win->docheight;
! if (win->docwidth > 0) {
! CLIPMIN(docwidth, MIN_WIDTH);
! r.right = LSLOP + docwidth + RSLOP + BAR + 1;
! }
! if (win->docheight > 0) {
! CLIPMIN(docheight, MIN_HEIGHT);
! r.bottom = docheight + BAR + 1;
! }
! /* For some reason 1 has to be added. Sigh. */
! }
reply= GrowWindow(w, PASSPOINT e.where, &r);
if (reply != 0) {
--- 520,548 ----
{
Rect r;
long reply;
+ WINDOW *win = whichwin(w);
! /* Don't mess at all with non-stdwin windows */
! if (win == NULL)
! return;
! /* Set minimal window size --
! 1x1 at least, plus space needed for scroll bars */
! r.left = LSLOP + 1 + RSLOP;
! r.top = 1;
! if (win->hbar != NULL)
! r.left = 3*BAR;
! if (win->vbar != NULL)
! r.top = 3*BAR;
! if (win->vbar != NULL)
! r.left += BAR;
! if (win->hbar != NULL)
! r.top += BAR;
! /* Windows may become as large as the user can get them,
! within reason -- the limit 0x7000 should avoid integer
! overflow in QuickDraw. */
! r.right = r.bottom = 0x7000;
reply= GrowWindow(w, PASSPOINT e.where, &r);
if (reply != 0) {
***************
*** 537,545 ****
/* XXX shouldn't mess at all with non-stdwin windows */
if (TrackGoAway(w, PASSPOINT e.where)) {
! ep->type= WE_COMMAND;
ep->window= whichwin(w);
- ep->u.command= WC_CLOSE;
}
}
--- 561,568 ----
/* XXX shouldn't mess at all with non-stdwin windows */
if (TrackGoAway(w, PASSPOINT e.where)) {
! ep->type= WE_CLOSE;
ep->window= whichwin(w);
}
}
***************
*** 596,608 ****
WindowPtr w;
{
Rect r;
! r= w->portRect;
! r.left= r.right - BAR;
! InvalRect(&r);
! r= w->portRect;
! r.top= r.bottom - BAR;
! InvalRect(&r);
}
void
--- 619,636 ----
WindowPtr w;
{
Rect r;
+ WINDOW *win = whichwin(w);
! if (win->vbar != NULL) {
! r = w->portRect;
! r.left = r.right - BAR;
! InvalRect(&r);
! }
! if (win->hbar != NULL) {
! r = w->portRect;
! r.top = r.bottom - BAR;
! InvalRect(&r);
! }
}
void
***************
*** 610,622 ****
WindowPtr w;
{
Rect r;
! r= w->portRect;
! r.left= r.right - BAR;
! ValidRect(&r);
! r= w->portRect;
! r.top= r.bottom - BAR;
! ValidRect(&r);
}
/* Variables needed in click and move detection. */
--- 638,655 ----
WindowPtr w;
{
Rect r;
+ WINDOW *win = whichwin(w);
! if (win->vbar != NULL) {
! r = w->portRect;
! r.left = r.right - BAR;
! ValidRect(&r);
! }
! if (win->hbar != NULL) {
! r = w->portRect;
! r.top = r.bottom - BAR;
! ValidRect(&r);
! }
}
/* Variables needed in click and move detection. */
***************
*** 624,631 ****
static int m_h, m_v; /* Doc. coord. of last mouse evt. */
static long m_when; /* TickCount of last mouse evt. */
static int m_clicks; /* N-fold click stage */
- static int m_button; /* Which 'button';
- 1=normal, 2=shift, 3=command. */
static void
make_mouse_event(ep, pwhere)
--- 657,662 ----
***************
*** 637,644 ****
int v= pwhere->v + win->orgv;
int dh= h - m_h;
int dv= v - m_v;
! if (dh*dh + dv*dv > CLICK_DIST*CLICK_DIST)
m_clicks= 0; /* Moved too much for a click */
if (e.what == mouseDown) {
--- 668,676 ----
int v= pwhere->v + win->orgv;
int dh= h - m_h;
int dv= v - m_v;
+ int mask;
! if (m_clicks != 0 && dh*dh + dv*dv > CLICK_DIST*CLICK_DIST)
m_clicks= 0; /* Moved too much for a click */
if (e.what == mouseDown) {
***************
*** 648,657 ****
++m_clicks;
ep->type= WE_MOUSE_DOWN;
_wm_down= TRUE;
- /* XXX Should swap buttons 2 & 3 (also in textedit)
- since X11 (e.g., xterm) uses button 3 for extend */
- m_button= (e.modifiers & cmdKey) ? 3 :
- (e.modifiers & shiftKey) ? 2 : 1;
}
else if (e.what == mouseUp) {
if (!_wm_down)
--- 680,685 ----
***************
*** 664,674 ****
return;
ep->type= WE_MOUSE_MOVE;
}
ep->u.where.h= m_h= h;
ep->u.where.v= m_v= v;
ep->u.where.clicks= m_clicks;
! ep->u.where.button= m_button;
! ep->u.where.mask= (ep->type == WE_MOUSE_UP) ? 0 : 1;
ep->window= win;
m_when= e.when;
}
--- 692,713 ----
return;
ep->type= WE_MOUSE_MOVE;
}
+ mask= (ep->type == WE_MOUSE_UP) ? 0 : WM_BUTTON1;
+ if (e.modifiers & cmdKey)
+ mask |= WM_META;
+ if (e.modifiers & shiftKey)
+ mask |= WM_SHIFT;
+ if (e.modifiers & alphaLock)
+ mask |= WM_LOCK;
+ if (e.modifiers & optionKey)
+ mask |= WM_OPTION;
+ if (e.modifiers & controlKey)
+ mask |= WM_CONTROL;
ep->u.where.h= m_h= h;
ep->u.where.v= m_v= v;
ep->u.where.clicks= m_clicks;
! ep->u.where.button= 1;
! ep->u.where.mask= mask;
ep->window= win;
m_when= e.when;
}
***************
*** 680,683 ****
--- 719,735 ----
_wresetmouse()
{
_wm_down= FALSE;
+ }
+
+ void
+ wsetactive(win)
+ WINDOW *win;
+ {
+ SelectWindow(win->w);
+ }
+
+ WINDOW *
+ wgetactive()
+ {
+ return whichwin(FrontWindow());
}
*** 0.9.5/Ports/mac/macwin.h Tue Feb 19 10:46:57 1991
--- stdwin/Ports/mac/macwin.h Sun Apr 7 16:55:08 1991
***************
*** 65,70 ****
--- 65,71 ----
#define c2pstr CtoPstr /* XXX actually, used nowhere */
/* Quickdraw globals are real globals in THINK C */
+ /* But don't use them, the console library breaks this!!! */
#define QD(var) (var)
/* THINK C can't declare forward functions as static */
***************
*** 108,113 ****
--- 109,115 ----
struct menubar mbar; /* List of attached local menus */
unsigned long timer; /* Tick count for timer event */
CURSOR *cursor; /* Cursor if not default */
+ COLOR fgcolor, bgcolor; /* Default colors for this window */
};
extern TEXTATTR wattr; /* Current text attributes */
***************
*** 135,150 ****
#define CLICK_DIST 5 /* Max mouse move within a click */
- /* Parameters for top left corner choice algorithm: */
- #define LEFT 20 /* Initial left */
- #define TOP 40 /* Initial top */
- #define HINCR 20 /* Increment for left */
- #define VINCR 16 /* Increment for top */
-
- /* Minimal window size (determined by room for scroll bars only): */
- #define MIN_WIDTH (2*BAR)
- #define MIN_HEIGHT (2*BAR)
-
/* Text drawn in the very left or right margin doesn't look nice.
Therefore, we have a little margin on each side.
Its width is determined here: */
--- 137,142 ----
***************
*** 156,161 ****
--- 148,155 ----
extern WINDOW *active; /* Active window, if any */
extern bool _wmenuhilite; /* Set if menu item highlighted */
extern bool _wm_down; /* Set if mouse down (in appl. area) */
+ extern COLOR _w_fgcolor; /* Current foreground color */
+ extern COLOR _w_bgcolor; /* Current background color */
/* Function prototypes: */
***************
*** 175,184 ****
void set_ibeam _ARGS((void));
void set_hand _ARGS((void));
! void makescrollbars _ARGS((WINDOW *win));
void movescrollbars _ARGS((WINDOW *win));
void hidescrollbars _ARGS((WINDOW *win));
void showscrollbars _ARGS((WINDOW *win));
void scrollby _ARGS((WINDOW *win, Rect *pr, int dh, int dv));
void do_scroll _ARGS((Point *pwhere,
--- 169,180 ----
void set_ibeam _ARGS((void));
void set_hand _ARGS((void));
! void makescrollbars _ARGS((WINDOW *win, /*bool*/int hor, /*bool*/int ver));
void movescrollbars _ARGS((WINDOW *win));
void hidescrollbars _ARGS((WINDOW *win));
void showscrollbars _ARGS((WINDOW *win));
+ void _wgrowicon _ARGS((WINDOW *win));
+ void _wfixorigin _ARGS((WINDOW *));
void scrollby _ARGS((WINDOW *win, Rect *pr, int dh, int dv));
void do_scroll _ARGS((Point *pwhere,
***************
*** 211,216 ****
--- 207,215 ----
bool checktimer _ARGS((EVENT *ep));
void autoscroll _ARGS((WINDOW *active, int h, int v));
void _wdo_menu _ARGS((EVENT *ep, long menu_item));
+
+ void _w_usefgcolor _ARGS((COLOR color));
+ void _w_usebgcolor _ARGS((COLOR color));
/* SetRect is much faster this way... */
#define SetRect(pr, l, t, r, b) ((pr)->left = (l), (pr)->top = (t), \
*** 0.9.5/Ports/mac/pstring.c Wed Nov 7 23:31:34 1990
--- stdwin/Ports/mac/pstring.c Tue Mar 26 11:11:41 1991
***************
*** 18,24 ****
dst = &buf[1];
while ((*dst++ = *src++) != '\0' && dst < &buf[256])
;
! buf[0] = dst - &buf[1];
return buf;
}
--- 18,24 ----
dst = &buf[1];
while ((*dst++ = *src++) != '\0' && dst < &buf[256])
;
! buf[0] = dst - &buf[1] - 1; /* XXX Recent bugfix! */
return buf;
}
*** 0.9.5/Ports/mac/scroll.c Wed Nov 7 23:37:48 1990
--- stdwin/Ports/mac/scroll.c Tue Mar 26 11:15:02 1991
***************
*** 1,3 ****
--- 1,9 ----
+ /*
+ This code is somehow broken.
+ If I click a few times on an arrow of the scroll bar the cursor freezes.
+ Other forms of scrolling don't have this problem. WHAT'S WRONG?!?!?!
+ */
+
/* MAC STDWIN -- SCROLLING. */
/* All non-public functions here assume the current grafport is set */
***************
*** 25,30 ****
--- 31,37 ----
STATIC void setscrollbarvalues _ARGS((WINDOW *win));
STATIC void usescrollbarvalues _ARGS((WINDOW *win));
STATIC void sizescrollbars _ARGS((WINDOW *win));
+ STATIC int calcneworigin _ARGS((int, int, int, int, int));
STATIC void calcbar _ARGS((ControlHandle bar,
int org, int size, int begin, int end));
STATIC void setbar _ARGS((ControlHandle bar, int winsize, int val, int max));
***************
*** 33,38 ****
--- 40,46 ----
STATIC void hidebar _ARGS((ControlHandle bar));
STATIC void movebar _ARGS((ControlHandle bar,
int left, int top, int right, int bottom));
+ void _wfixorigin _ARGS((WINDOW *));
void
wsetorigin(win, orgh, orgv)
***************
*** 187,211 ****
*((WindowPeek)(win->w))->dataHandle;
if (data != NULL) {
if (docwidth > 0) {
- CLIPMIN(docwidth, MIN_WIDTH);
data->stdState.right =
data->stdState.left
! + LSLOP + docwidth + RSLOP + BAR;
}
else
data->stdState.right = 0x7fff;
CLIPMAX(data->stdState.right,
screen->portRect.right-3);
if (docheight > 0) {
- CLIPMIN(docheight, MIN_HEIGHT);
data->stdState.bottom =
! data->stdState.top
! + docheight + BAR;
}
else
data->stdState.bottom = 0x7fff;
CLIPMAX(data->stdState.bottom,
screen->portRect.bottom-3);
}
}
}
--- 195,226 ----
*((WindowPeek)(win->w))->dataHandle;
if (data != NULL) {
if (docwidth > 0) {
data->stdState.right =
data->stdState.left
! + LSLOP + docwidth + RSLOP;
! if (win->vbar != NULL)
! data->stdState.right += BAR;
}
else
data->stdState.right = 0x7fff;
CLIPMAX(data->stdState.right,
screen->portRect.right-3);
+ if (win->hbar != NULL) {
+ CLIPMIN(data->stdState.right, 5*BAR);
+ }
if (docheight > 0) {
data->stdState.bottom =
! data->stdState.top + docheight;
! if (win->hbar != NULL)
! data->stdState.bottom += BAR;
}
else
data->stdState.bottom = 0x7fff;
CLIPMAX(data->stdState.bottom,
screen->portRect.bottom-3);
+ if (win->vbar != NULL) {
+ CLIPMIN(data->stdState.bottom, 5*BAR);
+ }
}
}
}
***************
*** 222,227 ****
--- 237,243 ----
/* Fix the window's origin after a document or window resize.
(Also used from do_size() in event.c) */
+ void
_wfixorigin(win)
WINDOW *win;
{
***************
*** 267,272 ****
--- 283,291 ----
ProcPtr action;
int width, height;
+ if (bar == NULL)
+ return;
+
wgetwinsize(win, &width, &height);
if (bar == win->hbar) {
***************
*** 306,311 ****
--- 325,332 ----
deadline= 0;
if (TrackControl(bar, PASSPOINT *pwhere, action) == inThumb)
usescrollbarvalues(win);
+
+ SetPort(win->w); /* THIS IS NEEDED!!! */
}
static pascal
***************
*** 315,321 ****
{
long now= TickCount();
if (now >= deadline && pcode != 0) {
! deltabar(bar, scrollstep);
usescrollbarvalues(scrollwin);
wupdate(scrollwin);
if (deadline == 0 && KeyThresh > KeyRepThresh)
--- 336,342 ----
{
long now= TickCount();
if (now >= deadline && pcode != 0) {
! deltabar(bar, scrollstep);
usescrollbarvalues(scrollwin);
wupdate(scrollwin);
if (deadline == 0 && KeyThresh > KeyRepThresh)
***************
*** 391,399 ****
}
}
void
! makescrollbars(win)
WINDOW *win;
{
Rect r;
int id= scrollBarProc;
--- 412,431 ----
}
}
+ #ifdef JURJENBARPROC
+ static int cdefexists _ARGS((int));
+ static int
+ cdefexists(id)
+ int id;
+ {
+ return GetResource('CDEF', id/16) != NULL;
+ }
+ #endif
+
void
! makescrollbars(win, hor, ver)
WINDOW *win;
+ /*bool*/int hor, ver;
{
Rect r;
int id= scrollBarProc;
***************
*** 412,438 ****
#endif JURJENBARPROC
SetRect(&r, 0, 0, 1, 1); /* Dummy rectangle */
! win->hbar= NewControl(win->w,
! &r, "", false, 0, 0, 0, scrollBarProc, 0L);
! win->vbar= NewControl(win->w,
! &r, "", false, 0, 0, 0, id, 0L);
sizescrollbars(win);
}
- #ifdef JURJENBARPROC
- static int
- cdefexists(id)
- int id;
- {
- return GetResource('CDEF', id/16) != NULL;
- }
- #endif
-
void
showscrollbars(win)
WINDOW *win;
{
! DrawGrowIcon(win->w);
showbar(win->hbar);
showbar(win->vbar);
}
--- 444,463 ----
#endif JURJENBARPROC
SetRect(&r, 0, 0, 1, 1); /* Dummy rectangle */
! if (hor)
! win->hbar= NewControl(win->w,
! &r, "", false, 0, 0, 0, scrollBarProc, 0L);
! if (ver)
! win->vbar= NewControl(win->w,
! &r, "", false, 0, 0, 0, id, 0L);
sizescrollbars(win);
}
void
showscrollbars(win)
WINDOW *win;
{
! _wgrowicon(win);
showbar(win->hbar);
showbar(win->vbar);
}
***************
*** 460,472 ****
{
Rect r;
! /* This should be done while the scroll bars are invisible. */
! r= win->w->portRect;
! movebar(win->vbar, r.right - BAR, r.top - 1,
! r.right + 1, r.bottom - BAR + 1);
! movebar(win->hbar, r.left - 1, r.bottom - BAR,
! r.right - BAR + 1, r.bottom + 1);
setscrollbarvalues(win);
}
--- 485,506 ----
{
Rect r;
! /* This must only be called while the scroll bars are invisible. */
! r = win->w->portRect;
! r.left = r.right - BAR;
! r.top--;
! r.bottom -= BAR-1;
! r.right++;
! movebar(win->vbar, r.left, r.top, r.right, r.bottom);
!
! r = win->w->portRect;
! r.left--;
! r.top = r.bottom - BAR;
! r.right -= BAR-1;
! r.bottom++;
! movebar(win->hbar, r.left, r.top, r.right, r.bottom);
!
setscrollbarvalues(win);
}
***************
*** 511,516 ****
--- 545,554 ----
int begin, end;
{
int range;
+
+ if (bar == NULL)
+ return;
+
/* For the caller it's easier to remember to pass win->org{h,v};
but for our calculations it's easier to have the sign reversed! */
org= -org;
***************
*** 526,534 ****
usescrollbarvalues(win)
WINDOW *win;
{
! wsetorigin(win,
! GetCtlValue(win->hbar) - GetCtlMin(win->hbar),
! GetCtlValue(win->vbar) - GetCtlMin(win->vbar));
/* Implies setscrollbarvalues! */
}
--- 564,576 ----
usescrollbarvalues(win)
WINDOW *win;
{
! int orgh = 0;
! int orgv = 0;
! if (win->hbar != NULL)
! orgh = GetCtlValue(win->hbar) - GetCtlMin(win->hbar);
! if (win->vbar != NULL)
! orgv = GetCtlValue(win->vbar) - GetCtlMin(win->vbar);
! wsetorigin(win, orgh, orgv);
/* Implies setscrollbarvalues! */
}
***************
*** 557,567 ****
ControlHandle bar;
int delta;
{
! int min= GetCtlMin(bar);
! int val= GetCtlValue(bar);
! int max= GetCtlMax(bar);
! int newval= val + delta;
if (newval > max)
newval= max;
if (newval < min)
--- 599,613 ----
ControlHandle bar;
int delta;
{
! int min, val, max, newval;
+ if (bar == NULL)
+ return;
+ min = GetCtlMin(bar);
+ val = GetCtlValue(bar);
+ max = GetCtlMax(bar);
+ newval = val + delta;
+
if (newval > max)
newval= max;
if (newval < min)
***************
*** 596,599 ****
--- 642,676 ----
MoveControl(bar, left, top);
SizeControl(bar, right-left, bottom-top);
}
+ }
+
+ void
+ _wgrowicon(win)
+ WINDOW *win;
+ {
+ Rect r;
+
+ /* If there are no scroll bars, there is no room to draw the
+ grow icon; the entire window belongs to the application.
+ However, clicks in the bottom right corner will still be
+ intercepted by the window manager. */
+
+ if (win->hbar == NULL && win->vbar == NULL)
+ return;
+
+ /* Clip the drawing of DrawGrowIcon to the scroll bars present. */
+
+ r= win->w->portRect;
+ if (win->hbar == NULL)
+ r.left = r.right - BAR;
+ if (win->vbar == NULL)
+ r.top = r.bottom - BAR;
+ ClipRect(&r);
+
+ DrawGrowIcon(win->w);
+
+ /* Reset clipping */
+
+ SetRect(&r, -32000, -32000, 32000, 32000);
+ ClipRect(&r);
}
More information about the Alt.sources
mailing list