Dragging to select now works.
[originally from svn r90]
-/* $Id: mac.c,v 1.1.2.13 1999/03/09 00:09:50 ben Exp $ */
+/* $Id: mac.c,v 1.1.2.14 1999/03/11 21:40:31 ben Exp $ */
/*
* Copyright (c) 1999 Ben Harris
* All rights reserved.
static void mac_newsession(void);
+struct mac_windows {
+ WindowPtr terminal; /* XXX: Temporary */
+ WindowPtr about;
+ WindowPtr licence;
+};
+
+struct mac_windows windows;
+
int main (int argc, char **argv) {
mac_startup();
mac_adjustmenus();
DrawMenuBar();
InitCursor();
+ windows.terminal = NULL;
+ windows.about = NULL;
+ windows.licence = NULL;
}
static void mac_eventloop(void) {
static void mac_activatewindow(WindowPtr window, Boolean active) {
+ mac_adjustmenus();
switch (mac_windowtype(window)) {
case wTerminal:
mac_activateterm(window, active);
* Make the menus look right before the user gets to see them.
*/
static void mac_adjustmenus(void) {
+ WindowPtr window;
+ MenuHandle menu;
+ window = FrontWindow();
+ menu = GetMenuHandle(mApple);
+ EnableItem(menu, 0);
+ EnableItem(menu, iAbout);
+
+ menu = GetMenuHandle(mFile);
+ EnableItem(menu, 0);
+ EnableItem(menu, iNew);
+ EnableItem(menu, iQuit);
+
+ switch (mac_windowtype(window)) {
+ case wTerminal:
+ mac_adjusttermmenus(window);
+ break;
+ default:
+ menu = GetMenuHandle(mEdit);
+ DisableItem(menu, 0);
+ break;
+ }
+ DrawMenuBar();
}
/*
StopAlert(128, nil);
exit(1);
}
+
+/*
+ * Local Variables:
+ * c-file-style: "simon"
+ * End:
+ */
/* from macterm.c */
extern void mac_newsession(void);
extern void mac_activateterm(WindowPtr, Boolean);
+extern void mac_adjusttermmenus(WindowPtr);
extern void mac_updateterm(WindowPtr);
extern void mac_clickterm(WindowPtr, EventRecord *);
extern void mac_growterm(WindowPtr, EventRecord *);
-/* $Id: mac_res.r,v 1.1.2.8 1999/03/09 00:06:34 ben Exp $ */
+/* $Id: mac_res.r,v 1.1.2.9 1999/03/11 21:40:31 ben Exp $ */
/*
* Copyright (c) 1999 Ben Harris
* All rights reserved.
/* Menu bar */
resource 'MBAR' (MBAR_Main, preload) {
- { mApple, mFile }
+ { mApple, mFile, mEdit }
};
resource 'MENU' (mApple, preload) {
}
};
+resource 'MENU' (mEdit, preload) {
+ mEdit,
+ textMenuProc,
+ 0b11111111111111111111111111111101,
+ enabled,
+ "Edit",
+ {
+ "Undo", noicon, "Z", nomark, plain,
+ "-", noicon, nokey, nomark, plain,
+ "Cut", noicon, "X", nomark, plain,
+ "Copy", noicon, "C", nomark, plain,
+ "Paste", noicon, "V", nomark, plain,
+ "Clear", noicon, nokey, nomark, plain,
+ "Select All", noicon, "A", nomark, plain,
+ }
+};
+
/* Fatal error box. Stolen from the Finder. */
resource 'ALRT' (wFatal, "fatalbox", purgeable) {
read 'pTST' (128, "test data", purgeable) "fragment";
-type 'cMAP' {
- hexstring;
+type 'pMAP' {
+ hex string;
};
-resource 'cMAP' (128, "Latin-1 G1 -> Mac OS Roman") {
+resource 'pMAP' (128, "Latin-1 G1 -> Mac OS Roman") {
$"20 c1 a2 a3 db b4 00 a4 ac a9 bb c7 c2 00 a8 f8"
$"a1 b1 00 00 ab b5 a6 e1 fc 00 bc c8 00 00 00 c0"
$"cb e7 e5 cc 80 81 ae 82 e9 83 e6 e8 ed ea eb ec"
$"00 96 98 97 99 9b 9a d6 bf 9d 9c 9e 9f 00 00 D8"
};
-resource 'cMAP' (129, "DEC line drawing -> Mac OS VT100") {
+resource 'pMAP' (129, "DEC line drawing -> Mac OS VT100") {
$"d7 bd 09 0c 0d 0a a1 b1 00 0b d2 d3 d4 d5 da e2"
$"e3 e4 f5 f6 f7 f8 f9 fa fb b2 b3 b9 ad a3 e1"
+};
\ No newline at end of file
-/* $Id: macresid.h,v 1.1.2.4 1999/02/28 02:38:40 ben Exp $ */
+/* $Id: macresid.h,v 1.1.2.5 1999/03/11 21:40:32 ben Exp $ */
/*
* macresid.h -- Mac resource IDs
/* Menu IDs */
#define mApple 128
#define mFile 129
+#define mEdit 130
/* Menu Items */
/* Apple menu */
#define iNew 1
#define iClose 2
#define iQuit 4
+/* Edit menu */
+#define iUndo 1
+#define iCut 3
+#define iCopy 4
+#define iPaste 5
+#define iClear 6
+#define iSelectAll 7
/* Window types (and resource IDs) */
#define wNone 0 /* Dummy value for no window */
-/* $Id: macterm.c,v 1.1.2.16 1999/03/09 00:09:50 ben Exp $ */
+/* $Id: macterm.c,v 1.1.2.17 1999/03/11 21:40:32 ben Exp $ */
/*
* Copyright (c) 1999 Ben Harris
* All rights reserved.
#include <Quickdraw.h>
#include <QuickdrawText.h>
#include <Resources.h>
+#include <Scrap.h>
#include <Sound.h>
#include <ToolUtils.h>
SetWinColor(s->window, cth);
}
+/*
+ * Enable/disable menu items based on the active terminal window.
+ */
+void mac_adjusttermmenus(WindowPtr window) {
+ struct mac_session *s;
+ MenuHandle menu;
+ long offset;
+
+ s = (struct mac_session *)GetWRefCon(window);
+ menu = GetMenuHandle(mEdit);
+ EnableItem(menu, 0);
+ DisableItem(menu, iUndo);
+ DisableItem(menu, iCut);
+ DisableItem(menu, iCopy);
+ if (GetScrap(NULL, 'TEXT', &offset) == noTypeErr)
+ DisableItem(menu, iPaste);
+ else
+ EnableItem(menu, iPaste);
+ DisableItem(menu, iClear);
+ EnableItem(menu, iSelectAll);
+}
+
void mac_clickterm(WindowPtr window, EventRecord *event) {
struct mac_session *s;
Point mouse;
lastact = MA_CLICK;
term_mouse(event->modifiers & shiftKey ? MB_EXTEND : MB_SELECT, lastact,
col, row);
- while (StillDown()) {
- /* XXX Do something */
- }
lastsess = s;
lastrow = row;
lastcol = col;
- lastwhen = event->when; /* XXX: should be time of mmouse _up_ */
+ while (StillDown()) {
+ GetMouse(&localwhere);
+ col = localwhere.h / font_width;
+ row = localwhere.v / font_height;
+ term_mouse(event->modifiers & shiftKey ? MB_EXTEND : MB_SELECT,
+ MA_DRAG, col, row);
+ if (row > rows - 1)
+ term_scroll(0, row - (rows - 1));
+ else if (row < 0)
+ term_scroll(0, row);
+ }
+ lastwhen = TickCount();
}
static pascal void mac_scrolltracker(ControlHandle control, short part) {
InvalRgn(update);
DisposeRgn(update);
}
+
+/*
+ * Emacs magic:
+ * Local Variables:
+ * c-file-style: "simon"
+ * End:
+ */