From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Marchionna Newsgroups: gmane.emacs.bugs Subject: bug#8680: emacs 24.0 OS X keypad patch Date: Mon, 23 May 2011 13:11:43 -0700 Message-ID: <82F88237-57F3-49B4-9EBB-DE0358BDEA53@pacbell.net> References: <625A3C9C-ACF2-42A0-B4E8-8ABDDA060131@pacbell.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: multipart/mixed; boundary=Apple-Mail-56--690694455 X-Trace: dough.gmane.org 1306181532 24120 80.91.229.12 (23 May 2011 20:12:12 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 23 May 2011 20:12:12 +0000 (UTC) To: 8680@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon May 23 22:12:08 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 1QObU0-0002yT-6z for geb-bug-gnu-emacs@m.gmane.org; Mon, 23 May 2011 22:12:08 +0200 Original-Received: from localhost ([::1]:53093 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QObTy-0002vt-S8 for geb-bug-gnu-emacs@m.gmane.org; Mon, 23 May 2011 16:12:06 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:49864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QObTv-0002vb-PB for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 16:12:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QObTu-0005Sa-Pe for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 16:12:03 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:44804) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QObTu-0005SU-K5 for bug-gnu-emacs@gnu.org; Mon, 23 May 2011 16:12:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QObTu-0002aT-8L; Mon, 23 May 2011 16:12:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <625A3C9C-ACF2-42A0-B4E8-8ABDDA060131@pacbell.net> Resent-From: Michael Marchionna Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 23 May 2011 20:12:02 +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.13061815179934 (code B ref 8680); Mon, 23 May 2011 20:12:02 +0000 Original-Received: (at 8680) by debbugs.gnu.org; 23 May 2011 20:11:57 +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 1QObTo-0002aB-Os for submit@debbugs.gnu.org; Mon, 23 May 2011 16:11:57 -0400 Original-Received: from nm17-vm0.access.bullet.mail.sp2.yahoo.com ([98.139.44.168]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1QObTm-0002Zz-Tf for 8680@debbugs.gnu.org; Mon, 23 May 2011 16:11:55 -0400 Original-Received: from [98.139.44.107] by nm17.access.bullet.mail.sp2.yahoo.com with NNFMP; 23 May 2011 20:11:48 -0000 Original-Received: from [98.139.44.86] by tm12.access.bullet.mail.sp2.yahoo.com with NNFMP; 23 May 2011 20:11:48 -0000 Original-Received: from [127.0.0.1] by omp1023.access.mail.sp2.yahoo.com with NNFMP; 23 May 2011 20:11:48 -0000 X-Yahoo-Newman-Id: 626881.32110.bm@omp1023.access.mail.sp2.yahoo.com Original-Received: (qmail 8746 invoked from network); 23 May 2011 20:11:48 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=pacbell.net; h=DKIM-Signature:Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:From:Content-Type:Subject:Date:Message-Id:To:Mime-Version:X-Mailer; b=ECr8ThDN4vI6lVYTCCpNZWn2mY3g0V/xgfVoeuRFjM9VjaHcRxtlK7oTm+lV8kyEhC5/6d9EgqgregNYYsqm1JrvrF2ZaoIeFIKKJF8Or0iYBtRVPrmsmMq70Z/g8E/ljtrw+Yai6jNVkMFI6rOvXUZDSbPO+q063Qv8Djfblmk= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pacbell.net; s=s1024; t=1306181508; bh=kSCesD0xXS9dfyk0HYz+qeQoRMScvMj/9RJWjPJrfOM=; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:From:Content-Type:Subject:Date:Message-Id:To:Mime-Version:X-Mailer; b=gsQ2e0EfsFs7Afqpc8ZEtYt4V18w6Mu49pX2YiA1Bjh6Gcy8AVZt0mUsus+TLkm+LpVo0cTnLWabhWYfsR9Tr3hHMcH4eil6CgF9T2/0IuZcxQwG9Lrg0buB0GDGzEEkiaKV5/Tglf0r8AOrMdrXBt7YZd9W1KbTXQvW2xw/92A= Original-Received: from morbo.el-rayo-x.foo (tralfaz@216.101.161.154 with plain) by smtp109.sbc.mail.gq1.yahoo.com with SMTP; 23 May 2011 13:11:46 -0700 PDT X-Yahoo-SMTP: uVslrc.swBAsbr9qUoHctqw_w91g6l3qy9ZsMsYbaY4- X-YMail-OSG: 7sXFwUsVM1kX1X37KoDRkdEKZP9EvHc83SuuqMXVR825u0y 5FAT_8o43Anf4MSnu2tnrOWtQ7eB2e5X24ZqRBd2SGWdEx3lS0UXKL2.nsPr N6YP2bd27fvzUdBp3X8.DDBuZtK8XmY1ltITWXkh22DLMO9o.t9e1tpvm5B7 e0p8jV1V8E8uSonPwCmes4sJx_mjLRD10DKPRAUrsbOMapM6PskJ93fx62BK Mt5OrfhRjafsnBJLlrsjmEPxXJCyhs8g2gjrlnItagCm5Yu4MtyHXgA_pWdL PLhGogk8fuoH0CYTmG8mbjY.KcyKUXh30PIgCuYLKTSBowSmPOPIqjvfdYSk _Gi0HVqy_gfwWV6ErWF3lLTE8atN52Iq3YAsMrc5C0YfVgg-- X-Yahoo-Newman-Property: ymail-3 X-Mailer: Apple Mail (2.1084) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 23 May 2011 16:12:02 -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:46667 Archived-At: --Apple-Mail-56--690694455 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 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. --Apple-Mail-56--690694455 Content-Disposition: attachment; filename=emacs-24-src-nsterm.m.patch Content-Type: application/octet-stream; name="emacs-24-src-nsterm.m.patch" Content-Transfer-Encoding: 7bit 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; --Apple-Mail-56--690694455--