예제 #1
0
        public override List <string> Suggest(string word)
        {
            var list = _hunspell.Suggest(word);

            AddIShouldBeLowercaseLSuggestion(list, word);
            return(list);
        }
예제 #2
0
        public override List <string> Suggest(string word)
        {
            string filtered = Regex.Replace(word, @"\p{Cs}", "");
            var    list     = _hunspell.Suggest(filtered);

            AddIShouldBeLowercaseLSuggestion(list, filtered);
            return(list);
        }
예제 #3
0
        /// <summary>
        /// Returns a list of suggestions for the specified (misspelled) word.
        /// </summary>
        /// <param name="word">The word.</param>
        /// <returns>
        /// A list of suggestions for the specified (misspelled) word.
        /// </returns>
        public IList <string> Suggest(string word)
        {
            // if spell check engine is not enabled
            if (!IsEnabled)
            {
                return(new List <string>());
            }

            return(_hunspell.Suggest(word));
        }
예제 #4
0
        private void textEditor_IndicatorClick(object sender, IndicatorClickEventArgs e)
        {
            var style = textEditor.IndicatorAllOnFor(e.Position);

            if ((style & 2) == 0)
            {
                return;
            }

            var lineIndex = textEditor.LineFromPosition(e.Position);
            var line      = textEditor.Lines[lineIndex];
            var offset    = e.Position - line.Position;
            var wordStart = FindWordStartBackwards(line.Text, offset);
            var wordEnd   = FindWordEnd(line.Text, offset);
            var word      = line.Text.Substring(wordStart, wordEnd - wordStart);

            var suggestions = SpellChecker.Suggest(word);

            var contextMenu = new ContextMenuStrip();

            if (suggestions.Count == 0)
            {
                contextMenu.Items.Add("No suggestions");
            }
            else
            {
                foreach (var suggestion in suggestions)
                {
                    var item = new ToolStripMenuItem(suggestion);
                    item.Click += (s, args) =>
                    {
                        textEditor.TargetStart = wordStart + line.Position;
                        textEditor.TargetEnd   = wordEnd + line.Position;
                        textEditor.ReplaceTarget(item.Text);
                    };
                    contextMenu.Items.Add(item);
                }
            }
            var addOption = new ToolStripMenuItem("add to dictionary");

            addOption.Click += (s, args) =>
            {
                ControllerCommand(new Commands.AddWordToDictionary(word));
                textEditor.Invalidate();
            };
            contextMenu.Items.Add(addOption);


            contextMenu.Show(this, textEditor.PointToClient(Control.MousePosition));
        }
예제 #5
0
        public ActionResult MemberKeywords(string term)
        {
            List <string> Names =
                _db.Members
                .Where(x => x.Name.Contains(term))
                .Select(x => x.Name.ToLower())
                .Distinct()
                .ToList();

            var spelling    = new NHunspell.Hunspell("en_US.aff", "en_US.dic");
            var suggestions =
                spelling.Spell(term) ?
                new List <string>()
            {
                term
            } :
            spelling.Suggest(term).Take(5);

            var results = suggestions.Union(Names);

            return(Json(results, JsonRequestBehavior.AllowGet));
        }
예제 #6
0
 public override List <string> Suggest(string word)
 {
     return(_hunspell.Suggest(word));
 }
예제 #7
0
        private void textEditor_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                miUndo.Enabled      = CanUndo;
                miRedo.Enabled      = CanRedo;
                miCut.Enabled       = true;
                miCopy.Enabled      = true;
                miDelete.Enabled    = Text.Length > 0;
                miSelectAll.Enabled = true;
                ContextPoint        = e.Location;

                this.ContextMenu = new ContextMenu();

                var charPosition = CharPositionFromPointClose(ContextPoint.X, ContextPoint.Y);
                if (SpellChecker != null && charPosition != -1 && ((IndicatorAllOnFor(charPosition) & 2) == 2))
                {
                    var lineIndex = LineFromPosition(charPosition);
                    var line      = Lines[lineIndex];
                    var offset    = charPosition - line.Position;
                    var wordStart = FindWordStartBackwards(line.Text, offset);
                    var wordEnd   = FindWordEnd(line.Text, offset);
                    var word      = line.Text.Substring(wordStart, wordEnd - wordStart);

                    var suggestions = SpellChecker.Suggest(word);

                    if (suggestions == null || suggestions.Count == 0)
                    {
                        this.ContextMenu.MenuItems.Add("No suggestions");
                    }
                    else
                    {
                        foreach (var suggestion in suggestions)
                        {
                            var item = new MenuItem(suggestion);
                            item.Click += (s, args) =>
                            {
                                TargetStart = wordStart + line.Position;
                                TargetEnd   = wordEnd + line.Position;
                                ReplaceTarget(item.Text);
                            };
                            this.ContextMenu.MenuItems.Add(item);
                        }
                    }
                    var addOption = new MenuItem("add to dictionary");
                    addOption.Click += (s, args) =>
                    {
                        ControllerCommand(new Commands.AddWordToDictionary(word));
                        Invalidate();
                    };
                    this.ContextMenu.MenuItems.Add(addOption);
                    this.ContextMenu.MenuItems.Add(new MenuItem("-"));
                }

                this.ContextMenu.MenuItems.Add(this.miUndo);
                this.ContextMenu.MenuItems.Add(this.miRedo);
                this.ContextMenu.MenuItems.Add(new MenuItem("-"));
                this.ContextMenu.MenuItems.Add(miCut);
                this.ContextMenu.MenuItems.Add(miCopy);
                this.ContextMenu.MenuItems.Add(miPaste);
                this.ContextMenu.MenuItems.Add(miDelete);
                this.ContextMenu.MenuItems.Add(new MenuItem("-"));
                this.ContextMenu.MenuItems.Add(miSelectAll);
                this.ContextMenu.MenuItems.Add(miSelectionWordCount);
                this.ContextMenu.MenuItems.Add(new MenuItem("-"));
                this.ContextMenu.MenuItems.Add(miDefineWord);
                this.ContextMenu.MenuItems.Add(miThesarus);

                this.ContextMenu.MenuItems.Add(new MenuItem("-"));
                if (IsDistractionFreeMode)
                {
                    this.ContextMenu.MenuItems.Add(miCloseDistractionFree);
                }
                else
                {
                    this.ContextMenu.MenuItems.Add(miLaunchDistractionFree);
                }

                if (CustomizeMenu != null)
                {
                    CustomizeMenu(ContextMenu);
                }

                this.ContextMenu.Show(this, e.Location);
            }
        }