X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/9897fb6cd830ce32b4b19dfe816888764f81bc98..62ddb51e0424dd4bd1098b024f2427959aefc729:/mac/macevlog.c diff --git a/mac/macevlog.c b/mac/macevlog.c index a0aa0dae..9c99f69f 100644 --- a/mac/macevlog.c +++ b/mac/macevlog.c @@ -1,4 +1,4 @@ -/* $Id: macevlog.c,v 1.4 2003/02/23 12:41:44 ben Exp $ */ +/* $Id$ */ /* * Copyright (c) 2003 Ben Harris * All rights reserved. @@ -46,6 +46,7 @@ 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) { @@ -57,7 +58,7 @@ 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; @@ -65,6 +66,7 @@ static void mac_createeventlog(Session *s) 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)); @@ -86,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) @@ -100,18 +101,21 @@ 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; + Session *s = frontend; ListBounds bounds, visible; Cell cell = { 0, 0 }; + char timebuf[40]; + struct tm tm; + char *string; + + tm=ltime(); + strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S\t", &tm); + + string=snewn(strlen(timebuf) + strlen(str) +1, char); + strcpy(string, timebuf); + strcat(string, str); if (s->eventlog == NULL) mac_createeventlog(s); @@ -128,10 +132,11 @@ void logevent(void *frontend, char *str) cell.v = bounds.bottom; LAddRow(1, cell.v, s->eventlog); - LSetCell(str, strlen(str), cell, s->eventlog); + LSetCell(string, strlen(string), 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); + sfree(string); } static void mac_draweventloggrowicon(Session *s) @@ -252,9 +257,16 @@ static 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); }