]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Resizing of terminal windows added. Seems to work, but term_size might benefit
authorBen Harris <bjh21@bjh21.me.uk>
Wed, 3 Mar 1999 22:03:54 +0000 (22:03 +0000)
committerBen Harris <bjh21@bjh21.me.uk>
Wed, 3 Mar 1999 22:03:54 +0000 (22:03 +0000)
from calling scroll_display.  This is where my scroll-optimisations look less
useful than Simon's.

[originally from svn r72]

mac.c
mac.h
macterm.c

diff --git a/mac.c b/mac.c
index 438838eb2841da441816ccf1c71acd1cfeba69db..19636019a6c403f62afda6a96fdf9b8f35c1a6ec 100644 (file)
--- a/mac.c
+++ b/mac.c
@@ -1,4 +1,4 @@
-/* $Id: mac.c,v 1.1.2.10 1999/03/01 22:26:49 ben Exp $ */
+/* $Id: mac.c,v 1.1.2.11 1999/03/03 22:03:54 ben Exp $ */
 /*
  * Copyright (c) 1999 Ben Harris
  * All rights reserved.
@@ -60,6 +60,7 @@ static void mac_startup(void);
 static void mac_eventloop(void);
 static void mac_event(EventRecord *);
 static void mac_contentclick(WindowPtr, EventRecord *);
+static void mac_growwindow(WindowPtr, EventRecord *);
 static void mac_activatewindow(WindowPtr, Boolean);
 static void mac_updatewindow(WindowPtr);
 static void mac_keypress(EventRecord *);
@@ -169,6 +170,7 @@ static void mac_event(EventRecord *event) {
            DragWindow(window, event->where, &qd.screenBits.bounds);
            break;
          case inGrow:
+           mac_growwindow(window, event);
            break;
          case inZoomIn:
          case inZoomOut:
@@ -215,6 +217,14 @@ static void mac_contentclick(WindowPtr window, EventRecord *event) {
     }
 }
 
+static void mac_growwindow(WindowPtr window, EventRecord *event) {
+
+    switch (mac_windowtype(window)) {
+      case wTerminal:
+       mac_growterm(window, event);
+    }
+}
+
 static void mac_activatewindow(WindowPtr window, Boolean active) {
 
     switch (mac_windowtype(window)) {
@@ -342,7 +352,7 @@ static void mac_adjustcursor(void) {
 
 static void mac_shutdown(void) {
 
-    ExitToShell();
+    exit(0);
 }
 
 void fatalbox(const char *fmt, ...) {
diff --git a/mac.h b/mac.h
index 1f0839743e625298443407b5f5809b61f28c58b3..078fa6f5cfa484661a3ff11c113a94890c15a988 100644 (file)
--- a/mac.h
+++ b/mac.h
@@ -6,6 +6,7 @@
 #define _PUTTY_MAC_H
 
 #include <MacTypes.h>
+#include <Events.h>
 #include <MacWindows.h>
 
 extern long mac_qdversion;
@@ -22,6 +23,8 @@ extern struct mac_gestalts mac_gestalts;
 extern void mac_newsession(void);
 extern void mac_activateterm(WindowPtr, Boolean);
 extern void mac_updateterm(WindowPtr);
+extern void mac_clickterm(WindowPtr, EventRecord *);
+extern void mac_growterm(WindowPtr, EventRecord *);
 
 extern void mac_loadconfig(Config *);
 
index 020fe3546e3396fb4fee541e680e6ed5bac07824..2e2152ea29bf9d7f89a17b0f1974b299883bf9e5 100644 (file)
--- a/macterm.c
+++ b/macterm.c
@@ -1,4 +1,4 @@
-/* $Id: macterm.c,v 1.1.2.13 1999/03/02 23:19:20 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>
@@ -62,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);
 
@@ -144,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);
@@ -238,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;