1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Erm, major change at the moment is a new test case. You need a file called

'fragment' to build it, but its licence prevents me distributing it at present.
Now, about those scrolling optimisations...

[originally from svn r63]
This commit is contained in:
Ben Harris 1999-02-28 17:05:11 +00:00
parent df4ff91c0e
commit eddbb40cf8
4 changed files with 113 additions and 27 deletions

20
mac.c
View File

@ -1,4 +1,4 @@
/* $Id: mac.c,v 1.1.2.8 1999/02/28 02:38:40 ben Exp $ */
/* $Id: mac.c,v 1.1.2.9 1999/02/28 17:05:10 ben Exp $ */
/*
* mac.c -- miscellaneous Mac-specific routines
*/
@ -29,8 +29,7 @@
QDGlobals qd;
static int cold = 1;
long mac_qdversion;
long mac_apprversion;
struct mac_gestalts mac_gestalts;
static void mac_startup(void);
static void mac_eventloop(void);
@ -73,17 +72,20 @@ static void mac_startup(void) {
cold = 0;
/* Find out if we've got Color Quickdraw */
if (Gestalt(gestaltQuickdrawVersion, &mac_qdversion) != noErr)
mac_qdversion = gestaltOriginalQD;
if (Gestalt(gestaltQuickdrawVersion, &mac_gestalts.qdvers) != noErr)
mac_gestalts.qdvers = gestaltOriginalQD;
/* ... and the Appearance Manager? */
if (Gestalt(gestaltAppearanceVersion, &mac_apprversion) != noErr)
if (Gestalt(gestaltAppearanceVersion, &mac_gestalts.apprvers) != noErr)
if (Gestalt(gestaltAppearanceAttr, NULL) == noErr)
mac_apprversion = 0x0100;
mac_gestalts.apprvers = 0x0100;
else
mac_apprversion = 0;
mac_gestalts.apprvers = 0;
/* Mac OS 8.5 Control Manager (proportional scrollbars)? */
if (Gestalt(gestaltControlMgrAttr, &mac_gestalts.cntlattr) != noErr)
mac_gestalts.cntlattr = 0;
/* We've been tested with the Appearance Manager */
if (mac_apprversion != 0)
if (mac_gestalts.apprvers != 0)
RegisterAppearanceClient();
menuBar = GetNewMBar(128);

8
mac.h
View File

@ -10,6 +10,14 @@
extern long mac_qdversion;
struct mac_gestalts {
long qdvers;
long apprvers;
long cntlattr;
};
extern struct mac_gestalts mac_gestalts;
/* from macterm.c */
extern void mac_newsession(void);
extern void mac_activateterm(WindowPtr, Boolean);

View File

@ -1,4 +1,30 @@
/* $Id: mac_res.r,v 1.1.2.5 1999/02/28 02:38:40 ben Exp $ */
/* $Id: mac_res.r,v 1.1.2.6 1999/02/28 17:05:11 ben Exp $ */
/*
* Copyright (c) 1999 Ben Harris
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* PuTTY resources */
#include "Types.r"
@ -590,3 +616,4 @@ resource 'pltt' (PREF_pltt, purgeable) {
}
};
read 'pTST' (128, "test data", purgeable) "fragment";

View File

@ -1,14 +1,43 @@
/* $Id: macterm.c,v 1.1.2.8 1999/02/28 17:05:11 ben Exp $ */
/*
* Copyright (c) 1999 Ben Harris
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* macterm.c -- Macintosh terminal front-end
*/
#include <MacTypes.h>
#include <Controls.h>
#include <Fonts.h>
#include <Gestalt.h>
#include <MacWindows.h>
#include <Palettes.h>
#include <Quickdraw.h>
#include <QuickdrawText.h>
#include <Resources.h>
#include <Sound.h>
#include <limits.h>
@ -44,6 +73,26 @@ static void inbuf_putstr(const char *c) {
inbuf_putc(*c++);
}
static void display_resource(unsigned long type, short id) {
Handle h;
int len, i;
char *t;
h = GetResource(type, id);
if (h == NULL)
fatalbox("Can't get test resource");
SetResAttrs(h, GetResAttrs(h) | resLocked);
t = *h;
len = GetResourceSizeOnDisk(h);
for (i = 0; i < len; i++) {
inbuf_putc(t[i]);
term_out();
}
SetResAttrs(h, GetResAttrs(h) & ~resLocked);
ReleaseResource(h);
}
void mac_newsession(void) {
struct mac_session *s;
int i;
@ -54,7 +103,7 @@ void mac_newsession(void) {
onlysession = s;
/* XXX: Own storage management? */
if (mac_qdversion == gestaltOriginalQD)
if (mac_gestalts.qdvers == gestaltOriginalQD)
s->window = GetNewWindow(wTerminal, NULL, (WindowPtr)-1);
else
s->window = GetNewCWindow(wTerminal, NULL, (WindowPtr)-1);
@ -68,19 +117,7 @@ void mac_newsession(void) {
SetPalette(s->window, s->palette, TRUE);
ActivatePalette(s->window);
ShowWindow(s->window);
inbuf_putstr("\033[1mBold\033[m \033[2mfaint\033[m \033[3mitalic\033[m \033[4mu_line\033[m "
"\033[5mslow bl\033[m \033[6mfast bl\033[m \033[7minverse\033[m \033[8mconceal\033[m "
"\033[9mstruck\033[m \033[21mdbl ul\033[m\015\012");
term_out();
inbuf_putstr("\033[30mblack \033[31mred \033[32mgreen \033[33myellow "
"\033[34mblue \033[35mmagenta \033[36mcyan \033[37mwhite\015\012");
term_out();
inbuf_putstr("\033[1m\033[30mblack \033[31mred \033[32mgreen \033[33myellow "
"\033[1m\033[34mblue \033[35mmagenta \033[36mcyan \033[37mwhite\015\012");
term_out();
inbuf_putstr("\033[37;44mwhite on blue \033[32;41mgreen on red\015\012");
term_out();
display_resource('pTST', 128);
}
static void mac_initfont(struct mac_session *s) {
@ -120,7 +157,7 @@ static void mac_adjustsize(struct mac_session *s) {
static void mac_initpalette(struct mac_session *s) {
WinCTab ct;
if (mac_qdversion == gestaltOriginalQD)
if (mac_gestalts.qdvers == gestaltOriginalQD)
return;
s->palette = NewPalette((*cfg.colours)->pmEntries, NULL, pmCourteous, 0);
if (s->palette == NULL)
@ -253,10 +290,22 @@ void free_ctx(struct mac_session *ctx) {
/*
* Set the scroll bar position
*
* total is the line number of the bottom of the working screen
* start is the line number of the top of the display
* page is the length of the displayed page
*/
void set_sbar(int total, int start, int page) {
struct mac_session *s = onlysession;
/* Do something once we actually have a scroll bar */
SetControlMinimum(s->scrollbar, 0);
SetControlMaximum(s->scrollbar, total - page);
SetControlValue(s->scrollbar, start);
#if 0
/* XXX: This doesn't compile for me - bjh */
if (mac_gestalts.cntlattr & gestaltControlMgrPresent)
SetControlViewSize(s->scrollbar, page);
#endif
}
/*
@ -326,7 +375,7 @@ void palette_set(int n, int r, int g, int b) {
void palette_reset(void) {
struct mac_session *s = onlysession;
if (mac_qdversion == gestaltOriginalQD)
if (mac_gestalts.qdvers == gestaltOriginalQD)
return;
CopyPalette(cfg.colours, s->palette, 0, 0, (*cfg.colours)->pmEntries);
ActivatePalette(s->window);