1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-25 07:28:20 +00:00

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.
This commit is contained in:
Gerd Möllmann 2024-07-30 07:47:44 +02:00
parent 9f7c1ace9f
commit ceb5a15222
2 changed files with 41 additions and 2 deletions

View File

@ -463,7 +463,7 @@ enum ns_return_frame_mode
@class EmacsLayer;
#ifdef NS_IMPL_COCOA
@interface EmacsView : NSView <NSTextInput, NSWindowDelegate>
@interface EmacsView : NSView <NSTextInput, NSTextInputClient, NSWindowDelegate>
#else
@interface EmacsView : NSView <NSTextInput>
#endif

View File

@ -7032,10 +7032,49 @@ In that case we use UCKeyTranslate (ns_get_shifted_character)
[nsEvArray removeObject: theEvent];
}
/***********************************************************************
NSTextInputClient
***********************************************************************/
#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
***********************************************************************/
/* <NSTextInput> implementation (called through [super interpretKeyEvents:]). */
/* <NSTextInput>: called when done composing;
NOTE: also called when we delete over working text, followed
immediately by doCommandBySelector: deleteBackward: */