1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-26 07:12:10 -05:00

The edit menu is now mostly functional. I'm not sure about paste, since I

haven't got a working backend at the moment, but it all looks OK.

[originally from svn r118]
This commit is contained in:
Ben Harris 1999-03-16 20:27:31 +00:00
parent fc69aeef23
commit e43dc5ecd4
8 changed files with 124 additions and 25 deletions

View 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'

37
mac.c
View File

@ -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)) {

1
mac.h
View File

@ -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 *);

View File

@ -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',

View File

@ -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);

View File

@ -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,16 +623,24 @@ void mac_updateterm(WindowPtr window) {
if (FrontWindow() != window)
EraseRect(&(*s->scrollbar)->contrlRect);
UpdateControls(window, window->visRgn);
/* Stop DrawGrowIcon giving us space for a horizontal scrollbar */
SetRect(&clip, window->portRect.right - 15, SHRT_MIN, SHRT_MAX, SHRT_MAX);
ClipRect(&clip);
DrawGrowIcon(window);
clip.left = SHRT_MIN;
ClipRect(&clip);
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, s->window->portRect.right - 15, SHRT_MIN,
SHRT_MAX, SHRT_MAX);
ClipRect(&clip);
DrawGrowIcon(s->window);
clip.left = SHRT_MIN;
ClipRect(&clip);
}
struct do_text_args {
struct mac_session *s;
Rect textrect;

View File

@ -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);

View 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;