mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-26 09:42:25 +00:00
Slightly cheesy size-tip implementation. This is suboptimal in two ways:
* It paints over the top-left corner of the terminal window. A little floating window would be rather nicer and not much harder to do. * It uses the low-memory global, DragHook, which is unavailable in Carbon and broken in some versions of Mac OS 8 (8.5?). I suspect this is unavoidable, though. [originally from svn r2287]
This commit is contained in:
parent
9ee5d85169
commit
7522f5302d
@ -1,4 +1,4 @@
|
|||||||
/* $Id: macterm.c,v 1.17 2002/12/07 15:21:56 ben Exp $ */
|
/* $Id: macterm.c,v 1.18 2002/12/08 01:17:31 ben Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999 Simon Tatham
|
* Copyright (c) 1999 Simon Tatham
|
||||||
* Copyright (c) 1999, 2002 Ben Harris
|
* Copyright (c) 1999, 2002 Ben Harris
|
||||||
@ -35,6 +35,7 @@
|
|||||||
#include <ControlDefinitions.h>
|
#include <ControlDefinitions.h>
|
||||||
#include <Fonts.h>
|
#include <Fonts.h>
|
||||||
#include <Gestalt.h>
|
#include <Gestalt.h>
|
||||||
|
#include <LowMem.h>
|
||||||
#include <MacMemory.h>
|
#include <MacMemory.h>
|
||||||
#include <MacWindows.h>
|
#include <MacWindows.h>
|
||||||
#include <MixedMode.h>
|
#include <MixedMode.h>
|
||||||
@ -78,6 +79,7 @@ static void mac_initpalette(Session *);
|
|||||||
static void mac_adjustwinbg(Session *);
|
static void mac_adjustwinbg(Session *);
|
||||||
static void mac_adjustsize(Session *, int, int);
|
static void mac_adjustsize(Session *, int, int);
|
||||||
static void mac_drawgrowicon(Session *s);
|
static void mac_drawgrowicon(Session *s);
|
||||||
|
static pascal void mac_growtermdraghook(void);
|
||||||
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);
|
||||||
static pascal void mac_set_attr_mask(short, short, GDHandle, long);
|
static pascal void mac_set_attr_mask(short, short, GDHandle, long);
|
||||||
@ -709,15 +711,51 @@ void request_paste(void *frontend)
|
|||||||
term_do_paste(s->term);
|
term_do_paste(s->term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
Rect msgrect;
|
||||||
|
Point msgorigin;
|
||||||
|
Point startmouse;
|
||||||
|
Session *s;
|
||||||
|
char oldmsg[20];
|
||||||
|
} growterm_state;
|
||||||
|
|
||||||
void mac_growterm(WindowPtr window, EventRecord *event) {
|
void mac_growterm(WindowPtr window, EventRecord *event) {
|
||||||
Rect limits;
|
Rect limits;
|
||||||
long grow_result;
|
long grow_result;
|
||||||
int newrows, newcols;
|
int newrows, newcols;
|
||||||
Session *s;
|
Session *s;
|
||||||
|
DragGrayRgnUPP draghooksave;
|
||||||
|
GrafPtr portsave;
|
||||||
|
FontInfo fi;
|
||||||
|
|
||||||
s = (Session *)GetWRefCon(window);
|
s = (Session *)GetWRefCon(window);
|
||||||
|
|
||||||
|
draghooksave = LMGetDragHook();
|
||||||
|
growterm_state.oldmsg[0] = '\0';
|
||||||
|
growterm_state.startmouse = event->where;
|
||||||
|
growterm_state.s = s;
|
||||||
|
GetPort(&portsave);
|
||||||
|
SetPort(s->window);
|
||||||
|
BackColor(whiteColor);
|
||||||
|
ForeColor(blackColor);
|
||||||
|
TextFont(systemFont);
|
||||||
|
TextFace(0);
|
||||||
|
TextSize(12);
|
||||||
|
GetFontInfo(&fi);
|
||||||
|
SetRect(&growterm_state.msgrect, 0, 0,
|
||||||
|
StringWidth("\p99999x99999") + 4, fi.ascent + fi.descent + 4);
|
||||||
|
SetPt(&growterm_state.msgorigin, 2, fi.ascent + 2);
|
||||||
|
LMSetDragHook(NewDragGrayRgnUPP(mac_growtermdraghook));
|
||||||
|
|
||||||
SetRect(&limits, s->font_width + 15, s->font_height, SHRT_MAX, SHRT_MAX);
|
SetRect(&limits, s->font_width + 15, s->font_height, SHRT_MAX, SHRT_MAX);
|
||||||
grow_result = GrowWindow(window, event->where, &limits);
|
grow_result = GrowWindow(window, event->where, &limits);
|
||||||
|
|
||||||
|
DisposeDragGrayRgnUPP(LMGetDragHook());
|
||||||
|
LMSetDragHook(draghooksave);
|
||||||
|
InvalRect(&growterm_state.msgrect);
|
||||||
|
|
||||||
|
SetPort(portsave);
|
||||||
|
|
||||||
if (grow_result != 0) {
|
if (grow_result != 0) {
|
||||||
newrows = HiWord(grow_result) / s->font_height;
|
newrows = HiWord(grow_result) / s->font_height;
|
||||||
newcols = (LoWord(grow_result) - 15) / s->font_width;
|
newcols = (LoWord(grow_result) - 15) / s->font_width;
|
||||||
@ -726,6 +764,35 @@ void mac_growterm(WindowPtr window, EventRecord *event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static pascal void mac_growtermdraghook(void)
|
||||||
|
{
|
||||||
|
Session *s = growterm_state.s;
|
||||||
|
GrafPtr portsave;
|
||||||
|
Point mouse;
|
||||||
|
char buf[20];
|
||||||
|
int newrows, newcols;
|
||||||
|
|
||||||
|
GetMouse(&mouse);
|
||||||
|
newrows = (mouse.v - growterm_state.startmouse.v) / s->font_height +
|
||||||
|
s->term->rows;
|
||||||
|
if (newrows < 1) newrows = 1;
|
||||||
|
newcols = (mouse.h - growterm_state.startmouse.h) / s->font_width +
|
||||||
|
s->term->cols;
|
||||||
|
if (newcols < 1) newcols = 1;
|
||||||
|
sprintf(buf, "%dx%d", newcols, newrows);
|
||||||
|
if (strcmp(buf, growterm_state.oldmsg) == 0)
|
||||||
|
return;
|
||||||
|
strcpy(growterm_state.oldmsg, buf);
|
||||||
|
c2pstr(buf);
|
||||||
|
|
||||||
|
GetPort(&portsave);
|
||||||
|
SetPort(growterm_state.s->window);
|
||||||
|
EraseRect(&growterm_state.msgrect);
|
||||||
|
MoveTo(growterm_state.msgorigin.h, growterm_state.msgorigin.v);
|
||||||
|
DrawString((StringPtr)buf);
|
||||||
|
SetPort(portsave);
|
||||||
|
}
|
||||||
|
|
||||||
void mac_activateterm(WindowPtr window, Boolean active) {
|
void mac_activateterm(WindowPtr window, Boolean active) {
|
||||||
Session *s;
|
Session *s;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user