Here's patch which adds STYLE_AUTOCOMPLETION and SCI_AUTOCUSESTYLE to enable it.
This is similar to STYLE_CALLTIP and SCI_CALLTIPUSESTYLE except that it only the font face name, font size, and character set attributes are used and not the colours.
It was actually added a long time ago by Jordan Russell for Inno Setup and I recently updated this to the lastest version of Scintilla and also added SCI_AUTOCUSESTYLE for backward compatibility. In Inno Setup this style is used to change the font for autocompletion lists to the normal dialog font.
The default value of 2 for the lineHeight property is how it was in old versions of Scintilla.
The patch includes updates of Scintilla.iface and ScintillaDoc.html.
https://patch-diff.githubusercontent.com/raw/jrsoftware/scintilla/pull/6.diff
https://patch-diff.githubusercontent.com/raw/jrsoftware/scintilla/pull/6.patch
https://github.com/jrsoftware/scintilla/pull/6/files
Style 40 is already used by lexers (with
SCE_PL_SUB_PROTOTYPEandSCE_RB_STDERR, for example) and can not be repurposed for other uses.Ah, sorry, I wasn't aware of that. We don't use a lexer so haven't run into this limitation. Is there a way to workaround this, assuming you find the feature interesting?
SC_ELEMENT_LIST*can be used to custom auto-completion list colors.Thanks but this patch is to change the font name & size and not the colors.
An extended style can be allocated with SCI_ALLOCATEEXTENDEDSTYLES.
Then there could be an API to set this as the autocompletion style.
Sounds good, thanks! Will look into this.
I've updated the patch: replaced STYLE_AUTOCOMPLETION and SCI_AUTOCUSESTYLE with SCI_AUTOCSETSTYLEOFFSET (and SCI_AUTOCGETSTYLEOFFSET). Also fixed some preexisting typos in Scintilla.iface.
I haven't worked with extended styles before but think I made it how they're supposed to work. My container now does calls like this:
Adding
STYLE_DEFAULT(32) appears wrong asSCI_ALLOCATEEXTENDEDSTYLESshould return the allocated style number.Please don't do this as it makes it more difficult to see what was changed by a feature. Fixing issues with other code should be in separate change sets.
I removed the typo fixes from the patch.
Also made it correct so the container doesn't have to add STYLE_DEFAULT anymore. I got confused by the use of 'Offset' in MarginSetStyleOffset but understand it now. The patch should now be good to commit.
This may produce different height lines than before (and different to the edit view) as it defaults to using the height of
STYLE_DEFAULTinstead of the max height of all fonts and doesn't take into account the extra ascent and descent that can be used to ensure extra-large text like emojis and accented characters are displayed OK.It is likely that changing the height of autocompletion list lines and thus number of lines visible is a motivation for this change but it shouldn't affect applications that do not call
SCI_AUTOCSETSTYLE.Possibly drop
FontMeasurements::lineHeightand use explicit code inScintillaBase::AutoCompleteStartthat maintains current behaviour unlessViewStyle::autocStylewas set.Thanks for reviewing again and sorry it wasn't correct yet. I've applied your recommendations to the patch. I based the method of getting a surface for measurement on how it's done for call tips.
The font pointer
Font *fontTextis being used after it may become invalid inside theac.Start(...)statement where the fonts may be refreshed. This caused a crash when I tested the code. It is safest to use the full expressionvs.styles[vs.autocStyle].font.get()for each use.The
scintilla.ifaceinterface definition file doesn't have an argument forAutoCSetStyle:It is worthwhile having some simple tests to check the API definition works as does the API.
The
surfaceMeasurecreation code is repeated before callingAutoCompleteStartand there could be a single implementation inside the method. This would also preserve the current method signature.Thanks, I've updated the patch with your suggestions.
Committed with minor changes as [d30a84]. The API numbers were changed to use some spare ones from near other autocompletion methods.
Related
Commit: [d30a84]
Thanks!