示例#1
0
// ------------------------------------------------------------
void SpellCheck::OnCheck(wxCommandEvent& e)
{
    IEditor* editor = GetEditor();

    if(!editor) return;
    wxString text = editor->GetEditorText();
    text += wxT(" "); // prevents indicator flickering at end of file

    if(m_pEngine != NULL) {
        if(GetCheckContinuous()) // switch continuous search off if running
            SetCheckContinuous(false);

        // if we don't have a dictionary yet, open settings
        if(!m_pEngine->GetDictionary()) {
            OnSettings(e);
            return;
        }

        switch(editor->GetLexerId()) {
        case 3: { // wxSCI_LEX_CPP
            if(m_mgr->IsWorkspaceOpen()) {
                m_pEngine->CheckCppSpelling(text);

                if(!m_checkContinuous) {
                    editor->ClearUserIndicators();
                }
            }
        } break;
        case 1: { // wxSCI_LEX_NULL
            m_pEngine->CheckSpelling(text);
            if(!m_checkContinuous) {
                editor->ClearUserIndicators();
            }
        } break;
        }
    }
}