From e4145254c3614839f8c87900445b785d9e9ee7dd Mon Sep 17 00:00:00 2001 From: Jonathan Hunt Date: Fri, 3 Jul 2015 09:11:16 +1000 Subject: Feature [feature-requests:#1109]. SCN_AUTOCCOMPLETED sent after text insertion. From Jonathan Hunt. --- src/ScintillaBase.cxx | 18 ++++++++++++------ src/ScintillaBase.h | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index b52fb9a04..3d908d026 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -168,10 +168,10 @@ int ScintillaBase::KeyCommand(unsigned int iMessage) { EnsureCaretVisible(); return 0; case SCI_TAB: - AutoCompleteCompleted(); + AutoCompleteCompleted(0, SC_AC_TAB); return 0; case SCI_NEWLINE: - AutoCompleteCompleted(); + AutoCompleteCompleted(0, SC_AC_NEWLINE); return 0; default: @@ -202,7 +202,7 @@ int ScintillaBase::KeyCommand(unsigned int iMessage) { void ScintillaBase::AutoCompleteDoubleClick(void *p) { ScintillaBase *sci = reinterpret_cast(p); - sci->AutoCompleteCompleted(); + sci->AutoCompleteCompleted(0, SC_AC_DOUBLECLICK); } void ScintillaBase::AutoCompleteInsert(Position startPos, int removeLen, const char *text, int textLen) { @@ -340,7 +340,7 @@ void ScintillaBase::AutoCompleteMoveToCurrentWord() { void ScintillaBase::AutoCompleteCharacterAdded(char ch) { if (ac.IsFillUpChar(ch)) { - AutoCompleteCompleted(); + AutoCompleteCompleted(ch, SC_AC_FILLUP); } else if (ac.IsStopChar(ch)) { AutoCompleteCancel(); } else { @@ -363,7 +363,7 @@ void ScintillaBase::AutoCompleteCharacterDeleted() { NotifyParent(scn); } -void ScintillaBase::AutoCompleteCompleted() { +void ScintillaBase::AutoCompleteCompleted(char ch, unsigned int completionMethod) { int item = ac.GetSelection(); if (item == -1) { AutoCompleteCancel(); @@ -376,6 +376,8 @@ void ScintillaBase::AutoCompleteCompleted() { SCNotification scn = {}; scn.nmhdr.code = listType > 0 ? SCN_USERLISTSELECTION : SCN_AUTOCSELECTION; scn.message = 0; + scn.ch = ch; + scn.listCompletionMethod = completionMethod; scn.wParam = listType; scn.listType = listType; Position firstPos = ac.posStart - ac.startLen; @@ -398,6 +400,10 @@ void ScintillaBase::AutoCompleteCompleted() { return; AutoCompleteInsert(firstPos, endPos - firstPos, selected.c_str(), static_cast(selected.length())); SetLastXChosen(); + + scn.nmhdr.code = SCN_AUTOCCOMPLETED; + NotifyParent(scn); + } int ScintillaBase::AutoCompleteGetCurrent() const { @@ -788,7 +794,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara return ac.posStart; case SCI_AUTOCCOMPLETE: - AutoCompleteCompleted(); + AutoCompleteCompleted(0, SC_AC_COMMAND); break; case SCI_AUTOCSETSEPARATOR: diff --git a/src/ScintillaBase.h b/src/ScintillaBase.h index d6401cc30..4bdf24ef2 100644 --- a/src/ScintillaBase.h +++ b/src/ScintillaBase.h @@ -75,7 +75,7 @@ protected: int AutoCompleteGetCurrentText(char *buffer) const; void AutoCompleteCharacterAdded(char ch); void AutoCompleteCharacterDeleted(); - void AutoCompleteCompleted(); + void AutoCompleteCompleted(char ch, unsigned int completionMethod); void AutoCompleteMoveToCurrentWord(); static void AutoCompleteDoubleClick(void *p); -- cgit v1.2.3