1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-26 15:22:09 -05:00

Meta key support, mostly.

[originally from svn r131]
This commit is contained in:
Ben Harris 1999-03-28 02:06:11 +00:00
parent 04aceed7bf
commit f050f04135
6 changed files with 60 additions and 16 deletions

16
mac.c
View File

@ -1,4 +1,4 @@
/* $Id: mac.c,v 1.1.2.18 1999/03/27 15:39:45 ben Exp $ */
/* $Id: mac.c,v 1.1.2.19 1999/03/28 02:06:10 ben Exp $ */
/*
* Copyright (c) 1999 Ben Harris
* All rights reserved.
@ -59,6 +59,7 @@ struct mac_gestalts mac_gestalts;
static void mac_startup(void);
static void mac_eventloop(void);
#pragma noreturn (mac_eventloop)
static void mac_event(EventRecord *);
static void mac_contentclick(WindowPtr, EventRecord *);
static void mac_growwindow(WindowPtr, EventRecord *);
@ -72,6 +73,7 @@ static void mac_adjustmenus(void);
static void mac_closewindow(WindowPtr);
static void mac_zoomwindow(WindowPtr, short);
static void mac_shutdown(void);
#pragma noreturn (mac_shutdown)
struct mac_windows {
WindowPtr terminal; /* XXX: Temporary */
@ -87,6 +89,8 @@ int main (int argc, char **argv) {
mac_eventloop();
}
#pragma noreturn (main)
static void mac_startup(void) {
Handle menuBar;
@ -290,11 +294,17 @@ static int mac_windowtype(WindowPtr window) {
static void mac_keypress(EventRecord *event) {
WindowPtr window;
if (event->what == keyDown && (event->modifiers & cmdKey)) {
window = FrontWindow();
/*
* Check for a command-key combination, but ignore it if it counts
* as a meta-key combination and we're in a terminal window.
*/
if (event->what == keyDown && (event->modifiers & cmdKey) &&
!((event->modifiers & cfg.meta_modifiers) == cfg.meta_modifiers &&
mac_windowtype(window) == wTerminal)) {
mac_adjustmenus();
mac_menucommand(MenuKey(event->message & charCodeMask));
} else {
window = FrontWindow();
switch (mac_windowtype(window)) {
case wTerminal:
mac_keyterm(window, event);

View File

@ -1,4 +1,4 @@
/* $Id: mac_res.r,v 1.1.2.13 1999/03/16 20:27:30 ben Exp $ */
/* $Id: mac_res.r,v 1.1.2.14 1999/03/28 02:06:10 ben Exp $ */
/*
* Copyright (c) 1999 Ben Harris
* All rights reserved.
@ -545,6 +545,7 @@ type 'pSET' {
longint; /* font_height */
integer; /* 'pltt' for colours */
integer; /* 'wORD' for wordness */
integer; /* meta modifiers */
};
resource 'pSET' (PREF_settings, "settings", purgeable) {
@ -576,6 +577,7 @@ resource 'pSET' (PREF_settings, "settings", purgeable) {
PREF_pltt, /* colours 'pltt' */
#define PREF_wordness 1024
PREF_wordness, /* wordness 'wORD */
0x900, /* meta modifiers (cmd+option) */
};
resource 'STR#' (PREF_strings, "strings", purgeable) {
@ -688,6 +690,7 @@ resource 'TMPL' (128, "pSET") {
"Font size", 'DLNG',
"pltt ID", 'DWRD',
"wORD ID", 'DWRD',
"meta modifiers", 'HWRD',
};
};

View File

@ -1,4 +1,4 @@
/* $Id: maccfg.c,v 1.1.2.4 1999/03/23 21:00:05 ben Exp $ */
/* $Id: maccfg.c,v 1.1.2.5 1999/03/28 02:06:10 ben Exp $ */
/*
* maccfg.c -- Mac port configuration
*/
@ -75,6 +75,7 @@ struct pSET {
long font_height;
short colours_id;
short wordness_id;
unsigned short meta_modifiers;
};
#pragma options align=reset
@ -112,6 +113,7 @@ void mac_loadconfig(Config *cfg) {
cfg->linux_funkeys = (s->kbd_flags & LINUX_FUNKEYS) != 0;
cfg->app_cursor = (s->kbd_flags & APP_CURSOR) != 0;
cfg->app_keypad = (s->kbd_flags & APP_KEYPAD) != 0;
cfg->meta_modifiers = s->meta_modifiers;
/* Terminal */
cfg->savelines = s->savelines;
cfg->dec_om = (s->term_flags & DEC_OM) != 0;

View File

@ -1,4 +1,4 @@
/* $Id: macterm.c,v 1.1.2.29 1999/03/27 15:39:45 ben Exp $ */
/* $Id: macterm.c,v 1.1.2.30 1999/03/28 02:06:10 ben Exp $ */
/*
* Copyright (c) 1999 Ben Harris
* All rights reserved.
@ -41,6 +41,7 @@
#include <QuickdrawText.h>
#include <Resources.h>
#include <Scrap.h>
#include <Script.h>
#include <Sound.h>
#include <ToolUtils.h>
@ -493,6 +494,25 @@ void mac_keyterm(WindowPtr window, EventRecord *event) {
back->send((char *)buf, len);
}
static UInt32 mac_rekey(EventModifiers newmodifiers, UInt32 oldmessage) {
UInt32 transresult, state;
Ptr kchr;
state = 0;
kchr = (Ptr)GetScriptManagerVariable(smKCHRCache);
transresult = KeyTranslate(kchr,
(oldmessage & keyCodeMask) >> 8 |
newmodifiers & 0xff00,
&state);
/*
* KeyTranslate returns two character codes. We only worry about
* one. Yes, this is slightly bogus, but it makes life less
* painful.
*/
return oldmessage & ~charCodeMask | transresult & 0xff;
}
static int mac_keytrans(struct mac_session *s, EventRecord *event,
unsigned char *output) {
unsigned char *p = output;
@ -500,6 +520,14 @@ static int mac_keytrans(struct mac_session *s, EventRecord *event,
/* No meta key yet -- that'll be rather fun. */
/* Check if the meta "key" was held down */
if ((event->modifiers & cfg.meta_modifiers) == cfg.meta_modifiers) {
*p++ = '\033';
event->modifiers &= ~cfg.meta_modifiers;
event->message = mac_rekey(event->modifiers, event->message);
}
/* Keys that we handle locally */
if (event->modifiers & shiftKey) {
switch (event->message & keyCodeMask) {
@ -669,8 +697,8 @@ void mac_updateterm(WindowPtr window) {
(*window->visRgn)->rgnBBox.right,
(*window->visRgn)->rgnBBox.bottom);
/* Restore default colours in case the Window Manager uses them */
PmForeColor(16);
PmBackColor(18);
PmForeColor(DEFAULT_FG);
PmBackColor(DEFAULT_BG);
if (FrontWindow() != window)
EraseRect(&(*s->scrollbar)->contrlRect);
UpdateControls(window, window->visRgn);

View File

@ -1,9 +1,14 @@
# $Id: mkputty.mpw,v 1.1.2.5 1999/03/28 02:06:11 ben Exp $
Set program PuTTY
Set makefile Makefile.mpw
# Run Make, then execute its output.
Echo "# `Date -t` ----- Build of {program}."
#if (`exists "#"Å"#"`)
# echo "# `Date -t` ----- Warning: auto-save file present."
#end
Echo "# `Date -t` ----- Analyzing dependencies."
Begin
Echo "Set Echo 1"
@ -17,12 +22,4 @@ Set type "`files -i -n -x t "{program}"
Set CaseSensitive True #filetype check for DA must be case sensitive
If "{type}" =~ /Å APPL/ OR "{type}" =~ /Å MPST/ # application or tool
Echo -n ¶t; Quote -n "{program}"; Echo -n " "
Else If "{type}" =~ /Å DFIL/ # desk accessory in Suitcase
Echo -n ¶t
Quote -n "Font/DA Mover" "{SystemFolder}"System "{program}";
Echo -n " # Install DA"
Else If "{type}" =~ /Å dfil/ # desk accessory (System 7)
Echo -n ¶t
Quote -n Duplicate -y "{program}" "{SystemFolder}Apple Menu Items";
Echo -n " # Install DA into Apple Menu"
End

View File

@ -144,6 +144,7 @@ typedef struct {
int linux_funkeys;
int app_cursor;
int app_keypad;
int meta_modifiers;
/* Terminal options */
int savelines;
int dec_om;
@ -209,6 +210,9 @@ void get_clip (void **, int *);
void optimised_move (int, int, int);
void do_scroll(int, int, int);
void fatalbox (const char *, ...);
#ifdef macintosh
#pragma noreturn (fatalbox)
#endif
void beep (void);
#define OPTIMISE_IS_SCROLL 1