diff options
| author | mitchell <unknown> | 2019-07-11 14:12:28 -0400 |
|---|---|---|
| committer | mitchell <unknown> | 2019-07-11 14:12:28 -0400 |
| commit | 2a15b94200abe8ee0df2dddc296f3dafd55655f8 (patch) | |
| tree | 7236773c70225185fe1532d109a66f98c39e8d18 /cocoa | |
| parent | 55446b8967ed0a7f66502424d309f0b8fa74919f (diff) | |
| download | scintilla-mirror-2a15b94200abe8ee0df2dddc296f3dafd55655f8.tar.gz | |
Backport: Bug [#2038]. Source of input reported in SCN_CHARADDED.
This may be SC_CHARACTERSOURCE_DIRECT_INPUT, SC_CHARACTERSOURCE_TENTATIVE_INPUT,
or SC_CHARACTERSOURCE_IME_RESULT.
Backport of changeset 7613:4cfac35c71bd.
Diffstat (limited to 'cocoa')
| -rw-r--r-- | cocoa/ScintillaCocoa.h | 2 | ||||
| -rw-r--r-- | cocoa/ScintillaCocoa.mm | 6 | ||||
| -rw-r--r-- | cocoa/ScintillaView.mm | 8 |
3 files changed, 8 insertions, 8 deletions
diff --git a/cocoa/ScintillaCocoa.h b/cocoa/ScintillaCocoa.h index 9a74cb6f3..7e91f4c1a 100644 --- a/cocoa/ScintillaCocoa.h +++ b/cocoa/ScintillaCocoa.h @@ -199,7 +199,7 @@ public: void ObserverRemove(); void IdleWork() override; void QueueIdleWork(WorkNeeded::workItems items, Sci::Position upTo) override; - ptrdiff_t InsertText(NSString *input); + ptrdiff_t InsertText(NSString *input, CharacterSource charSource); NSRange PositionsFromCharacters(NSRange rangeCharacters) const; NSRange CharactersFromPositions(NSRange rangePositions) const; NSString *RangeTextAsString(NSRange rangePositions) const; diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index b1b44ea00..b40743dad 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -2279,7 +2279,7 @@ bool ScintillaCocoa::KeyboardInput(NSEvent* event) /** * Used to insert already processed text provided by the Cocoa text input system. */ -ptrdiff_t ScintillaCocoa::InsertText(NSString *input) { +ptrdiff_t ScintillaCocoa::InsertText(NSString *input, CharacterSource charSource) { CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(), vs.styles[STYLE_DEFAULT].characterSet); std::string encoded = EncodedBytesString((CFStringRef)input, encoding); @@ -2292,11 +2292,11 @@ ptrdiff_t ScintillaCocoa::InsertText(NSString *input) { while (sv.length()) { const unsigned char leadByte = sv[0]; const unsigned int bytesInCharacter = UTF8BytesOfLead[leadByte]; - InsertCharacter(sv.c_str(), bytesInCharacter); + InsertCharacter(sv.c_str(), bytesInCharacter, charSource); sv = sv.substr(bytesInCharacter, sv.length()); } } else { - InsertCharacter(encoded.c_str(), static_cast<unsigned int>(encoded.length())); + InsertCharacter(encoded.c_str(), static_cast<unsigned int>(encoded.length()), charSource); } } return encoded.length(); diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm index ad8d7dc01..12e0495d6 100644 --- a/cocoa/ScintillaView.mm +++ b/cocoa/ScintillaView.mm @@ -565,7 +565,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) else if ([aString isKindOfClass:[NSAttributedString class]]) newText = (NSString*) [aString string]; - mOwner.backend->InsertText(newText); + mOwner.backend->InsertText(newText, EditModel::CharacterSource::directInput); } //-------------------------------------------------------------------------------------------------- @@ -674,7 +674,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) NSRange posRangeCurrent = mOwner.backend->PositionsFromCharacters(NSMakeRange(replacementRange.location, 0)); // Note: Scintilla internally works almost always with bytes instead chars, so we need to take // this into account when determining selection ranges and such. - ptrdiff_t lengthInserted = mOwner.backend->InsertText(newText); + ptrdiff_t lengthInserted = mOwner.backend->InsertText(newText, EditModel::CharacterSource::tentativeInput); posRangeCurrent.length = lengthInserted; mMarkedTextRange = mOwner.backend->CharactersFromPositions(posRangeCurrent); // Mark the just inserted text. Keep the marked range for later reset. @@ -2139,9 +2139,9 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context - (void)insertText: (id) aString { if ([aString isKindOfClass:[NSString class]]) - mBackend->InsertText(aString); + mBackend->InsertText(aString, EditModel::CharacterSource::directInput); else if ([aString isKindOfClass:[NSAttributedString class]]) - mBackend->InsertText([aString string]); + mBackend->InsertText([aString string], EditModel::CharacterSource::directInput); } //-------------------------------------------------------------------------------------------------- |
