MoveCursor() public method

public MoveCursor ( int relative ) : void
relative int
return void
示例#1
0
        public KeyActions PreProcessKey(KeyDescriptor descriptor)
        {
            switch (descriptor.SpecialKey)
            {
            case SpecialKey.Home:
                if ((descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift)
                {
                    return(KeyActions.Process);
                }
                List.SelectionFilterIndex = 0;
                return(KeyActions.Ignore);

            case SpecialKey.End:
                if ((descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift)
                {
                    return(KeyActions.Process);
                }
                List.SelectionFilterIndex = List.filteredItems.Count - 1;
                return(KeyActions.Ignore);

            case SpecialKey.Up:
                if ((descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift)
                {
                    if (!SelectionEnabled /*&& !CompletionWindowManager.ForceSuggestionMode*/)
                    {
                        AutoCompleteEmptyMatch = AutoSelect = true;
                    }
                    if (!List.InCategoryMode)
                    {
                        IdeApp.Preferences.EnableCompletionCategoryMode.Set(true);
                        List.UpdateCategoryMode();
                        return(KeyActions.Ignore);
                    }
                    List.MoveToCategory(-1);
                    return(KeyActions.Ignore);
                }
                if (SelectionEnabled && list.filteredItems.Count < 1)
                {
                    return(KeyActions.CloseWindow | KeyActions.Process);
                }
                if (!SelectionEnabled /*&& !CompletionWindowManager.ForceSuggestionMode*/)
                {
                    AutoCompleteEmptyMatch = AutoSelect = true;
                }
                else
                {
                    list.MoveCursor(-1);
                }
                return(KeyActions.Ignore);

            case SpecialKey.Tab:
                //tab always completes current item even if selection is disabled
                if (!AutoSelect)
                {
                    AutoSelect = true;
                }
                goto case SpecialKey.Return;

            case SpecialKey.Return:
                if (descriptor.ModifierKeys != ModifierKeys.None && descriptor.ModifierKeys != ModifierKeys.Shift)
                {
                    return(KeyActions.CloseWindow);
                }
                if (completionDataList == null || completionDataList.Count == 0)
                {
                    return(KeyActions.CloseWindow);
                }
                WasShiftPressed = (descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift;

                if (SelectedItem != null)
                {
                    switch (SelectedItem.Rules.EnterKeyRule)
                    {
                    case Microsoft.CodeAnalysis.Completion.EnterKeyRule.Always:
                        return(KeyActions.Complete | KeyActions.Process | KeyActions.CloseWindow);

                    case Microsoft.CodeAnalysis.Completion.EnterKeyRule.AfterFullyTypedWord:
                        if (PartialWord.Length == SelectedItem.CompletionText.Length)
                        {
                            return(KeyActions.Complete | KeyActions.Ignore | KeyActions.CloseWindow);
                        }
                        return(KeyActions.Complete | KeyActions.Process | KeyActions.CloseWindow);

                    case Microsoft.CodeAnalysis.Completion.EnterKeyRule.Never:
                    case Microsoft.CodeAnalysis.Completion.EnterKeyRule.Default:
                    default:
                        return(KeyActions.Complete | KeyActions.Ignore | KeyActions.CloseWindow);
                    }
                }
                return(KeyActions.Complete | KeyActions.Ignore | KeyActions.CloseWindow);

            case SpecialKey.Down:
                if ((descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift)
                {
                    if (!SelectionEnabled /*&& !CompletionWindowManager.ForceSuggestionMode*/)
                    {
                        AutoCompleteEmptyMatch = AutoSelect = true;
                    }
                    if (!List.InCategoryMode)
                    {
                        IdeApp.Preferences.EnableCompletionCategoryMode.Set(true);
                        List.UpdateCategoryMode();
                        return(KeyActions.Ignore);
                    }
                    List.MoveToCategory(1);
                    return(KeyActions.Ignore);
                }
                if (SelectionEnabled && list.filteredItems.Count < 1)
                {
                    return(KeyActions.CloseWindow | KeyActions.Process);
                }

                if (!SelectionEnabled /*&& !CompletionWindowManager.ForceSuggestionMode*/)
                {
                    AutoCompleteEmptyMatch = AutoSelect = true;
                }
                else
                {
                    list.MoveCursor(1);
                }
                return(KeyActions.Ignore);

            case SpecialKey.PageUp:
                if ((descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift)
                {
                    return(KeyActions.Process);
                }
                if (list.filteredItems.Count < 2)
                {
                    return(KeyActions.CloseWindow | KeyActions.Process);
                }
                scrollbar.Vadjustment.Value = Math.Max(0, scrollbar.Vadjustment.Value - scrollbar.Vadjustment.PageSize);
                list.MoveCursor(-8);
                return(KeyActions.Ignore);

            case SpecialKey.PageDown:
                if ((descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift)
                {
                    return(KeyActions.Process);
                }
                if (list.filteredItems.Count < 2)
                {
                    return(KeyActions.CloseWindow | KeyActions.Process);
                }
                scrollbar.Vadjustment.Value = Math.Max(0, Math.Min(scrollbar.Vadjustment.Upper - scrollbar.Vadjustment.PageSize, scrollbar.Vadjustment.Value + scrollbar.Vadjustment.PageSize));
                list.MoveCursor(8);
                return(KeyActions.Ignore);

            case SpecialKey.Left:
                //if (curPos == 0) return KeyActions.CloseWindow | KeyActions.Process;
                //curPos--;
                return(KeyActions.Process);

            case SpecialKey.Right:
                //if (curPos == word.Length) return KeyActions.CloseWindow | KeyActions.Process;
                //curPos++;
                return(KeyActions.Process);

//			case Gdk.Key.Caps_Lock:
//			case Gdk.Key.Num_Lock:
//			case Gdk.Key.Scroll_Lock:
//				return KeyActions.Ignore;
//
//			case Gdk.Key.Control_L:
//			case Gdk.Key.Control_R:
//			case Gdk.Key.Alt_L:
//			case Gdk.Key.Alt_R:
//			case Gdk.Key.Shift_L:
//			case Gdk.Key.Shift_R:
//			case Gdk.Key.ISO_Level3_Shift:
//				// AltGr
//				return KeyActions.Process;
            }
            var data = SelectedItem;

            if (descriptor.KeyChar == '\0')
            {
                return(KeyActions.Process);
            }

            if (descriptor.KeyChar == ' ' && (descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift)
            {
                return(KeyActions.CloseWindow | KeyActions.Process);
            }

            if (char.IsDigit(descriptor.KeyChar) && string.IsNullOrEmpty(CurrentCompletionText))
            {
                return(KeyActions.CloseWindow | KeyActions.Process);
            }

            if (data != null && data.MuteCharacter(descriptor.KeyChar, PartialWord))
            {
                if (data.IsCommitCharacter(descriptor.KeyChar, PartialWord))
                {
                    return(KeyActions.CloseWindow | KeyActions.Ignore | KeyActions.Complete);
                }
                return(KeyActions.CloseWindow | KeyActions.Ignore);
            }


            // special case end with punctuation like 'param:' -> don't input double punctuation, otherwise we would end up with 'param::'
            if (char.IsPunctuation(descriptor.KeyChar) && descriptor.KeyChar != '_')
            {
                if (descriptor.KeyChar == ':')
                {
                    foreach (var item in FilteredItems)
                    {
                        if (DataProvider.GetText(item).EndsWith(descriptor.KeyChar.ToString(), StringComparison.Ordinal))
                        {
                            list.SelectedItemIndex = item;
                            return(KeyActions.Complete | KeyActions.CloseWindow | KeyActions.Ignore);
                        }
                    }
                }
                else
                {
                    var selectedItem = list.SelectedItemIndex;
                    if (selectedItem < 0 || selectedItem >= DataProvider.ItemCount)
                    {
                        return(KeyActions.CloseWindow);
                    }
                    if (DataProvider.GetText(selectedItem).EndsWith(descriptor.KeyChar.ToString(), StringComparison.Ordinal))
                    {
                        return(KeyActions.Complete | KeyActions.CloseWindow | KeyActions.Ignore);
                    }
                }
            }
            if (data != null && data.IsCommitCharacter(descriptor.KeyChar, PartialWord))
            {
                var curword = PartialWord;
                var match   = FindMatchedEntry(curword).Index;
                if (match >= 0 && System.Char.IsPunctuation(descriptor.KeyChar))
                {
                    string text = DataProvider.GetCompletionText(FilteredItems [match]);
                    if (!text.StartsWith(curword, StringComparison.OrdinalIgnoreCase))
                    {
                        match = -1;
                    }
                }
                //if (match >= 0 && keyChar != '<' && keyChar != ' ') {
                //	ResetSizes ();
                //	UpdateWordSelection ();
                //	return KeyActions.CloseWindow | KeyActions.Process;
                //}

                if (list.SelectionEnabled && CompletionCharacters.CompleteOn(descriptor.KeyChar))
                {
                    if (descriptor.KeyChar == '{' && !list.AutoCompleteEmptyMatchOnCurlyBrace && string.IsNullOrEmpty(list.CompletionString))
                    {
                        return(KeyActions.CloseWindow | KeyActions.Process);
                    }
                    return(KeyActions.Complete | KeyActions.Process | KeyActions.CloseWindow);
                }
                return(KeyActions.CloseWindow | KeyActions.Process);
            }


            /*		//don't input letters/punctuation etc when non-shift modifiers are active
             *              bool nonShiftModifierActive = ((Gdk.ModifierType.ControlMask | Gdk.ModifierType.MetaMask
             | Gdk.ModifierType.Mod1Mask | Gdk.ModifierType.SuperMask)
             |                      & modifier) != 0;
             |              if (nonShiftModifierActive) {
             |                      if (modifier.HasFlag (Gdk.ModifierType.ControlMask) && char.IsLetterOrDigit ((char)key))
             |                              return KeyActions.Process | KeyActions.CloseWindow;
             |                      return KeyActions.Ignore;
             |              }*/


            return(KeyActions.Process);
        }
示例#2
0
        public KeyActions PreProcessKey(KeyDescriptor descriptor)
        {
            switch (descriptor.SpecialKey)
            {
            case SpecialKey.Home:
                if ((descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift)
                {
                    return(KeyActions.Process);
                }
                List.SelectionFilterIndex = 0;
                return(KeyActions.Ignore);

            case SpecialKey.End:
                if ((descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift)
                {
                    return(KeyActions.Process);
                }
                List.SelectionFilterIndex = List.filteredItems.Count - 1;
                return(KeyActions.Ignore);

            case SpecialKey.Up:
                if ((descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift)
                {
                    if (!SelectionEnabled /*&& !CompletionWindowManager.ForceSuggestionMode*/)
                    {
                        AutoCompleteEmptyMatch = AutoSelect = true;
                    }
                    if (!List.InCategoryMode)
                    {
                        IdeApp.Preferences.EnableCompletionCategoryMode.Set(true);
                        List.UpdateCategoryMode();
                        return(KeyActions.Ignore);
                    }
                    List.MoveToCategory(-1);
                    return(KeyActions.Ignore);
                }
                if (SelectionEnabled && list.filteredItems.Count < 1)
                {
                    return(KeyActions.CloseWindow | KeyActions.Process);
                }
                if (!SelectionEnabled /*&& !CompletionWindowManager.ForceSuggestionMode*/)
                {
                    AutoCompleteEmptyMatch = AutoSelect = true;
                }
                else
                {
                    list.MoveCursor(-1);
                }
                return(KeyActions.Ignore);

            case SpecialKey.Tab:
                //tab always completes current item even if selection is disabled
                if (!AutoSelect)
                {
                    AutoSelect = true;
                }
                goto case SpecialKey.Return;

            case SpecialKey.Return:
                lastCommitCharEndoffset = CompletionWidget.CaretOffset;
                WasShiftPressed         = (descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift;
                return(KeyActions.Complete | KeyActions.Ignore | KeyActions.CloseWindow);

            case SpecialKey.Down:
                if ((descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift)
                {
                    if (!SelectionEnabled /*&& !CompletionWindowManager.ForceSuggestionMode*/)
                    {
                        AutoCompleteEmptyMatch = AutoSelect = true;
                    }
                    if (!List.InCategoryMode)
                    {
                        IdeApp.Preferences.EnableCompletionCategoryMode.Set(true);
                        List.UpdateCategoryMode();
                        return(KeyActions.Ignore);
                    }
                    List.MoveToCategory(1);
                    return(KeyActions.Ignore);
                }
                if (SelectionEnabled && list.filteredItems.Count < 1)
                {
                    return(KeyActions.CloseWindow | KeyActions.Process);
                }

                if (!SelectionEnabled /*&& !CompletionWindowManager.ForceSuggestionMode*/)
                {
                    AutoCompleteEmptyMatch = AutoSelect = true;
                }
                else
                {
                    list.MoveCursor(1);
                }
                return(KeyActions.Ignore);

            case SpecialKey.PageUp:
                if ((descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift)
                {
                    return(KeyActions.Process);
                }
                if (list.filteredItems.Count < 2)
                {
                    return(KeyActions.CloseWindow | KeyActions.Process);
                }
                scrollbar.Vadjustment.Value = Math.Max(0, scrollbar.Vadjustment.Value - scrollbar.Vadjustment.PageSize);
                list.MoveCursor(-8);
                return(KeyActions.Ignore);

            case SpecialKey.PageDown:
                if ((descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift)
                {
                    return(KeyActions.Process);
                }
                if (list.filteredItems.Count < 2)
                {
                    return(KeyActions.CloseWindow | KeyActions.Process);
                }
                scrollbar.Vadjustment.Value = Math.Max(0, Math.Min(scrollbar.Vadjustment.Upper - scrollbar.Vadjustment.PageSize, scrollbar.Vadjustment.Value + scrollbar.Vadjustment.PageSize));
                list.MoveCursor(8);
                return(KeyActions.Ignore);

            case SpecialKey.Left:
                //if (curPos == 0) return KeyActions.CloseWindow | KeyActions.Process;
                //curPos--;
                return(KeyActions.Process);

            case SpecialKey.Right:
                //if (curPos == word.Length) return KeyActions.CloseWindow | KeyActions.Process;
                //curPos++;
                return(KeyActions.Process);

//			case Gdk.Key.Caps_Lock:
//			case Gdk.Key.Num_Lock:
//			case Gdk.Key.Scroll_Lock:
//				return KeyActions.Ignore;
//
//			case Gdk.Key.Control_L:
//			case Gdk.Key.Control_R:
//			case Gdk.Key.Alt_L:
//			case Gdk.Key.Alt_R:
//			case Gdk.Key.Shift_L:
//			case Gdk.Key.Shift_R:
//			case Gdk.Key.ISO_Level3_Shift:
//				// AltGr
//				return KeyActions.Process;
            }
            if (descriptor.KeyChar == '\0')
            {
                return(KeyActions.Process);
            }

            if (descriptor.KeyChar == ' ' && (descriptor.ModifierKeys & ModifierKeys.Shift) == ModifierKeys.Shift)
            {
                return(KeyActions.CloseWindow | KeyActions.Process);
            }

            // special case end with punctuation like 'param:' -> don't input double punctuation, otherwise we would end up with 'param::'
            if (char.IsPunctuation(descriptor.KeyChar) && descriptor.KeyChar != '_')
            {
                if (descriptor.KeyChar == ':')
                {
                    foreach (var item in FilteredItems)
                    {
                        if (DataProvider.GetText(item).EndsWith(descriptor.KeyChar.ToString(), StringComparison.Ordinal))
                        {
                            list.SelectedItem = item;
                            return(KeyActions.Complete | KeyActions.CloseWindow | KeyActions.Ignore);
                        }
                    }
                }
                else
                {
                    var selectedItem = list.SelectedItem;
                    if (selectedItem < 0 || selectedItem >= DataProvider.ItemCount)
                    {
                        return(KeyActions.CloseWindow);
                    }
                    if (DataProvider.GetText(selectedItem).EndsWith(descriptor.KeyChar.ToString(), StringComparison.Ordinal))
                    {
                        return(KeyActions.Complete | KeyActions.CloseWindow | KeyActions.Ignore);
                    }
                }
            }

            /*		//don't input letters/punctuation etc when non-shift modifiers are active
             *              bool nonShiftModifierActive = ((Gdk.ModifierType.ControlMask | Gdk.ModifierType.MetaMask
             | Gdk.ModifierType.Mod1Mask | Gdk.ModifierType.SuperMask)
             |                      & modifier) != 0;
             |              if (nonShiftModifierActive) {
             |                      if (modifier.HasFlag (Gdk.ModifierType.ControlMask) && char.IsLetterOrDigit ((char)key))
             |                              return KeyActions.Process | KeyActions.CloseWindow;
             |                      return KeyActions.Ignore;
             |              }*/


            return(KeyActions.Process);
        }
示例#3
0
        public KeyActions ProcessKey(Gdk.Key key, char keyChar, Gdk.ModifierType modifier)
        {
            switch (key)
            {
            case Gdk.Key.Home:
                if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
                {
                    return(KeyActions.Process);
                }
                List.Selection = 0;
                return(KeyActions.Ignore);

            case Gdk.Key.End:
                if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
                {
                    return(KeyActions.Process);
                }
                List.Selection = List.filteredItems.Count - 1;
                return(KeyActions.Ignore);

            case Gdk.Key.Up:
                if ((modifier & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask)
                {
                    if (!SelectionEnabled /*&& !CompletionWindowManager.ForceSuggestionMode*/)
                    {
                        AutoCompleteEmptyMatch = AutoSelect = true;
                    }
                    if (!List.InCategoryMode)
                    {
                        List.InCategoryMode = true;
                        return(KeyActions.Ignore);
                    }
                    List.MoveToCategory(-1);
                    return(KeyActions.Ignore);
                }
                if (SelectionEnabled && list.filteredItems.Count < 2)
                {
                    return(KeyActions.CloseWindow | KeyActions.Process);
                }
                if (!SelectionEnabled /*&& !CompletionWindowManager.ForceSuggestionMode*/)
                {
                    AutoCompleteEmptyMatch = AutoSelect = true;
                }
                else
                {
                    list.MoveCursor(-1);
                }
                return(KeyActions.Ignore);

            case Gdk.Key.Down:
                if ((modifier & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask)
                {
                    if (!SelectionEnabled /*&& !CompletionWindowManager.ForceSuggestionMode*/)
                    {
                        AutoCompleteEmptyMatch = AutoSelect = true;
                    }
                    if (!List.InCategoryMode)
                    {
                        List.InCategoryMode = true;
                        return(KeyActions.Ignore);
                    }
                    List.MoveToCategory(1);
                    return(KeyActions.Ignore);
                }
                if (SelectionEnabled && list.filteredItems.Count < 2)
                {
                    return(KeyActions.CloseWindow | KeyActions.Process);
                }

                if (!SelectionEnabled /*&& !CompletionWindowManager.ForceSuggestionMode*/)
                {
                    AutoCompleteEmptyMatch = AutoSelect = true;
                }
                else
                {
                    list.MoveCursor(1);
                }
                return(KeyActions.Ignore);

            case Gdk.Key.Page_Up:
                if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
                {
                    return(KeyActions.Process);
                }
                if (list.filteredItems.Count < 2)
                {
                    return(KeyActions.CloseWindow | KeyActions.Process);
                }
                list.MoveCursor(-(list.VisibleRows - 1));
                return(KeyActions.Ignore);

            case Gdk.Key.Page_Down:
                if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
                {
                    return(KeyActions.Process);
                }
                if (list.filteredItems.Count < 2)
                {
                    return(KeyActions.CloseWindow | KeyActions.Process);
                }
                list.MoveCursor(list.VisibleRows - 1);
                return(KeyActions.Ignore);

            case Gdk.Key.Left:
                //if (curPos == 0) return KeyActions.CloseWindow | KeyActions.Process;
                //curPos--;
                return(KeyActions.Process);

            case Gdk.Key.BackSpace:
                if (curPos == 0 || (modifier & Gdk.ModifierType.ControlMask) != 0)
                {
                    return(KeyActions.CloseWindow | KeyActions.Process);
                }
                curPos--;
                word.Remove(curPos, 1);
                ResetSizes();
                UpdateWordSelection();
                if (HideWhenWordDeleted && word.Length == 0)
                {
                    return(KeyActions.CloseWindow | KeyActions.Process);
                }
                return(KeyActions.Process);

            case Gdk.Key.Right:
                //if (curPos == word.Length) return KeyActions.CloseWindow | KeyActions.Process;
                //curPos++;
                return(KeyActions.Process);

            case Gdk.Key.Caps_Lock:
            case Gdk.Key.Num_Lock:
            case Gdk.Key.Scroll_Lock:
                return(KeyActions.Ignore);

            case Gdk.Key.Tab:
                //tab always completes current item even if selection is disabled
                if (!AutoSelect)
                {
                    AutoSelect = true;
                }
                goto case Gdk.Key.Return;

            case Gdk.Key.Return:
            case Gdk.Key.ISO_Enter:
            case Gdk.Key.Key_3270_Enter:
            case Gdk.Key.KP_Enter:
                WasShiftPressed = (modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask;
                return((!list.AutoSelect ? KeyActions.Process : (KeyActions.Complete | KeyActions.Ignore)) | KeyActions.CloseWindow);

            case Gdk.Key.Escape:
                return(KeyActions.CloseWindow | KeyActions.Ignore);

            case Gdk.Key.Control_L:
            case Gdk.Key.Control_R:
            case Gdk.Key.Alt_L:
            case Gdk.Key.Alt_R:
            case Gdk.Key.Shift_L:
            case Gdk.Key.Shift_R:
            case Gdk.Key.ISO_Level3_Shift:
                // AltGr
                return(KeyActions.Process);
            }
            if (keyChar == '\0')
            {
                return(KeyActions.Process);
            }

            if (keyChar == ' ' && (modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
            {
                return(KeyActions.CloseWindow | KeyActions.Process);
            }

            //don't input letters/punctuation etc when non-shift modifiers are active
            bool nonShiftModifierActive = ((Gdk.ModifierType.ControlMask | Gdk.ModifierType.MetaMask
                                            | Gdk.ModifierType.Mod1Mask | Gdk.ModifierType.SuperMask)
                                           & modifier) != 0;

            if (nonShiftModifierActive)
            {
                if (modifier.HasFlag(Gdk.ModifierType.ControlMask) && char.IsLetterOrDigit((char)key))
                {
                    return(KeyActions.Process | KeyActions.CloseWindow);
                }
                return(KeyActions.Ignore);
            }
            const string commitChars = " <>()[]{}=+-*/%~&|!";

            if (System.Char.IsLetterOrDigit(keyChar) || keyChar == '_')
            {
                word.Insert(curPos, keyChar);
                ResetSizes();
                UpdateWordSelection();
                curPos++;
                return(KeyActions.Process);
            }
            else if (System.Char.IsPunctuation(keyChar) || commitChars.Contains(keyChar))
            {
                //punctuation is only accepted if it actually matches an item in the list
                word.Insert(curPos, keyChar);

                bool hasMismatches;
                int  match = FindMatchedEntry(CurrentPartialWord, out hasMismatches);
                if (match >= 0 && System.Char.IsPunctuation(keyChar))
                {
                    string text = DataProvider.GetCompletionText(FilteredItems [match]);
                    if (!text.ToUpper().StartsWith(word.ToString().ToUpper()))
                    {
                        match = -1;
                    }
                }
                if (match >= 0 && !hasMismatches && keyChar != '<')
                {
                    ResetSizes();
                    UpdateWordSelection();
                    curPos++;
                    return(KeyActions.Process);
                }
                else
                {
                    word.Remove(curPos, 1);
                }

                if (CompleteWithSpaceOrPunctuation && list.SelectionEnabled)
                {
                    return(KeyActions.Complete | KeyActions.Process | KeyActions.CloseWindow);
                }
                return(KeyActions.CloseWindow | KeyActions.Process);
            }

            return(KeyActions.CloseWindow | KeyActions.Process);
        }
        public KeyActions PreProcessKey(Gdk.Key key, char keyChar, Gdk.ModifierType modifier)
        {
            switch (key)
            {
            case Gdk.Key.Home:
                if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
                {
                    return(KeyActions.Process);
                }
                List.SelectionFilterIndex = 0;
                return(KeyActions.Ignore);

            case Gdk.Key.End:
                if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
                {
                    return(KeyActions.Process);
                }
                List.SelectionFilterIndex = List.filteredItems.Count - 1;
                return(KeyActions.Ignore);

            case Gdk.Key.Up:
                if ((modifier & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask)
                {
                    if (!SelectionEnabled /*&& !CompletionWindowManager.ForceSuggestionMode*/)
                    {
                        AutoCompleteEmptyMatch = AutoSelect = true;
                    }
                    if (!List.InCategoryMode)
                    {
                        List.InCategoryMode = true;
                        return(KeyActions.Ignore);
                    }
                    List.MoveToCategory(-1);
                    return(KeyActions.Ignore);
                }
                if (SelectionEnabled && list.filteredItems.Count < 1)
                {
                    return(KeyActions.CloseWindow | KeyActions.Process);
                }
                if (!SelectionEnabled /*&& !CompletionWindowManager.ForceSuggestionMode*/)
                {
                    AutoCompleteEmptyMatch = AutoSelect = true;
                }
                else
                {
                    list.MoveCursor(-1);
                }
                return(KeyActions.Ignore);

            case Gdk.Key.Tab:
                //tab always completes current item even if selection is disabled
                if (!AutoSelect)
                {
                    AutoSelect = true;
                }
                goto case Gdk.Key.Return;

            case Gdk.Key.Return:
            case Gdk.Key.ISO_Enter:
            case Gdk.Key.Key_3270_Enter:
            case Gdk.Key.KP_Enter:
                endOffset       = CompletionWidget.CaretOffset;
                WasShiftPressed = (modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask;
                return((!AutoSelect ? KeyActions.Process : (KeyActions.Complete | KeyActions.Ignore)) | KeyActions.CloseWindow);

            case Gdk.Key.Down:
                if ((modifier & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask)
                {
                    if (!SelectionEnabled /*&& !CompletionWindowManager.ForceSuggestionMode*/)
                    {
                        AutoCompleteEmptyMatch = AutoSelect = true;
                    }
                    if (!List.InCategoryMode)
                    {
                        List.InCategoryMode = true;
                        return(KeyActions.Ignore);
                    }
                    List.MoveToCategory(1);
                    return(KeyActions.Ignore);
                }
                if (SelectionEnabled && list.filteredItems.Count < 1)
                {
                    return(KeyActions.CloseWindow | KeyActions.Process);
                }

                if (!SelectionEnabled /*&& !CompletionWindowManager.ForceSuggestionMode*/)
                {
                    AutoCompleteEmptyMatch = AutoSelect = true;
                }
                else
                {
                    list.MoveCursor(1);
                }
                return(KeyActions.Ignore);

            case Gdk.Key.Page_Up:
                if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
                {
                    return(KeyActions.Process);
                }
                if (list.filteredItems.Count < 2)
                {
                    return(KeyActions.CloseWindow | KeyActions.Process);
                }
                list.MoveCursor(-(list.VisibleRows - 1));
                return(KeyActions.Ignore);

            case Gdk.Key.Page_Down:
                if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
                {
                    return(KeyActions.Process);
                }
                if (list.filteredItems.Count < 2)
                {
                    return(KeyActions.CloseWindow | KeyActions.Process);
                }
                list.MoveCursor(list.VisibleRows - 1);
                return(KeyActions.Ignore);

            case Gdk.Key.Left:
                //if (curPos == 0) return KeyActions.CloseWindow | KeyActions.Process;
                //curPos--;
                return(KeyActions.Process);

            case Gdk.Key.Right:
                //if (curPos == word.Length) return KeyActions.CloseWindow | KeyActions.Process;
                //curPos++;
                return(KeyActions.Process);

            case Gdk.Key.Caps_Lock:
            case Gdk.Key.Num_Lock:
            case Gdk.Key.Scroll_Lock:
                return(KeyActions.Ignore);


            case Gdk.Key.Escape:
                return(KeyActions.CloseWindow | KeyActions.Ignore);

            case Gdk.Key.Control_L:
            case Gdk.Key.Control_R:
            case Gdk.Key.Alt_L:
            case Gdk.Key.Alt_R:
            case Gdk.Key.Shift_L:
            case Gdk.Key.Shift_R:
            case Gdk.Key.ISO_Level3_Shift:
                // AltGr
                return(KeyActions.Process);
            }
            if (keyChar == '\0')
            {
                return(KeyActions.Process);
            }

            if (keyChar == ' ' && (modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
            {
                return(KeyActions.CloseWindow | KeyActions.Process);
            }

            /*		//don't input letters/punctuation etc when non-shift modifiers are active
             *              bool nonShiftModifierActive = ((Gdk.ModifierType.ControlMask | Gdk.ModifierType.MetaMask
             | Gdk.ModifierType.Mod1Mask | Gdk.ModifierType.SuperMask)
             |                      & modifier) != 0;
             |              if (nonShiftModifierActive) {
             |                      if (modifier.HasFlag (Gdk.ModifierType.ControlMask) && char.IsLetterOrDigit ((char)key))
             |                              return KeyActions.Process | KeyActions.CloseWindow;
             |                      return KeyActions.Ignore;
             |              }*/


            return(KeyActions.Process);
        }
        public KeyActions PreProcessKey(Gdk.Key key, char keyChar, Gdk.ModifierType modifier)
        {
            switch (key)
            {
            case Gdk.Key.Home:
                if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
                {
                    return(KeyActions.Process);
                }
                List.SelectionFilterIndex = 0;
                return(KeyActions.Ignore);

            case Gdk.Key.End:
                if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
                {
                    return(KeyActions.Process);
                }
                List.SelectionFilterIndex = List.filteredItems.Count - 1;
                return(KeyActions.Ignore);

            case Gdk.Key.Up:
                if ((modifier & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask)
                {
                    if (!SelectionEnabled /*&& !CompletionWindowManager.ForceSuggestionMode*/)
                    {
                        AutoCompleteEmptyMatch = AutoSelect = true;
                    }
                    if (!List.InCategoryMode)
                    {
                        List.InCategoryMode = true;
                        return(KeyActions.Ignore);
                    }
                    List.MoveToCategory(-1);
                    return(KeyActions.Ignore);
                }
                if (SelectionEnabled && list.filteredItems.Count < 1)
                {
                    return(KeyActions.CloseWindow | KeyActions.Process);
                }
                if (!SelectionEnabled /*&& !CompletionWindowManager.ForceSuggestionMode*/)
                {
                    AutoCompleteEmptyMatch = AutoSelect = true;
                }
                else
                {
                    list.MoveCursor(-1);
                }
                return(KeyActions.Ignore);

            case Gdk.Key.Tab:
                //tab always completes current item even if selection is disabled
                if (!AutoSelect)
                {
                    AutoSelect = true;
                }
                goto case Gdk.Key.Return;

            case Gdk.Key.Return:
            case Gdk.Key.ISO_Enter:
            case Gdk.Key.Key_3270_Enter:
            case Gdk.Key.KP_Enter:
                endOffset       = CompletionWidget.CaretOffset;
                WasShiftPressed = (modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask;
                return(KeyActions.Complete | KeyActions.Ignore | KeyActions.CloseWindow);

            case Gdk.Key.Down:
                if ((modifier & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask)
                {
                    if (!SelectionEnabled /*&& !CompletionWindowManager.ForceSuggestionMode*/)
                    {
                        AutoCompleteEmptyMatch = AutoSelect = true;
                    }
                    if (!List.InCategoryMode)
                    {
                        List.InCategoryMode = true;
                        return(KeyActions.Ignore);
                    }
                    List.MoveToCategory(1);
                    return(KeyActions.Ignore);
                }
                if (SelectionEnabled && list.filteredItems.Count < 1)
                {
                    return(KeyActions.CloseWindow | KeyActions.Process);
                }

                if (!SelectionEnabled /*&& !CompletionWindowManager.ForceSuggestionMode*/)
                {
                    AutoCompleteEmptyMatch = AutoSelect = true;
                }
                else
                {
                    list.MoveCursor(1);
                }
                return(KeyActions.Ignore);

            case Gdk.Key.Page_Up:
                if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
                {
                    return(KeyActions.Process);
                }
                if (list.filteredItems.Count < 2)
                {
                    return(KeyActions.CloseWindow | KeyActions.Process);
                }
                list.MoveCursor(-8);
                return(KeyActions.Ignore);

            case Gdk.Key.Page_Down:
                if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
                {
                    return(KeyActions.Process);
                }
                if (list.filteredItems.Count < 2)
                {
                    return(KeyActions.CloseWindow | KeyActions.Process);
                }
                list.MoveCursor(8);
                return(KeyActions.Ignore);

            case Gdk.Key.Left:
                //if (curPos == 0) return KeyActions.CloseWindow | KeyActions.Process;
                //curPos--;
                return(KeyActions.Process);

            case Gdk.Key.Right:
                //if (curPos == word.Length) return KeyActions.CloseWindow | KeyActions.Process;
                //curPos++;
                return(KeyActions.Process);

            case Gdk.Key.Caps_Lock:
            case Gdk.Key.Num_Lock:
            case Gdk.Key.Scroll_Lock:
                return(KeyActions.Ignore);

            case Gdk.Key.Control_L:
            case Gdk.Key.Control_R:
            case Gdk.Key.Alt_L:
            case Gdk.Key.Alt_R:
            case Gdk.Key.Shift_L:
            case Gdk.Key.Shift_R:
            case Gdk.Key.ISO_Level3_Shift:
                // AltGr
                return(KeyActions.Process);
            }
            if (keyChar == '\0')
            {
                return(KeyActions.Process);
            }

            if (keyChar == ' ' && (modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
            {
                return(KeyActions.CloseWindow | KeyActions.Process);
            }

            // special case end with punctuation like 'param:' -> don't input double punctuation, otherwise we would end up with 'param::'
            if (char.IsPunctuation(keyChar) && keyChar != '_')
            {
                foreach (var item in FilteredItems)
                {
                    if (DataProvider.GetText(item).EndsWith(keyChar.ToString(), StringComparison.Ordinal))
                    {
                        list.SelectedItem = item;
                        return(KeyActions.Complete | KeyActions.CloseWindow | KeyActions.Ignore);
                    }
                }
            }



            /*		//don't input letters/punctuation etc when non-shift modifiers are active
             *              bool nonShiftModifierActive = ((Gdk.ModifierType.ControlMask | Gdk.ModifierType.MetaMask
             | Gdk.ModifierType.Mod1Mask | Gdk.ModifierType.SuperMask)
             |                      & modifier) != 0;
             |              if (nonShiftModifierActive) {
             |                      if (modifier.HasFlag (Gdk.ModifierType.ControlMask) && char.IsLetterOrDigit ((char)key))
             |                              return KeyActions.Process | KeyActions.CloseWindow;
             |                      return KeyActions.Ignore;
             |              }*/


            return(KeyActions.Process);
        }