mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-04-27 07:42:09 -05:00
Menu items now turn on and off in a vaguely useful way.
Dragging to select now works. [originally from svn r90]
This commit is contained in:
parent
d801319d6c
commit
84f1e71fad
42
mac.c
42
mac.c
@ -1,4 +1,4 @@
|
|||||||
/* $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
|
* Copyright (c) 1999 Ben Harris
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -75,6 +75,14 @@ static void mac_shutdown(void);
|
|||||||
|
|
||||||
static void mac_newsession(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) {
|
int main (int argc, char **argv) {
|
||||||
|
|
||||||
mac_startup();
|
mac_startup();
|
||||||
@ -123,6 +131,9 @@ static void mac_startup(void) {
|
|||||||
mac_adjustmenus();
|
mac_adjustmenus();
|
||||||
DrawMenuBar();
|
DrawMenuBar();
|
||||||
InitCursor();
|
InitCursor();
|
||||||
|
windows.terminal = NULL;
|
||||||
|
windows.about = NULL;
|
||||||
|
windows.licence = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mac_eventloop(void) {
|
static void mac_eventloop(void) {
|
||||||
@ -228,6 +239,7 @@ static void mac_growwindow(WindowPtr window, EventRecord *event) {
|
|||||||
|
|
||||||
static void mac_activatewindow(WindowPtr window, Boolean active) {
|
static void mac_activatewindow(WindowPtr window, Boolean active) {
|
||||||
|
|
||||||
|
mac_adjustmenus();
|
||||||
switch (mac_windowtype(window)) {
|
switch (mac_windowtype(window)) {
|
||||||
case wTerminal:
|
case wTerminal:
|
||||||
mac_activateterm(window, active);
|
mac_activateterm(window, active);
|
||||||
@ -348,7 +360,29 @@ static void mac_zoomwindow(WindowPtr window, short part) {
|
|||||||
* Make the menus look right before the user gets to see them.
|
* Make the menus look right before the user gets to see them.
|
||||||
*/
|
*/
|
||||||
static void mac_adjustmenus(void) {
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -386,3 +420,9 @@ void fatalbox(const char *fmt, ...) {
|
|||||||
StopAlert(128, nil);
|
StopAlert(128, nil);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Local Variables:
|
||||||
|
* c-file-style: "simon"
|
||||||
|
* End:
|
||||||
|
*/
|
||||||
|
1
mac.h
1
mac.h
@ -22,6 +22,7 @@ extern struct mac_gestalts mac_gestalts;
|
|||||||
/* from macterm.c */
|
/* from macterm.c */
|
||||||
extern void mac_newsession(void);
|
extern void mac_newsession(void);
|
||||||
extern void mac_activateterm(WindowPtr, Boolean);
|
extern void mac_activateterm(WindowPtr, Boolean);
|
||||||
|
extern void mac_adjusttermmenus(WindowPtr);
|
||||||
extern void mac_updateterm(WindowPtr);
|
extern void mac_updateterm(WindowPtr);
|
||||||
extern void mac_clickterm(WindowPtr, EventRecord *);
|
extern void mac_clickterm(WindowPtr, EventRecord *);
|
||||||
extern void mac_growterm(WindowPtr, EventRecord *);
|
extern void mac_growterm(WindowPtr, EventRecord *);
|
||||||
|
30
mac_res.r
30
mac_res.r
@ -1,4 +1,4 @@
|
|||||||
/* $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
|
* Copyright (c) 1999 Ben Harris
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -244,7 +244,7 @@ resource 'icl8' (130, purgeable) {
|
|||||||
/* Menu bar */
|
/* Menu bar */
|
||||||
|
|
||||||
resource 'MBAR' (MBAR_Main, preload) {
|
resource 'MBAR' (MBAR_Main, preload) {
|
||||||
{ mApple, mFile }
|
{ mApple, mFile, mEdit }
|
||||||
};
|
};
|
||||||
|
|
||||||
resource 'MENU' (mApple, preload) {
|
resource 'MENU' (mApple, preload) {
|
||||||
@ -273,6 +273,23 @@ resource 'MENU' (mFile, 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. */
|
/* Fatal error box. Stolen from the Finder. */
|
||||||
|
|
||||||
resource 'ALRT' (wFatal, "fatalbox", purgeable) {
|
resource 'ALRT' (wFatal, "fatalbox", purgeable) {
|
||||||
@ -641,11 +658,11 @@ resource 'pltt' (PREF_pltt, purgeable) {
|
|||||||
|
|
||||||
read 'pTST' (128, "test data", purgeable) "fragment";
|
read 'pTST' (128, "test data", purgeable) "fragment";
|
||||||
|
|
||||||
type 'cMAP' {
|
type 'pMAP' {
|
||||||
hexstring;
|
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"
|
$"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"
|
$"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"
|
$"cb e7 e5 cc 80 81 ae 82 e9 83 e6 e8 ed ea eb ec"
|
||||||
@ -654,6 +671,7 @@ resource 'cMAP' (128, "Latin-1 G1 -> Mac OS Roman") {
|
|||||||
$"00 96 98 97 99 9b 9a d6 bf 9d 9c 9e 9f 00 00 D8"
|
$"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"
|
$"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"
|
$"e3 e4 f5 f6 f7 f8 f9 fa fb b2 b3 b9 ad a3 e1"
|
||||||
|
};
|
10
macresid.h
10
macresid.h
@ -1,4 +1,4 @@
|
|||||||
/* $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
|
* macresid.h -- Mac resource IDs
|
||||||
@ -13,6 +13,7 @@
|
|||||||
/* Menu IDs */
|
/* Menu IDs */
|
||||||
#define mApple 128
|
#define mApple 128
|
||||||
#define mFile 129
|
#define mFile 129
|
||||||
|
#define mEdit 130
|
||||||
|
|
||||||
/* Menu Items */
|
/* Menu Items */
|
||||||
/* Apple menu */
|
/* Apple menu */
|
||||||
@ -21,6 +22,13 @@
|
|||||||
#define iNew 1
|
#define iNew 1
|
||||||
#define iClose 2
|
#define iClose 2
|
||||||
#define iQuit 4
|
#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) */
|
/* Window types (and resource IDs) */
|
||||||
#define wNone 0 /* Dummy value for no window */
|
#define wNone 0 /* Dummy value for no window */
|
||||||
|
48
macterm.c
48
macterm.c
@ -1,4 +1,4 @@
|
|||||||
/* $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
|
* Copyright (c) 1999 Ben Harris
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -38,6 +38,7 @@
|
|||||||
#include <Quickdraw.h>
|
#include <Quickdraw.h>
|
||||||
#include <QuickdrawText.h>
|
#include <QuickdrawText.h>
|
||||||
#include <Resources.h>
|
#include <Resources.h>
|
||||||
|
#include <Scrap.h>
|
||||||
#include <Sound.h>
|
#include <Sound.h>
|
||||||
#include <ToolUtils.h>
|
#include <ToolUtils.h>
|
||||||
|
|
||||||
@ -199,6 +200,28 @@ static void mac_updatewinbg(struct mac_session *s) {
|
|||||||
SetWinColor(s->window, cth);
|
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) {
|
void mac_clickterm(WindowPtr window, EventRecord *event) {
|
||||||
struct mac_session *s;
|
struct mac_session *s;
|
||||||
Point mouse;
|
Point mouse;
|
||||||
@ -251,13 +274,21 @@ static void text_click(struct mac_session *s, EventRecord *event) {
|
|||||||
lastact = MA_CLICK;
|
lastact = MA_CLICK;
|
||||||
term_mouse(event->modifiers & shiftKey ? MB_EXTEND : MB_SELECT, lastact,
|
term_mouse(event->modifiers & shiftKey ? MB_EXTEND : MB_SELECT, lastact,
|
||||||
col, row);
|
col, row);
|
||||||
while (StillDown()) {
|
|
||||||
/* XXX Do something */
|
|
||||||
}
|
|
||||||
lastsess = s;
|
lastsess = s;
|
||||||
lastrow = row;
|
lastrow = row;
|
||||||
lastcol = col;
|
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) {
|
static pascal void mac_scrolltracker(ControlHandle control, short part) {
|
||||||
@ -754,3 +785,10 @@ void do_scroll(int topline, int botline, int lines) {
|
|||||||
InvalRgn(update);
|
InvalRgn(update);
|
||||||
DisposeRgn(update);
|
DisposeRgn(update);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Emacs magic:
|
||||||
|
* Local Variables:
|
||||||
|
* c-file-style: "simon"
|
||||||
|
* End:
|
||||||
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user