]> asedeno.scripts.mit.edu Git - PuTTY.git/blob - macterm.c
Start of a Mac front-end to the terminal emulator.
[PuTTY.git] / macterm.c
1 /*
2  * macterm.c -- Macintosh terminal front-end
3  */
4
5 #include <MacWindows.h>
6
7 #include <stdlib.h>
8
9 #include "macresid.h"
10 #include "putty.h"
11
12 struct mac_session {
13         short fnum;
14         int fsize;
15 }
16
17 void mac_newsession(void) {
18     WindowPtr window;
19     struct mac_session *s;
20         
21     /* This should obviously be initialised by other means */
22     s = smalloc(sizeof(*s));
23     s->fnum = GetFNum("\pMonaco");
24     s->fsize = 9;
25     rows = 24;
26     cols = 80;
27         
28     /* XXX: non-Color-QuickDraw?  Own storage management? */
29     window = GetNewCWindow(wTerminal, NULL, (WindowPtr)-1);
30     SetPort(window);
31     mac_initfont(s);
32     term_init();
33     term_size(rows, cols);
34 }
35
36 void mac_initfont(struct mac_session *s) {
37     FMetricRec metrics;
38         
39     TextFont(s->fnum);
40     TextFace(0);
41     TextSize(s->fsize);
42     FontMetrics(&metrics);
43     font_width = metrics.widMax;
44     font_height = metrics.ascent + metrics.descent + metrics.leading;
45     SizeWindow(window, cols * font_width, rows * font_height, TRUE);
46 }