]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
The edit menu is now mostly functional. I'm not sure about paste, since I
authorBen Harris <bjh21@bjh21.me.uk>
Tue, 16 Mar 1999 20:27:31 +0000 (20:27 +0000)
committerBen Harris <bjh21@bjh21.me.uk>
Tue, 16 Mar 1999 20:27:31 +0000 (20:27 +0000)
haven't got a working backend at the moment, but it all looks OK.

[originally from svn r118]

Makefile.mpw
mac.c
mac.h
mac_res.r
maccfg.c
macterm.c
putty.h
terminal.c

index ccebe9a5b0ee6acd1329bf25b63fba1fb3b5f923..7d7c98af9884875c0997fa2c047eba3d5f3940bd 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: Makefile.mpw,v 1.1.2.2 1999/03/14 20:07:04 ben Exp $
+# $Id: Makefile.mpw,v 1.1.2.3 1999/03/16 20:27:30 ben Exp $
 # This is the Makefile for building PuTTY for the Mac OS.
 # Users of non-Mac systems will see some pretty strange characters around.
 
@@ -34,12 +34,14 @@ Libs
 PuTTY ÄÄ {Objects¥68K} {Libs¥68K}
        IF (`exists {Targ}.NJ`)
                ILink ¶
+                       -compact ¶
                        -o {Targ} {Sym¥68K} ¶
                        -t 'APPL' ¶
                        -c 'pTTY' ¶
                        -newerdeps {NewerDeps}
        ELSE
                ILink ¶
+                       -compact ¶
                        -o {Targ} {Sym¥68K} ¶
                        -t 'APPL' ¶
                        -c 'pTTY' ¶
diff --git a/mac.c b/mac.c
index 72a95b8bd9a45781817c1f0876607a46c4680cca..ea2664002b27ea743e84b996b15f62b5b0981326 100644 (file)
--- a/mac.c
+++ b/mac.c
@@ -1,4 +1,4 @@
-/* $Id: mac.c,v 1.1.2.15 1999/03/14 13:08:43 ben Exp $ */
+/* $Id: mac.c,v 1.1.2.16 1999/03/16 20:27:30 ben Exp $ */
 /*
  * Copyright (c) 1999 Ben Harris
  * All rights reserved.
@@ -304,35 +304,48 @@ static void mac_keypress(EventRecord *event) {
 static void mac_menucommand(long result) {
     short menu, item;
     Str255 da;
+    WindowPtr window;
 
     menu = HiWord(result);
     item = LoWord(result);
+    window = FrontWindow();
+    /* Things which do the same whatever window we're in. */
     switch (menu) {
       case mApple:
         switch (item) {
           case iAbout:
-            GetNewDialog(wAbout, NULL, (GrafPort *)-1);
-            break;
+           if (windows.about)
+               SelectWindow(windows.about);
+           else
+               windows.about = GetNewDialog(wAbout, NULL, (WindowPtr)-1);
+            goto done;
           default:
             GetMenuItemText(GetMenuHandle(mApple), item, da);
             OpenDeskAcc(da);
-            break;
+            goto done;
         }
         break;
       case mFile:
         switch (item) {
           case iNew:
             mac_newsession();
-            break;
+            goto done;
           case iClose:
-            mac_closewindow(FrontWindow());
-            break;
+            mac_closewindow(window);
+            goto done;
           case iQuit:
             mac_shutdown();
-            break;
+            goto done;
         }
         break;
     }
+    /* If we get here, handling is up to window-specific code. */
+    switch (mac_windowtype(window)) {
+      case wTerminal:
+       mac_menuterm(window, menu, item);
+       break;
+    }
+  done:
     HiliteMenu(0);
 }
 
@@ -345,6 +358,10 @@ static void mac_closewindow(WindowPtr window) {
       case wTerminal:
        /* FIXME: end session and stuff */
        break;
+      case wAbout:
+       windows.about = NULL;
+       CloseWindow(window);
+       break;
       default:
        CloseWindow(window);
        break;
@@ -371,6 +388,10 @@ static void mac_adjustmenus(void) {
     menu = GetMenuHandle(mFile);
     EnableItem(menu, 0);
     EnableItem(menu, iNew);
+    if (window != NULL)
+       EnableItem(menu, iClose);
+    else
+       DisableItem(menu, iClose);
     EnableItem(menu, iQuit);
 
     switch (mac_windowtype(window)) {
diff --git a/mac.h b/mac.h
index 407614a3fe3991d697c7a42afe152f41aad9dc76..cfc11a70972a2c2c224f89ed032d8c365967bdbc 100644 (file)
--- a/mac.h
+++ b/mac.h
@@ -27,6 +27,7 @@ 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);
 /* from maccfg.c */
 extern void mac_loadconfig(Config *);
 
index be599684c45da80c82bce83807aee840fd21c107..2cedc468df31db689a5779940fb91a58f85f5b66 100644 (file)
--- a/mac_res.r
+++ b/mac_res.r
@@ -1,4 +1,4 @@
-/* $Id: mac_res.r,v 1.1.2.12 1999/03/15 00:40:55 ben Exp $ */
+/* $Id: mac_res.r,v 1.1.2.13 1999/03/16 20:27:30 ben Exp $ */
 /*
  * Copyright (c) 1999 Ben Harris
  * All rights reserved.
@@ -459,8 +459,10 @@ type 'TEXT' {
 
 resource 'TEXT' (wLicence, "licence", purgeable) {
     "Copyright © 1997-9 Simon Tatham\n"
-    "Portions copyright Gary S. Brown, Eric Young and Ben Harris\n\n"
-    
+    "Portions copyright © 1999 Ben Harris\n"
+    "Portions copyright © 1993 Eric Young\n"
+    "Portions copyright © 1986 Gary S. Brown\n"
+    "\n"    
     "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 "
@@ -525,6 +527,9 @@ type 'pSET' {
     /* Colour options */
     boolean bold_font, bold_colour;
     align long;
+    /* Selection options */
+    boolean no_implicit_copy, implicit_copy;
+    align long;
     /* Non-boolean options */
     integer; integer;          /* host */
     longint;                   /* port */
@@ -556,6 +561,7 @@ resource 'pSET' (PREF_settings, "settings", purgeable) {
     no_auto_cr,
     use_icon_name,
     bold_colour,
+    no_implicit_copy,
 #define PREF_strings 1024
     PREF_strings, 1,           /* host 'STR#' */
     23, prot_telnet,           /* port, protocol */
@@ -653,6 +659,15 @@ resource 'TMPL' (128, "pSET") {
        "", 'BBIT',
        "", 'BBIT',
        "", 'ALNG',
+       "Implicit copy", 'BBIT',
+       "", 'BBIT',
+       "", 'BBIT',
+       "", 'BBIT',
+       "", 'BBIT',
+       "", 'BBIT',
+       "", 'BBIT',
+       "", 'BBIT',
+       "", 'ALNG',
        "Host STR# ID", 'DWRD',
        "Host STR# index", 'DWRD',
        "Port", 'DLNG',
index 704b1722cf7dea994ad43c7ca63e3f93011015b4..5b11cae4883e64b38e3af20795372c5adec3555d 100644 (file)
--- a/maccfg.c
+++ b/maccfg.c
@@ -1,4 +1,4 @@
-/* $Id: maccfg.c,v 1.1.2.2 1999/03/14 15:48:35 ben Exp $ */
+/* $Id: maccfg.c,v 1.1.2.3 1999/03/16 20:27:30 ben Exp $ */
 /*
  * maccfg.c -- Mac port configuration
  */
@@ -60,6 +60,8 @@ struct pSET {
 #define WIN_NAME_ALWAYS        0x10000000
     unsigned long colour_flags;
 #define BOLD_COLOUR    0x80000000
+    unsigned long selection_flags;
+#define IMPLICIT_COPY  0x80000000
     struct strloc host;
     long port;
     long protocol;
@@ -127,6 +129,7 @@ void mac_loadconfig(Config *cfg) {
     if (cfg->colours == NULL)
        fatalbox("Failed to get default palette");
     /* Selection */
+    cfg->implicit_copy = (s->selection_flags & IMPLICIT_COPY) != 0;
     get_wordness(s->wordness_id, cfg->wordness);
     SetResAttrs(h, GetResAttrs(h) & ~resLocked);
     ReleaseResource(h);
index 695031fa2641dfc8ed00ed3633641544b7b03bcc..a78e2307dbaa93d09cfa4ac44d96d3c6d4130ecc 100644 (file)
--- a/macterm.c
+++ b/macterm.c
@@ -1,4 +1,4 @@
-/* $Id: macterm.c,v 1.1.2.24 1999/03/15 14:22:45 ben Exp $ */
+/* $Id: macterm.c,v 1.1.2.25 1999/03/16 20:27:31 ben Exp $ */
 /*
  * Copyright (c) 1999 Ben Harris
  * All rights reserved.
@@ -33,6 +33,7 @@
 #include <Controls.h>
 #include <Fonts.h>
 #include <Gestalt.h>
+#include <MacMemory.h>
 #include <MacWindows.h>
 #include <Palettes.h>
 #include <Quickdraw.h>
@@ -78,6 +79,7 @@ static void mac_initfont(struct mac_session *);
 static void mac_initpalette(struct mac_session *);
 static void mac_adjustwinbg(struct mac_session *);
 static void mac_adjustsize(struct mac_session *, int, int);
+static void mac_drawgrowicon(struct mac_session *s);
 static pascal void mac_scrolltracker(ControlHandle, short);
 static pascal void do_text_for_device(short, short, GDHandle, long);
 static pascal void mac_set_attr_mask(short, short, GDHandle, long);
@@ -233,7 +235,10 @@ void mac_adjusttermmenus(WindowPtr window) {
     EnableItem(menu, 0);
     DisableItem(menu, iUndo);
     DisableItem(menu, iCut);
-    DisableItem(menu, iCopy);
+    if (term_hasselection())
+       EnableItem(menu, iCopy);
+    else
+       DisableItem(menu, iCopy);
     if (GetScrap(NULL, 'TEXT', &offset) == noTypeErr)
        DisableItem(menu, iPaste);
     else
@@ -242,6 +247,23 @@ void mac_adjusttermmenus(WindowPtr window) {
     EnableItem(menu, iSelectAll);
 }
 
+void mac_menuterm(WindowPtr window, short menu, short item) {
+    struct mac_session *s;
+
+    s = (struct mac_session *)GetWRefCon(window);
+    switch (menu) {
+      case mEdit:
+       switch (item) {
+         case iCopy:
+           term_copy();
+           break;
+         case iPaste:
+           term_paste();
+           break;
+       }
+    }
+}
+           
 void mac_clickterm(WindowPtr window, EventRecord *event) {
     struct mac_session *s;
     Point mouse;
@@ -321,8 +343,24 @@ void write_clip(void *data, int len) {
 }
 
 void get_clip(void **p, int *lenp) {
+    static Handle h = NULL;
+    long offset;
 
-    /* XXX: do something */
+    if (p == NULL) {
+       /* release memory */
+       if (h != NULL)
+           DisposeHandle(h);
+       h = NULL;
+    } else
+       if (GetScrap(NULL, 'TEXT', &offset) > 0) {
+           h = NewEmptyHandle();
+           *lenp = GetScrap(h, 'TEXT', &offset);
+           HLock(h);
+           *p = *h;
+       } else {
+           *p = NULL;
+           *lenp = 0;
+       }
 }
 
 static pascal void mac_scrolltracker(ControlHandle control, short part) {
@@ -565,11 +603,11 @@ void mac_activateterm(WindowPtr window, Boolean active) {
        PmBackColor(DEFAULT_BG); /* HideControl clears behind the control */
        HideControl(s->scrollbar);
     }
+    mac_drawgrowicon(s);
 }
 
 void mac_updateterm(WindowPtr window) {
     struct mac_session *s;
-    Rect clip;
 
     s = (struct mac_session *)GetWRefCon(window);
     BeginUpdate(window);
@@ -585,15 +623,23 @@ void mac_updateterm(WindowPtr window) {
     if (FrontWindow() != window)
        EraseRect(&(*s->scrollbar)->contrlRect);
     UpdateControls(window, window->visRgn);
+    mac_drawgrowicon(s);
+    free_ctx(NULL);
+    EndUpdate(window);
+}
+
+static void mac_drawgrowicon(struct mac_session *s) {
+    Rect clip;
+
+    SetPort(s->window);
     /* Stop DrawGrowIcon giving us space for a horizontal scrollbar */
-    SetRect(&clip, window->portRect.right - 15, SHRT_MIN, SHRT_MAX, SHRT_MAX);
+    SetRect(&clip, s->window->portRect.right - 15, SHRT_MIN,
+           SHRT_MAX, SHRT_MAX);
     ClipRect(&clip);
-    DrawGrowIcon(window);
+    DrawGrowIcon(s->window);
     clip.left = SHRT_MIN;
     ClipRect(&clip);
-    free_ctx(NULL);
-    EndUpdate(window);
-}
+}    
 
 struct do_text_args {
     struct mac_session *s;
diff --git a/putty.h b/putty.h
index 81935f760c339c5e1056974bb010e34bc0b63b35..34b57cb09f4f0c70cc2cd5704a4e7889b073c64a 100644 (file)
--- a/putty.h
+++ b/putty.h
@@ -164,7 +164,8 @@ typedef struct {
     unsigned char colours[22][3];
 #endif /* not macintosh */
     /* Selection options */
-#ifndef macintosh
+    int implicit_copy;
+#ifdef macintosh
     int mouse_is_xterm;
 #endif
     short wordness[256];
@@ -246,6 +247,7 @@ void term_clrsb (void);
 void term_mouse (Mouse_Button, Mouse_Action, int, int);
 void term_copy(void);
 void term_paste(void);
+int term_hasselection(void);
 void term_deselect (void);
 void term_update (void);
 void term_invalidate(void);
index da5fe9dab0075e4202bfc423e3309a3780aa3d07..aa5a9a6354ff8fff9d60a65ceed38160e913522e 100644 (file)
@@ -1427,7 +1427,8 @@ void term_mouse (Mouse_Button b, Mouse_Action a, int x, int y) {
        sel_spread();
     } else if ((b == MB_SELECT || b == MB_EXTEND) && a == MA_RELEASE)
        if (selstate == DRAGGING) {
-           term_copy();
+           if (cfg.implicit_copy)
+               term_copy();
            selstate = SELECTED;
        } else
            selstate = NO_SELECTION;
@@ -1492,6 +1493,14 @@ void term_paste() {
     get_clip(NULL, NULL);
 }
 
+/*
+ * Find out if there's a selection.
+ */
+int term_hasselection(void) {
+
+    return selstate == SELECTED;
+}
+
 static void deselect (void) {
     selstate = NO_SELECTION;
     selstart = selend = scrtop;