From: Gerd Möllmann Date: Tue, 30 Jul 2024 05:47:44 +0000 (+0200) Subject: MacOS: Let EmacsView implement NSTextInputClient X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=bf819b9c78abc95ef9103d6230de9cb2ce5b38d2;p=emacs.git MacOS: Let EmacsView implement NSTextInputClient * src/nsterm.h (@interface EmacsView): Implement NSTextInputClient protocol. * src/nsterm.m: Implement required NSTextInputClient methods, forwarding to existing NSTextInput methods. (cherry picked from commit ceb5a1522270c41d0c9f5e6b52d61e3173f72f1d) --- diff --git a/src/nsterm.h b/src/nsterm.h index e3f55c4e41c..a07829a36ec 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -463,7 +463,7 @@ enum ns_return_frame_mode @class EmacsLayer; #ifdef NS_IMPL_COCOA -@interface EmacsView : NSView +@interface EmacsView : NSView #else @interface EmacsView : NSView #endif diff --git a/src/nsterm.m b/src/nsterm.m index 8a0c12c7369..b56c587bc69 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -7032,9 +7032,48 @@ ns_create_font_panel_buttons (id target, SEL select, SEL cancel_action) [nsEvArray removeObject: theEvent]; } +/*********************************************************************** + NSTextInputClient + ***********************************************************************/ -/* implementation (called through [super interpretKeyEvents:]). */ +#ifdef NS_IMPL_COCOA + +- (void) insertText: (id) string + replacementRange: (NSRange) replacementRange +{ + if ([string isKindOfClass:[NSAttributedString class]]) + string = [string string]; + [self unmarkText]; + [self insertText:string]; +} + +- (void) setMarkedText: (id) string + selectedRange: (NSRange) selectedRange + replacementRange: (NSRange) replacementRange +{ + [self setMarkedText: string selectedRange: selectedRange]; +} + +- (nullable NSAttributedString *) + attributedSubstringForProposedRange: (NSRange) range + actualRange: (nullable NSRangePointer) actualRange +{ + return nil; +} + +- (NSRect) firstRectForCharacterRange: (NSRange) range + actualRange: (nullable NSRangePointer) actualRange +{ + return NSZeroRect; +} +#endif /* NS_IMPL_COCOA */ + +/*********************************************************************** + NSTextInput + ***********************************************************************/ + +/* implementation (called through [super interpretKeyEvents:]). */ /* : called when done composing; NOTE: also called when we delete over working text, followed