From: Ben Harris Date: Wed, 3 Mar 1999 22:03:54 +0000 (+0000) Subject: Resizing of terminal windows added. Seems to work, but term_size might benefit X-Git-Tag: ben-hacked-terminal~11 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;ds=sidebyside;h=c53d7fa6882d3295b09aeb57274ef1a37e62d3ae;p=PuTTY.git Resizing of terminal windows added. Seems to work, but term_size might benefit from calling scroll_display. This is where my scroll-optimisations look less useful than Simon's. [originally from svn r72] --- diff --git a/mac.c b/mac.c index 438838eb..19636019 100644 --- 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 1f083974..078fa6f5 100644 --- a/mac.h +++ b/mac.h @@ -6,6 +6,7 @@ #define _PUTTY_MAC_H #include +#include #include 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 *); diff --git a/macterm.c b/macterm.c index 020fe354..2e2152ea 100644 --- 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 #include #include +#include #include #include @@ -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;