//===================================================================== /// <inheritdoc /> public ISpellingDictionary GetDictionary(ITextBuffer buffer) { ISpellingDictionary service = null; if (buffer.Properties.TryGetProperty(typeof(SpellingDictionaryService), out service)) { return(service); } List <ISpellingDictionary> bufferSpecificDictionaries = new List <ISpellingDictionary>(); foreach (var provider in bufferSpecificDictionaryProviders) { var dictionary = provider.Value.GetDictionary(buffer); if (dictionary != null) { bufferSpecificDictionaries.Add(dictionary); } } // Create or get the existing global dictionary for the default language var globalDictionary = GlobalDictionary.CreateGlobalDictionary(null); if (globalDictionary != null) { service = new SpellingDictionaryService(bufferSpecificDictionaries, globalDictionary); buffer.Properties[typeof(SpellingDictionaryService)] = service; } return(service); }
/// <summary> /// Constructor for SpellDictionarySmartTagAction. /// </summary> /// <param name="word">The word to add or ignore.</param> /// <param name="dictionary">The dictionary (used to ignore the word).</param> /// <param name="displayText">Text to show in the context menu for this action.</param> /// <param name="ignore">Whether this is to ignore the word or add it to the dictionary.</param> public SpellDictionarySmartTagAction(string word, ISpellingDictionary dictionary, string displayText, bool ignore) { _word = word; _ignore = ignore; _dictionary = dictionary; DisplayText = displayText; }
public SpellingTagger(ITextBuffer buffer, ITextView view, ITagAggregator <INaturalTextTag> naturalTextAggregator, ITagAggregator <IUrlTag> urlAggregator, ISpellingDictionary dictionary) { _isClosed = false; _buffer = buffer; _naturalTextAggregator = naturalTextAggregator; _urlAggregator = urlAggregator; _dispatcher = Dispatcher.CurrentDispatcher; _dictionary = dictionary; _dirtySpans = new List <SnapshotSpan>(); _misspellings = new List <MisspellingTag>(); _buffer.Changed += BufferChanged; _naturalTextAggregator.TagsChanged += AggregatorTagsChanged; _urlAggregator.TagsChanged += AggregatorTagsChanged; _dictionary.DictionaryUpdated += DictionaryUpdated; view.Closed += ViewClosed; // To start with, the entire buffer is dirty // Split this into chunks, so we update pieces at a time ITextSnapshot snapshot = _buffer.CurrentSnapshot; foreach (var line in snapshot.Lines) { AddDirtySpan(line.Extent); } }
//===================================================================== /// <summary> /// When closed, disconnect event handlers and dispose of resources /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void ViewClosed(object sender, EventArgs e) { _isClosed = true; if (_timer != null) { _timer.Stop(); } if (_buffer != null) { _buffer.Changed -= BufferChanged; } if (_naturalTextAggregator != null) { _naturalTextAggregator.Dispose(); } if (_urlAggregator != null) { _urlAggregator.Dispose(); } if (_dictionary != null) { _dictionary.DictionaryUpdated -= DictionaryUpdated; _dictionary.ReplaceAll -= ReplaceAll; _dictionary.IgnoreOnce -= IgnoreOnce; _dictionary = null; } }
//===================================================================== /// <summary> /// Constructor for SpellDictionarySmartTagAction. /// </summary> /// <param name="word">The word to add or ignore.</param> /// <param name="dictionary">The dictionary used to ignore the word or add the word.</param> /// <param name="displayText">Text to show in the context menu for this action.</param> /// <param name="action">The action to take.</param> public SpellDictionarySmartTagAction(ITrackingSpan span, ISpellingDictionary dictionary, string displayText, DictionaryAction action) { this.span = span; this.dictionary = dictionary; this.action = action; this.DisplayText = displayText; }
public SpellSmartTagger(ITextBuffer buffer, ISpellingDictionary dictionary, ITagAggregator <IMisspellingTag> misspellingAggregator) { _buffer = buffer; _dictionary = dictionary; _misspellingAggregator = misspellingAggregator; _misspellingAggregator.TagsChanged += (sender, args) => { foreach (var span in args.Span.GetSpans(_buffer)) { RaiseTagsChangedEvent(span); } }; }
//===================================================================== /// <summary> /// Constructor for spelling suggestions smart tag actions /// </summary> /// <param name="span">The word span to replace</param> /// <param name="replaceWith">Text to replace misspelled word with</param> /// <param name="dictionary">The dictionary used to perform the Replace All action</param> public SpellSmartTagAction(ITrackingSpan span, string replaceWith, ISpellingDictionary dictionary) { this.span = span; this.replaceWith = replaceWith; this.dictionary = dictionary; }
public LineChecker(ISpellingDictionary dict,IWordSplitter splitter) { spellChecker = dict; Splitter = splitter; }