This commit is contained in:
Camilla Berglund 2016-02-26 10:34:23 +01:00
parent 3107c9548d
commit 59dbd3b6ce

View File

@ -148,7 +148,7 @@ static NSUInteger translateKeyToModifierFlag(int key)
// Defines a constant for empty ranges in NSTextInputClient // Defines a constant for empty ranges in NSTextInputClient
// //
static const NSRange kEmptyRange = {NSNotFound, 0}; static const NSRange kEmptyRange = { NSNotFound, 0 };
//------------------------------------------------------------------------ //------------------------------------------------------------------------
@ -612,14 +612,15 @@ static const NSRange kEmptyRange = {NSNotFound, 0};
- (BOOL)hasMarkedText - (BOOL)hasMarkedText
{ {
return (markedText.length > 0); return [markedText length] > 0;
} }
- (NSRange)markedRange - (NSRange)markedRange
{ {
return (markedText.length > 0) ? if ([markedText length] > 0)
NSMakeRange(0, markedText.length-1) : return NSMakeRange(0, [markedText length] - 1);
kEmptyRange; else
return kEmptyRange;
} }
- (NSRange)selectedRange - (NSRange)selectedRange
@ -627,18 +628,14 @@ static const NSRange kEmptyRange = {NSNotFound, 0};
return kEmptyRange; return kEmptyRange;
} }
- (void)setMarkedText:(id)aString - (void)setMarkedText:(id)string
selectedRange:(NSRange)selectedRange selectedRange:(NSRange)selectedRange
replacementRange:(NSRange)replacementRange replacementRange:(NSRange)replacementRange
{ {
if( [aString isKindOfClass: [NSAttributedString class]] ) if ([string isKindOfClass:[NSAttributedString class]])
{ [markedText initWithAttributedString:string];
[markedText initWithAttributedString: aString];
}
else else
{ [markedText initWithString:string];
[markedText initWithString: aString];
}
} }
- (void)unmarkText - (void)unmarkText
@ -651,37 +648,36 @@ static const NSRange kEmptyRange = {NSNotFound, 0};
return [NSArray array]; return [NSArray array];
} }
- (NSAttributedString*)attributedSubstringForProposedRange:(NSRange)aRange - (NSAttributedString*)attributedSubstringForProposedRange:(NSRange)range
actualRange:(NSRangePointer)actualRange actualRange:(NSRangePointer)actualRange
{ {
return nil; return nil;
} }
- (NSUInteger)characterIndexForPoint:(NSPoint)aPoint - (NSUInteger)characterIndexForPoint:(NSPoint)point
{ {
return 0; return 0;
} }
- (NSRect)firstRectForCharacterRange:(NSRange)aRange - (NSRect)firstRectForCharacterRange:(NSRange)range
actualRange:(NSRangePointer)actualRange actualRange:(NSRangePointer)actualRange
{ {
return NSMakeRect(0, 0, 0, 0); return NSMakeRect(0, 0, 0, 0);
} }
- (void)insertText:(id)aString replacementRange:(NSRange)replacementRange - (void)insertText:(id)string replacementRange:(NSRange)replacementRange
{ {
NSString* characters;
NSEvent* event = [NSApp currentEvent]; NSEvent* event = [NSApp currentEvent];
const int mods = translateFlags([event modifierFlags]); const int mods = translateFlags([event modifierFlags]);
const int plain = !(mods & GLFW_MOD_SUPER);
NSString* characters; if ([string isKindOfClass:[NSAttributedString class]])
if ([aString isKindOfClass: [NSAttributedString class]]) { characters = [string string];
characters = [aString string]; else
} else { characters = (NSString*) string;
characters = (NSString*)aString;
}
NSUInteger i, length = [characters length]; NSUInteger i, length = [characters length];
const int plain = !(mods & GLFW_MOD_SUPER);
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
{ {