]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - macterm.c
Resizing of terminal windows added. Seems to work, but term_size might benefit
[PuTTY.git] / macterm.c
index 0bf6230d1ce846cc97e52ffcdd26505836b3b643..2e2152ea29bf9d7f89a17b0f1974b299883bf9e5 100644 (file)
--- a/macterm.c
+++ b/macterm.c
@@ -1,4 +1,4 @@
-/* $Id: macterm.c,v 1.1.2.12 1999/03/02 21:51:55 ben Exp $ */
+/* $Id: macterm.c,v 1.1.2.14 1999/03/03 22:03:54 ben Exp $ */
 /*
  * Copyright (c) 1999 Ben Harris
  * All rights reserved.
@@ -39,6 +39,7 @@
 #include <QuickdrawText.h>
 #include <Resources.h>
 #include <Sound.h>
+#include <ToolUtils.h>
 
 #include <limits.h>
 #include <stdlib.h>
 #include "putty.h"
 #include "mac.h"
 
+#define DEFAULT_FG     16
+#define DEFAULT_FG_BOLD        17
+#define DEFAULT_BG     18
+#define DEFAULT_BG_BOLD        19
+
 struct mac_session {
     short              fontnum;
     int                        font_ascent;
@@ -57,7 +63,7 @@ struct mac_session {
 
 static void mac_initfont(struct mac_session *);
 static void mac_initpalette(struct mac_session *);
-static void mac_adjustsize(struct mac_session *);
+static void mac_adjustsize(struct mac_session *, int, int);
 static pascal void mac_scrolltracker(ControlHandle, short);
 static pascal void do_text_for_device(short, short, GDHandle, long);
 
@@ -139,19 +145,20 @@ static void mac_initfont(struct mac_session *s) {
     font_width = fi.widMax;
     font_height = fi.ascent + fi.descent + fi.leading;
     s->font_ascent = fi.ascent;
-    mac_adjustsize(s);
+    mac_adjustsize(s, rows, cols);
 }
 
 /*
  * To be called whenever the window size changes.
  * rows and cols should be desired values.
- * It's assumed the terminal emulator will be or has been informed.
+ * It's assumed the terminal emulator will be informed, and will set rows
+ * and cols for us.
  */
-static void mac_adjustsize(struct mac_session *s) {
+static void mac_adjustsize(struct mac_session *s, int newrows, int newcols) {
     int winwidth, winheight;
 
-    winwidth = cols * font_width + 15;
-    winheight = rows * font_height;
+    winwidth = newcols * font_width + 15;
+    winheight = newrows * font_height;
     SizeWindow(s->window, winwidth, winheight, true);
     HideControl(s->scrollbar);
     MoveControl(s->scrollbar, winwidth - 15, -1);
@@ -233,6 +240,23 @@ static pascal void mac_scrolltracker(ControlHandle control, short part) {
     }
 }
 
+void mac_growterm(WindowPtr window, EventRecord *event) {
+    Rect limits;
+    long grow_result;
+    int newrows, newcols;
+    struct mac_session *s;
+
+    s = (struct mac_session *)GetWRefCon(window);
+    SetRect(&limits, font_width + 15, font_height, SHRT_MAX, SHRT_MAX);
+    grow_result = GrowWindow(window, event->where, &limits);
+    if (grow_result != 0) {
+       newrows = HiWord(grow_result) / font_height;
+       newcols = (LoWord(grow_result) - 15) / font_width;
+       mac_adjustsize(s, newrows, newcols);
+       term_size(newrows, newcols, cfg.savelines);
+    }
+}
+
 void mac_activateterm(WindowPtr window, Boolean active) {
     struct mac_session *s;
 
@@ -261,10 +285,7 @@ void mac_updateterm(WindowPtr window) {
        EraseRect(&(*s->scrollbar)->contrlRect);
     UpdateControls(window, window->visRgn);
     /* Stop DrawGrowIcon giving us space for a horizontal scrollbar */
-    clip.left = window->portRect.right - 15;
-    clip.right = SHRT_MAX;
-    clip.top = SHRT_MIN;
-    clip.bottom = SHRT_MAX;
+    SetRect(&clip, window->portRect.right - 15, SHRT_MIN, SHRT_MAX, SHRT_MAX);
     ClipRect(&clip);
     DrawGrowIcon(window);
     clip.left = SHRT_MIN;
@@ -341,6 +362,13 @@ static pascal void do_text_for_device(short depth, short devflags,
        ForeColor(whiteColor);
        BackColor(blackColor);
        break;
+      case 2:
+       if ((a->attr & ATTR_BOLD) && cfg.bold_colour)
+           PmForeColor(DEFAULT_FG_BOLD);
+       else
+           PmForeColor(DEFAULT_FG);
+       PmBackColor(DEFAULT_BG);
+       break;
       default:
        fgcolour = ((a->attr & ATTR_FGMASK) >> ATTR_FGSHIFT) * 2;
        bgcolour = ((a->attr & ATTR_BGMASK) >> ATTR_BGSHIFT) * 2;
@@ -469,33 +497,6 @@ void palette_reset(void) {
     /* Palette Manager will generate update events as required. */
 }
 
-/*
- * Move `lines' lines from position `from' to position `to' in the
- * window.
- * Note that this is currently broken if "from" and "to" are more
- * than "lines" lines apart.
- */
-void optimised_move(int to, int from, int lines) {
-    Rect r;
-    RgnHandle update;
-    struct mac_session *s = onlysession;
-    int min, max, d;
-
-    SetPort(s->window);
-
-    min = (to < from ? to : from);
-    max = to + from - min;
-    d = max - min;
-
-    update = NewRgn();
-    r.left = 0; r.right = cols * font_width;
-    r.top = min * font_height; r.bottom = (max+lines) * font_height;
-    ScrollRect(&r, 0, (to - from) * font_height, update);
-    InvalRgn(update); /* XXX: necessary?  probably harmless anyway */
-    DisposeRgn(update);
-}
-
-
 /*
  * Scroll the screen. (`lines' is +ve for scrolling forward, -ve
  * for backward.)