From d5110563aee91348b5c60a13a0aaf2893d50d3ea Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Mon, 16 Apr 2012 09:05:21 +1000 Subject: =?UTF-8?q?Case-insensitive=20auto-completion=20selection.=20Bug?= =?UTF-8?q?=20#3516538.=20From=20Markus=20Ni=C3=9Fl.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/ScintillaDoc.html | 9 +++++++++ doc/ScintillaHistory.html | 1 + include/Scintilla.h | 4 ++++ include/Scintilla.iface | 10 ++++++++++ src/AutoComplete.cxx | 7 +++++-- src/AutoComplete.h | 1 + src/ScintillaBase.cxx | 7 +++++++ 7 files changed, 37 insertions(+), 2 deletions(-) diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 2536b36c6..87c71d158 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -3931,6 +3931,8 @@ struct Sci_TextToFind { SCI_AUTOCSETIGNORECASE(bool ignoreCase)
SCI_AUTOCGETIGNORECASE
+ SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR(int behaviour)
+ SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR
SCI_AUTOCSETAUTOHIDE(bool autoHide)
SCI_AUTOCGETAUTOHIDE
SCI_AUTOCSETDROPRESTOFWORD(bool @@ -4036,6 +4038,13 @@ struct Sci_TextToFind { By default, matching of characters to list members is case sensitive. These messages let you set and get case sensitivity.

+

SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR(int behaviour)
+ SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR
+ When autocompletion is set to ignore case (SCI_AUTOCSETIGNORECASE), by default it will + nonetheless select the first list member that matches in a case sensitive way to entered characters. + This corresponds to a behaviour property of AC_SELECT_CI_RESPECT_CS (0). + If you want autocompletion to ignore case at all, choose AC_SELECT_CI_IGNORE_CS (1).

+

SCI_AUTOCSETAUTOHIDE(bool autoHide)
SCI_AUTOCGETAUTOHIDE
By default, the list is cancelled if there are no viable matches (the user has typed diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index b6df6ac94..8276a7b68 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -398,6 +398,7 @@ zeniko James Ribe + Markus Nißl

diff --git a/include/Scintilla.h b/include/Scintilla.h index 7a6f58fac..8ff3d3142 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -685,6 +685,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETCHARSDEFAULT 2444 #define SCI_AUTOCGETCURRENT 2445 #define SCI_AUTOCGETCURRENTTEXT 2610 +#define SC_CASEINSENSITITIVEBEHAVIOUR_RESPECTCASE 0 +#define SC_CASEINSENSITITIVEBEHAVIOUR_IGNORECASE 1 +#define SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR 2634 +#define SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR 2635 #define SCI_ALLOCATE 2446 #define SCI_TARGETASUTF8 2447 #define SCI_SETLENGTHFORENCODE 2448 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index a2a38d51c..e34f79dad 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -1806,6 +1806,16 @@ fun int AutoCGetCurrent=2445(,) # Returns the length of the item text fun int AutoCGetCurrentText=2610(, stringresult s) +enu CaseInsensititiveBehaviour=SC_CASEINSENSITITIVEBEHAVIOUR_ +val SC_CASEINSENSITITIVEBEHAVIOUR_RESPECTCASE=0 +val SC_CASEINSENSITITIVEBEHAVIOUR_IGNORECASE=1 + +# Set auto-completion case insensitive behaviour to either prefer case-sensitive matches or have no preference. +set void AutoCSetCaseInsensitiveBehaviour=2634(int behaviour,) + +# Get auto-completion case insensitive behaviour. +get int AutoCGetCaseInsensitiveBehaviour=2635(,) + # Enlarge the document to a particular size of text bytes. fun void Allocate=2446(int bytes,) diff --git a/src/AutoComplete.cxx b/src/AutoComplete.cxx index 2752ef0c9..644f16517 100644 --- a/src/AutoComplete.cxx +++ b/src/AutoComplete.cxx @@ -14,6 +14,7 @@ #include "CharacterSet.h" #include "AutoComplete.h" +#include "Scintilla.h" #ifdef SCI_NAMESPACE using namespace Scintilla; @@ -30,7 +31,8 @@ AutoComplete::AutoComplete() : startLen(0), cancelAtStartPos(true), autoHide(true), - dropRestOfWord(false) { + dropRestOfWord(false), + ignoreCaseBehaviour(SC_CASEINSENSITITIVEBEHAVIOUR_RESPECTCASE) { lb = ListBox::Allocate(); stopChars[0] = '\0'; fillUpChars[0] = '\0'; @@ -153,7 +155,8 @@ void AutoComplete::Select(const char *word) { --pivot; } location = pivot; - if (ignoreCase) { + if (ignoreCase + && ignoreCaseBehaviour == SC_CASEINSENSITITIVEBEHAVIOUR_RESPECTCASE) { // Check for exact-case match for (; pivot <= end; pivot++) { lb->GetValue(pivot, item, maxItemLen); diff --git a/src/AutoComplete.h b/src/AutoComplete.h index aefab120a..19a1271ac 100644 --- a/src/AutoComplete.h +++ b/src/AutoComplete.h @@ -31,6 +31,7 @@ public: bool cancelAtStartPos; bool autoHide; bool dropRestOfWord; + unsigned int ignoreCaseBehaviour; AutoComplete(); ~AutoComplete(); diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index f78d0fb96..9d4f93c3f 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -727,6 +727,13 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara case SCI_AUTOCGETIGNORECASE: return ac.ignoreCase; + case SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR: + ac.ignoreCaseBehaviour = wParam; + break; + + case SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR: + return ac.ignoreCaseBehaviour; + case SCI_USERLISTSHOW: listType = wParam; AutoCompleteStart(0, reinterpret_cast(lParam)); -- cgit v1.2.3