private void btnIgnoreWord_Click(object sender, EventArgs e) { if (LanguageFeature.SupportsFeature(this.textView.Language, "Spellcheck.Check") == false) { return; } foreach (var ignoredWord in SpellcheckSettings.IgnoredWords) { if (ignoredWord.Equals(this.textView.SelectedText, StringComparison.CurrentCultureIgnoreCase) == false) { SpellcheckSettings.AddIgnoreWord(this.textView.SelectedText); } } this.selectionStart = this.textView.SelectionStart + this.textView.SelectionLength; this.GotoNext(); }
private bool GotoNext() { if (LanguageFeature.SupportsFeature(this.textView.Language, "Spellcheck.Check") == false) { return(false); } var searchFrom = Math.Max(0, this.selectionStart); var regex = new Regex(InvariantStrings.REGEX_WORD_BARRIER_STRICT + "([\\w'-]+?)" + InvariantStrings.REGEX_WORD_BARRIER_STRICT); var text = this.textView.TextGet(); while (true) { var match = regex.Match(text, searchFrom); if (match.Success == false) { break; } var value = match.Groups[2]; // Check for unwanted match characters, and abort if so is instructed. if (SpellcheckSettings.CheckIfWordIsValid(value.Value, this.textView.GetLineText(this.textView.GetLineFromCharIndex(searchFrom))) == false) { searchFrom += value.Length; continue; } var spellcheckValid = false; foreach (var check in LanguageFeature.FeatureFetchMultiple <bool>(this.textView.Language, "Spellcheck.Check", new LFSString(value.Value))) { spellcheckValid = check; if (spellcheckValid) { break; } } if (spellcheckValid == false) { this.lbxSuggestions.Items.Clear(); Tag = new object(); this.textView.SelectionStart = this.selectionStart = value.Index; this.textView.SelectionLength = this.selectionLength = value.Length; this.textView.ScrollToCaret(); Tag = null; foreach (string suggestion in LanguageFeature.FeatureFetchMultiple <string>(this.textView.Language, "Spellcheck.Suggest", new LFSString(value.Value))) { this.lbxSuggestions.Items.Add(suggestion); } if (this.lbxSuggestions.Items.Count == 0) { this.tbxReplaceWith.Clear(); this.tbxReplaceWith.Focus(); } else { this.lbxSuggestions.SelectedIndex = 0; } return(true); } searchFrom += value.Length; } Bridge.Get().Info(Strings.Spellchecking_EndOfText_Success, Strings.Spellchecking_Title); return(false); }