Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions call/ScintillaCall.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,14 @@ int ScintillaCall::AutoCGetMaxHeight() {
return static_cast<int>(Call(Message::AutoCGetMaxHeight));
}

void ScintillaCall::AutoCSetStyle(int style) {
Call(Message::AutoCSetStyle, style);
}

int ScintillaCall::AutoCGetStyle() {
return static_cast<int>(Call(Message::AutoCGetStyle));
}

void ScintillaCall::SetIndent(int indentSize) {
Call(Message::SetIndent, indentSize);
}
Expand Down
19 changes: 15 additions & 4 deletions doc/ScintillaDoc.html
Original file line number Diff line number Diff line change
Expand Up @@ -666,15 +666,16 @@ <h2 id="TextRetrievalAndModification">Text retrieval and modification</h2>

<p><b id="SCI_RELEASEALLEXTENDEDSTYLES">SCI_RELEASEALLEXTENDEDSTYLES</b><br />
<b id="SCI_ALLOCATEEXTENDEDSTYLES">SCI_ALLOCATEEXTENDEDSTYLES(int numberStyles) &rarr; int</b><br />
Extended styles are used for features like textual margins and annotations as well as internally by Scintilla.
They are outside the range 0..255 used for the styles bytes associated with document bytes.
Extended styles are used for features like textual margins and annotations and autocompletion lists as well as
internally by Scintilla. They are outside the range 0..255 used for the styles bytes associated with document bytes.
These functions manage the use of extended styles to ensures that components cooperate in defining styles.
<code>SCI_RELEASEALLEXTENDEDSTYLES</code> releases any extended styles allocated by the container.
<code>SCI_ALLOCATEEXTENDEDSTYLES</code> allocates a range of style numbers after the byte style values and returns
the number of the first allocated style.
Ranges for margin and annotation styles should be allocated before calling
Ranges for margin, annotation and autocompletion list styles should be allocated before calling
<a class="seealso" href="#SCI_MARGINSETSTYLEOFFSET">SCI_MARGINSETSTYLEOFFSET</a> or
<a class="seealso" href="#SCI_ANNOTATIONSETSTYLEOFFSET">SCI_ANNOTATIONSETSTYLEOFFSET</a>.</p>
<a class="seealso" href="#SCI_ANNOTATIONSETSTYLEOFFSET">SCI_ANNOTATIONSETSTYLEOFFSET</a> or
<a class="seealso" href="#SCI_AUTOCSETSTYLE">SCI_AUTOCSETSTYLE</a>.</p>

<p><b id="Sci_TextRange">Sci_TextRange</b> and <b id="Sci_CharacterRange">Sci_CharacterRange</b><br />
These structures are defined to be exactly the same shape as the Win32 <code>TEXTRANGE</code>
Expand Down Expand Up @@ -6494,6 +6495,16 @@ <h2 id="Autocompletion">Autocompletion</h2>
the available width are indicated by the presence of ellipsis.
</p>

<p>
<b id="SCI_AUTOCSETSTYLE">SCI_AUTOCSETSTYLE</b><br />
<b id="SCI_AUTOCGETSTYLE">SCI_AUTOCGETSTYLE &rarr; int</b><br />

Get or set the style used by autocompletion lists to determine the font facename, size and character set used to display characters. Defaults
to <code><a class="message" href="#StyleDefinition">STYLE_DEFAULT</a></code>. Always call
<a class="seealso" href="#SCI_ALLOCATEEXTENDEDSTYLES">SCI_ALLOCATEEXTENDEDSTYLES(1)</a> before <code>SCI_AUTOCSETSTYLE</code> and use the
result as the argument to <code>SCI_AUTOCSETSTYLE</code> and <code>SCI_STYLESETFONT</code> and others.
</p>

<p>
<b id="SC_ELEMENT_LIST">SC_ELEMENT_LIST : colouralpha</b><br />
<b id="SC_ELEMENT_LIST_BACK">SC_ELEMENT_LIST_BACK : colouralpha</b><br />
Expand Down
2 changes: 2 additions & 0 deletions include/Scintilla.h
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,8 @@ typedef sptr_t (*SciFnDirectStatus)(sptr_t ptr, unsigned int iMessage, uptr_t wP
#define SCI_AUTOCGETMAXWIDTH 2209
#define SCI_AUTOCSETMAXHEIGHT 2210
#define SCI_AUTOCGETMAXHEIGHT 2211
#define SCI_AUTOCSETSTYLE 2806
#define SCI_AUTOCGETSTYLE 2807
#define SCI_SETINDENT 2122
#define SCI_GETINDENT 2123
#define SCI_SETUSETABS 2124
Expand Down
6 changes: 6 additions & 0 deletions include/Scintilla.iface
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,12 @@ set void AutoCSetMaxHeight=2210(int rowCount,)
# Set the maximum height, in rows, of auto-completion and user lists.
get int AutoCGetMaxHeight=2211(,)

# Set the style number used for auto-completion and user lists fonts.
set void AutoCSetStyle=2806(int style,)

# Get the style number used for auto-completion and user lists fonts.
get int AutoCGetStyle=2807(,)

# Set the number of spaces used for one level of indentation.
set void SetIndent=2122(int indentSize,)

Expand Down
2 changes: 2 additions & 0 deletions include/ScintillaCall.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ class ScintillaCall {
int AutoCGetMaxWidth();
void AutoCSetMaxHeight(int rowCount);
int AutoCGetMaxHeight();
void AutoCSetStyle(int style);
int AutoCGetStyle();
void SetIndent(int indentSize);
int Indent();
void SetUseTabs(bool useTabs);
Expand Down
2 changes: 2 additions & 0 deletions include/ScintillaMessages.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ enum class Message {
AutoCGetMaxWidth = 2209,
AutoCSetMaxHeight = 2210,
AutoCGetMaxHeight = 2211,
AutoCSetStyle = 2806,
AutoCGetStyle = 2807,
SetIndent = 2122,
GetIndent = 2123,
SetUseTabs = 2124,
Expand Down
23 changes: 20 additions & 3 deletions src/ScintillaBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <cstdint>
#include <cassert>
#include <cstring>
#include <cmath>

#include <stdexcept>
#include <string>
Expand Down Expand Up @@ -273,8 +274,16 @@ void ScintillaBase::AutoCompleteStart(Sci::Position lenEntered, const char *list
ac.options,
};

int lineHeight;
if (vs.autocStyle != StyleDefault) {
AutoSurface surfaceMeasure(this);
lineHeight = static_cast<int>(std::lround(surfaceMeasure->Height(vs.styles[vs.autocStyle].font.get())));
} else {
lineHeight = vs.lineHeight;
}

ac.Start(wMain, idAutoComplete, sel.MainCaret(), PointMainCaret(),
lenEntered, vs.lineHeight, IsUnicodeMode(), technology, options);
lenEntered, lineHeight, IsUnicodeMode(), technology, options);

const PRectangle rcClient = GetClientRectangle();
Point pt = LocationFromPosition(sel.MainCaret() - lenEntered);
Expand Down Expand Up @@ -307,8 +316,8 @@ void ScintillaBase::AutoCompleteStart(Sci::Position lenEntered, const char *list
rcac.right = rcac.left + widthLB;
rcac.bottom = static_cast<XYPOSITION>(std::min(static_cast<int>(rcac.top) + heightLB, static_cast<int>(rcPopupBounds.bottom)));
ac.lb->SetPositionRelative(rcac, &wMain);
ac.lb->SetFont(vs.styles[StyleDefault].font.get());
const int aveCharWidth = static_cast<int>(vs.styles[StyleDefault].aveCharWidth);
ac.lb->SetFont(vs.styles[vs.autocStyle].font.get());
const int aveCharWidth = static_cast<int>(vs.styles[vs.autocStyle].aveCharWidth);
ac.lb->SetAverageCharWidth(aveCharWidth);
ac.lb->SetDelegate(this);

Expand Down Expand Up @@ -941,6 +950,14 @@ sptr_t ScintillaBase::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
case Message::AutoCGetMaxWidth:
return maxListWidth;

case Message::AutoCSetStyle:
vs.autocStyle = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;

case Message::AutoCGetStyle:
return vs.autocStyle;

case Message::RegisterImage:
ac.lb->RegisterImage(static_cast<int>(wParam), ConstCharPtrFromSPtr(lParam));
break;
Expand Down
5 changes: 4 additions & 1 deletion src/ViewStyle.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ ViewStyle::ViewStyle(size_t stylesSize_) :
ctrlCharPadding = 3; // +3 For a blank on front and rounded edge each side
lastSegItalicsOffset = 2;

autocStyle = StyleDefault;

localeName = localeNameDefault;
}

Expand Down Expand Up @@ -792,7 +794,8 @@ FontRealised *ViewStyle::Find(const FontSpecification &fs) {

void ViewStyle::FindMaxAscentDescent() noexcept {
for (size_t i = 0; i < styles.size(); i++) {
if (i == StyleCallTip)
if (i == StyleCallTip ||
(autocStyle != StyleDefault && i == static_cast<size_t>(autocStyle)))
continue;

const auto &style = styles[i];
Expand Down
1 change: 1 addition & 0 deletions src/ViewStyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class ViewStyle {
int marginNumberPadding; // the right-side padding of the number margin
int ctrlCharPadding; // the padding around control character text blobs
int lastSegItalicsOffset; // the offset so as not to clip italic characters at EOLs
int autocStyle;

using ElementMap = std::map<Scintilla::Element, ColourOptional>;
ElementMap elementColours;
Expand Down
4 changes: 4 additions & 0 deletions test/simpleTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3093,6 +3093,10 @@ def testChangeDefaults(self):
self.assertEqual(self.ed.AutoCGetDropRestOfWord(), 1)
self.ed.AutoCSetDropRestOfWord(0)

self.ed.AutoCSetStyle(13)
self.assertEqual(self.ed.AutoCGetStyle(), 13)
self.ed.AutoCSetStyle(32)

def testAutoShow(self):
self.assertEqual(self.ed.AutoCActive(), 0)
self.ed.SetSel(0, 0)
Expand Down