tdevdraw: OS X dead key support - plan9port - [fork] Plan 9 from user space
HTML git clone git://src.adamsgaard.dk/plan9port
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 5ec2425b17766f20600e224b05988dcc7580ea18
DIR parent 131ab3addbc9eaf629803992e058bea1ddf931cc
HTML Author: David Jeannot <djeannot24@gmail.com>
Date: Mon, 16 Jan 2012 17:02:06 -0500
devdraw: OS X dead key support
R=rsc
CC=plan9port.codebot
http://codereview.appspot.com/5503086
Diffstat:
M src/cmd/devdraw/cocoa-screen.m | 19 +++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)
---
DIR diff --git a/src/cmd/devdraw/cocoa-screen.m b/src/cmd/devdraw/cocoa-screen.m
t@@ -571,6 +571,23 @@ static int keycvt[] =
[QZ_KP9] '9',
};
+@interface apptext : NSTextView @end
+
+@implementation apptext
+- (void)doCommandBySelector:(SEL)s{} /* Esc key beeps otherwise */
+- (void)insertText:(id)arg{} /* to avoid a latency after some time */
+@end
+
+static void
+interpretdeadkey(NSEvent *e)
+{
+ static apptext *t;
+
+ if(t == nil)
+ t = [apptext new];
+ [t interpretKeyEvents:[NSArray arrayWithObject:e]];
+}
+
static void
getkeyboard(NSEvent *e)
{
t@@ -588,6 +605,8 @@ getkeyboard(NSEvent *e)
s = [e characters];
c = [s UTF8String][0];
+ interpretdeadkey(e);
+
if(m & NSCommandKeyMask){
if(' '<=c && c<='~')
keystroke(Kcmd+c);