mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 09:58:01 +00:00
Bloody Hell! It just managed to say "Hello, world" in a terminal window!
I'd better check this lot in before something bad happens to it. [originally from svn r56]
This commit is contained in:
parent
7c491e865f
commit
8ac1a08339
@ -1,4 +1,4 @@
|
||||
# $Id: PuTTY.make,v 1.1.2.5 1999/02/21 10:29:12 ben Exp $
|
||||
# $Id: PuTTY.make,v 1.1.2.6 1999/02/21 18:09:41 ben Exp $
|
||||
# This is the Makefile for building PuTTY for the Mac OS.
|
||||
# Users of non-Mac systems will see some pretty strange characters around.
|
||||
|
||||
@ -12,6 +12,7 @@ COptions = {Includes} {Sym
|
||||
|
||||
Objects¥68K = ¶
|
||||
"{ObjDir¥68K}mac.c.o" ¶
|
||||
"{ObjDir¥68K}macterm.c.o" ¶
|
||||
"{ObjDir¥68K}misc.c.o" ¶
|
||||
# "{ObjDir¥68K}ssh.c.o" ¶
|
||||
# "{ObjDir¥68K}sshcrc.c.o" ¶
|
||||
@ -43,9 +44,12 @@ PuTTY
|
||||
Rez mac_res.r -o {Targ} {Includes} -append
|
||||
|
||||
|
||||
"{ObjDir¥68K}mac.c.o" Ä {¥MondoBuild¥} mac.c putty.h macresid.h
|
||||
"{ObjDir¥68K}mac.c.o" Ä {¥MondoBuild¥} mac.c putty.h mac.h macresid.h
|
||||
{C} mac.c -o {Targ} {COptions}
|
||||
|
||||
"{ObjDir¥68K}macterm.c.o" Ä {¥MondoBuild¥} macterm.c mac.h putty.h
|
||||
{C} macterm.c -o {Targ} {COptions}
|
||||
|
||||
"{ObjDir¥68K}misc.c.o" Ä {¥MondoBuild¥} misc.c putty.h
|
||||
{C} misc.c -o {Targ} {COptions}
|
||||
|
||||
|
21
mac.c
21
mac.c
@ -1,4 +1,4 @@
|
||||
/* $Id: mac.c,v 1.1.2.5 1999/02/20 23:55:55 ben Exp $ */
|
||||
/* $Id: mac.c,v 1.1.2.6 1999/02/21 18:09:41 ben Exp $ */
|
||||
/*
|
||||
* mac.c -- miscellaneous Mac-specific routines
|
||||
*/
|
||||
@ -12,18 +12,23 @@
|
||||
#include <Dialogs.h>
|
||||
#include <Devices.h>
|
||||
#include <DiskInit.h>
|
||||
#include <Gestalt.h>
|
||||
#include <ToolUtils.h>
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h> /* putty.h needs size_t */
|
||||
|
||||
#define PUTTY_DO_GLOBALS
|
||||
|
||||
#include "macresid.h"
|
||||
#include "putty.h"
|
||||
#include "mac.h"
|
||||
|
||||
QDGlobals qd;
|
||||
|
||||
int cold = 1;
|
||||
static int cold = 1;
|
||||
long mac_qdversion;
|
||||
|
||||
static void mac_startup(void);
|
||||
static void mac_eventloop(void);
|
||||
@ -64,6 +69,10 @@ static void mac_startup(void) {
|
||||
InitDialogs(nil);
|
||||
cold = 0;
|
||||
|
||||
/* Find out if we've got Color Quickdraw */
|
||||
if (Gestalt(gestaltQuickdrawVersion, &mac_qdversion) != noErr)
|
||||
mac_qdversion = gestaltOriginalQD;
|
||||
|
||||
menuBar = GetNewMBar(128);
|
||||
if (menuBar == NULL)
|
||||
fatalbox("Unable to create menu bar.");
|
||||
@ -172,7 +181,13 @@ static void mac_updatewindow(WindowPtr window) {
|
||||
|
||||
switch (mac_windowtype(window)) {
|
||||
case wTerminal:
|
||||
/* XXX: DO something */
|
||||
BeginUpdate(window);
|
||||
term_paint((struct mac_session *)GetWRefCon(window),
|
||||
(*window->visRgn)->rgnBBox.left,
|
||||
(*window->visRgn)->rgnBBox.top,
|
||||
(*window->visRgn)->rgnBBox.right,
|
||||
(*window->visRgn)->rgnBBox.bottom);
|
||||
EndUpdate(window);
|
||||
break;
|
||||
case wAbout:
|
||||
BeginUpdate(window);
|
||||
|
16
mac_res.r
16
mac_res.r
@ -1,4 +1,4 @@
|
||||
/* $Id: mac_res.r,v 1.1.2.1 1999/02/21 10:29:13 ben Exp $ */
|
||||
/* $Id: mac_res.r,v 1.1.2.2 1999/02/21 18:09:41 ben Exp $ */
|
||||
/* PuTTY resources */
|
||||
|
||||
#define PICT_RezTemplateVersion 1
|
||||
@ -45,8 +45,8 @@ resource 'SIZE' (-1) {
|
||||
reserved,
|
||||
reserved,
|
||||
reserved,
|
||||
65536, /* Minimum size */
|
||||
65536, /* Preferred size */
|
||||
1024 * 1024, /* Minimum size */
|
||||
1024 * 1024, /* Preferred size */
|
||||
};
|
||||
|
||||
resource 'FREF' (128, purgeable) {
|
||||
@ -267,11 +267,11 @@ resource 'MENU' (mApple, preload) {
|
||||
resource 'MENU' (mFile, preload) {
|
||||
mFile,
|
||||
textMenuProc,
|
||||
0b11111111111111111111111111111101,
|
||||
0b11111111111111111111111111111011,
|
||||
enabled,
|
||||
"File",
|
||||
{
|
||||
"New Session" noicon, "N", nomark, plain,
|
||||
"New Session", noicon, "N", nomark, plain,
|
||||
"Close", noicon, "W", nomark, plain,
|
||||
"-", noicon, nokey, nomark, plain,
|
||||
"Quit", noicon, "Q", nomark, plain,
|
||||
@ -313,12 +313,12 @@ resource 'DITL' (wFatal, "fatalbox", purgeable) {
|
||||
/* Terminal window */
|
||||
|
||||
resource 'WIND' (wTerminal, "terminal", purgeable) {
|
||||
{ 0, 0, 0, 0 },
|
||||
{ 0, 0, 200, 200 },
|
||||
zoomDocProc,
|
||||
invisible,
|
||||
goAway,
|
||||
0x0,
|
||||
"untitled"
|
||||
"untitled",
|
||||
staggerParentWindowScreen
|
||||
};
|
||||
|
||||
@ -344,7 +344,7 @@ resource 'DITL' (wAbout, "about", purgeable) {
|
||||
{ 13, 13, 29, 173 },
|
||||
StaticText { disabled, "PuTTY"},
|
||||
{ 42, 13, 74, 173 },
|
||||
StaticText { disabled, "Mac Development\n© 1997-9 Simon Tatham"},
|
||||
StaticText { disabled,"Experimantal Mac Port\n© 1997-9 Simon Tatham"},
|
||||
}
|
||||
};
|
||||
|
||||
|
174
macterm.c
174
macterm.c
@ -2,45 +2,175 @@
|
||||
* macterm.c -- Macintosh terminal front-end
|
||||
*/
|
||||
|
||||
#include <MacTypes.h>
|
||||
#include <Fonts.h>
|
||||
#include <Gestalt.h>
|
||||
#include <MacWindows.h>
|
||||
#include <QuickdrawText.h>
|
||||
#include <Sound.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "macresid.h"
|
||||
#include "putty.h"
|
||||
#include "mac.h"
|
||||
|
||||
struct mac_session {
|
||||
short fnum;
|
||||
int fsize;
|
||||
}
|
||||
short fontnum;
|
||||
int font_ascent;
|
||||
WindowPtr(window);
|
||||
};
|
||||
|
||||
static void mac_initfont(struct mac_session *);
|
||||
|
||||
/* Temporary hack till I get the terminal emulator supporting multiple sessions */
|
||||
|
||||
static struct mac_session *onlysession;
|
||||
|
||||
void mac_newsession(void) {
|
||||
WindowPtr window;
|
||||
struct mac_session *s;
|
||||
|
||||
/* This should obviously be initialised by other means */
|
||||
s = smalloc(sizeof(*s));
|
||||
s->fnum = GetFNum("\pMonaco");
|
||||
s->fsize = 9;
|
||||
rows = 24;
|
||||
cols = 80;
|
||||
strcpy(cfg.font, "Monaco");
|
||||
cfg.fontisbold = 0;
|
||||
cfg.fontheight = 9;
|
||||
onlysession = s;
|
||||
|
||||
/* XXX: non-Color-QuickDraw? Own storage management? */
|
||||
window = GetNewCWindow(wTerminal, NULL, (WindowPtr)-1);
|
||||
SetPort(window);
|
||||
mac_initfont(s);
|
||||
if (mac_qdversion == gestaltOriginalQD)
|
||||
s->window = GetNewWindow(wTerminal, NULL, (WindowPtr)-1);
|
||||
else
|
||||
s->window = GetNewCWindow(wTerminal, NULL, (WindowPtr)-1);
|
||||
SetWRefCon(s->window, (long)s);
|
||||
term_init();
|
||||
term_size(rows, cols);
|
||||
term_size(24, 80, 100);
|
||||
mac_initfont(s);
|
||||
ShowWindow(s->window);
|
||||
}
|
||||
|
||||
void mac_initfont(struct mac_session *s) {
|
||||
FMetricRec metrics;
|
||||
|
||||
TextFont(s->fnum);
|
||||
TextFace(0);
|
||||
TextSize(s->fsize);
|
||||
FontMetrics(&metrics);
|
||||
font_width = metrics.widMax;
|
||||
font_height = metrics.ascent + metrics.descent + metrics.leading;
|
||||
SizeWindow(window, cols * font_width, rows * font_height, TRUE);
|
||||
static void inbuf_putc(int c) {
|
||||
inbuf[inbuf_head] = c;
|
||||
inbuf_head = (inbuf_head+1) & INBUF_MASK;
|
||||
}
|
||||
|
||||
static void inbuf_putstr(const char *c) {
|
||||
while (*c)
|
||||
inbuf_putc(*c++);
|
||||
}
|
||||
|
||||
static void mac_initfont(struct mac_session *s) {
|
||||
Str255 macfont;
|
||||
FontInfo fi;
|
||||
|
||||
SetPort(s->window);
|
||||
macfont[0] = sprintf((char *)&macfont[1], "%s", cfg.font);
|
||||
GetFNum(macfont, &s->fontnum);
|
||||
TextFont(s->fontnum);
|
||||
TextFace(cfg.fontisbold ? bold : 0);
|
||||
TextSize(cfg.fontheight);
|
||||
GetFontInfo(&fi);
|
||||
font_width = fi.widMax;
|
||||
font_height = fi.ascent + fi.descent + fi.leading;
|
||||
s->font_ascent = fi.ascent;
|
||||
SizeWindow(s->window, cols * font_width, rows * font_height, true);
|
||||
inbuf_putstr("Hello,\007 world\007");
|
||||
term_out();
|
||||
}
|
||||
|
||||
/*
|
||||
* Call from the terminal emulator to draw a bit of text
|
||||
*
|
||||
* x and y are text row and column (zero-based)
|
||||
*/
|
||||
void do_text(struct mac_session *s, int x, int y, char *text, int len,
|
||||
unsigned long attr) {
|
||||
int style = 0;
|
||||
|
||||
SetPort(s->window);
|
||||
TextFont(s->fontnum);
|
||||
if (cfg.fontisbold || (attr & ATTR_BOLD) && !cfg.bold_colour)
|
||||
style |= bold;
|
||||
if (attr & ATTR_UNDER)
|
||||
style |= underline;
|
||||
TextFace(style);
|
||||
TextSize(cfg.fontheight);
|
||||
TextMode(srcCopy);
|
||||
SetFractEnable(FALSE); /* We want characters on pixel boundaries */
|
||||
MoveTo(x * font_width, y * font_height + s->font_ascent);
|
||||
DrawText(text, 0, len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Call from the terminal emulator to get its graphics context.
|
||||
* I feel this should disappear entirely (and do_text should take
|
||||
* a Session as an argument. Simon may disagree.
|
||||
*/
|
||||
struct mac_session *get_ctx(void) {
|
||||
|
||||
return onlysession;
|
||||
}
|
||||
|
||||
/*
|
||||
* Presumably this does something in Windows
|
||||
*/
|
||||
void free_ctx(struct mac_session *ctx) {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the scroll bar position
|
||||
*/
|
||||
void set_sbar(int total, int start, int page) {
|
||||
|
||||
/* Do something once we actually have a scroll bar */
|
||||
}
|
||||
|
||||
/*
|
||||
* Beep
|
||||
*/
|
||||
void beep(void) {
|
||||
|
||||
SysBeep(30);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set icon string -- a no-op here (WIndowshade?)
|
||||
*/
|
||||
void set_icon(char *icon) {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the window title
|
||||
*/
|
||||
void set_title(char *title) {
|
||||
Str255 mactitle;
|
||||
|
||||
mactitle[0] = sprintf((char *)&mactitle[1], "%s", title);
|
||||
SetWTitle(onlysession->window, mactitle);
|
||||
}
|
||||
|
||||
/*
|
||||
* Resize the window at the emulator's request
|
||||
*/
|
||||
void request_resize(int w, int h) {
|
||||
|
||||
/* XXX: Do something */
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the logical palette
|
||||
*/
|
||||
void palette_set(int n, int r, int g, int b) {
|
||||
|
||||
/* XXX: Do something */
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset to the default palette
|
||||
*/
|
||||
void palette_reset(void) {
|
||||
|
||||
/* XXX: Do something */
|
||||
}
|
||||
|
41
putty.h
41
putty.h
@ -6,6 +6,7 @@
|
||||
#ifdef macintosh
|
||||
#include <MacTypes.h>
|
||||
typedef UInt32 DWORD;
|
||||
struct mac_session;
|
||||
#endif /* macintosh */
|
||||
|
||||
#ifndef TRUE
|
||||
@ -41,7 +42,8 @@ typedef UInt32 DWORD;
|
||||
#define CHAR_MASK 0x000000FFUL
|
||||
|
||||
#ifdef macintosh
|
||||
typedef void *Context; /* Temporarily until I work out what it should really be */
|
||||
struct mac_session;
|
||||
typedef struct mac_session *Context;
|
||||
#else /* not macintosh */
|
||||
typedef HDC Context;
|
||||
#endif /* not macintosh */
|
||||
@ -59,24 +61,6 @@ typedef HDC Context;
|
||||
#define GLOBAL extern
|
||||
#endif
|
||||
|
||||
struct session {
|
||||
/* Display state */
|
||||
int rows, cols, savelines;
|
||||
int font_width, font_height;
|
||||
int has_focus;
|
||||
/* Buffers */
|
||||
unsigned char inbuf[INBUF_SIZE];
|
||||
int inbuf_head, inbuf_reap;
|
||||
unsigned char outbuf[OUTBUF_SIZE];
|
||||
int outbuf_head, outbuf_reap;
|
||||
/* Emulator state */
|
||||
int app_cursor_keys, app_keypad_keys;
|
||||
/* Backend */
|
||||
Backend *back;
|
||||
/* Config that created this session */
|
||||
Config cfg;
|
||||
}
|
||||
|
||||
GLOBAL int rows, cols, savelines;
|
||||
|
||||
GLOBAL int font_width, font_height;
|
||||
@ -171,6 +155,25 @@ typedef struct {
|
||||
|
||||
GLOBAL Config cfg;
|
||||
|
||||
typedef struct {
|
||||
/* Display state */
|
||||
int rows, cols, savelines;
|
||||
int font_width, font_height;
|
||||
int has_focus;
|
||||
/* Buffers */
|
||||
unsigned char inbuf[INBUF_SIZE];
|
||||
int inbuf_head, inbuf_reap;
|
||||
unsigned char outbuf[OUTBUF_SIZE];
|
||||
int outbuf_head, outbuf_reap;
|
||||
/* Emulator state */
|
||||
int app_cursor_keys, app_keypad_keys;
|
||||
/* Backend */
|
||||
Backend *back;
|
||||
/* Config that created this session */
|
||||
Config cfg;
|
||||
} Session;
|
||||
|
||||
|
||||
/*
|
||||
* Exports from window.c.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user