-/* $Id: macterm.c,v 1.66 2003/02/04 02:03:53 ben Exp $ */
+/* $Id: macterm.c,v 1.70 2003/02/11 23:10:34 ben Exp $ */
/*
* Copyright (c) 1999 Simon Tatham
* Copyright (c) 1999, 2002 Ben Harris
{
char *errmsg;
int i;
+ WinInfo *wi;
init_ucs(s);
s->window = GetNewCWindow(wTerminal, NULL, (WindowPtr)-1);
else
s->window = GetNewWindow(wTerminal, NULL, (WindowPtr)-1);
- SetWRefCon(s->window, (long)s);
+ wi = smalloc(sizeof(*wi));
+ wi->s = s;
+ wi->wtype = wTerminal;
+ SetWRefCon(s->window, (long)wi);
s->scrollbar = GetNewControl(cVScroll, s->window);
s->term = term_init(&s->cfg, &s->ucsdata, s);
ActivatePalette(s->window);
}
- s->logctx = log_init(s, &s->cfg);
+ s->logctx = log_init(s->term, &s->cfg);
term_provide_logctx(s->term, s->logctx);
errmsg = s->back->init(s->term, &s->backhandle, &s->cfg, s->cfg.host,
#endif
SetPort((GrafPtr)GetWindowPort(window));
- s = (Session *)GetWRefCon(window);
+ s = mac_windowsession(window);
GlobalToLocal(&mouse);
part = FindControl(mouse, window, &control);
if (control == s->scrollbar) {
long offset;
#endif
- s = (Session *)GetWRefCon(window);
+ s = mac_windowsession(window);
menu = GetMenuHandle(mFile);
DisableItem(menu, iSave); /* XXX enable if modified */
EnableItem(menu, iSaveAs);
#if TARGET_API_MAC_CARBON
if (1)
#else
- if (GetScrap(NULL, 'TEXT', &offset) == noTypeErr)
+ if (GetScrap(NULL, kScrapFlavorTypeText, &offset) == noTypeErr)
#endif
DisableItem(menu, iPaste);
else
EnableItem(menu, iPaste);
DisableItem(menu, iClear);
EnableItem(menu, iSelectAll);
+ menu = GetMenuHandle(mWindow);
+ EnableItem(menu, 0);
+ EnableItem(menu, iShowEventLog);
}
void mac_menuterm(WindowPtr window, short menu, short item) {
Session *s;
- s = (Session *)GetWRefCon(window);
+ s = mac_windowsession(window);
switch (menu) {
case mEdit:
switch (item) {
term_do_paste(s->term);
break;
}
+ break;
+ case mWindow:
+ switch(item) {
+ case iShowEventLog:
+ mac_showeventlog(s);
+ break;
+ }
+ break;
}
}
int part;
static ControlActionUPP mac_scrolltracker_upp = NULL;
- s = (Session *)GetWRefCon(window);
+ s = mac_windowsession(window);
SetPort((GrafPtr)GetWindowPort(window));
mouse = event->where;
GlobalToLocal(&mouse);
*/
if (ZeroScrap() != noErr)
return;
- PutScrap(len * sizeof(*data), 'utxt', data);
+ PutScrap(len * sizeof(*data), kScrapFlavorTypeUnicode, data);
/* Replace LINE SEPARATORs with CR for TEXT output. */
for (i = 0; i < len; i++)
s->font_charset, NULL, ".", 1);
} else
return;
- PutScrap(olen, 'TEXT', mactextbuf);
+ PutScrap(olen, kScrapFlavorTypeText, mactextbuf);
sfree(mactextbuf);
stsz = offsetof(StScrpRec, scrpStyleTab) + sizeof(ScrpSTElement);
stsc->scrpStyleTab[0].scrpColor.red = 0;
stsc->scrpStyleTab[0].scrpColor.green = 0;
stsc->scrpStyleTab[0].scrpColor.blue = 0;
- PutScrap(stsz, 'styl', stsc);
+ PutScrap(stsz, kScrapFlavorTypeTextStyle, stsc);
sfree(stsc);
#endif
}
sfree(data);
data = NULL;
} else {
- if (GetScrap(NULL, 'utxt', &offset) > 0) {
+ if (GetScrap(NULL, kScrapFlavorTypeUnicode, &offset) > 0) {
if (h == NULL)
h = NewHandle(0);
- *lenp = GetScrap(h, 'utxt', &offset) / sizeof(**p);
+ *lenp =
+ GetScrap(h, kScrapFlavorTypeUnicode, &offset) / sizeof(**p);
HLock(h);
*p = (wchar_t *)*h;
- } else if (GetScrap(NULL, 'TEXT', &offset) > 0) {
+ } else if (GetScrap(NULL, kScrapFlavorTypeText, &offset) > 0) {
texth = NewHandle(0);
- textlen = GetScrap(texth, 'TEXT', &offset);
+ textlen = GetScrap(texth, kScrapFlavorTypeText, &offset);
HLock(texth);
data = smalloc(textlen * 2);
/* XXX should use 'styl' scrap if it's there. */
Session *s;
#if TARGET_API_MAC_CARBON
- s = (Session *)GetWRefCon(GetControlOwner(control));
+ s = mac_windowsession(GetControlOwner(control));
#else
- s = (Session *)GetWRefCon((*control)->contrlOwner);
+ s = mac_windowsession((*control)->contrlOwner);
#endif
switch (part) {
case kControlUpButtonPart:
}
void mac_keyterm(WindowPtr window, EventRecord *event) {
- Session *s = (Session *)GetWRefCon(window);
+ Session *s = mac_windowsession(window);
Key_Sym keysym = PK_NULL;
unsigned int mods = 0, flags = PKF_NUMLOCK;
UniChar utxt[1];
FontInfo fi;
#endif
- s = (Session *)GetWRefCon(window);
+ s = mac_windowsession(window);
#if !TARGET_API_MAC_CARBON
draghooksave = LMGetDragHook();
void mac_closeterm(WindowPtr window)
{
- Session *s = (Session *)GetWRefCon(window);
+ Session *s = mac_windowsession(window);
/* XXX warn on close */
HideWindow(s->window);
if (s->uni_to_font != NULL)
DisposeUnicodeToTextInfo(&s->uni_to_font);
term_free(s->term);
+ mac_freeeventlog(s);
+ sfree((WinInfo *)GetWRefCon(s->window));
DisposeWindow(s->window);
DisposePalette(s->palette);
sfree(s);
void mac_activateterm(WindowPtr window, Boolean active) {
Session *s;
- s = (Session *)GetWRefCon(window);
+ s = mac_windowsession(window);
s->term->has_focus = active;
term_update(s->term);
if (active)
RgnHandle visrgn;
#endif
- s = (Session *)GetWRefCon(window);
+ s = mac_windowsession(window);
SetPort((GrafPtr)GetWindowPort(window));
BeginUpdate(window);
pre_paint(s);
/*
* Resize the window at the emulator's request
*/
-void request_resize(void *frontend, int w, int h) {
+void request_resize(void *frontend, int w, int h)
+{
Session *s = frontend;
+ RgnHandle grayrgn;
+ Rect graybox;
+ int wlim, hlim;
+ /* Arbitrarily clip to the size of the desktop. */
+ grayrgn = GetGrayRgn();
+#if TARGET_API_MAC_CARBON
+ GetRegionBounds(grayrgn, &graybox);
+#else
+ graybox = (*grayrgn)->rgnBBox;
+#endif
+ wlim = (graybox.right - graybox.left) / s->font_width;
+ hlim = (graybox.bottom - graybox.top) / s->font_height;
+ if (w > wlim) w = wlim;
+ if (h > hlim) h = hlim;
term_size(s->term, h, w, s->cfg.savelines);
mac_initfont(s);
}
DisposeRgn(update);
}
-void logevent(void *frontend, char *str) {
-
- fprintf(stderr, "%s\n", str);
-}
-
/* Dummy routine, only required in plink. */
void ldisc_update(void *frontend, int echo, int edit)
{