コード例 #1
0
        public TooltipItem GetItem(Mono.TextEditor.TextEditor editor, int offset)
        {
            string offsetWord = (editor as TextEdit).GetOffsetWord(offset, true);

            //if((string.IsNullOrEmpty(offsetWord)) || !offsetWord.Contains(".") ) return null;
            if ((string.IsNullOrEmpty(offsetWord)))
            {
                return(null);
            }


            // tooltip, len nad slovami s bodkou alebo Type
            if (!offsetWord.Contains("."))
            {
                Completion.CompletionData cdType = MainClass.CompletedCache.ListDataTypes.Find(x => x.CompletionText == offsetWord);
                if (cdType != null)
                {
                    return(new TooltipItem(cdType.Description));
                }
                else
                {
                    return(null);
                }
            }

            Completion.CompletionData cd = editor.GetCompletionData(offsetWord);             //ParseString(writeWord,fullWord,completiontype);

            if (cd != null)
            {
                return(new TooltipItem(cd.Description));
            }
            return(null);
        }
コード例 #2
0
        protected override Gtk.Window CreateTooltipWindow(Mono.TextEditor.TextEditor editor, int offset, Gdk.ModifierType modifierState, TooltipItem item)
        {
            var doc = IdeApp.Workbench.ActiveDocument;

            if (doc == null)
            {
                return(null);
            }

            var titem = (ToolTipData)item.Item;

            var tooltipInformation = CreateTooltip(titem, offset, null, modifierState);

            if (tooltipInformation == null || string.IsNullOrEmpty(tooltipInformation.SignatureMarkup))
            {
                return(null);
            }

            var result = new TooltipInformationWindow();

            result.ShowArrow = true;
            result.AddOverload(tooltipInformation);
            result.RepositionWindow();
            return(result);
        }
コード例 #3
0
        public DisassemblyView()
        {
            ContentName = GettextCatalog.GetString("Disassembly");
            sw          = new Gtk.ScrolledWindow();
            editor      = new TextEditor();
            editor.Document.ReadOnly = true;

            editor.Options = new CommonTextEditorOptions {
                ShowLineNumberMargin = false,
            };

            sw.Add(editor);
            sw.HscrollbarPolicy = Gtk.PolicyType.Automatic;
            sw.VscrollbarPolicy = Gtk.PolicyType.Automatic;
            sw.ShowAll();
            sw.Vadjustment.ValueChanged      += OnScrollEditor;
            sw.VScrollbar.ButtonPressEvent   += OnPress;
            sw.VScrollbar.ButtonReleaseEvent += OnRelease;
            sw.VScrollbar.Events             |= Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask;
            sw.ShadowType = Gtk.ShadowType.In;

            sw.Sensitive = false;

            currentDebugLineMarker         = new CurrentDebugLineTextMarker(editor);
            DebuggingService.StoppedEvent += OnStop;
        }
コード例 #4
0
        protected override void GetRequiredPosition(Mono.TextEditor.TextEditor editor, Gtk.Window tipWindow, out int requiredWidth, out double xalign)
        {
            var win = (TooltipInformationWindow)tipWindow;

            requiredWidth = win.Allocation.Width;
            xalign        = 0.5;
        }
コード例 #5
0
        static string GetLocalExpression(TextEditor editor, LocalResolveResult lr, DomRegion expressionRegion)
        {
            var start       = new DocumentLocation(expressionRegion.BeginLine, expressionRegion.BeginColumn);
            var end         = new DocumentLocation(expressionRegion.EndLine, expressionRegion.EndColumn);
            int startOffset = editor.Document.LocationToOffset(start);
            int endOffset   = editor.Document.LocationToOffset(end);
            var ed          = (ExtensibleTextEditor)editor;

            // In a setter, the 'value' variable will have a begin line/column of 0,0 which is an undefined offset
            if (lr.Variable.Region.BeginLine != 0 && lr.Variable.Region.BeginColumn != 0)
            {
                // Use the start and end offsets of the variable region so that we get the "@" in variable names like "@class"
                start       = new DocumentLocation(lr.Variable.Region.BeginLine, lr.Variable.Region.BeginColumn);
                end         = new DocumentLocation(lr.Variable.Region.EndLine, lr.Variable.Region.EndColumn);
                startOffset = editor.Document.LocationToOffset(start);
                endOffset   = editor.Document.LocationToOffset(end);
            }

            string expression = ed.GetTextBetween(startOffset, endOffset).Trim();

            // Note: When the LocalResolveResult is a parameter, the Variable.Region includes the type
            if (lr.IsParameter)
            {
                int index = IndexOfLastWhiteSpace(expression);
                if (index != -1)
                {
                    expression = expression.Substring(index + 1);
                }
            }

            return(expression);
        }
コード例 #6
0
ファイル: PatchWidget.cs プロジェクト: acken/monodevelop
		public PatchWidget (ComparisonView comparisonView, VersionControlDocumentInfo info)
		{
			this.Build ();
			diffEditor = new Mono.TextEditor.TextEditor ();
			diffEditor.Document.MimeType = "text/x-diff";
			diffEditor.Options.FontName = info.Document.Editor.Options.FontName;
			diffEditor.Options.ColorScheme = info.Document.Editor.Options.ColorScheme;
			diffEditor.Options.ShowFoldMargin = false;
			diffEditor.Options.ShowIconMargin = false;
			diffEditor.Options.ShowTabs = true;
			diffEditor.Options.ShowSpaces = true;
			diffEditor.Options.ShowInvalidLines = info.Document.Editor.Options.ShowInvalidLines;
			diffEditor.Document.ReadOnly = true;
			scrolledwindow1.Child = diffEditor;
			diffEditor.ShowAll ();
			using (var writer = new StringWriter ()) {
				UnifiedDiff.WriteUnifiedDiff (comparisonView.Diff, writer, 
				                              System.IO.Path.GetFileName (info.Item.Path) + "    (repository)", 
				                              System.IO.Path.GetFileName (info.Item.Path) + "    (working copy)",
				                              3);
				diffEditor.Document.Text = writer.ToString ();
			}
			buttonSave.Clicked += delegate {
				var dlg = new OpenFileDialog (GettextCatalog.GetString ("Save as..."), FileChooserAction.Save) {
					TransientFor = IdeApp.Workbench.RootWindow
				};
				
				if (!dlg.Run ())
					return;
				File.WriteAllText (dlg.SelectedFile, diffEditor.Document.Text);
			};
		}
コード例 #7
0
		public DisassemblyView ()
		{
			ContentName = GettextCatalog.GetString ("Disassembly");
			sw = new Gtk.ScrolledWindow ();
			editor = new TextEditor ();
			editor.Document.ReadOnly = true;
			
			editor.Options = new CommonTextEditorOptions {
				ShowLineNumberMargin = false,
			};
			
			sw.Add (editor);
			sw.HscrollbarPolicy = Gtk.PolicyType.Automatic;
			sw.VscrollbarPolicy = Gtk.PolicyType.Automatic;
			sw.ShowAll ();
			sw.Vadjustment.ValueChanged += OnScrollEditor;
			sw.VScrollbar.ButtonPressEvent += OnPress;
			sw.VScrollbar.ButtonReleaseEvent += OnRelease;
			sw.VScrollbar.Events |= Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask;
			sw.ShadowType = Gtk.ShadowType.In;
			
			sw.Sensitive = false;
			
			currentDebugLineMarker = new CurrentDebugLineTextMarker (editor);
			DebuggingService.StoppedEvent += OnStop;
		}
コード例 #8
0
        public PatchWidget(ComparisonView comparisonView, VersionControlDocumentInfo info)
        {
            this.Build();
            diffEditor = new Mono.TextEditor.TextEditor();
            diffEditor.Document.MimeType        = "text/x-diff";
            diffEditor.Options.FontName         = info.Document.TextEditorData.Options.FontName;
            diffEditor.Options.ColorScheme      = info.Document.TextEditorData.Options.ColorScheme;
            diffEditor.Options.ShowFoldMargin   = false;
            diffEditor.Options.ShowIconMargin   = false;
            diffEditor.Options.ShowTabs         = true;
            diffEditor.Options.ShowSpaces       = true;
            diffEditor.Options.ShowInvalidLines = info.Document.TextEditorData.Options.ShowInvalidLines;
            diffEditor.Document.ReadOnly        = true;
            scrolledwindow1.Child = diffEditor;
            diffEditor.ShowAll();
            using (var writer = new StringWriter()) {
                UnifiedDiff.WriteUnifiedDiff(comparisonView.Diff, writer,
                                             System.IO.Path.GetFileName(info.Item.Path) + "    (repository)",
                                             System.IO.Path.GetFileName(info.Item.Path) + "    (working copy)",
                                             3);
                diffEditor.Document.Text = writer.ToString();
            }
            buttonSave.Clicked += delegate {
                var dlg = new OpenFileDialog(GettextCatalog.GetString("Save as..."), FileChooserAction.Save)
                {
                    TransientFor = IdeApp.Workbench.RootWindow
                };

                if (!dlg.Run())
                {
                    return;
                }
                File.WriteAllText(dlg.SelectedFile, diffEditor.Document.Text);
            };
        }
コード例 #9
0
        public Gtk.Window CreateTooltipWindow(Mono.TextEditor.TextEditor editor, int offset, Gdk.ModifierType modifierState, TooltipItem item)
        {
            var ed  = (ExtensibleTextEditor)editor;
            var doc = ed.ParsedDocument;

            if (doc == null)
            {
                return(null);
            }

            var resolveResult = (ResolveResult)item.Item;

            if (lastResult != null && lastWindow.IsRealized &&
                resolveResult != null && lastResult.Type.Equals(resolveResult.Type))
            {
                return(lastWindow);
            }
            var result = new LanguageItemWindow(ed, modifierState, resolveResult, null, doc.ParsedFile);

            lastWindow = result;
            lastResult = resolveResult;
            if (result.IsEmpty)
            {
                return(null);
            }
            return(result);
        }
コード例 #10
0
        public void GetRequiredPosition(Mono.TextEditor.TextEditor editor, Gtk.Window tipWindow, out int requiredWidth, out double xalign)
        {
            LanguageItemWindow win = (LanguageItemWindow)tipWindow;

            requiredWidth = win.SetMaxWidth(win.Screen.Width);
            xalign        = 0.5;
        }
コード例 #11
0
        public override void Run(RefactoringOptions options)
        {
            var data = options.GetTextEditorData();

            SearchMatchingExpressions(options);

            base.Run(options);
            if (selectionEnd >= 0)
            {
                options.Document.Editor.Caret.Offset = selectionEnd;
                options.Document.Editor.SetSelection(selectionStart, selectionEnd);
            }
            else
            {
                Mono.TextEditor.TextEditor editor = data.Parent;
                TextLink link = new TextLink("name");
                if (varName != null)
                {
                    foreach (var offset in offsets)
                    {
                        link.AddLink(new Segment(offset - selectionStart, varName.Length));
                    }
                }
                List <TextLink> links = new List <TextLink> ();
                links.Add(link);
                TextLinkEditMode tle = new TextLinkEditMode(editor, selectionStart, links);
                tle.SetCaretPosition = false;
                if (tle.ShouldStartTextLinkMode)
                {
                    tle.OldMode = data.CurrentMode;
                    tle.StartMode();
                    data.CurrentMode = tle;
                }
            }
        }
コード例 #12
0
        public SqlEditorWidget()
        {
            this.Build();

            sourceView = new Mono.TextEditor.TextEditor();
            // The SourceEditor Addin should be initialized before opening any Project.
            // Database Addin works with or without project opened.
            MonoDevelop.SourceEditor.Extension.TemplateExtensionNodeLoader.Init();
            sourceView.Document.MimeType = "text/x-sql";

            // TODO: Set styling ?
            //	sourceView.Options = new MonoDevelop.SourceEditor.StyledSourceEditorOptions (null);
            //	sourceView.ShowLineNumbers = true;

            sourceView.Document.TextReplaced        += BufferChanged;
            sourceView.TextViewMargin.ButtonPressed += delegate(object s, MarginMouseEventArgs args) {
                if (args.Button == 3)
                {
                    IdeApp.CommandService.ShowContextMenu("/MonoDevelop/Database/ContextMenu/SqlEditor");
                }
            };

            scrolledwindow.Add(sourceView);
            ShowAll();
        }
コード例 #13
0
//		PinWindow pinWindow;
//		TreeIter currentPinIter;

        public DebugValueWindow(Mono.TextEditor.TextEditor editor, int offset, StackFrame frame, ObjectValue value, PinnedWatch watch) : base(Gtk.WindowType.Toplevel)
        {
            this.TypeHint    = WindowTypeHint.PopupMenu;
            this.AllowShrink = false;
            this.AllowGrow   = false;
            this.Decorated   = false;

            TransientFor = (Gtk.Window)editor.Toplevel;

            // Avoid getting the focus when the window is shown. We'll get it when the mouse enters the window
            AcceptFocus = false;

            sw = new ScrolledWindow();
            sw.HscrollbarPolicy = PolicyType.Never;
            sw.VscrollbarPolicy = PolicyType.Never;

            tree = new ObjectValueTreeView();
            sw.Add(tree);
            ContentBox.Add(sw);

            tree.Frame                = frame;
            tree.CompactView          = true;
            tree.AllowAdding          = false;
            tree.AllowEditing         = true;
            tree.HeadersVisible       = false;
            tree.AllowPinning         = true;
            tree.RootPinAlwaysVisible = true;
            tree.PinnedWatch          = watch;
            DocumentLocation location = editor.Document.OffsetToLocation(offset);

            tree.PinnedWatchLine = location.Line;
            tree.PinnedWatchFile = ((ExtensibleTextEditor)editor).View.ContentName;

            tree.AddValue(value);
            tree.Selection.UnselectAll();
            tree.SizeAllocated    += OnTreeSizeChanged;
            tree.PinStatusChanged += delegate {
                Destroy();
            };

//			tree.MotionNotifyEvent += HandleTreeMotionNotifyEvent;

            sw.ShowAll();

//			pinWindow = new PinWindow (this);
//			pinWindow.SetPinned (false);
//			pinWindow.ButtonPressEvent += HandlePinWindowButtonPressEvent;

            tree.StartEditing += delegate {
                Modal = true;
            };

            tree.EndEditing += delegate {
                Modal = false;
            };

            ShowArrow          = true;
            Theme.CornerRadius = 3;
        }
コード例 #14
0
 public void DrawIcon(Mono.TextEditor.TextEditor editor, Gdk.Drawable win, LineSegment line, int lineNumber, int x, int y, int width, int height)
 {
     if (DebuggingService.IsDebugging)
     {
         return;
     }
     win.DrawPixbuf(editor.Style.BaseGC(Gtk.StateType.Normal), errors.Any(e => e.IsError) ? errorPixbuf : warningPixbuf, 0, 0, x + (width - errorPixbuf.Width) / 2, y + (height - errorPixbuf.Height) / 2, errorPixbuf.Width, errorPixbuf.Height, Gdk.RgbDither.None, 0, 0);
 }
コード例 #15
0
 protected override void OnDestroyed()
 {
     base.OnDestroyed();
     adj           = null;
     textEditor    = null;
     providerTasks = null;
     PropertyService.RemovePropertyHandler("ScrollBar.Mode", ScrollBarModeChanged);
 }
コード例 #16
0
		public override TooltipItem GetItem (TextEditor editor, int offset)
		{
			if (offset >= editor.Document.TextLength)
				return null;

			if (!DebuggingService.IsDebugging || DebuggingService.IsRunning)
				return null;

			StackFrame frame = DebuggingService.CurrentFrame;
			if (frame == null)
				return null;

			var ed = (ExtensibleTextEditor) editor;
			string expression = null;
			int startOffset;

			if (ed.IsSomethingSelected && offset >= ed.SelectionRange.Offset && offset <= ed.SelectionRange.EndOffset) {
				startOffset = ed.SelectionRange.Offset;
				expression = ed.SelectedText;
			} else {
				var doc = IdeApp.Workbench.ActiveDocument;
				if (doc == null || doc.ParsedDocument == null)
					return null;

				var resolver = doc.GetContent<IDebuggerExpressionResolver> ();
				var data = editor.GetTextEditorData ();

				if (resolver != null) {
					expression = resolver.ResolveExpression (data, doc, offset, out startOffset);
				} else {
					int endOffset = data.FindCurrentWordEnd (offset);
					startOffset = data.FindCurrentWordStart (offset);

					expression = data.GetTextAt (startOffset, endOffset - startOffset);
				}
			}
			
			if (string.IsNullOrEmpty (expression))
				return null;
			
			ObjectValue val;
			if (!cachedValues.TryGetValue (expression, out val)) {
				var options = DebuggingService.DebuggerSession.EvaluationOptions.Clone ();
				options.AllowMethodEvaluation = true;
				options.AllowTargetInvoke = true;

				val = frame.GetExpressionValue (expression, options);
				cachedValues [expression] = val;
			}
			
			if (val == null || val.IsUnknown || val.IsNotSupported)
				return null;
			
			val.Name = expression;
			
			return new TooltipItem (val, startOffset, expression.Length);
		}
コード例 #17
0
 protected override void OnDestroyed()
 {
     base.OnDestroyed();
     if (textEditor != null)
     {
         textEditor.SizeAllocated -= HandleSizeAllocated;
         textEditor = null;
     }
 }
コード例 #18
0
 public void DrawIcon(Mono.TextEditor.TextEditor editor, Cairo.Context cr, DocumentLine line, int lineNumber, double x, double y, double width, double height)
 {
     editor.GdkWindow.DrawPixbuf(cache.editor.Style.BaseGC(Gtk.StateType.Normal),
                                 errors.Any(e => e.IsError) ? cache.errorPixbuf : cache.warningPixbuf,
                                 0, 0,
                                 (int)(x + (width - cache.errorPixbuf.Width) / 2),
                                 (int)(y + (height - cache.errorPixbuf.Height) / 2),
                                 cache.errorPixbuf.Width, cache.errorPixbuf.Height,
                                 Gdk.RgbDither.None, 0, 0);
 }
コード例 #19
0
        public Gtk.Window CreateTooltipWindow(Mono.TextEditor.TextEditor editor, int offset, Gdk.ModifierType modifierState, TooltipItem item)
        {
            LanguageItemWindow result = new LanguageItemWindow((ExtensibleTextEditor)editor, modifierState, null, (string)item.Item, null);

            if (result.IsEmpty)
            {
                return(null);
            }
            return(result);
        }
コード例 #20
0
        public void ShowOverlay(TextEditor textEditor)
        {
            this.textEditor = textEditor;
            this.ShowAll();
            textEditor.AddTopLevelWidget(this, 0, 0);
            textEditor.SizeAllocated += HandleSizeAllocated;
            var child = (TextEditor.EditorContainerChild)textEditor [this];

            child.FixedPosition = true;
        }
コード例 #21
0
        public ParameterDataProvider(Mono.TextEditor.TextEditor editor, string functionName)
        {
            //this.editor = editor;
            List <CompletionData> cd = editor.GetCompletionMemberData(functionName);

            if (cd != null)
            {
                list.AddRange(cd);
            }
        }
コード例 #22
0
        public override TooltipItem GetItem(Mono.TextEditor.TextEditor editor, int offset)
        {
            var doc = IdeApp.Workbench.ActiveDocument;

            if (doc == null || doc.ParsedDocument == null)
            {
                return(null);
            }
            var unit = doc.ParsedDocument.GetAst <SyntaxTree> ();

            if (unit == null)
            {
                return(null);
            }

            var file = doc.ParsedDocument.ParsedFile as CSharpUnresolvedFile;

            if (file == null)
            {
                return(null);
            }

            ResolveResult result;
            AstNode       node;
            var           loc = editor.OffsetToLocation(offset);

            if (!doc.TryResolveAt(loc, out result, out node))
            {
                if (node is CSharpTokenNode)
                {
                    int startOffset2 = editor.LocationToOffset(node.StartLocation);
                    int endOffset2   = editor.LocationToOffset(node.EndLocation);

                    return(new TooltipItem(new ToolTipData(unit, result, node, null), startOffset2, endOffset2 - startOffset2));
                }
                return(null);
            }
            if (node == lastNode)
            {
                return(lastResult);
            }
            var resolver = new CSharpAstResolver(doc.Compilation, unit, file);

            resolver.ApplyNavigator(new NodeListResolveVisitorNavigator(node), CancellationToken.None);

            var hoverNode = node.GetNodeAt(loc) ?? node;

            int startOffset = editor.LocationToOffset(hoverNode.StartLocation);
            int endOffset   = editor.LocationToOffset(hoverNode.EndLocation);

            return(lastResult = new TooltipItem(new ToolTipData(unit, result, node, resolver), startOffset, endOffset - startOffset));
        }
コード例 #23
0
        void OnOKClicked(object sender, EventArgs e)
        {
            TextEditorData data = options.GetTextEditorData();

            Mono.TextEditor.TextEditor editor = data.Parent;
// Insertion cursor mode test:
            if (editor != null)
            {
                IType type = properties.DeclaringMember.DeclaringType;

                InsertionCursorEditMode mode = new InsertionCursorEditMode(editor, CodeGenerationService.GetInsertionPoints(options.Document, type));
                for (int i = 0; i < mode.InsertionPoints.Count; i++)
                {
                    var point = mode.InsertionPoints[i];
                    if (point.Location < editor.Caret.Location)
                    {
                        mode.CurIndex = i;
                    }
                    else
                    {
                        break;
                    }
                }
                ModeHelpWindow helpWindow = new ModeHelpWindow();
                helpWindow.TransientFor = IdeApp.Workbench.RootWindow;
                helpWindow.TitleText    = GettextCatalog.GetString("<b>Extract Method -- Targeting</b>");
                helpWindow.Items.Add(new KeyValuePair <string, string> (GettextCatalog.GetString("<b>Key</b>"), GettextCatalog.GetString("<b>Behavior</b>")));
                helpWindow.Items.Add(new KeyValuePair <string, string> (GettextCatalog.GetString("<b>Up</b>"), GettextCatalog.GetString("Move to <b>previous</b> target point.")));
                helpWindow.Items.Add(new KeyValuePair <string, string> (GettextCatalog.GetString("<b>Down</b>"), GettextCatalog.GetString("Move to <b>next</b> target point.")));
                helpWindow.Items.Add(new KeyValuePair <string, string> (GettextCatalog.GetString("<b>Enter</b>"), GettextCatalog.GetString("<b>Declare new method</b> at target point.")));
                helpWindow.Items.Add(new KeyValuePair <string, string> (GettextCatalog.GetString("<b>Esc</b>"), GettextCatalog.GetString("<b>Cancel</b> this refactoring.")));
                mode.HelpWindow = helpWindow;
                mode.StartMode();
                methodName       = entry.Text;
                activeModifier   = comboboxModifiers.Active;
                generateComments = checkbuttonGenerateComment.Active;

                mode.Exited += delegate(object s, InsertionCursorEventArgs args) {
                    if (args.Success)
                    {
                        SetProperties();
                        properties.InsertionPoint = args.InsertionPoint;
                        List <Change>    changes = extractMethod.PerformChanges(options, properties);
                        IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetBackgroundProgressMonitor(this.Title, null);
                        RefactoringService.AcceptChanges(monitor, options.Dom, changes);
                    }
                };
            }

            ((Widget)this).Destroy();
        }
コード例 #24
0
ファイル: CodeCoverageView.cs プロジェクト: lenoil98/Mono-D
            public override void DrawAfterEol(Mono.TextEditor.TextEditor textEditor, Cairo.Context cr, double y, EndOfLineMetrics lineHeight)
            {
                using (var pango = cr.CreateLayout()) {
                    pango.FontDescription = textEditor.Options.Font;
                    cr.SetSourceColor(bg);

                    pango.SetText(hits.ToString());

                    cr.MoveTo(lineHeight.TextRenderEndPosition, y);
                    cr.ShowLayout(pango);
                }

                base.DrawAfterEol(textEditor, cr, y, lineHeight);
            }
コード例 #25
0
 public void DrawIcon(Mono.TextEditor.TextEditor editor, Cairo.Context cr, LineSegment line, int lineNumber, double x, double y, double width, double height)
 {
     if (DebuggingService.IsDebugging)
     {
         return;
     }
     editor.GdkWindow.DrawPixbuf(editor.Style.BaseGC(Gtk.StateType.Normal),
                                 errors.Any(e => e.IsError) ? errorPixbuf : warningPixbuf,
                                 0, 0,
                                 (int)(x + (width - errorPixbuf.Width) / 2),
                                 (int)(y + (height - errorPixbuf.Height) / 2),
                                 errorPixbuf.Width, errorPixbuf.Height,
                                 Gdk.RgbDither.None, 0, 0);
 }
コード例 #26
0
        public TooltipItem GetItem(Mono.TextEditor.TextEditor editor, int offset)
        {
            ExtensibleTextEditor ed = (ExtensibleTextEditor)editor;

            ICSharpCode.NRefactory.TypeSystem.DomRegion region;
            var resolveResult = ed.GetLanguageItem(offset, out region);

            if (resolveResult == null)
            {
                return(null);
            }
            int startOffset = offset;
            int endOffset   = offset;

            return(new TooltipItem(resolveResult, startOffset, endOffset - startOffset));
        }
コード例 #27
0
        public void DrawIcon(Mono.TextEditor.TextEditor editor, Cairo.Context cr, DocumentLine line, int lineNumber, double x, double y, double width, double height)
        {
            double size;

            if (width > height)
            {
                x   += (width - height) / 2;
                size = height;
            }
            else
            {
                y   += (height - width) / 2;
                size = width;
            }

            DrawIcon(cr, x, y, size);
        }
コード例 #28
0
        public TooltipItem GetItem(Mono.TextEditor.TextEditor editor, int offset)
        {
            ExtensibleTextEditor ed = (ExtensibleTextEditor)editor;

            ResolveResult resolveResult = ed.GetLanguageItem(offset);

            if (resolveResult == null)
            {
                return(null);
            }
            int startOffset = editor.Document.LocationToOffset(resolveResult.ResolvedExpression.Region.Start.Line - 1,
                                                               resolveResult.ResolvedExpression.Region.Start.Column - 1);
            int endOffset = editor.Document.LocationToOffset(resolveResult.ResolvedExpression.Region.End.Line - 1,
                                                             resolveResult.ResolvedExpression.Region.End.Column - 1);

            return(new TooltipItem(resolveResult, startOffset, endOffset - startOffset));
        }
コード例 #29
0
ファイル: ShowTextDialog.cs プロジェクト: Kalnor/monodevelop
		public ShowTextDialog (string text, string mimeType)
		{
			this.Build();
			
			sourceView = new Mono.TextEditor.TextEditor ();
			// TODO: Set styling ?
			//sourceView.Options = new MonoDevelop.SourceEditor.StyledSourceEditorOptions (null);
			sourceView.Document.MimeType = mimeType;
			sourceView.Document.Text = text;
//			sourceView.ShowLineNumbers = true;
			sourceView.Document.ReadOnly = true;
			
			vboxContent.PackStart (sourceView, true, true, 0);
			vboxContent.ShowAll ();
			if (text != null)
				sourceView.Document.Text = text;
		}
コード例 #30
0
        public override void Run(RefactoringOptions options)
        {
            base.Run(options);

            TextEditorData data = options.GetTextEditorData();

            Mono.TextEditor.TextEditor editor = data.Parent;

            List <TextLink>     links          = new List <TextLink> ();
            TextLink            link           = new TextLink("name");
            int                 referenceCount = 1;
            MemberResolveResult resolveResult  = options.ResolveResult as MemberResolveResult;
            IProperty           property       = resolveResult.ResolvedMember as IProperty;

            if (property.HasGet)
            {
                referenceCount++;
            }
            if (property.HasSet)
            {
                referenceCount++;
            }
            for (int i = refactoringStartOffset; i < data.Document.Length - backingStoreName.Length; i++)
            {
                if (data.Document.GetTextAt(i, backingStoreName.Length) == backingStoreName)
                {
                    link.AddLink(new Segment(i - refactoringStartOffset, backingStoreName.Length));
                    if (link.Count == referenceCount)
                    {
                        break;
                    }
                }
            }

            links.Add(link);
            TextLinkEditMode tle = new TextLinkEditMode(editor, refactoringStartOffset, links);

            tle.SetCaretPosition = false;
            if (tle.ShouldStartTextLinkMode)
            {
                tle.OldMode = data.CurrentMode;
                tle.StartMode();
                data.CurrentMode = tle;
            }
        }
コード例 #31
0
        void DrawMessageExtendIcon(Mono.TextEditor.TextEditor editor, Cairo.Context g, double y, int errorCounterWidth, int eh)
        {
            EnsureLayoutCreated(editor);
            double rW = errorCounterWidth - 2;
            double rH = editor.LineHeight * 3 / 4;

            double rX = editor.Allocation.Width - rW - 2;
            double rY = y + (editor.LineHeight - rH) / 2;

            BookmarkMarker.DrawRoundRectangle(g, rX, rY, 8, rW, rH);

            g.Color = oldIsOver ? new Cairo.Color(0.3, 0.3, 0.3) : new Cairo.Color(0.5, 0.5, 0.5);
            g.Fill();
            if (CollapseExtendedErrors)
            {
                if (errorCountLayout != null)
                {
                    g.Color = cache.gcLight;
                    g.Save();
                    g.Translate(rX + rW / 4, rY + (rH - eh) / 2);
                    g.ShowLayout(errorCountLayout);
                    g.Restore();
                }
                else
                {
                    g.MoveTo(rX + rW / 2 - rW / 4, rY + rH / 4);
                    g.LineTo(rX + rW / 2 + rW / 4, rY + rH / 4);
                    g.LineTo(rX + rW / 2, rY + rH - rH / 4);
                    g.ClosePath();

                    g.Color = new Cairo.Color(1, 1, 1);
                    g.Fill();
                }
            }
            else
            {
                g.MoveTo(rX + rW / 2 - rW / 4, rY + rH - rH / 4);
                g.LineTo(rX + rW / 2 + rW / 4, rY + rH - rH / 4);
                g.LineTo(rX + rW / 2, rY + rH / 4);
                g.ClosePath();

                g.Color = new Cairo.Color(1, 1, 1);
                g.Fill();
            }
        }
コード例 #32
0
        public TooltipItem GetItem(Mono.TextEditor.TextEditor editor, int offset)
        {
            var ed = editor as ExtensibleTextEditor;

            if (ed == null)
            {
                return(null);
            }

            string errorInformation = ed.GetErrorInformationAt(offset);

            if (string.IsNullOrEmpty(errorInformation))
            {
                return(null);
            }

            return(new TooltipItem(errorInformation, editor.Document.GetLineByOffset(offset)));
        }
コード例 #33
0
ファイル: DebugTextMarker.cs プロジェクト: anthrax3/ide-1
        public void DrawIcon(Mono.TextEditor.TextEditor editor, Gdk.Drawable win, LineSegment line, int lineNumber, int x, int y, int width, int height)
        {
            int size;

            if (width > height)
            {
                x   += (width - height) / 2;
                size = height;
            }
            else
            {
                y   += (height - width) / 2;
                size = width;
            }

            using (Cairo.Context cr = Gdk.CairoHelper.Create(win))
                DrawIcon(cr, x, y, size);
        }
コード例 #34
0
        public DebugValueWindow(Mono.TextEditor.TextEditor editor, int offset, StackFrame frame, ObjectValue value, PinnedWatch watch)
        {
            TransientFor = (Gtk.Window)editor.Toplevel;

            // Avoid getting the focus when the window is shown. We'll get it when the mouse enters the window
            AcceptFocus = false;

            sw = new ScrolledWindow();
            sw.HscrollbarPolicy = PolicyType.Never;
            sw.VscrollbarPolicy = PolicyType.Never;

            tree = new ObjectValueTreeView();
            sw.Add(tree);
            Add(sw);

            tree.Frame          = frame;
            tree.CompactView    = true;
            tree.AllowAdding    = false;
            tree.AllowEditing   = true;
            tree.HeadersVisible = false;
            tree.AllowPinning   = true;
            tree.PinnedWatch    = watch;
            DocumentLocation location = editor.Document.OffsetToLocation(offset);

            tree.PinnedWatchLine = location.Line + 1;
            tree.PinnedWatchFile = ((ExtensibleTextEditor)editor).View.ContentName;

            tree.AddValue(value);
            tree.Selection.UnselectAll();
            tree.SizeAllocated    += OnTreeSizeChanged;
            tree.PinStatusChanged += delegate {
                Destroy();
            };

            sw.ShowAll();

            tree.StartEditing += delegate {
                Modal = true;
            };

            tree.EndEditing += delegate {
                Modal = false;
            };
        }
コード例 #35
0
		public SqlEditorWidget()
		{
			this.Build();
			
			sourceView = new Mono.TextEditor.TextEditor ();
			// The SourceEditor Addin should be initialized before opening any Project.
			// Database Addin works with or without project opened.
			MonoDevelop.SourceEditor.Extension.TemplateExtensionNodeLoader.Init ();
			sourceView.Document.MimeType = "text/x-sql";
			
			// TODO: Set styling ?
			//	sourceView.Options = new MonoDevelop.SourceEditor.StyledSourceEditorOptions (null);
			//	sourceView.ShowLineNumbers = true;
			
			sourceView.Document.TextReplaced += BufferChanged;
			sourceView.DoPopupMenu = delegate (Gdk.EventButton e) {
				IdeApp.CommandService.ShowContextMenu (sourceView, e, "/MonoDevelop/Database/ContextMenu/SqlEditor");
			};

			scrolledwindow.Add (sourceView);
			ShowAll ();
		}
コード例 #36
0
ファイル: EditorView.cs プロジェクト: ykhorzon/ApsimX
        /// <summary>
        /// Default constructor that configures the Completion form.
        /// </summary>
        public EditorView(ViewBase owner) : base(owner)
        {
            scroller = new ScrolledWindow();
            textEditor = new TextEditor();
            scroller.Add(textEditor);
            _mainWidget = scroller;
            TextEditorOptions options = new TextEditorOptions();
            options.EnableSyntaxHighlighting = true;
            options.ColorScheme = "Visual Studio";
            options.HighlightCaretLine = true;
            textEditor.Options = options;
            textEditor.Document.LineChanged += OnTextHasChanged;
            textEditor.LeaveNotifyEvent += OnTextBoxLeave;
            _mainWidget.Destroyed += _mainWidget_Destroyed;

            CompletionForm = new Window(WindowType.Popup);
            Frame completionFrame = new Frame();
            CompletionForm.Add(completionFrame);
            ScrolledWindow completionScroller = new ScrolledWindow();
            completionFrame.Add(completionScroller);
            completionModel = new ListStore(typeof(Gdk.Pixbuf), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string));
            CompletionView = new TreeView(completionModel);
            completionScroller.Add(CompletionView);
            TreeViewColumn column = new TreeViewColumn();
            CellRendererPixbuf iconRender = new Gtk.CellRendererPixbuf();
            column.PackStart(iconRender, false);
            CellRendererText textRender = new Gtk.CellRendererText();
            textRender.Editable = false;
            column.PackStart(textRender, true);
            column.SetAttributes(iconRender, "pixbuf", 0);
            column.SetAttributes(textRender, "text", 1);
            column.Title = "Item";
            column.Resizable = true;
            CompletionView.AppendColumn(column);
            textRender = new CellRendererText();
            column = new TreeViewColumn("Units", textRender, "text", 2);
            column.Resizable = true;
            CompletionView.AppendColumn(column);
            textRender = new CellRendererText();
            column = new TreeViewColumn("Type", textRender, "text", 3);
            column.Resizable = true;
            CompletionView.AppendColumn(column);
            textRender = new CellRendererText();
            column = new TreeViewColumn("Descr", textRender, "text", 4);
            column.Resizable = true;
            CompletionView.AppendColumn(column);
            functionPixbuf = new Gdk.Pixbuf(null, "ApsimNG.Resources.Function.png", 16, 16);
            propertyPixbuf = new Gdk.Pixbuf(null, "ApsimNG.Resources.Property.png", 16, 16);
            textEditor.TextArea.KeyPressEvent += OnKeyPress;
            CompletionView.HasTooltip = true;
            CompletionView.TooltipColumn = 5;
            CompletionForm.FocusOutEvent += OnLeaveCompletion;
            CompletionView.ButtonPressEvent += OnContextListMouseDoubleClick;
            CompletionView.KeyPressEvent += OnContextListKeyDown;
            CompletionView.KeyReleaseEvent += CompletionView_KeyReleaseEvent;
            IntelliSenseChars = ".";
        }
コード例 #37
0
		public AssemblyBrowserWidget ()
		{
			this.Build( );
			TreeView = new ExtensibleTreeView (new NodeBuilder[] { 
				new ErrorNodeBuilder (),
				new AssemblyNodeBuilder (this),
				new ModuleReferenceNodeBuilder (),
				new ModuleDefinitionNodeBuilder (this),
				new ReferenceFolderNodeBuilder (this),
				new ResourceFolderNodeBuilder (),
				new ResourceNodeBuilder (),
				new NamespaceBuilder (this),
				new DomTypeNodeBuilder (this),
				new DomMethodNodeBuilder (this),
				new DomFieldNodeBuilder (this),
				new DomEventNodeBuilder (this),
				new DomPropertyNodeBuilder (this),
				new BaseTypeFolderNodeBuilder (this),
				new DomReturnTypeNodeBuilder (this),
				new ReferenceNodeBuilder (this),
				}, new TreePadOption [] {
				new TreePadOption ("PublicApiOnly", GettextCatalog.GetString ("Show public members only"), true)
			});
			TreeView.Tree.Selection.Mode = Gtk.SelectionMode.Single;
			TreeView.Tree.CursorChanged += HandleCursorChanged;
			TreeView.ShadowType = ShadowType.In;
			treeViewPlaceholder.Add (TreeView);
			treeViewPlaceholder.ShowAll ();
			
//			this.descriptionLabel.ModifyFont (Pango.FontDescription.FromString ("Sans 9"));
			this.documentationLabel.ModifyFont (Pango.FontDescription.FromString ("Sans 12"));
			this.documentationLabel.ModifyBg (Gtk.StateType.Normal, new Gdk.Color (255, 255, 225));
			this.documentationLabel.Wrap = true;
			
			var options = new MonoDevelop.Ide.Gui.CommonTextEditorOptions () {
				ShowFoldMargin = false,
				ShowIconMargin = false,
				ShowInvalidLines = false,
				ShowLineNumberMargin = false,
				ShowSpaces = false,
				ShowTabs = false,
				HighlightCaretLine = true,
			};
			inspectEditor = new Mono.TextEditor.TextEditor (new Mono.TextEditor.Document (), options);
			inspectEditor.ButtonPressEvent += HandleInspectEditorButtonPressEvent;
			
			this.inspectEditor.Document.ReadOnly = true;
//			this.inspectEditor.Document.SyntaxMode = new Mono.TextEditor.Highlighting.MarkupSyntaxMode ();
			this.inspectEditor.TextViewMargin.GetLink = delegate(Mono.TextEditor.MarginMouseEventArgs arg) {
				var loc = inspectEditor.PointToLocation (arg.X, arg.Y);
				int offset = inspectEditor.LocationToOffset (loc);
				var referencedSegment = ReferencedSegments != null ? ReferencedSegments.FirstOrDefault (seg => seg.Contains (offset)) : null;
				if (referencedSegment == null)
					return null;
				if (referencedSegment.Reference is TypeDefinition)
					return new DomCecilType ((TypeDefinition)referencedSegment.Reference).HelpUrl;
				
				if (referencedSegment.Reference is MethodDefinition)
					return new DomCecilMethod ((MethodDefinition)referencedSegment.Reference).HelpUrl;
				
				if (referencedSegment.Reference is PropertyDefinition)
					return new DomCecilProperty ((PropertyDefinition)referencedSegment.Reference).HelpUrl;
				
				if (referencedSegment.Reference is FieldDefinition)
					return new DomCecilField ((FieldDefinition)referencedSegment.Reference).HelpUrl;
				
				if (referencedSegment.Reference is EventDefinition)
					return new DomCecilEvent ((EventDefinition)referencedSegment.Reference).HelpUrl;
				
				if (referencedSegment.Reference is FieldDefinition)
					return new DomCecilField ((FieldDefinition)referencedSegment.Reference).HelpUrl;
				
				if (referencedSegment.Reference is TypeReference) {
					var returnType = DomCecilMethod.GetReturnType ((TypeReference)referencedSegment.Reference);
					if (returnType.GenericArguments.Count == 0)
						return "T:" + returnType.FullName;
					return "T:" + returnType.FullName + "`" + returnType.GenericArguments.Count;
				}
				return referencedSegment.Reference.ToString ();
			};
			this.inspectEditor.LinkRequest += InspectEditorhandleLinkRequest;
			this.scrolledwindowEditor.Child = this.inspectEditor;
//			this.inspectLabel.ModifyBg (Gtk.StateType.Normal, new Gdk.Color (255, 255, 250));
			
//			this.vpaned1.ExposeEvent += VPaneExpose;
			this.hpaned1.ExposeEvent += HPaneExpose;
/*			this.notebook1.SwitchPage += delegate {
				// Hack for the switch page select all bug.
//				this.inspectLabel.Selectable = false;
			};*/

			this.languageCombobox.AppendText (GettextCatalog.GetString ("Summary"));
			this.languageCombobox.AppendText (GettextCatalog.GetString ("IL"));
			this.languageCombobox.AppendText (GettextCatalog.GetString ("C#"));
			this.languageCombobox.Active = PropertyService.Get ("AssemblyBrowser.InspectLanguage", 2);
			this.languageCombobox.Changed += LanguageComboboxhandleChanged;
			this.searchentry1.Ready = true;
			this.searchentry1.WidthRequest = 200;
			this.searchentry1.Visible = true;
			this.searchentry1.EmptyMessage = GettextCatalog.GetString ("Search for types or members");
			this.searchentry1.InnerEntry.Changed += SearchEntryhandleChanged;
			
			CheckMenuItem checkMenuItem = this.searchentry1.AddFilterOption (0, GettextCatalog.GetString ("Types"));
			checkMenuItem.Active = true;
			checkMenuItem.Toggled += delegate {
				if (checkMenuItem.Active) {
					searchMode = AssemblyBrowserWidget.SearchMode.Type;
					CreateColumns ();
					StartSearch ();
				}
			};
			
			CheckMenuItem checkMenuItem1 = this.searchentry1.AddFilterOption (1, GettextCatalog.GetString ("Members"));
			checkMenuItem1.Toggled += delegate {
				if (checkMenuItem1.Active) {
					searchMode = AssemblyBrowserWidget.SearchMode.Member;
					CreateColumns ();
					StartSearch ();
				}
			};
			comboboxVisibilty.InsertText (0, GettextCatalog.GetString ("Only public members"));
			comboboxVisibilty.InsertText (1, GettextCatalog.GetString ("All members"));
			comboboxVisibilty.Active = 0;
			comboboxVisibilty.Changed += delegate {
				PublicApiOnly = comboboxVisibilty.Active == 0;
				this.TreeView.GetRootNode ().Options[ "PublicApiOnly"] = PublicApiOnly;
				FillInspectLabel ();
			};
			/*
			this.searchInCombobox.Active = 0;
			this.searchInCombobox.Changed += SearchInComboboxhandleChanged;
			*/
			this.notebook1.SetTabLabel (this.documentationScrolledWindow, new Label (GettextCatalog.GetString ("Documentation")));
			this.notebook1.SetTabLabel (this.notebookInspection, new Label (GettextCatalog.GetString ("Inspect")));
			this.notebook1.SetTabLabel (this.searchWidget, new Label (GettextCatalog.GetString ("Search")));
			//this.searchWidget.Visible = false;
				
			typeListStore = new Gtk.ListStore (typeof (Gdk.Pixbuf), // type image
			                                   typeof (string),     // name
			                                   typeof (string),     // namespace
			                                   typeof (string),     // assembly
				                               typeof (IMember)
			                                  );
			
			memberListStore = new Gtk.ListStore (typeof (Gdk.Pixbuf), // member image
			                                   typeof (string),     // name
			                                   typeof (string),     // Declaring type full name
			                                   typeof (string),     // assembly
				                               typeof (IMember)
			                                  );
			CreateColumns ();
			SetInspectWidget ();
//			this.searchEntry.Changed += SearchEntryhandleChanged;
			this.searchTreeview.RowActivated += SearchTreeviewhandleRowActivated;
			this.searchentry1.ShowAll ();
			this.buttonBack.Clicked += this.OnNavigateBackwardActionActivated;
			this.buttonForeward.Clicked += this.OnNavigateForwardActionActivated;
			this.notebook1.ShowTabs = false;
			this.notebookInspection.ShowTabs = false;
			this.ShowAll ();
		}
コード例 #38
0
ファイル: QuickTaskStrip.cs プロジェクト: Kalnor/monodevelop
		protected override void OnDestroyed ()
		{
			base.OnDestroyed ();
			adj = null;
			textEditor = null;
			providerTasks = null;
			PropertyService.RemovePropertyHandler ("ScrollBar.Mode", ScrollBarModeChanged);
			EnableFancyFeatures.Changed -= HandleChanged;
		}
コード例 #39
0
ファイル: POEditorWidget.cs プロジェクト: Kalnor/monodevelop
		void AddTextview (int index)
		{
			ScrolledWindow window = new ScrolledWindow ();
			Mono.TextEditor.TextEditor textView = new Mono.TextEditor.TextEditor ();
			window.Child = textView;
			textView.Options = options;
			textView.Document.TextReplaced += delegate {
				if (this.isUpdating)
					return;
				try {
					if (this.currentEntry != null) {
						string escapedText = textView.Document.Text;
						string oldText     = this.currentEntry.GetTranslation (index);
						this.currentEntry.SetTranslation (escapedText, index);
						AddChange (this.currentEntry, oldText, escapedText, index);
					}
					IdeApp.Workbench.StatusBar.ShowReady ();
					textView.ModifyBase (Gtk.StateType.Normal, Style.Base (Gtk.StateType.Normal));
				} catch (System.Exception e) {
					IdeApp.Workbench.StatusBar.ShowError (e.Message);
					textView.ModifyBase (Gtk.StateType.Normal, errorColor);
				}
				treeviewEntries.QueueDraw ();
				UpdateProgressBar ();
				UpdateTasks ();
			};
			
			Label label = new Label ();
			label.Text = this.Catalog.PluralFormsDescriptions [index];
			window.ShowAll ();
			this.notebookTranslated.AppendPage (window, label);
		}
コード例 #40
0
		public override TooltipItem GetItem (TextEditor editor, int offset)
		{
			if (offset >= editor.Document.TextLength)
				return null;

			if (!DebuggingService.IsDebugging || DebuggingService.IsRunning)
				return null;

			StackFrame frame = DebuggingService.CurrentFrame;
			if (frame == null)
				return null;

			var ed = (ExtensibleTextEditor) editor;
			string expression = null;
			int startOffset;

			if (ed.IsSomethingSelected && offset >= ed.SelectionRange.Offset && offset <= ed.SelectionRange.EndOffset) {
				startOffset = ed.SelectionRange.Offset;
				expression = ed.SelectedText;
			} else {
				var doc = IdeApp.Workbench.ActiveDocument;
				if (doc == null || doc.ParsedDocument == null)
					return null;

				ResolveResult result;
				AstNode node;

				var loc = editor.OffsetToLocation (offset);
				if (!TryResolveAt (doc, loc, out result, out node))
					return null;

				expression = ResolveExpression (editor.GetTextEditorData (), result, node, out startOffset);
			}
			
			if (string.IsNullOrEmpty (expression))
				return null;
			
			ObjectValue val;
			if (!cachedValues.TryGetValue (expression, out val)) {
				val = frame.GetExpressionValue (expression, true);
				cachedValues [expression] = val;
			}
			
			if (val == null || val.IsUnknown || val.IsNotSupported)
				return null;
			
			val.Name = expression;
			
			return new TooltipItem (val, startOffset, expression.Length);
		}
コード例 #41
0
		public override TooltipItem GetItem (TextEditor editor, int offset)
		{
			if (offset >= editor.Document.TextLength)
				return null;
			
			if (!DebuggingService.IsDebugging || DebuggingService.IsRunning)
				return null;
				
			StackFrame frame = DebuggingService.CurrentFrame;
			if (frame == null)
				return null;

			var ed = (ExtensibleTextEditor)editor;
			DomRegion expressionRegion;
			string expression = null;
			ResolveResult res;
			int startOffset;

			if (ed.IsSomethingSelected && offset >= ed.SelectionRange.Offset && offset <= ed.SelectionRange.EndOffset) {
				startOffset = ed.SelectionRange.Offset;
				expression = ed.SelectedText;
			} else if ((res = ed.GetLanguageItem (offset, out expressionRegion)) != null && !res.IsError && res.GetType () != typeof (ResolveResult)) {
				if (!TryResolveExpression (editor.GetTextEditorData (), res, expressionRegion, out expression))
					return null;

				startOffset = editor.LocationToOffset (new DocumentLocation (expressionRegion.BeginLine, expressionRegion.BeginColumn));
			} else {
				var data = editor.GetTextEditorData ();
				startOffset = data.FindCurrentWordStart (offset);
				int endOffset = data.FindCurrentWordEnd (offset);

				expression = ed.GetTextBetween (ed.OffsetToLocation (startOffset), ed.OffsetToLocation (endOffset));
			}
			
			if (string.IsNullOrEmpty (expression))
				return null;
			
			ObjectValue val;
			if (!cachedValues.TryGetValue (expression, out val)) {
				val = frame.GetExpressionValue (expression, true);
				cachedValues [expression] = val;
			}
			
			if (val == null || val.IsUnknown || val.IsNotSupported)
				return null;
			
			val.Name = expression;
			
			return new TooltipItem (val, startOffset, expression.Length);
		}
コード例 #42
0
		public override TooltipItem GetItem (TextEditor editor, int offset)
		{
			if (offset >= editor.Document.TextLength)
				return null;
			
			if (!DebuggingService.IsDebugging || DebuggingService.IsRunning)
				return null;
				
			StackFrame frame = DebuggingService.CurrentFrame;
			if (frame == null)
				return null;
			
			var ed = (ExtensibleTextEditor)editor;
			
			string expression = null;
			int startOffset = 0, length = 0;
			if (ed.IsSomethingSelected && offset >= ed.SelectionRange.Offset && offset <= ed.SelectionRange.EndOffset) {
				expression = ed.SelectedText;
				startOffset = ed.SelectionRange.Offset;
				length = ed.SelectionRange.Length;
			} else {
				DomRegion expressionRegion;
				ResolveResult res = ed.GetLanguageItem (offset, out expressionRegion);
				
				if (res == null || res.IsError || res.GetType () == typeof (ResolveResult))
					return null;
				
				//Console.WriteLine ("res is a {0}", res.GetType ().Name);
				
				if (expressionRegion.IsEmpty)
					return null;

				if (res is NamespaceResolveResult ||
				    res is ConversionResolveResult ||
				    res is ForEachResolveResult ||
				    res is TypeIsResolveResult ||
				    res is TypeOfResolveResult ||
				    res is ErrorResolveResult)
					return null;
				
				var start = new DocumentLocation (expressionRegion.BeginLine, expressionRegion.BeginColumn);
				var end   = new DocumentLocation (expressionRegion.EndLine, expressionRegion.EndColumn);
				
				startOffset = editor.Document.LocationToOffset (start);
				int endOffset = editor.Document.LocationToOffset (end);
				length = endOffset - startOffset;
				
				if (res is LocalResolveResult) {
					var lr = (LocalResolveResult) res;

					// In a setter, the 'value' variable will have a begin line/column of 0,0 which is an undefined offset
					if (lr.Variable.Region.BeginLine != 0 && lr.Variable.Region.BeginColumn != 0) {
						// Use the start and end offsets of the variable region so that we get the "@" in variable names like "@class"
						start = new DocumentLocation (lr.Variable.Region.BeginLine, lr.Variable.Region.BeginColumn);
						end = new DocumentLocation (lr.Variable.Region.EndLine, lr.Variable.Region.EndColumn);
						startOffset = editor.Document.LocationToOffset (start);
						endOffset = editor.Document.LocationToOffset (end);
					}

					expression = ed.GetTextBetween (startOffset, endOffset).Trim ();

					// Note: When the LocalResolveResult is a parameter, the Variable.Region includes the type
					if (lr.IsParameter) {
						int index = IndexOfLastWhiteSpace (expression);
						if (index != -1)
							expression = expression.Substring (index + 1);
					}

					length = expression.Length;
				} else if (res is InvocationResolveResult) {
					var ir = (InvocationResolveResult) res;
					
					if (ir.Member.Name != ".ctor")
						return null;
					
					expression = ir.Member.DeclaringType.FullName;
				} else if (res is MemberResolveResult) {
					var mr = (MemberResolveResult) res;
					
					if (mr.TargetResult == null) {
						// User is hovering over a member definition...
						
						if (mr.Member is IProperty) {
							// Visual Studio will evaluate Properties if you hover over their definitions...
							var prop = (IProperty) mr.Member;
							
							if (prop.CanGet) {
								if (prop.IsStatic)
									expression = prop.FullName;
								else
									expression = prop.Name;
							} else {
								return null;
							}
						} else if (mr.Member is IField) {
							var field = (IField) mr.Member;
							
							if (field.IsStatic)
								expression = field.FullName;
							else
								expression = field.Name;
						} else {
							return null;
						}
					}
					
					// If the TargetResult is not null, then treat it like any other ResolveResult.
				} else if (res is ConstantResolveResult) {
					// Fall through...
				} else if (res is ThisResolveResult) {
					// Fall through...
				} else if (res is TypeResolveResult) {
					// Fall through...
				} else {
					return null;
				}
				
				if (expression == null)
					expression = ed.GetTextBetween (start, end);
			}
			
			if (string.IsNullOrEmpty (expression))
				return null;
			
			ObjectValue val;
			if (!cachedValues.TryGetValue (expression, out val)) {
				val = frame.GetExpressionValue (expression, true);
				cachedValues [expression] = val;
			}
			
			if (val == null || val.IsUnknown || val.IsNotSupported)
				return null;
			
			val.Name = expression;
			
			return new TooltipItem (val, startOffset, length);
		}
コード例 #43
0
		public void ShowOverlay (TextEditor textEditor)
		{
			this.textEditor = textEditor;
			this.ShowAll ();
			textEditor.AddTopLevelWidget (this, 0, 0);
			textEditor.SizeAllocated += HandleSizeAllocated;
			var child = (TextEditor.EditorContainerChild)textEditor [this];
			child.FixedPosition = true;
		}
コード例 #44
0
		static string GetMemberExpression (TextEditor editor, MemberResolveResult mr, DomRegion expressionRegion)
		{
			var ed = (ExtensibleTextEditor) editor;
			string expression = null;
			string member = null;

			if (mr.Member != null) {
				if (mr.Member is IProperty) {
					// Visual Studio will evaluate Properties if you hover over their definitions...
					var prop = (IProperty) mr.Member;

					if (prop.CanGet) {
						if (prop.IsStatic)
							expression = prop.FullName;
						else
							member = prop.Name;
					} else {
						return null;
					}
				} else if (mr.Member is IField) {
					var field = (IField) mr.Member;

					if (field.IsStatic)
						expression = field.FullName;
					else
						member = field.Name;
				} else {
					return null;
				}
			}

			if (expression == null) {
				if (member == null)
					return null;

				if (mr.TargetResult != null) {
					if (mr.TargetResult is LocalResolveResult) {
						expression = GetLocalExpression (editor, (LocalResolveResult) mr.TargetResult, expressionRegion);
					} else if (mr.TargetResult is MemberResolveResult) {
						expression = GetMemberExpression (editor, (MemberResolveResult) mr.TargetResult, expressionRegion);
					} else {
						var targetRegion = mr.TargetResult.GetDefinitionRegion ();

						if (targetRegion.BeginLine != 0 && targetRegion.BeginColumn != 0) {
							var start = new DocumentLocation (targetRegion.BeginLine, targetRegion.BeginColumn);
							var end   = new DocumentLocation (targetRegion.EndLine, targetRegion.EndColumn);
							expression = ed.GetTextBetween (start, end).Trim ();
						}
					}
				}

				if (!string.IsNullOrEmpty (expression))
					expression += "." + member;
				else
					expression = member;
			}

			return expression;
		}
コード例 #45
0
		protected override void OnDestroyed ()
		{
			if (searchBackgoundWorker != null && searchBackgoundWorker.IsBusy) {
				searchBackgoundWorker.CancelAsync ();
				searchBackgoundWorker.Dispose ();
				searchBackgoundWorker = null;
			}
			
			if (this.TreeView != null) {
			//	Dispose (TreeView.GetRootNode ());
				TreeView.Tree.CursorChanged -= HandleCursorChanged;
				this.TreeView.Clear ();
				this.TreeView = null;
			}
			
			if (definitions != null) {
				definitions.Clear ();
				definitions = null;
			}
			
			ActiveMember = null;
			if (memberListStore != null) {
				memberListStore.Dispose ();
				memberListStore = null;
			}
			
			if (typeListStore != null) {
				typeListStore.Dispose ();
				typeListStore = null;
			}
			
			if (documentationPanel != null) {
				documentationPanel.Destroy ();
				documentationPanel = null;
			}
			if (inspectEditor != null) {
				inspectEditor.LinkRequest -= InspectEditorhandleLinkRequest;
				inspectEditor.Destroy ();
				inspectEditor = null;
			}
			
			if (this.UIManager != null) {
				this.UIManager.Dispose ();
				this.UIManager = null;
			}
			this.languageCombobox.Changed -= LanguageComboboxhandleChanged;
//			this.searchInCombobox.Changed -= SearchInComboboxhandleChanged;
//			this.searchEntry.Changed -= SearchEntryhandleChanged;
			this.searchTreeview.RowActivated -= SearchTreeviewhandleRowActivated;
			hpaned1.ExposeEvent -= HPaneExpose;
			PropertyService.PropertyChanged -= HandlePropertyChanged;
			base.OnDestroyed ();
		}
コード例 #46
0
		public override TooltipItem GetItem (TextEditor editor, int offset)
		{
			if (offset >= editor.Document.TextLength)
				return null;
			
			if (!DebuggingService.IsDebugging || DebuggingService.IsRunning)
				return null;
				
			StackFrame frame = DebuggingService.CurrentFrame;
			if (frame == null)
				return null;
			
			var ed = (ExtensibleTextEditor)editor;
			int startOffset = 0, length = 0;
			DomRegion expressionRegion;
			string expression = null;
			ResolveResult res;

			if (ed.IsSomethingSelected && offset >= ed.SelectionRange.Offset && offset <= ed.SelectionRange.EndOffset) {
				expression = ed.SelectedText;
				startOffset = ed.SelectionRange.Offset;
				length = ed.SelectionRange.Length;
			} else if ((res = ed.GetLanguageItem (offset, out expressionRegion)) != null && !res.IsError && res.GetType () != typeof (ResolveResult)) {
				//Console.WriteLine ("res is a {0}", res.GetType ().Name);
				
				if (expressionRegion.IsEmpty)
					return null;

				if (res is NamespaceResolveResult ||
				    res is ConversionResolveResult ||
				    res is ConstantResolveResult ||
				    res is ForEachResolveResult ||
				    res is TypeIsResolveResult ||
				    res is TypeOfResolveResult ||
				    res is ErrorResolveResult)
					return null;

				if (res.IsCompileTimeConstant)
					return null;
				
				var start = new DocumentLocation (expressionRegion.BeginLine, expressionRegion.BeginColumn);
				var end   = new DocumentLocation (expressionRegion.EndLine, expressionRegion.EndColumn);
				
				startOffset = editor.Document.LocationToOffset (start);
				int endOffset = editor.Document.LocationToOffset (end);
				length = endOffset - startOffset;
				
				if (res is LocalResolveResult) {
					expression = GetLocalExpression (editor, (LocalResolveResult) res, expressionRegion);
					length = expression.Length;
				} else if (res is InvocationResolveResult) {
					var ir = (InvocationResolveResult) res;
					
					if (ir.Member.Name != ".ctor")
						return null;
					
					expression = ir.Member.DeclaringType.FullName;
				} else if (res is MemberResolveResult) {
					expression = GetMemberExpression (editor, (MemberResolveResult) res, expressionRegion);
				} else if (res is NamedArgumentResolveResult) {
					// Fall through...
				} else if (res is ThisResolveResult) {
					// Fall through...
				} else if (res is TypeResolveResult) {
					// Fall through...
				} else {
					return null;
				}
				
				if (expression == null)
					expression = ed.GetTextBetween (start, end);
			} else {
				var data = editor.GetTextEditorData ();
				startOffset = data.FindCurrentWordStart (offset);
				int endOffset = data.FindCurrentWordEnd (offset);

				expression = ed.GetTextBetween (ed.OffsetToLocation (startOffset), ed.OffsetToLocation (endOffset));
			}
			
			if (string.IsNullOrEmpty (expression))
				return null;
			
			ObjectValue val;
			if (!cachedValues.TryGetValue (expression, out val)) {
				val = frame.GetExpressionValue (expression, true);
				cachedValues [expression] = val;
			}
			
			if (val == null || val.IsUnknown || val.IsNotSupported)
				return null;
			
			val.Name = expression;
			
			return new TooltipItem (val, startOffset, length);
		}
コード例 #47
0
		public override bool IsInteractive (TextEditor editor, Gtk.Window tipWindow)
		{
			return DebuggingService.IsDebugging;
		}
コード例 #48
0
		static string GetLocalExpression (TextEditor editor, LocalResolveResult lr, DomRegion expressionRegion)
		{
			var start = new DocumentLocation (expressionRegion.BeginLine, expressionRegion.BeginColumn);
			var end   = new DocumentLocation (expressionRegion.EndLine, expressionRegion.EndColumn);
			int startOffset = editor.Document.LocationToOffset (start);
			int endOffset = editor.Document.LocationToOffset (end);
			var ed = (ExtensibleTextEditor) editor;

			// In a setter, the 'value' variable will have a begin line/column of 0,0 which is an undefined offset
			if (lr.Variable.Region.BeginLine != 0 && lr.Variable.Region.BeginColumn != 0) {
				// Use the start and end offsets of the variable region so that we get the "@" in variable names like "@class"
				start = new DocumentLocation (lr.Variable.Region.BeginLine, lr.Variable.Region.BeginColumn);
				end = new DocumentLocation (lr.Variable.Region.EndLine, lr.Variable.Region.EndColumn);
				startOffset = editor.Document.LocationToOffset (start);
				endOffset = editor.Document.LocationToOffset (end);
			}

			string expression = ed.GetTextBetween (startOffset, endOffset).Trim ();

			// Note: When the LocalResolveResult is a parameter, the Variable.Region includes the type
			if (lr.IsParameter) {
				int index = IndexOfLastWhiteSpace (expression);
				if (index != -1)
					expression = expression.Substring (index + 1);
			}

			return expression;
		}
コード例 #49
0
		public override Gtk.Window ShowTooltipWindow (TextEditor editor, int offset, Gdk.ModifierType modifierState, int mouseX, int mouseY, TooltipItem item)
		{
			var location = editor.OffsetToLocation (item.ItemSegment.Offset);
			var point = editor.LocationToPoint (location);
			int lineHeight = (int) editor.LineHeight;
			int y = (int) point.Y;

			// find the top of the line that the mouse is hovering over
			while (y + lineHeight < mouseY)
				y += lineHeight;

			var caret = new Gdk.Rectangle (mouseX - editor.Allocation.X, y - editor.Allocation.Y, 1, lineHeight);

			tooltip = new DebugValueWindow (editor, offset, DebuggingService.CurrentFrame, (ObjectValue) item.Item, null);
			tooltip.ShowPopup (editor, caret, PopupPosition.TopLeft);

			return tooltip;
		}
コード例 #50
0
		/// <summary>
		/// Creates a new AnnotationMargin
		/// </summary>
		/// <param name="repo">
		/// A <see cref="Repository"/>: The repo to use for annotation
		/// </param>
		/// <param name="editor">
		/// A <see cref="Mono.TextEditor.TextEditor"/>: The editor to which the margin belongs
		/// </param>
		/// <param name="doc">
		/// A <see cref="Ide.Gui.Document"/>: The document to be annotated
		/// </param>
		public AnnotationMargin (Repository repo, Mono.TextEditor.TextEditor editor, Ide.Gui.Document doc)
		{
			this.repo = repo;
			this.width = 0;
			this.editor = editor;
			annotations = new List<string> ();
			UpdateAnnotations (null, null);
			
			tooltipProvider = new AnnotationTooltipProvider (this);
			
			editor.Document.TextReplacing += EditorDocumentTextReplacing;
			editor.Document.LineChanged += EditorDocumentLineChanged;
			editor.Caret.PositionChanged += EditorCarethandlePositionChanged;
			editor.TooltipProviders.Add (tooltipProvider);

			doc.Saved += UpdateAnnotations;
			
			layout = new Pango.Layout (editor.PangoContext);
			layout.FontDescription = editor.Options.Font;
			
			lineNumberBgGC = new Gdk.GC (editor.GdkWindow);
			lineNumberBgGC.RgbFgColor = editor.ColorStyle.LineNumber.BackgroundColor;
			
			lineNumberGC = new Gdk.GC (editor.GdkWindow);
			lineNumberGC.RgbFgColor = editor.ColorStyle.LineNumber.Color;
			
			lineNumberHighlightGC = new Gdk.GC (editor.GdkWindow);
			lineNumberHighlightGC.RgbFgColor = editor.ColorStyle.LineNumberFgHighlighted;
			
			locallyModifiedGC = new Gdk.GC (editor.GdkWindow);
			locallyModifiedGC.RgbFgColor = editor.ColorStyle.LineDirtyBg;
		}
コード例 #51
0
		public DebugTextMarker (Mono.TextEditor.TextEditor editor)
		{
			this.editor = editor;
		}
コード例 #52
0
		protected override void OnDestroyed ()
		{
			base.OnDestroyed ();
			if (textEditor != null) {
				textEditor.SizeAllocated -= HandleSizeAllocated;
				textEditor = null;
			}
		}