mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 09:58:01 +00:00
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]
This commit is contained in:
parent
a9b471d5b3
commit
c53d7fa688
14
mac.c
14
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
|
* Copyright (c) 1999 Ben Harris
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -60,6 +60,7 @@ static void mac_startup(void);
|
|||||||
static void mac_eventloop(void);
|
static void mac_eventloop(void);
|
||||||
static void mac_event(EventRecord *);
|
static void mac_event(EventRecord *);
|
||||||
static void mac_contentclick(WindowPtr, EventRecord *);
|
static void mac_contentclick(WindowPtr, EventRecord *);
|
||||||
|
static void mac_growwindow(WindowPtr, EventRecord *);
|
||||||
static void mac_activatewindow(WindowPtr, Boolean);
|
static void mac_activatewindow(WindowPtr, Boolean);
|
||||||
static void mac_updatewindow(WindowPtr);
|
static void mac_updatewindow(WindowPtr);
|
||||||
static void mac_keypress(EventRecord *);
|
static void mac_keypress(EventRecord *);
|
||||||
@ -169,6 +170,7 @@ static void mac_event(EventRecord *event) {
|
|||||||
DragWindow(window, event->where, &qd.screenBits.bounds);
|
DragWindow(window, event->where, &qd.screenBits.bounds);
|
||||||
break;
|
break;
|
||||||
case inGrow:
|
case inGrow:
|
||||||
|
mac_growwindow(window, event);
|
||||||
break;
|
break;
|
||||||
case inZoomIn:
|
case inZoomIn:
|
||||||
case inZoomOut:
|
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) {
|
static void mac_activatewindow(WindowPtr window, Boolean active) {
|
||||||
|
|
||||||
switch (mac_windowtype(window)) {
|
switch (mac_windowtype(window)) {
|
||||||
@ -342,7 +352,7 @@ static void mac_adjustcursor(void) {
|
|||||||
|
|
||||||
static void mac_shutdown(void) {
|
static void mac_shutdown(void) {
|
||||||
|
|
||||||
ExitToShell();
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fatalbox(const char *fmt, ...) {
|
void fatalbox(const char *fmt, ...) {
|
||||||
|
3
mac.h
3
mac.h
@ -6,6 +6,7 @@
|
|||||||
#define _PUTTY_MAC_H
|
#define _PUTTY_MAC_H
|
||||||
|
|
||||||
#include <MacTypes.h>
|
#include <MacTypes.h>
|
||||||
|
#include <Events.h>
|
||||||
#include <MacWindows.h>
|
#include <MacWindows.h>
|
||||||
|
|
||||||
extern long mac_qdversion;
|
extern long mac_qdversion;
|
||||||
@ -22,6 +23,8 @@ extern struct mac_gestalts mac_gestalts;
|
|||||||
extern void mac_newsession(void);
|
extern void mac_newsession(void);
|
||||||
extern void mac_activateterm(WindowPtr, Boolean);
|
extern void mac_activateterm(WindowPtr, Boolean);
|
||||||
extern void mac_updateterm(WindowPtr);
|
extern void mac_updateterm(WindowPtr);
|
||||||
|
extern void mac_clickterm(WindowPtr, EventRecord *);
|
||||||
|
extern void mac_growterm(WindowPtr, EventRecord *);
|
||||||
|
|
||||||
extern void mac_loadconfig(Config *);
|
extern void mac_loadconfig(Config *);
|
||||||
|
|
||||||
|
33
macterm.c
33
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
|
* Copyright (c) 1999 Ben Harris
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -39,6 +39,7 @@
|
|||||||
#include <QuickdrawText.h>
|
#include <QuickdrawText.h>
|
||||||
#include <Resources.h>
|
#include <Resources.h>
|
||||||
#include <Sound.h>
|
#include <Sound.h>
|
||||||
|
#include <ToolUtils.h>
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -62,7 +63,7 @@ struct mac_session {
|
|||||||
|
|
||||||
static void mac_initfont(struct mac_session *);
|
static void mac_initfont(struct mac_session *);
|
||||||
static void mac_initpalette(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 mac_scrolltracker(ControlHandle, short);
|
||||||
static pascal void do_text_for_device(short, short, GDHandle, long);
|
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_width = fi.widMax;
|
||||||
font_height = fi.ascent + fi.descent + fi.leading;
|
font_height = fi.ascent + fi.descent + fi.leading;
|
||||||
s->font_ascent = fi.ascent;
|
s->font_ascent = fi.ascent;
|
||||||
mac_adjustsize(s);
|
mac_adjustsize(s, rows, cols);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* To be called whenever the window size changes.
|
* To be called whenever the window size changes.
|
||||||
* rows and cols should be desired values.
|
* 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;
|
int winwidth, winheight;
|
||||||
|
|
||||||
winwidth = cols * font_width + 15;
|
winwidth = newcols * font_width + 15;
|
||||||
winheight = rows * font_height;
|
winheight = newrows * font_height;
|
||||||
SizeWindow(s->window, winwidth, winheight, true);
|
SizeWindow(s->window, winwidth, winheight, true);
|
||||||
HideControl(s->scrollbar);
|
HideControl(s->scrollbar);
|
||||||
MoveControl(s->scrollbar, winwidth - 15, -1);
|
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) {
|
void mac_activateterm(WindowPtr window, Boolean active) {
|
||||||
struct mac_session *s;
|
struct mac_session *s;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user