From 65d5ace8e85111ecbd5035541ab24fdcfc065c7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerd=20M=C3=B6llmann?= Date: Tue, 30 Jul 2024 07:47:44 +0200 Subject: [PATCH] NS: Let EmacsView implement NSTextInputClient * src/nsterm.h (@interface EmacsView): Implement NSTextInputClient protocol. * src/nsterm.m: Implement required NSTextInputClient methods, forwarding to existing NSTextInput methods. --- src/nsterm.h | 4 ++-- src/nsterm.m | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/nsterm.h b/src/nsterm.h index 5d4810cba4a..f3dcb07a0f1 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -463,9 +463,9 @@ #define NSTRACE_UNSILENCE() @class EmacsLayer; #ifdef NS_IMPL_COCOA -@interface EmacsView : NSView +@interface EmacsView : NSView #else -@interface EmacsView : NSView +@interface EmacsView : NSView #endif { #ifdef NS_IMPL_COCOA diff --git a/src/nsterm.m b/src/nsterm.m index cd6ffabddde..c659ef40c73 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -7049,9 +7049,44 @@ In that case we use UCKeyTranslate (ns_get_shifted_character) [nsEvArray removeObject: theEvent]; } +/*********************************************************************** + NSTextInputClient + ***********************************************************************/ -/* implementation (called through [super interpretKeyEvents:]). */ +- (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; +} + +/*********************************************************************** + NSTextInput + ***********************************************************************/ + +/* implementation (called through [super interpretKeyEvents:]). */ /* : called when done composing; NOTE: also called when we delete over working text, followed -- 2.45.2