void OnlineSpellChecker::DissectWordAndCheck(cbStyledTextCtrl *stc, int wordstart, int wordend)const
{
    wxString word = stc->GetTextRange(wordstart, wordend);
    //Manager::Get()->GetLogManager()->Log(wxT("dissecting: \"") + word + wxT("\""));
    //and now decide whether the word is an abbreviation and split words when case changes to uppercase
    bool upper = wxIsupper(word[0]) != 0;
    int a, b, c;
    a = 0; b = 0; c = 0;
    for (; c < word.length();) {
        wxChar cc = word[c];
        if (upper == (wxIsupper(cc) != 0)) {
            //same case
            c++;
            b = c;
        } else {
            //case changed...
            if (upper) {
                if (b - a == 1) {
                    //start of word
                    c++;
                    b = c;
                } else {
                    //abbreviation, ignore
                    a = c;
                    c++;
                    b = c;
                }
                upper = false;
            } else {
                //check the word:
                //Manager::Get()->GetLogManager()->Log(wxT("checking: \"") + word.Mid(a, b - a) + wxT("\""));
                if ( !m_pSpellChecker->IsWordInDictionary(word.Mid(a, b - a)) )
                    stc->IndicatorFillRange(wordstart + a, b - a);
                //next:
                a = c;
                c++;
                b = c;
                upper = true;
            }
        }
    }
    //check the remaining letters
    if (upper == false || b - a == 1) {
        //check the word:
        //Manager::Get()->GetLogManager()->Log(wxT("checking: \"") + word.Mid(a, b - a) + wxT("\""));
        if ( !m_pSpellChecker->IsWordInDictionary(word.Mid(a, b - a)) )
            stc->IndicatorFillRange(wordstart + a, b - a);
    }
}
示例#2
0
bool wxExViMacros::SetRegister(const char name, const std::string& value)
{
  if (!isalnum(name) && !isdigit(name) && 
       name != '%' && name != '_' && name != '*' && name != '.')
  {
    return false;
  }
  
  if (name == '*')
  {
    wxExClipboardAdd(value);
    return true;
  }

  std::vector<std::string> v;
  
  // The black hole register, everything written to it is discarded.
  if (name != '_')
  {
    if (wxIsupper(name))
    {
      v.emplace_back(GetRegister(tolower(name)) + value);
    }
    else
    {
      v.emplace_back(value);
    }
  }
  
  m_Macros[std::string(1, (char)tolower(name))] = v;
  m_IsModified = true;
  
  return true;
}
示例#3
0
wxFileName ClangPlugin::FindSourceIn(const wxArrayString& candidateFilesArray, const wxFileName& activeFile, bool& isCandidate)
{
    bool extStartsWithCapital = wxIsupper(activeFile.GetExt()[0]);
    wxFileName candidateFile;
    for (size_t i = 0; i < candidateFilesArray.GetCount(); ++i)
    {
        wxFileName currentCandidateFile(candidateFilesArray[i]);
        if (IsSourceOf(currentCandidateFile, activeFile, isCandidate))
        {
            bool isUpper = wxIsupper(currentCandidateFile.GetExt()[0]);
            if (isUpper == extStartsWithCapital && !isCandidate)
                return currentCandidateFile;
            else
                candidateFile = currentCandidateFile;
        }
    }
    isCandidate = true;
    return candidateFile;
}
void OnlineSpellChecker::DissectWordAndCheck(cbStyledTextCtrl *stc, int wordstart, int wordend)const
{
    wxString word = stc->GetTextRange(wordstart, wordend);
    const bool isMultibyte = ((int)word.Length() != wordend - wordstart);
    //Manager::Get()->GetLogManager()->Log(wxT("dissecting: \"") + word + wxT("\""));
    //and now decide whether the word is an abbreviation and split words when case changes to uppercase
    bool upper = wxIsupper(word[0]) != 0;
    int a, b;
    a = 0; b = 0;
    for (unsigned int c = 0; c < word.length();) {
        wxChar cc = word[c];
        if (upper == (wxIsupper(cc) != 0)) {
            //same case
            c++;
            b = c;
        } else {
            //case changed...
            if (upper) {
                if (b - a == 1) {
                    //start of word
                    c++;
                    b = c;
                } else {
                    //abbreviation, ignore
                    a = c;
                    c++;
                    b = c;
                }
                upper = false;
            } else {
                //check the word:
                //Manager::Get()->GetLogManager()->Log(wxT("checking: \"") + word.Mid(a, b - a) + wxT("\""));
                if ( !m_pSpellChecker->IsWordInDictionary(word.Mid(a, b - a)) )
                {
                    if (isMultibyte) // not perfect, so only try if necessary
                    {
                        int len = 0;
                        const int startPos = stc->FindText(wordstart + a, wordend, word.Mid(a, b - a), wxSCI_FIND_MATCHCASE, &len);
                        if (startPos != wxNOT_FOUND)
                            stc->IndicatorFillRange(startPos, len);
                    }
                    else
                        stc->IndicatorFillRange(wordstart + a, b - a);
                }
                //next:
                a = c;
                c++;
                b = c;
                upper = true;
            }
        }
    }
    //check the remaining letters
    if (upper == false || b - a == 1) {
        //check the word:
        //Manager::Get()->GetLogManager()->Log(wxT("checking: \"") + word.Mid(a, b - a) + wxT("\""));
        if ( !m_pSpellChecker->IsWordInDictionary(word.Mid(a, b - a)) )
        {
            if (isMultibyte) // not perfect, so only try if necessary
            {
                int len = 0;
                const int startPos = stc->FindText(wordstart + a, wordend, word.Mid(a, b - a), wxSCI_FIND_MATCHCASE, &len);
                if (startPos != wxNOT_FOUND)
                    stc->IndicatorFillRange(startPos, len);
            }
            else
                stc->IndicatorFillRange(wordstart + a, b - a);
        }
    }
}