From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#8680: emacs 24.0 OS X keypad patch Date: Mon, 04 Jul 2011 13:42:57 -0400 Message-ID: References: <625A3C9C-ACF2-42A0-B4E8-8ABDDA060131@pacbell.net> <82F88237-57F3-49B4-9EBB-DE0358BDEA53@pacbell.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1309801472 18452 80.91.229.12 (4 Jul 2011 17:44:32 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 4 Jul 2011 17:44:32 +0000 (UTC) Cc: Adrian Robert To: 8680@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jul 04 19:44:28 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QdnC7-00065l-Vn for geb-bug-gnu-emacs@m.gmane.org; Mon, 04 Jul 2011 19:44:28 +0200 Original-Received: from localhost ([::1]:50087 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QdnC7-00043q-0K for geb-bug-gnu-emacs@m.gmane.org; Mon, 04 Jul 2011 13:44:27 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:35861) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QdnBk-000433-Vx for bug-gnu-emacs@gnu.org; Mon, 04 Jul 2011 13:44:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QdnBi-0006M1-NH for bug-gnu-emacs@gnu.org; Mon, 04 Jul 2011 13:44:04 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38193) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QdnBi-0006Lu-7G for bug-gnu-emacs@gnu.org; Mon, 04 Jul 2011 13:44:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QdnBh-0008EP-SM; Mon, 04 Jul 2011 13:44:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 04 Jul 2011 17:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8680 X-GNU-PR-Package: emacs,ns X-GNU-PR-Keywords: Original-Received: via spool by 8680-submit@debbugs.gnu.org id=B8680.130980139331572 (code B ref 8680); Mon, 04 Jul 2011 17:44:01 +0000 Original-Received: (at 8680) by debbugs.gnu.org; 4 Jul 2011 17:43:13 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QdnAt-0008DA-MX for submit@debbugs.gnu.org; Mon, 04 Jul 2011 13:43:12 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QdnAr-0008Cv-2E; Mon, 04 Jul 2011 13:43:10 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAH/7EU5FxIxr/2dsb2JhbABTp3t4iHrAfYY2BJ5chCw X-IronPort-AV: E=Sophos;i="4.65,474,1304308800"; d="scan'208";a="120399100" Original-Received: from 69-196-140-107.dsl.teksavvy.com (HELO pastel.home) ([69.196.140.107]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 04 Jul 2011 13:42:58 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 0324259173; Mon, 4 Jul 2011 13:42:57 -0400 (EDT) In-Reply-To: <82F88237-57F3-49B4-9EBB-DE0358BDEA53@pacbell.net> (Michael Marchionna's message of "Mon, 23 May 2011 13:11:43 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 04 Jul 2011 13:44:01 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:47968 Archived-At: reassign 8680 emacs,ns tags 8680 +patch thanks Could someone familiar with the MacOSX code take a look at this bug report? Stefan >>>>> "Michael" == Michael Marchionna writes: > Adding keypad keycodes to the existing translation table leads to some keys > being wrongly interpreted as keypad keys. To avoid that, this patch > uses a separate translation table exclusively for keys that > generate a NSNumericPadKeyMask. > diff --git a/src/nsterm.m b/src/nsterm.m > index 91f0cbb..d537ee3 100644 > --- a/src/nsterm.m > +++ b/src/nsterm.m > @@ -87,6 +87,7 @@ static unsigned convert_ns_to_X_keysym[] = > NSBeginFunctionKey, 0x58, > NSSelectFunctionKey, 0x60, > NSPrintFunctionKey, 0x61, > + NSClearLineFunctionKey, 0x0B, > NSExecuteFunctionKey, 0x62, > NSInsertFunctionKey, 0x63, > NSUndoFunctionKey, 0x65, > @@ -134,6 +135,35 @@ static unsigned convert_ns_to_X_keysym[] = > 0x1B, 0x1B /* escape */ > }; > +static unsigned convert_nskeypad_to_X_keysym[] = > +{ > + /* Arrow keys are both function and keypad keys */ > + NSLeftArrowFunctionKey, 0x51, > + NSUpArrowFunctionKey, 0x52, > + NSRightArrowFunctionKey, 0x53, > + NSDownArrowFunctionKey, 0x54, > + > + 0x41, 0xAE, /* KP_Decimal */ > + 0x43, 0xAA, /* KP_Multiply */ > + 0x45, 0xAB, /* KP_Add */ > + 0x4B, 0xAF, /* KP_Divide */ > + 0x4E, 0xAD, /* KP_Subtract */ > + 0x51, 0xBD, /* KP_Equal */ > + 0x52, 0xB0, /* KP_0 */ > + 0x53, 0xB1, /* KP_1 */ > + 0x54, 0xB2, /* KP_2 */ > + 0x55, 0xB3, /* KP_3 */ > + 0x56, 0xB4, /* KP_4 */ > + 0x57, 0xB5, /* KP_5 */ > + 0x58, 0xB6, /* KP_6 */ > + 0x59, 0xB7, /* KP_7 */ > + 0x5B, 0xB8, /* KP_8 */ > + 0x5C, 0xB9, /* KP_9 */ > + > + // The enter key is on the keypad but modifier isnt set > + NSEnterCharacter, 0x8D > +}; > + > static Lisp_Object Qmodifier_value; > Lisp_Object Qalt, Qcontrol, Qhyper, Qmeta, Qsuper, Qnone; > @@ -1924,13 +1954,33 @@ ns_convert_key (unsigned code) > unsigned keysym; > /* An array would be faster, but less easy to read. */ > for (keysym = 0; keysym < last_keysym; keysym += 2) > - if (code == convert_ns_to_X_keysym[keysym]) > - return 0xFF00 | convert_ns_to_X_keysym[keysym+1]; > + > + if (code == convert_ns_to_X_keysym[keysym]) { > + return 0xFF00 | convert_ns_to_X_keysym[keysym+1]; > + } > return 0; > /* if decide to use keyCode and Carbon table, use this line: > return code > 0xff ? 0 : 0xFF00 | ns_keycode_to_xkeysym_table[code]; */ > } > +static unsigned > +ns_convert_keypad (unsigned code) > +/* -------------------------------------------------------------------------- > + Internal call used by NSView-keyDown. > + -------------------------------------------------------------------------- */ > +{ > + const unsigned last_keysym = (sizeof (convert_nskeypad_to_X_keysym) > + / sizeof (convert_nskeypad_to_X_keysym[0])); > + unsigned keysym; > + /* An array would be faster, but less easy to read. */ > + for (keysym = 0; keysym < last_keysym; keysym += 2) { > + if (code == convert_nskeypad_to_X_keysym[keysym]) { > + return 0xFF00 | convert_nskeypad_to_X_keysym[keysym+1]; > + } > + } > + return 0; > +} > + > char * > x_get_keysym_name (int keysym) > @@ -4503,10 +4553,10 @@ ns_term_shutdown (int sig) > Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (emacsframe); > int code; > unsigned fnKeysym = 0; > - int flags; > static NSMutableArray *nsEvArray; > static BOOL firstTime = YES; > int left_is_none; > + unsigned int flags = [theEvent modifierFlags]; > NSTRACE (keyDown); > @@ -4550,9 +4600,13 @@ ns_term_shutdown (int sig) > code = ([[theEvent charactersIgnoringModifiers] length] == 0) ? > 0 : [[theEvent charactersIgnoringModifiers] characterAtIndex: 0]; > /* (Carbon way: [theEvent keyCode]) */ > + > /* is it a "function key"? */ > - fnKeysym = ns_convert_key (code); > + if (code < 0x00ff && (flags & NSNumericPadKeyMask) ) > + fnKeysym = ns_convert_keypad([theEvent keyCode]); > + else > + fnKeysym = ns_convert_key(code); > if (fnKeysym) > { > /* COUNTERHACK: map 'Delete' on upper-right main KB to 'Backspace', > @@ -4565,7 +4619,6 @@ ns_term_shutdown (int sig) > /* are there modifiers? */ emacs_event-> modifiers = 0; > - flags = [theEvent modifierFlags]; > if (flags & NSHelpKeyMask) emacs_event-> modifiers |= hyper_modifier;