void ShowPopup(Gdk.EventButton evt)
        {
            view.FireCompletionContextChanged();
            CompletionWindowManager.HideWindow();
            ParameterInformationWindowManager.HideWindow(null, view);
            HideTooltip();
            const string    menuPath = "/MonoDevelop/SourceEditor2/ContextMenu/Editor";
            var             ctx      = ExtensionContext ?? AddinManager.AddinEngine;
            CommandEntrySet cset     = IdeApp.CommandService.CreateCommandEntrySet(ctx, menuPath);

            Gtk.Menu menu = IdeApp.CommandService.CreateMenu(cset);

            var imMenu = CreateInputMethodMenuItem(GettextCatalog.GetString("_Input Methods"));

            if (imMenu != null)
            {
                menu.Append(new SeparatorMenuItem());
                menu.Append(imMenu);
            }

            menu.Destroyed += delegate {
                this.QueueDraw();
            };

            if (evt != null)
            {
                GtkWorkarounds.ShowContextMenu(menu, this, evt);
            }
            else
            {
                var pt = LocationToPoint(this.Caret.Location);
                GtkWorkarounds.ShowContextMenu(menu, this, new Gdk.Rectangle(pt.X, pt.Y, 1, (int)LineHeight));
            }
        }
 void HAdjustment_ValueChanged(object sender, EventArgs e)
 {
     if (!isInKeyStroke)
     {
         CompletionWindowManager.HideWindow();
         ParameterInformationWindowManager.HideWindow(null, view);
     }
 }
 protected void OnCompletionContextChanged(object o, EventArgs a)
 {
     if (autoHideCompletionWindow)
     {
         CompletionWindowManager.HideWindow();
         ParameterInformationWindowManager.HideWindow(this, CompletionWidget);
     }
 }
Exemplo n.º 4
0
        public override bool KeyPress(Gdk.Key key, char keyChar, Gdk.ModifierType modifier)
        {
            if (this.CompletionWidget != null && (keyChar == ')' || keyChar == ';'))
            {
                ParameterInformationWindowManager.HideWindow(this, CompletionWidget);
            }

            return(base.KeyPress(key, keyChar, modifier));
        }
Exemplo n.º 5
0
 protected override void HAdjustmentValueChanged()
 {
     base.HAdjustmentValueChanged();
     if (!isInKeyStroke)
     {
         CompletionWindowManager.HideWindow();
         ParameterInformationWindowManager.HideWindow();
     }
 }
Exemplo n.º 6
0
        public override void CursorPositionChanged()
        {
            if (CompletionWidget != null && Document.Editor.Caret.Offset < lastTriggerOffset)
            {
                ParameterInformationWindowManager.HideWindow(this, CompletionWidget);
                lastTriggerOffset = -1;
            }

            base.CursorPositionChanged();
        }
Exemplo n.º 7
0
 protected void OnCompletionContextChanged(object o, EventArgs a)
 {
     if (autoHideCompletionWindow)
     {
         CompletionWindowManager.HideWindow();
     }
     if (autoHideParameterWindow)
     {
         ParameterInformationWindowManager.HideWindow(this, CompletionWidget);
     }
     ParameterInformationWindowManager.UpdateCursorPosition(this, CompletionWidget);
 }
Exemplo n.º 8
0
        public override bool KeyPress(Gdk.Key key, char keyChar, Gdk.ModifierType modifier)
        {
            updater.BeginUpdate();
            if (this.CompletionWidget != null && (keyChar == ')' || keyChar == ';'))
            {
                ParameterInformationWindowManager.HideWindow(this, CompletionWidget);
            }

            var ret = base.KeyPress(key, keyChar, modifier);

            updater.FinishUpdate();
            return(ret);
        }
Exemplo n.º 9
0
        void ShowPopup(Gdk.EventButton evt)
        {
            view.FireCompletionContextChanged();
            CompletionWindowManager.HideWindow();
            ParameterInformationWindowManager.HideWindow(null, view);
            HideTooltip();
            if (string.IsNullOrEmpty(menuPath))
            {
                return;
            }
            var             ctx  = view.WorkbenchWindow?.ExtensionContext ?? AddinManager.AddinEngine;
            CommandEntrySet cset = IdeApp.CommandService.CreateCommandEntrySet(ctx, menuPath);

            if (Platform.IsMac)
            {
                if (evt == null)
                {
                    int x, y;
                    var pt = LocationToPoint(this.Caret.Location);
                    TranslateCoordinates(Toplevel, pt.X, pt.Y, out x, out y);

                    IdeApp.CommandService.ShowContextMenu(this, x, y, cset, this);
                }
                else
                {
                    IdeApp.CommandService.ShowContextMenu(this, evt, cset, this);
                }
            }
            else
            {
                Gtk.Menu menu   = IdeApp.CommandService.CreateMenu(cset);
                var      imMenu = CreateInputMethodMenuItem(GettextCatalog.GetString("_Input Methods"));
                if (imMenu != null)
                {
                    menu.Append(new SeparatorMenuItem());
                    menu.Append(imMenu);
                }

                menu.Hidden += HandleMenuHidden;
                if (evt != null)
                {
                    GtkWorkarounds.ShowContextMenu(menu, this, evt);
                }
                else
                {
                    var pt = LocationToPoint(this.Caret.Location);

                    GtkWorkarounds.ShowContextMenu(menu, this, (int)pt.X, (int)pt.Y);
                }
            }
        }
Exemplo n.º 10
0
        public override void Dispose()
        {
            if (!disposed)
            {
                CompletionWindowManager.HideWindow();
                ParameterInformationWindowManager.HideWindow(this, CompletionWidget);

                disposed = true;
                CompletionWindowManager.WindowClosed -= HandleWindowClosed;
                if (CompletionWidget != null)
                {
                    CompletionWidget.CompletionContextChanged -= OnCompletionContextChanged;
                }
            }
            base.Dispose();
        }
Exemplo n.º 11
0
 internal protected virtual void OnCompletionContextChanged(object o, EventArgs a)
 {
     if (!IsActiveExtension())
     {
         return;
     }
     if (autoHideCompletionWindow)
     {
         CompletionWindowManager.HideWindow();
     }
     if (autoHideParameterWindow)
     {
         ParameterInformationWindowManager.HideWindow(this, CompletionWidget);
     }
     ParameterInformationWindowManager.UpdateCursorPosition(this, CompletionWidget);
 }
        public override void Dispose()
        {
            if (!disposed)
            {
                completionTokenSrc.Cancel();
                parameterHintingSrc.Cancel();

                CompletionWindowManager.HideWindow();
                ParameterInformationWindowManager.HideWindow(this, CompletionWidget);

                disposed          = true;
                Editor.FocusLost -= HandleFocusOutEvent;
                //				document.Editor.Paste -= HandlePaste;
                Deinitialize();
            }
            base.Dispose();
        }
Exemplo n.º 13
0
        protected override bool OnButtonReleaseEvent(Gdk.EventButton e)
        {
            int         offset      = this.Document.LocationToOffset(this.Caret.Location);
            int         lineNumber  = this.Document.OffsetToLineNumber(offset);
            LineSegment lineSegment = this.Document.GetLine(lineNumber);

            string lineText = this.Document.GetTextBetween(lineSegment.Offset, offset);


            int countBrackets1 = lineText.Count(c => c == '(');
            int countBrackets2 = lineText.Count(c => c == ')');

            if (countBrackets1 <= countBrackets2)
            {
                ParameterInformationWindowManager.HideWindow(this);
            }
            return(base.OnButtonReleaseEvent(e));
        }
Exemplo n.º 14
0
        public override bool KeyPress(Gdk.Key key, char keyChar, Gdk.ModifierType modifier)
        {
            updater.BeginUpdate();
            if (this.CompletionWidget != null)
            {
                switch (keyChar)
                {
                case '(':
                case ')':
                case ';':
                case ']':
                    ParameterInformationWindowManager.HideWindow(this, CompletionWidget);
                    break;

                default:
                    if (lastTriggerOffset >= 0 && char.IsDigit(keyChar))
                    {
                        bool containsDigitsOnly = true;

                        for (int offset = lastTriggerOffset; offset < CompletionWidget.CaretOffset; offset++)
                        {
                            if (!char.IsDigit(CompletionWidget.GetChar(offset)))
                            {
                                containsDigitsOnly = false;
                                break;
                            }
                        }

                        if (containsDigitsOnly)
                        {
                            CompletionWindowManager.HideWindow();
                        }
                    }
                    break;
                }
            }

            var ret = base.KeyPress(key, keyChar, modifier);

            updater.FinishUpdate();
            return(ret);
        }
Exemplo n.º 15
0
        public override void Initialize()
        {
            base.Initialize();

            CompletionWindowManager.WindowClosed += HandleWindowClosed;
            CompletionWidget = Document.GetContent <ICompletionWidget> ();
            if (CompletionWidget != null)
            {
                CompletionWidget.CompletionContextChanged += OnCompletionContextChanged;
            }
            document.Editor.Paste += (insertionOffset, text, insertedChars) => {
                ParameterInformationWindowManager.HideWindow(this, CompletionWidget);
                CompletionWindowManager.HideWindow();
            };
            if (document.Editor.Parent != null)
            {
                document.Editor.Parent.TextArea.FocusOutEvent += delegate {
                    ParameterInformationWindowManager.HideWindow(this, CompletionWidget);
                    CompletionWindowManager.HideWindow();
                };
            }
        }
Exemplo n.º 16
0
        public override void Dispose()
        {
            if (!disposed)
            {
                CompletionWindowManager.HideWindow();
                ParameterInformationWindowManager.HideWindow(this, CompletionWidget);

                disposed = true;
                if (document.Editor.Parent != null)
                {
                    document.Editor.Parent.TextArea.FocusOutEvent -= HandleFocusOutEvent;
                }
                document.Editor.Paste -= HandlePaste;
                document.Editor.Caret.PositionChanged -= HandlePositionChanged;
                CompletionWindowManager.WindowClosed  -= HandleWindowClosed;
                if (CompletionWidget != null)
                {
                    CompletionWidget.CompletionContextChanged -= OnCompletionContextChanged;
                }
            }
            base.Dispose();
        }
 protected override bool OnFocusOutEvent(Gdk.EventFocus evnt)
 {
     CompletionWindowManager.HideWindow();
     ParameterInformationWindowManager.HideWindow(null, view);
     return(base.OnFocusOutEvent(evnt));
 }
//		void HandlePaste (int insertionOffset, string text, int insertedChars)
//		{
//			ParameterInformationWindowManager.HideWindow (this, CompletionWidget);
//			CompletionWindowManager.HideWindow ();
//		}
//
        void HandleFocusOutEvent(object sender, EventArgs args)
        {
            ParameterInformationWindowManager.HideWindow(this, CompletionWidget);
            CompletionWindowManager.HideWindow();
        }
Exemplo n.º 19
0
 protected override void VAdjustmentValueChanged()
 {
     base.VAdjustmentValueChanged();
     CompletionWindowManager.HideWindow();
     ParameterInformationWindowManager.HideWindow();
 }
Exemplo n.º 20
0
        protected override bool OnKeyPressEvent(Gdk.EventKey evnt)
        {
            char charKey = (char)Gdk.Keyval.ToUnicode(evnt.KeyValue);

            if ((evnt.State == Gdk.ModifierType.ControlMask) && (charKey == 'v'))
            {
                PasteClipboard();
                return(true);
            }
            ;
            if ((evnt.State == Gdk.ModifierType.ControlMask) && (charKey == 'c'))
            {
                CopyClipboard();
                return(true);
            }
            ;

            KeyActions ka = KeyActions.None;

            //if (currentCompletionContext != null) {
            if (CompletionWindowManager.PreProcessKeyEvent(evnt.Key, (char)evnt.Key, evnt.State, out ka))
            {
                CompletionWindowManager.PostProcessKeyEvent(ka);

                if (evnt.Key == Gdk.Key.Up || evnt.Key == Gdk.Key.Down || evnt.Key == Gdk.Key.Return ||
                    evnt.Key == Gdk.Key.Left || evnt.Key == Gdk.Key.Right)                          //)
                {
                    return(true);
                }
            }
            //}

            if (ParameterInformationWindowManager.IsWindowVisible)
            {
                if (ParameterInformationWindowManager.ProcessKeyEvent(this, evnt.Key, evnt.State))
                {
                    return(false);
                }
            }

            if (CompletionWindowManager.IsTemplateModes)
            {
                return(true);
            }


            bool result = base.OnKeyPressEvent(evnt);

            if (!MainClass.Settings.SourceEditorSettings.AggressivelyTriggerCL)
            {
                return(result);
            }
            if (banCompletion)
            {
                return(result);
            }

            completionType = CompletionTyp.allType;

            if ((evnt.State != Gdk.ModifierType.None) && charKey != '(' && charKey != ')')
            {
                return(result);
            }

            int         offset      = this.Document.LocationToOffset(this.Caret.Location);
            int         lineNumber  = this.Document.OffsetToLineNumber(offset);
            LineSegment lineSegment = this.Document.GetLine(lineNumber);

            string lineText = this.Document.GetTextBetween(lineSegment.Offset, offset);


            int countBrackets1 = lineText.Count(c => c == '(');
            int countBrackets2 = lineText.Count(c => c == ')');

            if (countBrackets1 <= countBrackets2)
            {
                ParameterInformationWindowManager.HideWindow(this);
            }

            if (((charKey == '\0') || (char.IsPunctuation(charKey)) &&
                 (char.IsSymbol(charKey))
                 // ||( char.IsWhiteSpace(charKey) )
                 ) &&
                (charKey != '#') &&
                (charKey != '_') &&
                (charKey != '.'))
            {
                return(result);
            }


            int endOffset = offset;

            offset = FindPrevWordOffset(offset);

            if (offset > 0 || endOffset > 0 || offset < endOffset)
            {
                int    offset2      = FindPrevWordOffsetStartSpace(offset);
                string previousWord = this.Document.GetTextBetween(offset2, offset).Trim();

                int    offset3         = FindPrevWordOffsetWithoutDot(offset);
                string previousWordDot = this.Document.GetTextBetween(offset3, offset).Trim();

                //Console.WriteLine("previousWord-> {0}",previousWord);
                //Console.WriteLine("previousWord-> {0}",previousWordDot);

                /*int lineNumber= this.Document.OffsetToLineNumber(endOffset);
                 * LineSegment lineSegment = this.Document.GetLine(lineNumber);
                 *
                 * string lineText =this.Document.GetTextBetween(lineSegment.Offset,endOffset);
                 */

                if (!string.IsNullOrEmpty(lineText))                  // som za komentarom
                {
                    if (lineText.Contains("//"))
                    {
                        return(result);
                    }
                }

                string docText = this.Document.GetTextBetween(0, endOffset);

                int countCommentStart = CountExpresion("/*", docText);             //
                int countCommentEnd   = CountExpresion("*/", docText);             //
                //int countComment = CountExpresion(""",docText);

                int countSem = docText.Count(c => c == '"');

                if (charKey == '(')
                {
                    int    offsetB       = FindPrevWordOffsetWithoutBrackets(offset);
                    string previousWordB = this.Document.GetTextBetween(offsetB, offset - 1).Trim();
                    if ((charKey == '(') || (previousWordB.Trim().Contains('(')))
                    {
                        ParameterDataProvider pdp = new ParameterDataProvider(this, previousWordB.Trim());

                        /*IParameterDataProvider cp = null;
                         * CodeCompletionContext ctx = CreateCodeCompletionContext (cpos);
                         * cp = ParameterCompletionCommand (ctx);
                         */
                        ParameterInformationWindowManager.ShowWindow(this, pdp);

                        return(result);
                    }
                    return(result);
                }
                if (charKey == ')')
                {
                    ParameterInformationWindowManager.HideWindow(this);
                    return(result);
                }

                /*if(lineText.Trim().StartsWith("include")){
                 *      completionType = CompletionTyp.includeType;
                 *
                 *      Gtk.Action act = MainClass.MainWindow.EditorNotebook.EditorAction.GetAction("sourceeditor_insertautocomplete");
                 *      if (act!=null){
                 *              act.Activate();
                 *      }
                 *      return result;
                 * }*/

                // komentar alebo string "" /**/
                if ((countCommentStart > countCommentEnd) || (!ItEven(countSem)))
                {
                    return(result);
                }

                if ((charKey == '.') || (previousWordDot.Trim().Contains('.')))
                {
                    completionType = CompletionTyp.dotType;
                }

                if (previousWord.Trim() == "new")
                {
                    completionType = CompletionTyp.newType;
                }



                string word = this.Document.GetTextAt(offset, endOffset - offset).Trim();
                if ((!IsKeyvord(previousWord.Trim()) && IsIdentifier(word)) ||
                    (previousWord.Trim() == "new") ||
                    (charKey == '.'))
                {
                    Gtk.Action act = MainClass.MainWindow.EditorNotebook.EditorAction.GetAction("sourceeditor_insertautocomplete");
                    if (act != null)
                    {
                        act.Activate();
                    }
                }
            }

            return(result);
        }
Exemplo n.º 21
0
 void HandlePaste(int insertionOffset, string text, int insertedChars)
 {
     ParameterInformationWindowManager.HideWindow(this, CompletionWidget);
     CompletionWindowManager.HideWindow();
 }