Add support for generating MPW Makefiles. This makes the following changes:
[u/mdw/putty] / mac / macterm.c
index 299debf..daed7f6 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: macterm.c,v 1.12 2002/11/26 01:32:51 ben Exp $ */
+/* $Id: macterm.c,v 1.16 2002/11/29 00:32:03 ben Exp $ */
 /*
  * Copyright (c) 1999 Simon Tatham
  * Copyright (c) 1999, 2002 Ben Harris
@@ -94,13 +94,9 @@ static RoutineDescriptor mac_scrolltracker_upp =
 static RoutineDescriptor do_text_for_device_upp =
     BUILD_ROUTINE_DESCRIPTOR(uppDeviceLoopDrawingProcInfo,
                             (ProcPtr)do_text_for_device);
-static RoutineDescriptor mac_set_attr_mask_upp =
-    BUILD_ROUTINE_DESCRIPTOR(uppDeviceLoopDrawingProcInfo,
-                            (ProcPtr)mac_set_attr_mask);
 #else /* not TARGET_RT_MAC_CFM */
 #define mac_scrolltracker_upp  mac_scrolltracker
 #define do_text_for_device_upp do_text_for_device
-#define mac_set_attr_mask_upp  mac_set_attr_mask
 #endif /* not TARGET_RT_MAC_CFM */
 
 static void inbuf_putc(Session *s, int c) {
@@ -170,7 +166,6 @@ void mac_newsession(void) {
 
     mac_initfont(s);
     mac_initpalette(s);
-    s->attr_mask = ATTR_MASK;
     if (HAVE_COLOR_QD()) {
        /* Set to FALSE to not get palette updates in the background. */
        SetPalette(s->window, s->palette, TRUE); 
@@ -779,15 +774,21 @@ void mac_updateterm(WindowPtr window) {
 
 static void mac_drawgrowicon(Session *s) {
     Rect clip;
+    RgnHandle savergn;
 
     SetPort(s->window);
-    /* Stop DrawGrowIcon giving us space for a horizontal scrollbar */
-    SetRect(&clip, s->window->portRect.right - 15, SHRT_MIN,
-           SHRT_MAX, SHRT_MAX);
+    /*
+     * Stop DrawGrowIcon giving us space for a horizontal scrollbar
+     * See Tech Note TB575 for details.
+     */
+    clip = s->window->portRect;
+    clip.left = clip.right - 15;
+    savergn = NewRgn();
+    GetClip(savergn);
     ClipRect(&clip);
     DrawGrowIcon(s->window);
-    clip.left = SHRT_MIN;
-    ClipRect(&clip);
+    SetClip(savergn);
+    DisposeRgn(savergn);
 }    
 
 struct do_text_args {
@@ -797,6 +798,7 @@ struct do_text_args {
     int len;
     unsigned long attr;
     int lattr;
+    Point numer, denom;
 };
 
 /*
@@ -826,6 +828,7 @@ void do_text(Context ctx, int x, int y, char *text, int len,
     a.len = len;
     a.attr = attr;
     a.lattr = lattr;
+    a.numer.h = a.numer.v = a.denom.h = a.denom.v = 1;
     SetPort(s->window);
     TextFont(s->fontnum);
     if (s->cfg.fontisbold || (attr & ATTR_BOLD) && !s->cfg.bold_colour)
@@ -835,7 +838,6 @@ void do_text(Context ctx, int x, int y, char *text, int len,
     TextFace(style);
     TextSize(s->cfg.fontheight);
     TextMode(srcOr);
-    SetFractEnable(FALSE); /* We want characters on pixel boundaries */
     if (HAVE_COLOR_QD())
        if (style & bold) {
            SpaceExtra(s->font_boldadjust << 16);
@@ -907,7 +909,11 @@ static pascal void do_text_for_device(short depth, short devflags,
     EraseRect(&a->textrect);
     MoveTo(a->textrect.left, a->textrect.top + a->s->font_ascent);
     /* FIXME: Sort out bold width adjustments on Original QuickDraw. */
-    DrawText(a->text, 0, a->len);
+    if (a->s->window->grafProcs != NULL)
+       InvokeQDTextUPP(a->len, a->text, a->numer, a->denom,
+                       a->s->window->grafProcs->textProc);
+    else
+       StdText(a->len, a->text, a->numer, a->denom);
 
     if (a->attr & TATTR_PASCURS) {
        PenNormal();
@@ -935,12 +941,34 @@ void do_cursor(Context ctx, int x, int y, char *text, int len,
  * Should probably be called start_redraw or something.
  */
 void pre_paint(Session *s) {
+    GDHandle gdh;
+    Rect myrect, tmprect;
 
-    s->attr_mask = ATTR_INVALID;
-    if (HAVE_COLOR_QD())
-       DeviceLoop(s->window->visRgn, &mac_set_attr_mask_upp, (long)s, 0);
-    else
-       mac_set_attr_mask(1, 0, NULL, (long)s);
+    s->term->attr_mask = 0xffffffff;
+    if (HAVE_COLOR_QD()) {
+       SetPort(s->window);
+       myrect = (*s->window->visRgn)->rgnBBox;
+       LocalToGlobal((Point *)&myrect.top);
+       LocalToGlobal((Point *)&myrect.bottom);
+       for (gdh = GetDeviceList();
+            gdh != NULL;
+            gdh = GetNextDevice(gdh)) {
+           if (TestDeviceAttribute(gdh, screenDevice) &&
+               TestDeviceAttribute(gdh, screenActive) &&
+               SectRect(&(*gdh)->gdRect, &myrect, &tmprect)) {
+               switch ((*(*gdh)->gdPMap)->pixelSize) {
+                 case 1:
+                   if (s->cfg.bold_colour)
+                       s->term->attr_mask &= ~ATTR_BOLD;
+                   /* FALLTHROUGH */
+                 case 2:
+                   s->term->attr_mask &= ~ATTR_COLOURS;
+               }
+           }
+       }
+    } else
+       s->term->attr_mask &= ~(ATTR_COLOURS |
+                               (s->cfg.bold_colour ? ATTR_BOLD : 0));
 }
 
 Context get_ctx(void *frontend) {
@@ -954,26 +982,6 @@ void free_ctx(Context ctx) {
 
 }
 
-static pascal void mac_set_attr_mask(short depth, short devflags,
-                                    GDHandle device, long cookie) {
-
-    Session *s = (Session *)cookie;
-
-    switch (depth) {
-      default:
-       s->attr_mask |= ATTR_FGMASK | ATTR_BGMASK;
-       /* FALLTHROUGH */
-      case 2:
-       s->attr_mask |= ATTR_BOLD;
-       /* FALLTHROUGH */
-      case 1:
-       s->attr_mask |= ATTR_UNDER | ATTR_REVERSE | TATTR_ACTCURS |
-           TATTR_PASCURS | ATTR_ASCII | ATTR_GBCHR | ATTR_LINEDRW |
-           (s->cfg.bold_colour ? 0 : ATTR_BOLD); 
-       break;
-    }
-}
-
 /*
  * Presumably this does something in Windows
  */
@@ -1263,11 +1271,12 @@ void do_scroll(void *frontend, int topline, int botline, int lines) {
     Rect r;
     RgnHandle update;
 
-    /* FIXME: This is seriously broken on Original QuickDraw.  No idea why. */
     SetPort(s->window);
     PenNormal();
     if (HAVE_COLOR_QD())
        PmBackColor(DEFAULT_BG);
+    else
+       BackColor(blackColor); /* XXX make configurable */
     update = NewRgn();
     SetRect(&r, 0, topline * s->font_height,
            s->term->cols * s->font_width, (botline + 1) * s->font_height);