]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - mac.c
Menu items now turn on and off in a vaguely useful way.
[PuTTY.git] / mac.c
diff --git a/mac.c b/mac.c
index 19636019a6c403f62afda6a96fdf9b8f35c1a6ec..db6ff19ab6d0fe87007dc0c22959cfb27a6fdcd1 100644 (file)
--- a/mac.c
+++ b/mac.c
@@ -1,4 +1,4 @@
-/* $Id: mac.c,v 1.1.2.11 1999/03/03 22:03:54 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.
@@ -44,6 +44,7 @@
 #include <limits.h>
 #include <stdarg.h>
 #include <stdlib.h>            /* putty.h needs size_t */
+#include <stdio.h>             /* for vsprintf */
 
 #define PUTTY_DO_GLOBALS
 
@@ -74,6 +75,14 @@ static void mac_shutdown(void);
 
 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();
@@ -122,6 +131,9 @@ static void mac_startup(void) {
     mac_adjustmenus();
     DrawMenuBar();
     InitCursor();
+    windows.terminal = NULL;
+    windows.about = NULL;
+    windows.licence = NULL;
 }
 
 static void mac_eventloop(void) {
@@ -227,6 +239,7 @@ static void mac_growwindow(WindowPtr window, EventRecord *event) {
 
 static void mac_activatewindow(WindowPtr window, Boolean active) {
 
+    mac_adjustmenus();
     switch (mac_windowtype(window)) {
       case wTerminal:
        mac_activateterm(window, active);
@@ -273,11 +286,19 @@ static int mac_windowtype(WindowPtr window) {
  */
 static void mac_keypress(EventRecord *event) {
     char key;
+    WindowPtr window;
 
     if (event->what == keyDown && (event->modifiers & cmdKey)) {
        mac_adjustmenus();
        mac_menucommand(MenuKey(event->message & charCodeMask));
-    }
+    } else {
+       window = FrontWindow();
+       switch (mac_windowtype(window)) {
+         case wTerminal:
+           mac_keyterm(window, event);
+           break;
+       }
+    }       
 }
 
 static void mac_menucommand(long result) {
@@ -339,7 +360,29 @@ static void mac_zoomwindow(WindowPtr window, short part) {
  * 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();
 }
 
 /*
@@ -350,6 +393,16 @@ static void mac_adjustcursor(void) {
     SetCursor(&qd.arrow);
 }
 
+void write_clip(void *data, int len) {
+
+    /* XXX: do something */
+}
+
+void get_clip(void **p, int *lenp) {
+
+    /* XXX: do something */
+}
+
 static void mac_shutdown(void) {
 
     exit(0);
@@ -367,3 +420,9 @@ void fatalbox(const char *fmt, ...) {
     StopAlert(128, nil);
     exit(1);
 }
+
+/*
+ * Local Variables:
+ * c-file-style: "simon"
+ * End:
+ */