diff options
| -rw-r--r-- | call/ScintillaCall.cxx | 8 | ||||
| -rw-r--r-- | doc/ScintillaDoc.html | 40 | ||||
| -rw-r--r-- | doc/ScintillaHistory.html | 5 | ||||
| -rw-r--r-- | include/Scintilla.h | 4 | ||||
| -rw-r--r-- | include/Scintilla.iface | 12 | ||||
| -rw-r--r-- | include/ScintillaCall.h | 2 | ||||
| -rw-r--r-- | include/ScintillaMessages.h | 2 | ||||
| -rw-r--r-- | include/ScintillaTypes.h | 5 | ||||
| -rw-r--r-- | src/AutoComplete.cxx | 4 | ||||
| -rw-r--r-- | src/AutoComplete.h | 4 | ||||
| -rw-r--r-- | src/Platform.h | 1 | ||||
| -rw-r--r-- | src/ScintillaBase.cxx | 16 | ||||
| -rw-r--r-- | win32/PlatWin.cxx | 12 | 
13 files changed, 103 insertions, 12 deletions
| diff --git a/call/ScintillaCall.cxx b/call/ScintillaCall.cxx index bec5ccfed..23de3f004 100644 --- a/call/ScintillaCall.cxx +++ b/call/ScintillaCall.cxx @@ -936,6 +936,14 @@ bool ScintillaCall::AutoCGetAutoHide() {  	return Call(Message::AutoCGetAutoHide);  } +void ScintillaCall::AutoCSetOptions(Scintilla::AutoCompleteOption options) { +	Call(Message::AutoCSetOptions, static_cast<uintptr_t>(options)); +} + +AutoCompleteOption ScintillaCall::AutoCGetOptions() { +	return static_cast<Scintilla::AutoCompleteOption>(Call(Message::AutoCGetOptions)); +} +  void ScintillaCall::AutoCSetDropRestOfWord(bool dropRestOfWord) {  	Call(Message::AutoCSetDropRestOfWord, dropRestOfWord);  } diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 03fe95ea9..531fca5aa 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -128,7 +128,7 @@      <h1>Scintilla Documentation</h1> -    <p>Last edited 25 June 2021 NH</p> +    <p>Last edited 17 July 2021 NH</p>      <p style="background:#90F0C0">Scintilla 5 has moved the lexers from Scintilla into a new      <a href="Lexilla.html">Lexilla</a> project.<br /> @@ -5741,6 +5741,8 @@ struct Sci_TextToFind {       <a class="message" href="#SCI_AUTOCSETDROPRESTOFWORD">SCI_AUTOCSETDROPRESTOFWORD(bool      dropRestOfWord)</a><br />       <a class="message" href="#SCI_AUTOCGETDROPRESTOFWORD">SCI_AUTOCGETDROPRESTOFWORD → bool</a><br /> +     <a class="message" href="#SCI_AUTOCSETOPTIONS">SCI_AUTOCSETOPTIONS(int options)</a><br /> +     <a class="message" href="#SCI_AUTOCGETOPTIONS">SCI_AUTOCGETOPTIONS → int</a><br />       <a class="message" href="#SCI_REGISTERIMAGE">SCI_REGISTERIMAGE(int type, const char *xpmData)</a><br />       <a class="message" href="#SCI_REGISTERRGBAIMAGE">SCI_REGISTERRGBAIMAGE(int type, const char *pixels)</a><br />       <a class="message" href="#SCI_CLEARREGISTEREDIMAGES">SCI_CLEARREGISTEREDIMAGES</a><br /> @@ -5887,6 +5889,42 @@ struct Sci_TextToFind {       When an item is selected, any word characters following the caret are first erased if      <code class="parameter">dropRestOfWord</code> is set <code>true</code>. The default is <code>false</code>.</p> +    <p><b id="SCI_AUTOCSETOPTIONS">SCI_AUTOCSETOPTIONS(int options)</b><br /> +     <b id="SCI_AUTOCGETOPTIONS">SCI_AUTOCGETOPTIONS → int</b><br /> +     Set options for autocompletion from the following list.</p> + +    <table class="standard" summary="Autocompletion options"> +      <tbody> +        <tr> +          <th align="left">Symbol</th> + +          <th>Value</th> + +          <th align="left">Purpose</th> +        </tr> +      </tbody> + +      <tbody valign="top"> +        <tr> +          <td align="left"><code>SC_AUTOCOMPLETE_NORMAL</code></td> + +          <td align="center">0</td> + +          <td>Display autocompletion using default settings.</td> +        </tr> + +        <tr> +          <td align="left"><code>SC_AUTOCOMPLETE_FIXED_SIZE</code></td> + +          <td align="center">1</td> + +          <td>On Win32 only, use a fixed size list instead of one that can be resized by the user. +	  This also avoids a header rectangle above the list.</td> +        </tr> + +      </tbody> +    </table> +      <p>        <b id="SCI_REGISTERIMAGE">SCI_REGISTERIMAGE(int type, const char *xpmData)</b><br />        <b id="SCI_REGISTERRGBAIMAGE">SCI_REGISTERRGBAIMAGE(int type, const char *pixels)</b><br /> diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 84710410d..8fddafc03 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -590,6 +590,11 @@  	<a href="https://sourceforge.net/p/scintilla/feature-requests/1370/">Feature #1370</a>.  	</li>  	<li> +	Add SCI_AUTOCSETOPTIONS to allow choosing a non-resizeable autocompletion list +	on Win32. +	<a href="https://sourceforge.net/p/scintilla/feature-requests/1284/">Feature #1284</a>. +	</li> +	<li>  	On Win32, when technology is changed, buffering is set to a reasonable value for the technology:  	on for GDI and off for Direct2D as Direct2D performs its own buffering.  	<a href="https://sourceforge.net/p/scintilla/feature-requests/1400/">Feature #1400</a>. diff --git a/include/Scintilla.h b/include/Scintilla.h index 088abc0d8..97fbd3be0 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -405,6 +405,10 @@ typedef sptr_t (*SciFnDirectStatus)(sptr_t ptr, unsigned int iMessage, uptr_t wP  #define SCI_USERLISTSHOW 2117  #define SCI_AUTOCSETAUTOHIDE 2118  #define SCI_AUTOCGETAUTOHIDE 2119 +#define SC_AUTOCOMPLETE_NORMAL 0 +#define SC_AUTOCOMPLETE_FIXED_SIZE 1 +#define SCI_AUTOCSETOPTIONS 2638 +#define SCI_AUTOCGETOPTIONS 2639  #define SCI_AUTOCSETDROPRESTOFWORD 2270  #define SCI_AUTOCGETDROPRESTOFWORD 2271  #define SCI_REGISTERIMAGE 2405 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index b59cda663..cc7dedf36 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -1009,6 +1009,18 @@ set void AutoCSetAutoHide=2118(bool autoHide,)  # Retrieve whether or not autocompletion is hidden automatically when nothing matches.  get bool AutoCGetAutoHide=2119(,) +# Define option flags for autocompletion lists +enu AutoCompleteOption=SC_AUTOCOMPLETE_ +val SC_AUTOCOMPLETE_NORMAL=0 +# Win32 specific: +val SC_AUTOCOMPLETE_FIXED_SIZE=1 + +# Set autocompletion options. +set void AutoCSetOptions=2638(AutoCompleteOption options,) + +# Retrieve autocompletion options. +get AutoCompleteOption AutoCGetOptions=2639(,) +  # Set whether or not autocompletion deletes any word characters  # after the inserted text upon completion.  set void AutoCSetDropRestOfWord=2270(bool dropRestOfWord,) diff --git a/include/ScintillaCall.h b/include/ScintillaCall.h index e0cfdd052..098b9ec1d 100644 --- a/include/ScintillaCall.h +++ b/include/ScintillaCall.h @@ -274,6 +274,8 @@ public:  	void UserListShow(int listType, const char *itemList);  	void AutoCSetAutoHide(bool autoHide);  	bool AutoCGetAutoHide(); +	void AutoCSetOptions(Scintilla::AutoCompleteOption options); +	Scintilla::AutoCompleteOption AutoCGetOptions();  	void AutoCSetDropRestOfWord(bool dropRestOfWord);  	bool AutoCGetDropRestOfWord();  	void RegisterImage(int type, const char *xpmData); diff --git a/include/ScintillaMessages.h b/include/ScintillaMessages.h index a0c641a39..9293a5a6b 100644 --- a/include/ScintillaMessages.h +++ b/include/ScintillaMessages.h @@ -210,6 +210,8 @@ enum class Message {  	UserListShow = 2117,  	AutoCSetAutoHide = 2118,  	AutoCGetAutoHide = 2119, +	AutoCSetOptions = 2638, +	AutoCGetOptions = 2639,  	AutoCSetDropRestOfWord = 2270,  	AutoCGetDropRestOfWord = 2271,  	RegisterImage = 2405, diff --git a/include/ScintillaTypes.h b/include/ScintillaTypes.h index ca0a07527..830ccadba 100644 --- a/include/ScintillaTypes.h +++ b/include/ScintillaTypes.h @@ -230,6 +230,11 @@ enum class IndicFlag {  	ValueFore = 1,  }; +enum class AutoCompleteOption { +	Normal = 0, +	FixedSize = 1, +}; +  enum class IndentView {  	None = 0,  	Real = 1, diff --git a/src/AutoComplete.cxx b/src/AutoComplete.cxx index fec0f20e9..87077e92a 100644 --- a/src/AutoComplete.cxx +++ b/src/AutoComplete.cxx @@ -39,6 +39,7 @@ AutoComplete::AutoComplete() :  	typesep('?'),  	ignoreCase(false),  	chooseSingle(false), +	options(AutoCompleteOption::Normal),  	posStart(0),  	startLen(0),  	cancelAtStartPos(true), @@ -63,10 +64,11 @@ bool AutoComplete::Active() const noexcept {  void AutoComplete::Start(Window &parent, int ctrlID,  	Sci::Position position, Point location, Sci::Position startLen_, -	int lineHeight, bool unicodeMode, Technology technology) { +	int lineHeight, bool unicodeMode, Technology technology, ListOptions listOptions) {  	if (active) {  		Cancel();  	} +	lb->SetOptions(listOptions);  	lb->Create(parent, ctrlID, location, lineHeight, unicodeMode, technology);  	lb->Clear();  	active = true; diff --git a/src/AutoComplete.h b/src/AutoComplete.h index c46530771..fa8f57287 100644 --- a/src/AutoComplete.h +++ b/src/AutoComplete.h @@ -25,6 +25,7 @@ public:  	bool ignoreCase;  	bool chooseSingle; +	AutoCompleteOption options;  	std::unique_ptr<ListBox> lb;  	Sci::Position posStart;  	Sci::Position startLen; @@ -49,7 +50,8 @@ public:  	/// Display the auto completion list positioned to be near a character position  	void Start(Window &parent, int ctrlID, Sci::Position position, Point location, -		Sci::Position startLen_, int lineHeight, bool unicodeMode, Scintilla::Technology technology); +		Sci::Position startLen_, int lineHeight, bool unicodeMode, Scintilla::Technology technology, +		ListOptions listOptions);  	/// The stop chars are characters which, when typed, cause the auto completion list to disappear  	void SetStopChars(const char *stopChars_); diff --git a/src/Platform.h b/src/Platform.h index 10c63dd23..ce04d9b22 100644 --- a/src/Platform.h +++ b/src/Platform.h @@ -313,6 +313,7 @@ struct ListOptions {  	std::optional<ColourRGBA> back;  	std::optional<ColourRGBA> foreSelected;  	std::optional<ColourRGBA> backSelected; +	AutoCompleteOption options=AutoCompleteOption::Normal;  };  class ListBox : public Window { diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index 0adca2f6f..238299734 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -257,16 +257,17 @@ void ScintillaBase::AutoCompleteStart(Sci::Position lenEntered, const char *list  			return;  		}  	} -	ac.Start(wMain, idAutoComplete, sel.MainCaret(), PointMainCaret(), -				lenEntered, vs.lineHeight, IsUnicodeMode(), technology);  	ListOptions options{  		vs.ElementColour(Element::List),  		vs.ElementColour(Element::ListBack),  		vs.ElementColour(Element::ListSelected), -		vs.ElementColour(Element::ListSelectedBack) +		vs.ElementColour(Element::ListSelectedBack), +		ac.options,  	}; -	ac.lb->SetOptions(options); + +	ac.Start(wMain, idAutoComplete, sel.MainCaret(), PointMainCaret(), +				lenEntered, vs.lineHeight, IsUnicodeMode(), technology, options);  	const PRectangle rcClient = GetClientRectangle();  	Point pt = LocationFromPosition(sel.MainCaret() - lenEntered); @@ -942,6 +943,13 @@ sptr_t ScintillaBase::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {  	case Message::AutoCGetAutoHide:  		return ac.autoHide; +	case Message::AutoCSetOptions: +		ac.options = static_cast<AutoCompleteOption>(wParam); +		break; + +	case Message::AutoCGetOptions: +		return static_cast<sptr_t>(ac.options); +  	case Message::AutoCSetDropRestOfWord:  		ac.dropRestOfWord = wParam != 0;  		break; diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 371edc957..3e966b4d3 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -2932,10 +2932,11 @@ class ListBoxX : public ListBox {  	Point location;	// Caret location at which the list is opened  	int wheelDelta; // mouse wheel residue  	ListOptions options; +	DWORD frameStyle = WS_THICKFRAME;  	HWND GetHWND() const noexcept;  	void AppendListItem(const char *text, const char *numword); -	static void AdjustWindowRect(PRectangle *rc, UINT dpi) noexcept; +	void AdjustWindowRect(PRectangle *rc, UINT dpiAdjust) const noexcept;  	int ItemHeight() const;  	int MinClientWidth() const noexcept;  	int TextOffset() const; @@ -3014,7 +3015,7 @@ void ListBoxX::Create(Window &parent_, int ctrlID_, Point location_, int lineHei  	// Window created as popup so not clipped within parent client area  	wid = ::CreateWindowEx(  		WS_EX_WINDOWEDGE, ListBoxX_ClassName, TEXT(""), -		WS_POPUP | WS_THICKFRAME, +		WS_POPUP | frameStyle,  		100,100, 150,80, hwndParent,  		NULL,  		hinstanceParent, @@ -3318,14 +3319,15 @@ void ListBoxX::SetList(const char *list, char separator, char typesep) {  void ListBoxX::SetOptions(ListOptions options_) {  	options = options_; +	frameStyle = FlagSet(options.options, AutoCompleteOption::FixedSize) ? WS_BORDER : WS_THICKFRAME;  } -void ListBoxX::AdjustWindowRect(PRectangle *rc, UINT dpi) noexcept { +void ListBoxX::AdjustWindowRect(PRectangle *rc, UINT dpiAdjust) const noexcept {  	RECT rcw = RectFromPRectangle(*rc);  	if (fnAdjustWindowRectExForDpi) { -		fnAdjustWindowRectExForDpi(&rcw, WS_THICKFRAME, false, WS_EX_WINDOWEDGE, dpi); +		fnAdjustWindowRectExForDpi(&rcw, frameStyle, false, WS_EX_WINDOWEDGE, dpiAdjust);  	} else { -		::AdjustWindowRectEx(&rcw, WS_THICKFRAME, false, WS_EX_WINDOWEDGE); +		::AdjustWindowRectEx(&rcw, frameStyle, false, WS_EX_WINDOWEDGE);  	}  	*rc = PRectangle::FromInts(rcw.left, rcw.top, rcw.right, rcw.bottom);  } | 
