示例#1
0
 internal DictionaryInfo(Uri pathUri, SpellerInterop.ILexicon lexicon) 
 {
     _pathUri = pathUri; 
     _lexicon = lexicon; 
 }
示例#2
0
        private bool EnsureInitialized()
        { 
            if (_spellerInterop != null)
                return true;

            if (_failedToInit) 
                return false;
 
            Invariant.Assert(_highlightLayer == null); 
            Invariant.Assert(_statusTable == null);
 
            try
            {
                _spellerInterop = new SpellerInterop();
            } 
            catch (DllNotFoundException)
            { 
                _failedToInit = true; 
            }
            catch (EntryPointNotFoundException) 
            {
                _failedToInit = true;
            }
 
            if (_failedToInit)
                return false; 
 
            _highlightLayer = new SpellerHighlightLayer(this);
 
            _statusTable = new SpellerStatusTable(_textEditor.TextContainer.Start, _highlightLayer);

            _textEditor.TextContainer.Highlights.AddLayer(_highlightLayer);
 
            //
 
 
            _spellerInterop.SetContextOption("IsSpellSuggestingMWEs", false);
 
            _spellingReform = (SpellingReform)_textEditor.UiScope.GetValue(SpellCheck.SpellingReformProperty);

            return true;
        } 
示例#3
0
        // Flags a run of text with an error.
        // In two exceptional circumstances we schedule an idle-time callback
        // to re-analyze the run instead of marking it:
        // - when the caret is within the error text. 
        // - when an IME composition covers the text.
        private void MarkErrorRange(TextMap textMap, SpellerInterop.STextRange sTextRange) 
        { 
            ITextPointer errorStart;
            ITextPointer errorEnd; 

            if (sTextRange.Start + sTextRange.Length > textMap.ContentEndOffset)
            {
                // We found an error that starts in the content but extends into 
                // the context.  This must be a multi-word error.
                // For now, ignore it. 
                // 
                return;
            } 

            errorStart = textMap.MapOffsetToPosition(sTextRange.Start);
            errorEnd = textMap.MapOffsetToPosition(sTextRange.Start + sTextRange.Length);
 
            if (sTextRange.Start < textMap.ContentStartOffset)
            { 
                Invariant.Assert(sTextRange.Start + sTextRange.Length > textMap.ContentStartOffset); 

                // We've found an error that start in the context and extends into 
                // the content.  This can happen as more text is revealed to the
                // speller engine as the caret moves forward.
                // E.g., while scanning "avalon's" we flag an error over "avalon",
                // ignoring the "'s" because the caret is positioned within that segment. 
                // Then, the user hits space and now we analyze "'s" along with its
                // preceding context "avalon".  In this final scan, "avalon's" as a while 
                // is flagged as an error and we enter this if statement. 

                // We must mark the range clean before we can mark it dirty. 
                // _statusTable.MarkErrorRange can only handle clean runs.
                _statusTable.MarkCleanRange(errorStart, errorEnd);
            }
 
            _statusTable.MarkErrorRange(errorStart, errorEnd);
        }