settings->Editor->General settings->Code completion->Autolaunch after typing # letters
i don't know why the settings for code completion are split up
This is because the setting here will be shared by all kinds of code completion plugins, I mean we have a lot of cc plugins, such as the build in cc, the clang cc, the python cc.
Any ideas oBFusCATed, is there a way to get the behaviour I'm looking for from the built in Code Completion?
Hi, I think it can be adjusted, but I don't know how to do that, in the source code:
void CodeCompletion::DoCodeComplete(int caretPos, cbEditor* ed, std::vector<CCToken>& tokens, bool preprocessorOnly)
There are some snippet:
if (colour_set)
{
wxString lastSearch = m_NativeParser.LastAIGlobalSearch().Lower();
int iidx = ilist->GetImageCount();
FileType fTp = FileTypeOf(ed->GetShortName());
bool isC = (fTp == ftHeader || fTp == ftSource|| fTp == ftTemplateSource);
// theme keywords
HighlightLanguage lang = ed->GetLanguage();
if (lang == HL_NONE)
lang = colour_set->GetLanguageForFilename(ed->GetFilename());
wxString strLang = colour_set->GetLanguageName(lang);
// if its sourcecode/header file and a known fileformat, show the corresponding icon
if (isC && strLang == wxT("C/C++"))
stc->RegisterImage(iidx, wxBitmap(cpp_keyword_xpm));
else if (isC && strLang == wxT("D"))
stc->RegisterImage(iidx, wxBitmap(d_keyword_xpm));
else
stc->RegisterImage(iidx, wxBitmap(unknown_keyword_xpm));
// the first two keyword sets are the primary and secondary keywords (for most lexers at least)
// but this is now configurable in global settings
for (int i = 0; i <= wxSCI_KEYWORDSET_MAX; ++i)
{
if (!m_LexerKeywordsToInclude[i])
continue;
wxString keywords = colour_set->GetKeywords(lang, i);
wxStringTokenizer tkz(keywords, wxT(" \t\r\n"), wxTOKEN_STRTOK);
while (tkz.HasMoreTokens())
{
wxString kw = tkz.GetNextToken();
if ( kw.Lower().StartsWith(lastSearch)
&& uniqueStrings.find(kw) == uniqueStrings.end() )
{
tokens.push_back(CCToken(wxNOT_FOUND, kw, iidx));
}
}
}
}
You see, all the keywords were added directly to the "tokens", but I think they don't have much precedence, as I can see the cunstructor of CCToken.
/** Structure representing a generic token, passed between CC plugins and CCManager. */
struct CCToken
{
/** @brief Convenience constructor.
*
* Represents a generic token, passed between CC plugins and CCManager.
*
* @param _id Internal identifier for a CC plugin to reference the token in its data structure.
* @param dispNm The string CCManager will use to display this token.
* @param categ The category corresponding to the index of the registered image (during autocomplete).
* Negative values are reserved for CCManager.
*/
CCToken(int _id, const wxString& dispNm, int categ = -1) :
id(_id), category(categ), weight(5), displayName(dispNm), name(dispNm) {}
/** @brief Construct a fully specified CCToken.
*
* Represents a generic token, passed between CC plugins and CCManager.
*
* @param _id Internal identifier for a CC plugin to reference the token in its data structure.
* @param dispNm The verbose string CCManager will use to display this token.
* @param nm Minimal name of the token that CCManager may choose to display in restricted circumstances.
* @param _weight Lower numbers are placed earlier in listing, 5 is default; try to keep 0-10.
* @param categ The category corresponding to the index of the registered image (during autocomplete).
* Negative values are reserved for CCManager.
*/
CCToken(int _id, const wxString& dispNm, const wxString& nm, int _weight, int categ = -1) :
id(_id), category(categ), weight(_weight), displayName(dispNm), name(nm) {}
int id; //!< CCManager will pass this back unmodified. Use it as an internal identifier for the token.
int category; //!< The category corresponding to the index of the registered image (during autocomplete).
int weight; //!< Lower numbers are placed earlier in listing, 5 is default; try to keep 0-10.
wxString displayName; //!< Verbose string representing the token.
wxString name; //!< Minimal name of the token that CCManager may choose to display in restricted circumstances.
};
So, we have to adjust the "weight" parameter. We need an algorithm to dynamically adjust the "weight" for each added keywords.