Beispiel #1
0
 /// <summary>
 /// Forces the form to close, only when leaving npp
 /// </summary>
 public static void ForceClose()
 {
     try {
         if (_form != null)
             _form.ForceClose();
         _form = null;
     } catch (Exception e) {
         ErrorHandler.LogError(e);
     }
 }
Beispiel #2
0
        /// <summary>
        /// This function handles the display of the autocomplete form, create or update it
        /// </summary>
        private static void ShowSuggestionList(string keyword)
        {
            if (CurrentItems.Count == 0) {
                Close();
                return;
            }

            // instanciate the form if needed
            if (_form == null) {
                _form = new AutoCompletionForm(keyword) {
                    UnfocusedOpacity = Config.Instance.AutoCompleteUnfocusedOpacity,
                    FocusedOpacity = Config.Instance.AutoCompleteFocusedOpacity
                };
                _form.InsertSuggestion += OnInsertSuggestion;
                _form.Show(Npp.Win32WindowNpp);
                _form.SetItems(CurrentItems);
            } else if (_needToSetItems) {
                // we changed the mode, we need to Set the items of the autocompletion
                _form.SetItems(CurrentItems, _needToSetActiveTypes || !_form.Visible);
                _needToSetItems = false;
            } else {
                _form.SortItems();
            }

            // only activate certain types
            if (_needToSetActiveTypes || !_form.Visible) {
                // only activate certain types
                switch (CurrentTypeOfList) {
                    case TypeOfList.Complete:
                        _form.SetUnActiveType(new List<CompletionType> {
                            CompletionType.KeywordObject
                        });
                        break;
                    case TypeOfList.KeywordObject:
                        _form.SetActiveType(new List<CompletionType> {
                            CompletionType.KeywordObject
                        });
                        break;
                    default:
                        _form.SetUnActiveType(null);
                        break;
                }
            }

            // filter with keyword (keyword can be empty)
            _form.FilterByText = keyword;

            // close?
            if (!_openedFromShortCut && Config.Instance.AutoCompleteOnKeyInputHideIfEmpty && _form.TotalItems == 0) {
                Close();
                return;
            }

            // if the form was already visible, don't go further
            if (_form.Visible) return;

            _form.SelectFirstItem();

            // update position (and alternate color config)
            var point = Npp.GetCaretScreenLocation();
            var lineHeight = Npp.TextHeight(Npp.Line.CurrentLine);
            point.Y += lineHeight;
            _form.SetPosition(point, lineHeight + 2);
            _form.UnCloack();
        }
Beispiel #3
0
        /// <summary>
        /// This function handles the display of the autocomplete form, create or update it
        /// </summary>
        private static void ShowSuggestionList(string keyword)
        {
            if (CurrentItems.Count == 0)
            {
                Close();
                return;
            }

            // instanciate the form if needed
            if (_form == null)
            {
                _form = new AutoCompletionForm(keyword)
                {
                    UnfocusedOpacity = Config.Instance.AutoCompleteUnfocusedOpacity,
                    FocusedOpacity   = Config.Instance.AutoCompleteFocusedOpacity
                };
                _form.InsertSuggestion += OnInsertSuggestion;
                _form.Show(Npp.Win32WindowNpp);
                _form.SetItems(CurrentItems);
            }
            else if (_needToSetItems)
            {
                // we changed the mode, we need to Set the items of the autocompletion
                _form.SetItems(CurrentItems, _needToSetActiveTypes || !_form.Visible);
                _needToSetItems = false;
            }
            else
            {
                _form.SortItems();
            }

            // only activate certain types
            if (_needToSetActiveTypes || !_form.Visible)
            {
                // only activate certain types
                switch (CurrentTypeOfList)
                {
                case TypeOfList.Complete:
                    _form.SetUnActiveType(new List <CompletionType> {
                        CompletionType.KeywordObject
                    });
                    break;

                case TypeOfList.KeywordObject:
                    _form.SetActiveType(new List <CompletionType> {
                        CompletionType.KeywordObject
                    });
                    break;

                default:
                    _form.SetUnActiveType(null);
                    break;
                }
            }

            // filter with keyword (keyword can be empty)
            _form.FilterByText = keyword;

            // close?
            if (!_openedFromShortCut && Config.Instance.AutoCompleteOnKeyInputHideIfEmpty && _form.TotalItems == 0)
            {
                Close();
                return;
            }

            // if the form was already visible, don't go further
            if (_form.Visible)
            {
                return;
            }

            _form.SelectFirstItem();

            // update position (and alternate color config)
            var point      = Npp.GetCaretScreenLocation();
            var lineHeight = Npp.TextHeight(Npp.Line.CurrentLine);

            point.Y += lineHeight;
            _form.SetPosition(point, lineHeight + 2);
            _form.UnCloack();
        }