X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/7dcd1f879d7a6d11cc7c4f67ee75a745578a46ad..f33ba69e92f389f5884eae5a586858a629a5260b:/mac/macevlog.c diff --git a/mac/macevlog.c b/mac/macevlog.c index 2bc89299..43a2658f 100644 --- a/mac/macevlog.c +++ b/mac/macevlog.c @@ -1,4 +1,4 @@ -/* $Id: macevlog.c,v 1.1 2003/02/07 01:38:12 ben Exp $ */ +/* $Id: macevlog.c,v 1.8 2003/05/04 14:18:18 simon Exp $ */ /* * Copyright (c) 2003 Ben Harris * All rights reserved. @@ -42,13 +42,15 @@ static void mac_draweventloggrowicon(Session *s); static void mac_adjusteventlogscrollbar(Session *s); +static void mac_clickeventlog(WindowPtr, EventRecord *); +static void mac_activateeventlog(WindowPtr, EventRecord *); +static void mac_groweventlog(WindowPtr, EventRecord *); +static void mac_updateeventlog(WindowPtr); +static void mac_closeeventlog(WindowPtr); static void mac_createeventlog(Session *s) { Rect view; -#if TARGET_API_MAC_CARBON - Rect controlrect; -#endif ListBounds bounds = { 0, 0, 0, 1 }; /* 1 column, 0 rows */ Point csize = { 0, 0 }; GrafPtr saveport; @@ -56,9 +58,15 @@ static void mac_createeventlog(Session *s) WinInfo *wi; s->eventlog_window = GetNewWindow(wEventLog, NULL, (WindowPtr)-1); - wi = smalloc(sizeof(*wi)); + wi = snew(WinInfo); + memset(wi, 0, sizeof(*wi)); wi->s = s; wi->wtype = wEventLog; + wi->click = &mac_clickeventlog; + wi->activate = &mac_activateeventlog; + wi->grow = &mac_groweventlog; + wi->update = &mac_updateeventlog; + wi->close = &mac_closeeventlog; SetWRefCon(s->eventlog_window, (long)wi); GetPort(&saveport); SetPort((GrafPtr)GetWindowPort(s->eventlog_window)); @@ -80,7 +88,6 @@ static void mac_createeventlog(Session *s) #else (*s->eventlog)->selFlags = lExtendDrag | lNoDisjoint | lNoExtend; #endif - ShowWindow(s->eventlog_window); } void mac_freeeventlog(Session *s) @@ -94,17 +101,10 @@ void mac_freeeventlog(Session *s) } } -/* - * FIXME: logevent() should be passed a frontend handle, but backends have to - * have a terminal handle instead, because they pass it to from_backend(), - * so we accept a terminal handle here as well, and hope no-one tries to call - * us with sensible arguments. - */ -void logevent(void *frontend, char *str) +void logevent(void *frontend, const char *str) { - Terminal *term = frontend; - Session *s = term->frontend; - ListBounds bounds; + Session *s = frontend; + ListBounds bounds, visible; Cell cell = { 0, 0 }; if (s->eventlog == NULL) @@ -114,12 +114,18 @@ void logevent(void *frontend, char *str) #if TARGET_API_MAC_CARBON GetListDataBounds(s->eventlog, &bounds); + GetListVisibleCells(s->eventlog, &visible); #else bounds = (*s->eventlog)->dataBounds; + visible = (*s->eventlog)->visible; #endif + cell.v = bounds.bottom; LAddRow(1, cell.v, s->eventlog); LSetCell(str, strlen(str), cell, s->eventlog); + /* ">=" and "2" because there can be a blank cell below the last one. */ + if (visible.bottom >= bounds.bottom) + LScroll(0, 2, s->eventlog); } static void mac_draweventloggrowicon(Session *s) @@ -178,7 +184,7 @@ void mac_clickeventlog(WindowPtr window, EventRecord *event) SetPort(saveport); } -void mac_groweventlog(WindowPtr window, EventRecord *event) +static void mac_groweventlog(WindowPtr window, EventRecord *event) { Session *s = mac_windowsession(window); Rect limits; @@ -210,7 +216,7 @@ void mac_groweventlog(WindowPtr window, EventRecord *event) #endif } -void mac_activateeventlog(WindowPtr window, EventRecord *event) +static void mac_activateeventlog(WindowPtr window, EventRecord *event) { Session *s = mac_windowsession(window); int active = (event->modifiers & activeFlag) != 0; @@ -219,7 +225,7 @@ void mac_activateeventlog(WindowPtr window, EventRecord *event) mac_draweventloggrowicon(s); } -void mac_updateeventlog(WindowPtr window) +static void mac_updateeventlog(WindowPtr window) { Session *s = mac_windowsession(window); #if TARGET_API_MAC_CARBON @@ -240,9 +246,16 @@ void mac_updateeventlog(WindowPtr window) EndUpdate(window); } +static void mac_closeeventlog(WindowPtr window) +{ + + HideWindow(window); +} + void mac_showeventlog(Session *s) { + SelectWindow(s->eventlog_window); ShowWindow(s->eventlog_window); }