Esempio n. 1
0
void ContextBase::OnUserTypedXChars(const wxString& word)
{
    // user typed more than X chars
    // trigger code complete event (as if the user typed ctrl-space)
    // if no one handles this event, fire a word completion event
    if(IsCommentOrString(GetCtrl().GetCurrentPos())) {
        return;
    }

    const TagsOptionsData& options = TagsManagerST::Get()->GetCtagsOptions();
    if(options.GetFlags() & CC_WORD_ASSIST) {
        // Try to call code completion
        clCodeCompletionEvent ccEvt(wxEVT_CC_CODE_COMPLETE);
        ccEvt.SetEditor(&GetCtrl());
        ccEvt.SetPosition(GetCtrl().GetCurrentPos());
        ccEvt.SetWord(word);

        if(!EventNotifier::Get()->ProcessEvent(ccEvt)) {
            // This is ugly, since CodeLite should not be calling
            // the plugins... we take comfort in the fact that it
            // merely fires an event and not calling it directly
            wxCommandEvent wordCompleteEvent(wxEVT_MENU, XRCID("word_complete_no_single_insert"));
            wxTheApp->ProcessEvent(wordCompleteEvent);
        }
    }
}
Esempio n. 2
0
void ContextBase::OnUserTypedXChars(const wxString& word)
{
    // user typed more than 3 chars, display completion box with C++ keywords
    if(IsCommentOrString(GetCtrl().GetCurrentPos())) {
        return;
    }

    TagEntryPtrVector_t tags;
    if(TagsManagerST::Get()->GetCtagsOptions().GetFlags() & CC_CPP_KEYWORD_ASISST) {
        clCodeCompletionEvent ccEvt(wxEVT_CC_CODE_COMPLETE_LANG_KEYWORD);
        ccEvt.SetEditor(&GetCtrl());
        ccEvt.SetWord(word);

        if(EventNotifier::Get()->ProcessEvent(ccEvt)) {
            tags = ccEvt.GetTags();
        }

        if(!tags.empty()) {
            GetCtrl().ShowCompletionBox(tags,  // list of tags
                                        word); // do not automatically insert word if there is only single choice
        }
    }
}