void CSpellingDlg::OnChange() { CString changeToWord; GetDlgItemText(IDC_CHANGETO, changeToWord); if (changeToWord.GetLength() > 0) { // Replace the current word with the word in the Change To field. if (SSCE_ReplaceStringWord(SSCE_GetSid(), text, textSz, cursor, (SSCE_CHAR *)(const TCHAR *)changeToWord) >= 0) { // Change the word in the edit control. CString problemWord; GetDlgItemText(IDC_PROBLEMWORD, problemWord); editCtrl->SetSel(cursor, cursor + problemWord.GetLength()); editCtrl->ReplaceSel(changeToWord); } } else { // The change-to field is empty, so this is a deletion. // Delete the current word and any leading whitespace. CString delText; cursor = SSCE_DelStringWord(SSCE_GetSid(), text, cursor, (SSCE_CHAR *)(TCHAR *)delText.GetBuffer(SSCE_MAX_WORD_SZ * 2), SSCE_MAX_WORD_SZ * 2); delText.ReleaseBuffer(); if (cursor >= 0) { // Delete the word and leading whitespace in the edit control. editCtrl->SetSel(cursor, cursor + delText.GetLength()); editCtrl->ReplaceSel(_T("")); } } // Keep checking. We don't skip to the next word so the replacement // will be spell-checked. runChecker(); }
void CSpellingDlg::OnIgnore() { // Skip to the next word. SSCE_CHAR word[SSCE_MAX_WORD_SZ]; cursor = SSCE_GetStringWord(SSCE_GetSid(), text, cursor, word, sizeof(word)); cursor += lstrlen((TCHAR *)word); // Keep checking. runChecker(); }
void CSpellingDlg::OnIgnoreAll() { // Add the current word to the temporary dictionary SSCE_S16 lexId = SSCE_GetLexId(0); if (lexId >= 0) { CString problemWord; GetDlgItemText(IDC_PROBLEMWORD, problemWord); SSCE_AddToLex(SSCE_GetSid(), lexId, (SSCE_CHAR *)(const TCHAR *)problemWord, SSCE_IGNORE_ACTION, 0); } // Keep checking. The current word will automatically be skipped. runChecker(); }
BOOL CSpellingDlg::OnInitDialog() { CDialog::OnInitDialog(); // Get the contents of the edit control into a buffer. Allocate // extra space to allow room for growth. CString contents; editCtrl->GetWindowText(contents); int textLen = contents.GetLength(); int growth = textLen / 5; growth = max(growth, 256); textSz = textLen + growth; text = new SSCE_CHAR[textSz]; lstrcpy((TCHAR *)text, contents); cursor = 0; runChecker(); return (TRUE); }
int main(int argc, char** argv) { currentMode = INVALID_MODE; if (argc == 1) { currentMode = MASTER_MODE; } else { if(!strcmp("-d",argv[1])) { currentMode = INTERACTIVE_MODE; } else { currentMode = (testMode) atoi(argv[1]); } } int err = 0; switch (currentMode) { case MASTER_MODE: err = runMaster(argv[0],0); break; case INTERACTIVE_MODE: err = runMaster(argv[0],1); break; case SUBJECT_MODE: err = runSubject(); break; case CHECKER_MODE: err = runChecker(); break; default: printf("Usage: %s [-d]\n -d: Run interactively (facilitates debugging)\n", argv[0]); err = 1; } return err; }
void CSpellingDlg::OnAdd() { // Add the current word to the selected user dictionary. // A different (slightly more complicated method) would involve // displaying a dropdown-list of user dictionary files (call // SSCE_GetUserLexFiles) and letting the user pick the user // dictionary file to add the word to. CString userDictFile; SSCE_GetSelUserLexFile(userDictFile.GetBuffer(MAX_PATH), MAX_PATH); userDictFile.ReleaseBuffer(); if (userDictFile.GetLength() > 0) { SSCE_S16 lexId = SSCE_GetLexId(userDictFile); if (lexId >= 0) { CString problemWord; GetDlgItemText(IDC_PROBLEMWORD, problemWord); SSCE_AddToLex(SSCE_GetSid(), lexId, (SSCE_CHAR *)(const TCHAR *)problemWord, SSCE_IGNORE_ACTION, 0); } } // Keep checking. No need to skip this word because it will be automatically // ignored. runChecker(); }
void CSpellingDlg::OnChangeAll() { // Add the problem word and replacement word to the temporary dictionary // with SSCE_AUTO_CHANGE_PRESERVE_CASE_ACTION. The word will be // automatically corrected. CString changeToWord; GetDlgItemText(IDC_CHANGETO, changeToWord); if (changeToWord.GetLength() > 0) { // Add the word and replacement to the temporary dictionary SSCE_S16 lexId = SSCE_GetLexId(0); if (lexId >= 0) { CString problemWord; GetDlgItemText(IDC_PROBLEMWORD, problemWord); SSCE_AddToLex(SSCE_GetSid(), lexId, (SSCE_CHAR *)(const TCHAR *)problemWord, SSCE_AUTO_CHANGE_PRESERVE_CASE_ACTION, (SSCE_CHAR *)(const TCHAR *)changeToWord); } } // Keep checking. No need to skip this word because it will be replaced // automatically. runChecker(); }