diff options
| author | nyamatongwe <unknown> | 2011-05-27 08:51:23 +1000 | 
|---|---|---|
| committer | nyamatongwe <unknown> | 2011-05-27 08:51:23 +1000 | 
| commit | fd5b70c3920c79afb024c7e958a592b44fcc288c (patch) | |
| tree | 6b0b42b3ef053b793007f174fb3b08e49fd3ebf2 /cocoa/ScintillaView.mm | |
| parent | 97298b076704c5272477308e652107d2422c002a (diff) | |
| download | scintilla-mirror-fd5b70c3920c79afb024c7e958a592b44fcc288c.tar.gz | |
IME fixed to avoid inserting keys that are part of a character.
Allows for either NSString or NSAttributedString.
From Mike Schroeder of Adobe.
Diffstat (limited to 'cocoa/ScintillaView.mm')
| -rw-r--r-- | cocoa/ScintillaView.mm | 26 | 
1 files changed, 19 insertions, 7 deletions
diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm index 09f290b1e..4cebd7e9e 100644 --- a/cocoa/ScintillaView.mm +++ b/cocoa/ScintillaView.mm @@ -239,9 +239,15 @@ NSString *SCIUpdateUINotification = @"SCIUpdateUI";   */  - (void) insertText: (id) aString  { -  // Remove any previously marked text first. -  [self removeMarkedText]; -  mOwner.backend->InsertText((NSString*) aString); +	// Remove any previously marked text first. +	[self removeMarkedText]; +	NSString* newText = @""; +	if ([aString isKindOfClass:[NSString class]]) +		newText = (NSString*) aString; +	else if ([aString isKindOfClass:[NSAttributedString class]]) +		newText = (NSString*) [aString string]; +	 +	mOwner.backend->InsertText(newText);  }  //-------------------------------------------------------------------------------------------------- @@ -274,7 +280,12 @@ NSString *SCIUpdateUINotification = @"SCIUpdateUI";  {    // Since we did not return any valid attribute for marked text (see validAttributesForMarkedText)    // we can safely assume the passed in text is an NSString instance. -  NSString* newText = (NSString*) aString; +	NSString* newText = @""; +	if ([aString isKindOfClass:[NSString class]]) +		newText = (NSString*) aString; +	else if ([aString isKindOfClass:[NSAttributedString class]]) +		newText = (NSString*) [aString string]; +    int currentPosition = [mOwner getGeneralProperty: SCI_GETCURRENTPOS parameter: 0];    // Replace marked text if there is one. @@ -363,7 +374,8 @@ NSString *SCIUpdateUINotification = @"SCIUpdateUI";   */  - (void) keyDown: (NSEvent *) theEvent  { -  mOwner.backend->KeyboardInput(theEvent); +  if (mMarkedTextRange.length == 0) +	mOwner.backend->KeyboardInput(theEvent);    NSArray* events = [NSArray arrayWithObject: theEvent];    [self interpretKeyEvents: events];  } @@ -777,9 +789,9 @@ static void notification(intptr_t windowid, unsigned int iMessage, uintptr_t wPa      // Setup a special indicator used in the editor to provide visual feedback for       // input composition, depending on language, keyboard etc. -    [self setColorProperty: SCI_INDICSETFORE parameter: INPUT_INDICATOR fromHTML: @"#FF9A00"]; +    [self setColorProperty: SCI_INDICSETFORE parameter: INPUT_INDICATOR fromHTML: @"#FF0000"];      [self setGeneralProperty: SCI_INDICSETUNDER parameter: INPUT_INDICATOR value: 1]; -    [self setGeneralProperty: SCI_INDICSETSTYLE parameter: INPUT_INDICATOR value: INDIC_ROUNDBOX]; +    [self setGeneralProperty: SCI_INDICSETSTYLE parameter: INPUT_INDICATOR value: INDIC_PLAIN];      [self setGeneralProperty: SCI_INDICSETALPHA parameter: INPUT_INDICATOR value: 100];    }    return self;  | 
