-/* $Id: mac.c,v 1.48 2003/02/12 23:53:15 ben Exp $ */
+/* $Id: mac.c,v 1.49 2003/02/15 16:22:15 ben Exp $ */
/*
- * Copyright (c) 1999 Ben Harris
+ * Copyright (c) 1999, 2003 Ben Harris
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
static void mac_keypress(EventRecord *);
static int mac_windowtype(WindowPtr);
static void mac_menucommand(long);
-static void mac_openabout(void);
static void mac_openlicence(void);
static void mac_adjustcursor(RgnHandle);
static void mac_adjustmenus(void);
}
}
-static void mac_contentclick(WindowPtr window, EventRecord *event) {
- short item;
- DialogRef dialog;
+static void mac_contentclick(WindowPtr window, EventRecord *event)
+{
- switch (mac_windowtype(window)) {
- case wTerminal:
- mac_clickterm(window, event);
- break;
- case wAbout:
- dialog = GetDialogFromWindow(window);
- if (DialogSelect(event, &dialog, &item))
- switch (item) {
- case wiAboutLicence:
- mac_openlicence();
- break;
- }
- break;
- case wSettings:
- mac_clickdlg(window, event);
- break;
- case wEventLog:
- mac_clickeventlog(window, event);
- break;
- }
+ if (mac_wininfo(window)->click != NULL)
+ (*mac_wininfo(window)->click)(window, event);
}
-static void mac_growwindow(WindowPtr window, EventRecord *event) {
+static void mac_growwindow(WindowPtr window, EventRecord *event)
+{
- switch (mac_windowtype(window)) {
- case wTerminal:
- mac_growterm(window, event);
- break;
- case wEventLog:
- mac_groweventlog(window, event);
- break;
- }
+ if (mac_wininfo(window)->grow != NULL)
+ (*mac_wininfo(window)->grow)(window, event);
}
-static void mac_activatewindow(WindowPtr window, EventRecord *event) {
- int active;
+static void mac_activatewindow(WindowPtr window, EventRecord *event)
+{
- active = (event->modifiers & activeFlag) != 0;
mac_adjustmenus();
- switch (mac_windowtype(window)) {
- case wTerminal:
- mac_activateterm(window, active);
- break;
- case wSettings:
- mac_activatedlg(window, event);
- break;
- case wAbout:
- mac_activateabout(window, event);
- break;
- case wEventLog:
- mac_activateeventlog(window, event);
- break;
- }
-}
-
-static void mac_activateabout(WindowPtr window, EventRecord *event) {
- DialogRef dialog;
- DialogItemType itemtype;
- Handle itemhandle;
- short item;
- Rect itemrect;
- int active;
-
- dialog = GetDialogFromWindow(window);
- active = (event->modifiers & activeFlag) != 0;
- GetDialogItem(dialog, wiAboutLicence, &itemtype, &itemhandle, &itemrect);
- HiliteControl((ControlHandle)itemhandle, active ? 0 : 255);
- DialogSelect(event, &dialog, &item);
+ if (mac_wininfo(window)->activate != NULL)
+ (*mac_wininfo(window)->activate)(window, event);
}
static void mac_updatewindow(WindowPtr window)
{
-#if TARGET_API_MAC_CARBON
- RgnHandle rgn;
-#endif
- switch (mac_windowtype(window)) {
- case wTerminal:
- mac_updateterm(window);
- break;
- case wAbout:
- case wSettings:
- BeginUpdate(window);
-#if TARGET_API_MAC_CARBON
- rgn = NewRgn();
- GetPortVisibleRegion(GetWindowPort(window), rgn);
- UpdateDialog(GetDialogFromWindow(window), rgn);
- DisposeRgn(rgn);
-#else
- UpdateDialog(window, window->visRgn);
-#endif
- EndUpdate(window);
- break;
- case wLicence:
- mac_updatelicence(window);
- break;
- case wEventLog:
- mac_updateeventlog(window);
- break;
- }
-}
-
-static void mac_updatelicence(WindowPtr window)
-{
- Handle h;
- int len;
- long fondsize;
- Rect textrect;
-
- SetPort((GrafPtr)GetWindowPort(window));
- BeginUpdate(window);
- fondsize = GetScriptVariable(smRoman, smScriptSmallFondSize);
- TextFont(HiWord(fondsize));
- TextSize(LoWord(fondsize));
- h = Get1Resource('TEXT', wLicence);
- len = GetResourceSizeOnDisk(h);
-#if TARGET_API_MAC_CARBON
- GetPortBounds(GetWindowPort(window), &textrect);
-#else
- textrect = window->portRect;
-#endif
- if (h != NULL) {
- HLock(h);
- TETextBox(*h, len, &textrect, teFlushDefault);
- HUnlock(h);
- }
- EndUpdate(window);
+ if (mac_wininfo(window)->update != NULL)
+ (*mac_wininfo(window)->update)(window);
}
/*
mac_adjustmenus();
mac_menucommand(MenuKey(event->message & charCodeMask));
} else {
- switch (mac_windowtype(window)) {
- case wTerminal:
- mac_keyterm(window, event);
- break;
- }
+ if (mac_wininfo(window)->key != NULL)
+ (*mac_wininfo(window)->key)(window, event);
}
}
break;
}
/* If we get here, handling is up to window-specific code. */
- switch (mac_windowtype(window)) {
- case wTerminal:
- mac_menuterm(window, menu, item);
- break;
- }
+ if (mac_wininfo(window)->menu != NULL)
+ (*mac_wininfo(window)->menu)(window, menu, item);
+
done:
HiliteMenu(0);
}
-static void mac_openabout(void) {
- DialogItemType itemtype;
- Handle item;
- VersRecHndl vers;
- Rect box;
- StringPtr longvers;
- WinInfo *wi;
-
- if (windows.about)
- SelectWindow(windows.about);
- else {
- windows.about =
- GetDialogWindow(GetNewDialog(wAbout, NULL, (WindowPtr)-1));
- wi = smalloc(sizeof(*wi));
- wi->s = NULL;
- wi->wtype = wAbout;
- SetWRefCon(windows.about, (long)wi);
- vers = (VersRecHndl)Get1Resource('vers', 1);
- if (vers != NULL && *vers != NULL) {
- longvers = (*vers)->shortVersion + (*vers)->shortVersion[0] + 1;
- GetDialogItem(GetDialogFromWindow(windows.about), wiAboutVersion,
- &itemtype, &item, &box);
- assert(itemtype & kStaticTextDialogItem);
- SetDialogItemText(item, longvers);
- }
- ShowWindow(windows.about);
- }
-}
-
-static void mac_openlicence(void) {
- WinInfo *wi;
-
- if (windows.licence)
- SelectWindow(windows.licence);
- else {
- windows.licence = GetNewWindow(wLicence, NULL, (WindowPtr)-1);
- wi = smalloc(sizeof(*wi));
- wi->s = NULL;
- wi->wtype = wLicence;
- SetWRefCon(windows.licence, (long)wi);
- ShowWindow(windows.licence);
- }
-}
-
static void mac_closewindow(WindowPtr window) {
switch (mac_windowtype(window)) {
CloseDeskAcc(GetWindowKind(window));
break;
#endif
- case wTerminal:
- mac_closeterm(window);
- break;
- case wAbout:
- windows.about = NULL;
- DisposeDialog(GetDialogFromWindow(window));
- break;
- case wLicence:
- windows.licence = NULL;
- DisposeWindow(window);
+ default:
+ if (mac_wininfo(window)->close != NULL)
+ (*mac_wininfo(window)->close)(window);
break;
}
}
DisableItem(menu, iClose);
EnableItem(menu, iQuit);
- switch (mac_windowtype(window)) {
- case wSettings:
- DisableItem(menu, iSave); /* XXX enable if modified */
- EnableItem(menu, iSaveAs);
- EnableItem(menu, iDuplicate);
- menu = GetMenuHandle(mEdit);
- DisableItem(menu, 0);
- break;
- case wTerminal:
- mac_adjusttermmenus(window);
- break;
- default:
+ if (mac_wininfo(window)->adjustmenus != NULL)
+ (*mac_wininfo(window)->adjustmenus)(window);
+ else {
DisableItem(menu, iSave);
DisableItem(menu, iSaveAs);
DisableItem(menu, iDuplicate);
DisableItem(menu, 0);
menu = GetMenuHandle(mWindow);
DisableItem(menu, 0); /* Until we get more than 1 item on it. */
- break;
}
DrawMenuBar();
}
#endif
}
} else {
- switch (mac_windowtype(window)) {
- case wTerminal:
- mac_adjusttermcursor(window, mouse, cursrgn);
- break;
- default:
+ if (mac_wininfo(window)->adjustcursor != NULL)
+ (*mac_wininfo(window)->adjustcursor)(window, mouse, cursrgn);
+ else {
#if TARGET_API_MAC_CARBON
GetQDGlobalsArrow(&arrow);
SetCursor(&arrow);
SetCursor(&qd.arrow);
CopyRgn(window->visRgn, cursrgn);
#endif
- break;
}
}
}
typedef struct {
struct Session *s; /* Only used in PuTTY */
struct KeyState *ks; /* Only used in PuTTYgen */
+
+ void (*activate) (WindowPtr, EventRecord *);
+ void (*adjustcursor)(WindowPtr, Point, RgnHandle);
+ void (*adjustmenus) (WindowPtr);
+ void (*update) (WindowPtr);
+ void (*click) (WindowPtr, EventRecord *);
+ void (*grow) (WindowPtr, EventRecord *);
+ void (*key) (WindowPtr, EventRecord *);
+ void (*menu) (WindowPtr, short, short);
+ void (*close) (WindowPtr);
+
int wtype;
} WinInfo;
+#define mac_wininfo(w) ((WinInfo *)GetWRefCon(w))
#define mac_windowsession(w) (((WinInfo *)GetWRefCon(w))->s)
typedef struct Session {
extern void mac_dupsession(void);
extern void mac_savesession(void);
extern void mac_savesessionas(void);
-extern void mac_clickdlg(WindowPtr, EventRecord *);
-extern void mac_activatedlg(WindowPtr, EventRecord *);
/* from maceventlog.c */
-void mac_freeeventlog(Session *);
-extern void mac_clickeventlog(WindowPtr, EventRecord *);
-extern void mac_activateeventlog(WindowPtr, EventRecord *);
-extern void mac_groweventlog(WindowPtr, EventRecord *);
-extern void mac_updateeventlog(WindowPtr);
+extern void mac_freeeventlog(Session *);
extern void mac_showeventlog(Session *);
/* from macterm.c */
extern void mac_opensession(void);
extern void mac_startsession(Session *);
extern void mac_pollterm(void);
-extern void mac_activateterm(WindowPtr, Boolean);
-extern void mac_adjusttermcursor(WindowPtr, Point, RgnHandle);
-extern void mac_adjusttermmenus(WindowPtr);
-extern void mac_updateterm(WindowPtr);
-extern void mac_clickterm(WindowPtr, EventRecord *);
-extern void mac_growterm(WindowPtr, EventRecord *);
-extern void mac_keyterm(WindowPtr, EventRecord *);
-extern void mac_menuterm(WindowPtr, short, short);
-extern void mac_closeterm(WindowPtr);
/* from macstore.c */
extern OSErr get_putty_dir(Boolean makeit, short *pVRefNum, long *pDirID);
extern OSErr get_session_dir(Boolean makeit, short *pVRefNum, long *pDirID);
extern Socket ot_new(SockAddr addr, int, int, int, int, Plug);
extern Socket ot_newlistener(char *, int, Plug, int);
extern char *ot_addr_error(SockAddr);
+/* from macabout.c */
+extern void mac_openabout(void);
/* from macpgkey.c */
extern void mac_newkey(void);
/* Apple Event Handlers (in various files) */
--- /dev/null
+/* $Id: macabout.c,v 1.1 2003/02/15 16:22:15 ben Exp $ */
+/*
+ * Copyright (c) 1999, 2002, 2003 Ben Harris
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <MacTypes.h>
+#include <Dialogs.h>
+#include <MacWindows.h>
+#include <Resources.h>
+#include <Script.h>
+#include <ToolUtils.h>
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include "putty.h"
+#include "mac.h"
+#include "macresid.h"
+
+static struct mac_windows {
+ WindowPtr about;
+ WindowPtr licence;
+} windows;
+
+static void mac_openlicence(void);
+
+static void mac_clickabout(WindowPtr window, EventRecord *event)
+{
+ short item;
+ DialogRef dialog;
+
+ dialog = GetDialogFromWindow(window);
+ if (DialogSelect(event, &dialog, &item))
+ switch (item) {
+ case wiAboutLicence:
+ mac_openlicence();
+ break;
+ }
+}
+
+static void mac_activateabout(WindowPtr window, EventRecord *event)
+{
+ DialogRef dialog;
+ DialogItemType itemtype;
+ Handle itemhandle;
+ short item;
+ Rect itemrect;
+ int active;
+
+ dialog = GetDialogFromWindow(window);
+ active = (event->modifiers & activeFlag) != 0;
+ GetDialogItem(dialog, wiAboutLicence, &itemtype, &itemhandle, &itemrect);
+ HiliteControl((ControlHandle)itemhandle, active ? 0 : 255);
+ DialogSelect(event, &dialog, &item);
+}
+
+static void mac_updateabout(WindowPtr window)
+{
+#if TARGET_API_MAC_CARBON
+ RgnHandle rgn;
+#endif
+
+ BeginUpdate(window);
+#if TARGET_API_MAC_CARBON
+ rgn = NewRgn();
+ GetPortVisibleRegion(GetWindowPort(window), rgn);
+ UpdateDialog(GetDialogFromWindow(window), rgn);
+ DisposeRgn(rgn);
+#else
+ UpdateDialog(window, window->visRgn);
+#endif
+ EndUpdate(window);
+}
+
+static void mac_updatelicence(WindowPtr window)
+{
+ Handle h;
+ int len;
+ long fondsize;
+ Rect textrect;
+
+ SetPort((GrafPtr)GetWindowPort(window));
+ BeginUpdate(window);
+ fondsize = GetScriptVariable(smRoman, smScriptSmallFondSize);
+ TextFont(HiWord(fondsize));
+ TextSize(LoWord(fondsize));
+ h = Get1Resource('TEXT', wLicence);
+ len = GetResourceSizeOnDisk(h);
+#if TARGET_API_MAC_CARBON
+ GetPortBounds(GetWindowPort(window), &textrect);
+#else
+ textrect = window->portRect;
+#endif
+ if (h != NULL) {
+ HLock(h);
+ TETextBox(*h, len, &textrect, teFlushDefault);
+ HUnlock(h);
+ }
+ EndUpdate(window);
+}
+
+void mac_openabout(void)
+{
+ DialogItemType itemtype;
+ Handle item;
+ VersRecHndl vers;
+ Rect box;
+ StringPtr longvers;
+ WinInfo *wi;
+
+ if (windows.about)
+ SelectWindow(windows.about);
+ else {
+ windows.about =
+ GetDialogWindow(GetNewDialog(wAbout, NULL, (WindowPtr)-1));
+ wi = smalloc(sizeof(*wi));
+ memset(wi, 0, sizeof(*wi));
+ wi->wtype = wAbout;
+ wi->update = &mac_updateabout;
+ wi->click = &mac_clickabout;
+ wi->activate = &mac_activateabout;
+ SetWRefCon(windows.about, (long)wi);
+ vers = (VersRecHndl)Get1Resource('vers', 1);
+ if (vers != NULL && *vers != NULL) {
+ longvers = (*vers)->shortVersion + (*vers)->shortVersion[0] + 1;
+ GetDialogItem(GetDialogFromWindow(windows.about), wiAboutVersion,
+ &itemtype, &item, &box);
+ assert(itemtype & kStaticTextDialogItem);
+ SetDialogItemText(item, longvers);
+ }
+ ShowWindow(windows.about);
+ }
+}
+
+static void mac_openlicence(void)
+{
+ WinInfo *wi;
+
+ if (windows.licence)
+ SelectWindow(windows.licence);
+ else {
+ windows.licence = GetNewWindow(wLicence, NULL, (WindowPtr)-1);
+ wi = smalloc(sizeof(*wi));
+ memset(wi, 0, sizeof(*wi));
+ wi->wtype = wLicence;
+ wi->update = &mac_updatelicence;
+ SetWRefCon(windows.licence, (long)wi);
+ ShowWindow(windows.licence);
+ }
+}
+
-/* $Id: macdlg.c,v 1.11 2003/02/04 23:39:26 ben Exp $ */
+/* $Id: macdlg.c,v 1.12 2003/02/15 16:22:15 ben Exp $ */
/*
* Copyright (c) 2002 Ben Harris
* All rights reserved.
#include "macresid.h"
#include "storage.h"
+static void mac_clickdlg(WindowPtr, EventRecord *);
+static void mac_activatedlg(WindowPtr, EventRecord *);
+static void mac_updatedlg(WindowPtr);
+static void mac_adjustdlgmenus(WindowPtr);
+
void mac_newsession(void)
{
Session *s;
+ WinInfo *wi;
/* This should obviously be initialised by other means */
s = smalloc(sizeof(*s));
s->settings_window =
GetDialogWindow(GetNewDialog(wSettings, NULL, (WindowPtr)-1));
- SetWRefCon(s->settings_window, (long)s);
+ wi = smalloc(sizeof(*wi));
+ memset(wi, 0, sizeof(*wi));
+ wi->s = s;
+ wi->wtype = wSettings;
+ wi->update = &mac_updatedlg;
+ wi->click = &mac_clickdlg;
+ wi->activate = &mac_activatedlg;
+ wi->adjustmenus = &mac_adjustdlgmenus;
+ SetWRefCon(s->settings_window, (long)wi);
ShowWindow(s->settings_window);
}
return errAEEventNotHandled;
}
-void mac_activatedlg(WindowPtr window, EventRecord *event)
+static void mac_activatedlg(WindowPtr window, EventRecord *event)
{
DialogItemType itemtype;
Handle itemhandle;
DialogSelect(event, &dialog, &item);
}
-void mac_clickdlg(WindowPtr window, EventRecord *event)
+static void mac_clickdlg(WindowPtr window, EventRecord *event)
{
short item;
Session *s = mac_windowsession(window);
}
}
+static void mac_updatedlg(WindowPtr window)
+{
+#if TARGET_API_MAC_CARBON
+ RgnHandle rgn;
+#endif
+
+ BeginUpdate(window);
+#if TARGET_API_MAC_CARBON
+ rgn = NewRgn();
+ GetPortVisibleRegion(GetWindowPort(window), rgn);
+ UpdateDialog(GetDialogFromWindow(window), rgn);
+ DisposeRgn(rgn);
+#else
+ UpdateDialog(window, window->visRgn);
+#endif
+ EndUpdate(window);
+}
+
+#if TARGET_API_MAC_CARBON
+#define EnableItem EnableMenuItem
+#define DisableItem DisableMenuItem
+#endif
+static void mac_adjustdlgmenus(WindowPtr window)
+{
+ MenuHandle menu;
+
+ menu = GetMenuHandle(mFile);
+ DisableItem(menu, iSave); /* XXX enable if modified */
+ EnableItem(menu, iSaveAs);
+ EnableItem(menu, iDuplicate);
+
+ menu = GetMenuHandle(mEdit);
+ DisableItem(menu, 0);
+}
+
/*
* Local Variables:
* c-file-style: "simon"
-/* $Id: macevlog.c,v 1.1 2003/02/07 01:38:12 ben Exp $ */
+/* $Id: macevlog.c,v 1.2 2003/02/15 16:22:15 ben Exp $ */
/*
* Copyright (c) 2003 Ben Harris
* All rights reserved.
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_createeventlog(Session *s)
{
s->eventlog_window = GetNewWindow(wEventLog, NULL, (WindowPtr)-1);
wi = smalloc(sizeof(*wi));
+ 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;
SetWRefCon(s->eventlog_window, (long)wi);
GetPort(&saveport);
SetPort((GrafPtr)GetWindowPort(s->eventlog_window));
SetPort(saveport);
}
-void mac_groweventlog(WindowPtr window, EventRecord *event)
+static void mac_groweventlog(WindowPtr window, EventRecord *event)
{
Session *s = mac_windowsession(window);
Rect limits;
#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;
mac_draweventloggrowicon(s);
}
-void mac_updateeventlog(WindowPtr window)
+static void mac_updateeventlog(WindowPtr window)
{
Session *s = mac_windowsession(window);
#if TARGET_API_MAC_CARBON
-/* $Id: macterm.c,v 1.70 2003/02/11 23:10:34 ben Exp $ */
+/* $Id: macterm.c,v 1.71 2003/02/15 16:22:15 ben Exp $ */
/*
* Copyright (c) 1999 Simon Tatham
* Copyright (c) 1999, 2002 Ben Harris
static pascal void mac_scrolltracker(ControlHandle, short);
static pascal void do_text_for_device(short, short, GDHandle, long);
static void text_click(Session *, EventRecord *);
+static void mac_activateterm(WindowPtr, EventRecord *);
+static void mac_adjusttermcursor(WindowPtr, Point, RgnHandle);
+static void mac_adjusttermmenus(WindowPtr);
+static void mac_updateterm(WindowPtr);
+static void mac_clickterm(WindowPtr, EventRecord *);
+static void mac_growterm(WindowPtr, EventRecord *);
+static void mac_keyterm(WindowPtr, EventRecord *);
+static void mac_menuterm(WindowPtr, short, short);
+static void mac_closeterm(WindowPtr);
void pre_paint(Session *s);
void post_paint(Session *s);
else
s->window = GetNewWindow(wTerminal, NULL, (WindowPtr)-1);
wi = smalloc(sizeof(*wi));
+ memset(wi, 0, sizeof(*wi));
wi->s = s;
wi->wtype = wTerminal;
+ wi->activate = &mac_activateterm;
+ wi->adjustcursor = &mac_adjusttermcursor;
+ wi->adjustmenus = &mac_adjusttermmenus;
+ wi->update = &mac_updateterm;
+ wi->click = &mac_clickterm;
+ wi->grow = &mac_growterm;
+ wi->key = &mac_keyterm;
+ wi->menu = &mac_menuterm;
+ wi->close = &mac_closeterm;
SetWRefCon(s->window, (long)wi);
s->scrollbar = GetNewControl(cVScroll, s->window);
s->term = term_init(&s->cfg, &s->ucsdata, s);
static UnicodeToTextFallbackUPP uni_to_font_fallback_upp;
-static void mac_initfont(Session *s) {
+static void mac_initfont(Session *s)
+{
FontInfo fi;
TextEncoding enc;
OptionBits fbflags;
mac_drawgrowicon(s);
}
-static void mac_initpalette(Session *s) {
+static void mac_initpalette(Session *s)
+{
if (!HAVE_COLOR_QD())
return;
* Set the background colour of the window correctly. Should be
* called whenever the default background changes.
*/
-static void mac_adjustwinbg(Session *s) {
+static void mac_adjustwinbg(Session *s)
+{
if (!HAVE_COLOR_QD())
return;
/*
* Set the cursor shape correctly
*/
-void mac_adjusttermcursor(WindowPtr window, Point mouse, RgnHandle cursrgn) {
+static void mac_adjusttermcursor(WindowPtr window, Point mouse,
+ RgnHandle cursrgn)
+{
Session *s;
ControlHandle control;
short part;
#define DisableItem DisableMenuItem
#define EnableItem EnableMenuItem
#endif
-void mac_adjusttermmenus(WindowPtr window) {
+static void mac_adjusttermmenus(WindowPtr window)
+{
Session *s;
MenuHandle menu;
#if !TARGET_API_MAC_CARBON
EnableItem(menu, iShowEventLog);
}
-void mac_menuterm(WindowPtr window, short menu, short item) {
+static void mac_menuterm(WindowPtr window, short menu, short item)
+{
Session *s;
s = mac_windowsession(window);
}
}
-void mac_clickterm(WindowPtr window, EventRecord *event) {
+static void mac_clickterm(WindowPtr window, EventRecord *event)
+{
Session *s;
Point mouse;
ControlHandle control;
}
}
-static void text_click(Session *s, EventRecord *event) {
+static void text_click(Session *s, EventRecord *event)
+{
Point localwhere;
int row, col;
static UInt32 lastwhen = 0;
#endif
}
-void get_clip(void *frontend, wchar_t **p, int *lenp) {
+void get_clip(void *frontend, wchar_t **p, int *lenp)
+{
#if TARGET_API_MAC_CARBON
*lenp = 0;
#else
#endif
}
-static pascal void mac_scrolltracker(ControlHandle control, short part) {
+static pascal void mac_scrolltracker(ControlHandle control, short part)
+{
Session *s;
#if TARGET_API_MAC_CARBON
}
}
-void mac_keyterm(WindowPtr window, EventRecord *event) {
+static void mac_keyterm(WindowPtr window, EventRecord *event)
+{
Session *s = mac_windowsession(window);
Key_Sym keysym = PK_NULL;
unsigned int mods = 0, flags = PKF_NUMLOCK;
char oldmsg[20];
} growterm_state;
-void mac_growterm(WindowPtr window, EventRecord *event) {
+static void mac_growterm(WindowPtr window, EventRecord *event)
+{
Rect limits;
long grow_result;
int newrows, newcols;
sfree(s);
}
-void mac_activateterm(WindowPtr window, Boolean active) {
+static void mac_activateterm(WindowPtr window, EventRecord *event)
+{
Session *s;
+ Boolean active = (event->modifiers & activeFlag) != 0;
s = mac_windowsession(window);
s->term->has_focus = active;
mac_drawgrowicon(s);
}
-void mac_updateterm(WindowPtr window) {
+static void mac_updateterm(WindowPtr window)
+{
Session *s;
Rect bbox;
#if TARGET_API_MAC_CARBON
EndUpdate(window);
}
-static void mac_drawgrowicon(Session *s) {
+static void mac_drawgrowicon(Session *s)
+{
Rect clip;
RgnHandle savergn;
* x and y are text row and column (zero-based)
*/
void do_text(Context ctx, int x, int y, char *text, int len,
- unsigned long attr, int lattr) {
+ unsigned long attr, int lattr)
+{
Session *s = ctx;
int style;
struct do_text_args a;
}
static pascal void do_text_for_device(short depth, short devflags,
- GDHandle device, long cookie) {
+ GDHandle device, long cookie)
+{
struct do_text_args *a = (struct do_text_args *)cookie;
int bgcolour, fgcolour, bright, reverse, tmp;
#if TARGET_API_MAC_CARBON
* Call from the terminal emulator to get its graphics context.
* Should probably be called start_redraw or something.
*/
-void pre_paint(Session *s) {
+void pre_paint(Session *s)
+{
GDHandle gdh;
Rect myrect, tmprect;
#if TARGET_API_MAC_CARBON
(s->cfg.bold_colour ? ATTR_BOLD : 0));
}
-Context get_ctx(void *frontend) {
+Context get_ctx(void *frontend)
+{
Session *s = frontend;
pre_paint(s);
return s;
}
-void free_ctx(Context ctx) {
+void free_ctx(Context ctx)
+{
}
/*
* Presumably this does something in Windows
*/
-void post_paint(Session *s) {
+void post_paint(Session *s)
+{
}
* start is the line number of the top of the display
* page is the length of the displayed page
*/
-void set_sbar(void *frontend, int total, int start, int page) {
+void set_sbar(void *frontend, int total, int start, int page)
+{
Session *s = frontend;
/* We don't redraw until we've set everything up, to avoid glitches */
/*
* Set the window title
*/
-void set_title(void *frontend, char *title) {
+void set_title(void *frontend, char *title)
+{
Session *s = frontend;
Str255 mactitle;
/*
* Set the logical palette. Called by the terminal emulator.
*/
-void palette_set(void *frontend, int n, int r, int g, int b) {
+void palette_set(void *frontend, int n, int r, int g, int b)
+{
Session *s = frontend;
static const int first[21] = {
0, 2, 4, 6, 8, 10, 12, 14,
/*
* Reset to the default palette
*/
-void palette_reset(void *frontend) {
+void palette_reset(void *frontend)
+{
Session *s = frontend;
/* This maps colour indices in cfg to those used in our palette. */
static const int ww[] = {
* Scroll the screen. (`lines' is +ve for scrolling forward, -ve
* for backward.)
*/
-void do_scroll(Context ctx, int topline, int botline, int lines) {
+void do_scroll(Context ctx, int topline, int botline, int lines)
+{
Session *s = ctx;
Rect r;
RgnHandle scrollrgn = NewRgn();