window.
Pasting works!
[originally from svn r123]
-/* $Id: mac.c,v 1.1.2.16 1999/03/16 20:27:30 ben Exp $ */
+/* $Id: mac.c,v 1.1.2.17 1999/03/21 23:23:42 ben Exp $ */
/*
* Copyright (c) 1999 Ben Harris
* All rights reserved.
static void mac_keypress(EventRecord *);
static int mac_windowtype(WindowPtr);
static void mac_menucommand(long);
-static void mac_adjustcursor(void);
+static void mac_adjustcursor(RgnHandle);
static void mac_adjustmenus(void);
static void mac_closewindow(WindowPtr);
static void mac_zoomwindow(WindowPtr, short);
Boolean gotevent;
EventRecord event;
int i;
+ RgnHandle cursrgn;
+ cursrgn = NewRgn();
for (;;) {
- mac_adjustcursor();
- gotevent = WaitNextEvent(everyEvent, &event, LONG_MAX, NULL);
- mac_adjustcursor();
+ mac_adjustcursor(cursrgn);
+ gotevent = WaitNextEvent(everyEvent, &event, LONG_MAX, cursrgn);
+ mac_adjustcursor(cursrgn);
if (gotevent)
mac_event(&event);
}
+ DisposeRgn(cursrgn);
}
static void mac_event(EventRecord *event) {
/*
* Make sure the right cursor's being displayed.
*/
-static void mac_adjustcursor(void) {
+static void mac_adjustcursor(RgnHandle cursrgn) {
+ Point mouse;
+ WindowPtr window, front;
+ short part;
- SetCursor(&qd.arrow);
+ GetMouse(&mouse);
+ LocalToGlobal(&mouse);
+ part = FindWindow(mouse, &window);
+ front = FrontWindow();
+ if (part != inContent || window == NULL || window != front) {
+ /* Cursor isn't in the front window, so switch to arrow */
+ SetCursor(&qd.arrow);
+ SetRectRgn(cursrgn, SHRT_MIN, SHRT_MIN, SHRT_MAX, SHRT_MAX);
+ if (front != NULL)
+ DiffRgn(cursrgn, front->visRgn, cursrgn);
+ } else {
+ switch (mac_windowtype(window)) {
+ case wTerminal:
+ mac_adjusttermcursor(window, mouse, cursrgn);
+ break;
+ default:
+ SetCursor(&qd.arrow);
+ CopyRgn(window->visRgn, cursrgn);
+ break;
+ }
+ }
}
static void mac_shutdown(void) {
/* from macterm.c */
extern void mac_newsession(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 *);
-/* $Id: macterm.c,v 1.1.2.26 1999/03/18 00:04:34 ben Exp $ */
+/* $Id: macterm.c,v 1.1.2.27 1999/03/21 23:23:42 ben Exp $ */
/*
* Copyright (c) 1999 Ben Harris
* All rights reserved.
SetWinColor(s->window, s->wctab);
}
+/*
+ * Set the cursor shape correctly
+ */
+void mac_adjusttermcursor(WindowPtr window, Point mouse, RgnHandle cursrgn) {
+ struct mac_session *s;
+ ControlHandle control;
+ short part;
+ int x, y;
+
+ SetPort(window);
+ s = (struct mac_session *)GetWRefCon(window);
+ GlobalToLocal(&mouse);
+ part = FindControl(mouse, window, &control);
+ if (control == s->scrollbar) {
+ SetCursor(&qd.arrow);
+ RectRgn(cursrgn, &(*s->scrollbar)->contrlRect);
+ SectRgn(cursrgn, window->visRgn, cursrgn);
+ } else {
+ x = mouse.h / font_width;
+ y = mouse.v / font_height;
+ SetCursor(*GetCursor(iBeamCursor));
+ /* Ask for shape changes if we leave this character cell. */
+ SetRectRgn(cursrgn, x * font_width, y * font_height,
+ (x + 1) * font_width, (y + 1) * font_height);
+ SectRgn(cursrgn, window->visRgn, cursrgn);
+ }
+}
+
/*
* Enable/disable menu items based on the active terminal window.
*/
h = NULL;
} else
if (GetScrap(NULL, 'TEXT', &offset) > 0) {
- h = NewEmptyHandle();
+ h = NewHandle(0);
*lenp = GetScrap(h, 'TEXT', &offset);
HLock(h);
*p = *h;
+ if (*p == NULL || *lenp <= 0)
+ fatalbox("Empty scrap");
} else {
*p = NULL;
*lenp = 0;
s = (struct mac_session *)GetWRefCon(window);
len = mac_keytrans(s, event, buf);
back->send((char *)buf, len);
- term_out();
- term_update();
}
static int mac_keytrans(struct mac_session *s, EventRecord *event,
-/* $Id: testback.c,v 1.1.2.2 1999/03/18 00:04:34 ben Exp $ */
+/* $Id: testback.c,v 1.1.2.3 1999/03/21 23:23:43 ben Exp $ */
/*
* Copyright (c) 1999 Simon Tatham
* Copyright (c) 1999 Ben Harris
inbuf_head = new_head;
}
}
+ term_out();
+ term_update();
}