本文整理汇总了C++中lexerconf::Ptr_t::GetKeyWords方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr_t::GetKeyWords方法的具体用法?C++ Ptr_t::GetKeyWords怎么用?C++ Ptr_t::GetKeyWords使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lexerconf::Ptr_t
的用法示例。
在下文中一共展示了Ptr_t::GetKeyWords方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PhpKeywords
PHPEntityBase::List_t PHPCodeCompletion::PhpKeywords(const wxString& prefix) const
{
LexerConf::Ptr_t lexer = ColoursAndFontsManager::Get().GetLexer("php");
if(!lexer) return PHPEntityBase::List_t();
wxString lcPrefix = prefix.Lower();
PHPEntityBase::List_t lst;
wxString phpKeywords = lexer->GetKeyWords(4);
wxArrayString phpKeywordsArr = ::wxStringTokenize(phpKeywords, " \t", wxTOKEN_STRTOK);
for(size_t i = 0; i < phpKeywordsArr.GetCount(); ++i) {
wxString lcWord = phpKeywordsArr.Item(i).Lower();
if(lcWord.StartsWith(lcPrefix)) {
PHPEntityBase::Ptr_t keyword(new PHPEntityKeyword());
keyword->SetFullName(phpKeywordsArr.Item(i));
keyword->SetShortName(phpKeywordsArr.Item(i));
lst.push_back(keyword);
}
}
return lst;
}
示例2: ApplySettings
void ContextPhp::ApplySettings()
{
SetName(wxT("php"));
LexerConf::Ptr_t lexPtr;
if(EditorConfigST::Get()->IsOk()) {
lexPtr = EditorConfigST::Get()->GetLexer(GetName());
}
LEditor& rCtrl = GetCtrl();
if(lexPtr) {
rCtrl.SetLexer(lexPtr->GetLexerId());
for(int i = 0; i <= 4; ++i) {
wxString keyWords = lexPtr->GetKeyWords(i);
keyWords.Replace(wxT("\n"), wxT(" "));
keyWords.Replace(wxT("\r"), wxT(" "));
rCtrl.SetKeyWords(i, keyWords);
}
} else {
rCtrl.SetLexer(wxSTC_LEX_NULL);
}
DoApplySettings(lexPtr);
}
示例3: OnWordComplete
void WordCompletionPlugin::OnWordComplete(wxCommandEvent& event)
{
event.Skip();
IEditor* activeEditor = m_mgr->GetActiveEditor();
CHECK_PTR_RET(activeEditor);
WordCompletionSettings settings;
settings.Load();
// Enabled?
if(!settings.IsEnabled()) return;
// Build the suggetsion list
wxString suggestString;
wxCodeCompletionBoxEntry::Vec_t entries;
wxCodeCompletionBox::BmpVec_t bitmaps;
bitmaps.push_back(m_images.Bitmap("m_bmpWord"));
// Filter (what the user has typed so far)
wxStyledTextCtrl* stc = activeEditor->GetCtrl();
int curPos = stc->GetCurrentPos();
int start = stc->WordStartPosition(stc->GetCurrentPos(), true);
if(curPos < start) return;
wxString filter = stc->GetTextRange(start, curPos);
wxString lcFilter = filter.Lower();
wxStringSet_t words = m_dictionary->GetWords();
// Parse the current bufer (if modified), to include non saved words
if(activeEditor->IsModified()) {
wxStringSet_t unsavedBufferWords;
WordCompletionThread::ParseBuffer(stc->GetText(), unsavedBufferWords);
// Merge the results
words.insert(unsavedBufferWords.begin(), unsavedBufferWords.end());
}
// Get the editor keywords and add them
LexerConf::Ptr_t lexer = ColoursAndFontsManager::Get().GetLexerForFile(activeEditor->GetFileName().GetFullName());
if(lexer) {
wxString keywords;
for(size_t i = 0; i < wxSTC_KEYWORDSET_MAX; ++i) {
keywords << lexer->GetKeyWords(i) << " ";
}
wxArrayString langWords = ::wxStringTokenize(keywords, "\n\t \r", wxTOKEN_STRTOK);
words.insert(langWords.begin(), langWords.end());
}
wxStringSet_t filterdSet;
if(lcFilter.IsEmpty()) {
filterdSet.swap(words);
} else {
for(wxStringSet_t::iterator iter = words.begin(); iter != words.end(); ++iter) {
wxString word = *iter;
wxString lcWord = word.Lower();
if(settings.GetComparisonMethod() == WordCompletionSettings::kComparisonStartsWith) {
if(lcWord.StartsWith(lcFilter) && filter != word) {
filterdSet.insert(word);
}
} else {
if(lcWord.Contains(lcFilter) && filter != word) {
filterdSet.insert(word);
}
}
}
}
for(wxStringSet_t::iterator iter = filterdSet.begin(); iter != filterdSet.end(); ++iter) {
entries.push_back(wxCodeCompletionBoxEntry::New(*iter, 0));
}
wxCodeCompletionBoxManager::Get().ShowCompletionBox(activeEditor->GetCtrl(),
entries,
bitmaps,
event.GetId() == XRCID("text_word_complete") ?
wxCodeCompletionBox::kInsertSingleMatch :
wxCodeCompletionBox::kNone,
wxNOT_FOUND);
}
示例4: OnWordComplete
void WordCompletionPlugin::OnWordComplete(clCodeCompletionEvent& event)
{
event.Skip(); // Always skip this
IEditor* activeEditor = dynamic_cast<IEditor*>(event.GetEditor());
CHECK_PTR_RET(activeEditor);
WordCompletionSettings settings;
settings.Load();
// Enabled?
if(!settings.IsEnabled()) {
return;
}
// Build the suggetsion list
static wxBitmap sBmp = wxNullBitmap;
if(!sBmp.IsOk()) {
sBmp = m_mgr->GetStdIcons()->LoadBitmap("word");
}
// Filter (what the user has typed so far)
// wxStyledTextCtrl* stc = activeEditor->GetCtrl();
// int curPos = stc->GetCurrentPos();
// int start = stc->WordStartPosition(stc->GetCurrentPos(), true);
// if(curPos < start) return;
wxString filter = event.GetWord().Lower(); // stc->GetTextRange(start, curPos);
wxStringSet_t words = m_dictionary->GetWords();
// Parse the current bufer (if modified), to include non saved words
if(activeEditor->IsModified()) {
// For performance (this parsing is done in the main thread)
// only parse the visible area of the document
wxStringSet_t unsavedBufferWords;
wxStyledTextCtrl* stc = activeEditor->GetCtrl();
int startPos = stc->PositionFromLine(stc->GetFirstVisibleLine());
int endPos = stc->GetCurrentPos();
wxString buffer = stc->GetTextRange(startPos, endPos);
WordCompletionThread::ParseBuffer(buffer, unsavedBufferWords);
// Merge the results
words.insert(unsavedBufferWords.begin(), unsavedBufferWords.end());
}
// Get the editor keywords and add them
LexerConf::Ptr_t lexer = ColoursAndFontsManager::Get().GetLexerForFile(activeEditor->GetFileName().GetFullName());
if(lexer) {
wxString keywords;
for(size_t i = 0; i < wxSTC_KEYWORDSET_MAX; ++i) {
keywords << lexer->GetKeyWords(i) << " ";
}
wxArrayString langWords = ::wxStringTokenize(keywords, "\n\t \r", wxTOKEN_STRTOK);
words.insert(langWords.begin(), langWords.end());
}
wxStringSet_t filterdSet;
if(filter.IsEmpty()) {
filterdSet.swap(words);
} else {
for(wxStringSet_t::iterator iter = words.begin(); iter != words.end(); ++iter) {
wxString word = *iter;
wxString lcWord = word.Lower();
if(settings.GetComparisonMethod() == WordCompletionSettings::kComparisonStartsWith) {
if(lcWord.StartsWith(filter) && filter != word) {
filterdSet.insert(word);
}
} else {
if(lcWord.Contains(filter) && filter != word) {
filterdSet.insert(word);
}
}
}
}
wxCodeCompletionBoxEntry::Vec_t entries;
for(wxStringSet_t::iterator iter = filterdSet.begin(); iter != filterdSet.end(); ++iter) {
entries.push_back(wxCodeCompletionBoxEntry::New(*iter, sBmp));
}
event.GetEntries().insert(event.GetEntries().end(), entries.begin(), entries.end());
}