Пример #1
0
		public override void InformMouseHover (Mono.TextEditor.MonoTextEditor editor, Margin margin, MarginMouseEventArgs args)
		{
			if (!(margin is ActionMargin))
				return;
			string toolTip;
			if (unitTest.IsFixture) {
				if (isFailed) {
					toolTip = GettextCatalog.GetString ("NUnit Fixture failed (click to run)");
					if (!string.IsNullOrEmpty (failMessage))
						toolTip += Environment.NewLine + failMessage.TrimEnd ();
				} else {
					toolTip = GettextCatalog.GetString ("NUnit Fixture (click to run)");
				}
			} else {
				if (isFailed) {
					toolTip = GettextCatalog.GetString ("NUnit Test failed (click to run)");
					if (!string.IsNullOrEmpty (failMessage))
						toolTip += Environment.NewLine + failMessage.TrimEnd ();
					foreach (var id in unitTest.TestCases) {
						if (host.IsFailure (unitTest.UnitTestIdentifier, id)) {
							var msg = host.GetMessage (unitTest.UnitTestIdentifier, id);
							if (!string.IsNullOrEmpty (msg)) {
								toolTip += Environment.NewLine + "Test" + id + ":";
								toolTip += Environment.NewLine + msg.TrimEnd ();
							}
						}
					}
				} else {
					toolTip = GettextCatalog.GetString ("NUnit Test (click to run)");
				}

			}
			editor.TooltipText = toolTip;
		}
Пример #2
0
		bool IActionTextLineMarker.MousePressed (Mono.TextEditor.MonoTextEditor editor, MarginMouseEventArgs args)
		{
			var handler = MousePressed;
			if (handler != null)
				handler (this, new TextEventArgsWrapper (args));
			return false;
		}
Пример #3
0
		void IActionTextLineMarker.MouseHover (MonoTextEditor editor, MarginMouseEventArgs args, TextLineMarkerHoverResult result)
		{
			MouseHover?.Invoke (this, new TextEventArgsWrapper (args));
			result.Cursor = textLinkCursor;
			if (OnlyShowLinkOnHover) {
				editor.GetTextEditorData ().Document.CommitLineUpdate (args.LineSegment);
				editor.TextViewMargin.HoveredLineChanged += new UpdateOldLine (editor, args.LineSegment).TextViewMargin_HoveredLineChanged;
			}
		}
		void IIconBarMarker.MouseHover (MarginMouseEventArgs args)
		{
			var sb = new System.Text.StringBuilder ();
			foreach (var error in errors) {
				if (sb.Length > 0)
					sb.AppendLine ();
				sb.Append (error.ErrorMessage);
			}
			args.Editor.TooltipText = sb.ToString ();
		}
Пример #5
0
		bool IActionTextLineMarker.MouseReleased (MonoTextEditor editor, MarginMouseEventArgs args)
		{
			if ((Platform.IsMac && (args.ModifierState & Gdk.ModifierType.Mod2Mask) == Gdk.ModifierType.Mod2Mask) ||
			    (!Platform.IsMac && (args.ModifierState & Gdk.ModifierType.ControlMask) == Gdk.ModifierType.ControlMask))
				activateLink?.Invoke (LinkRequest.RequestNewView);
			else
				activateLink?.Invoke (LinkRequest.SameView);
			
			return false;
		}
Пример #6
0
		internal protected override void MouseReleased (MarginMouseEventArgs args)
		{
			base.MouseReleased (args);
			
			DocumentLine lineSegment = args.LineSegment;
			if (lineSegment != null) {
				foreach (TextLineMarker marker in lineSegment.Markers) {
					if (marker is IIconBarMarker) 
						((IIconBarMarker)marker).MouseRelease (args);
				}
			}
		}
Пример #7
0
		internal protected override void MousePressed (MarginMouseEventArgs args)
		{
			base.MousePressed (args);

			DocumentLine lineSegment = args.LineSegment;
			if (lineSegment != null) {
				foreach (TextLineMarker marker in lineSegment.Markers) {
					var marginMarker = marker as MarginMarker;
					if (marginMarker != null) 
						marginMarker.InformMousePress (editor, this, args);
				}
			}
		}
Пример #8
0
		public override void InformMouseHover (MonoTextEditor editor, Margin margin, MarginMouseEventArgs args)
		{
			base.InformMouseHover (editor, margin, args);
			if (!string.IsNullOrEmpty (Tooltip)) {
				if (CanDrawForeground (margin))
					// update tooltip during the next ui loop run,
					// otherwise Gtk will not update the position of the tooltip
					Gtk.Application.Invoke (delegate {
						args.Editor.TooltipText = Tooltip;
					});
				else if (args.Editor.TooltipText == Tooltip)
					args.Editor.TooltipText = null;
			}
		}
Пример #9
0
		internal protected override void MousePressed (MarginMouseEventArgs args)
		{
			base.MousePressed (args);
			
			DocumentLine lineSegment = args.LineSegment;
			if (lineSegment != null) {
				foreach (TextLineMarker marker in lineSegment.Markers) {
					var marginMarker = marker as MarginMarker;
					if (marginMarker != null) 
						marginMarker.InformMousePress (editor, this, args);

#pragma warning disable 618
					if (marker is IIconBarMarker) 
						((IIconBarMarker)marker).MousePress (args);
#pragma warning restore 618
				}
			}
		}
Пример #10
0
        internal protected override void MousePressed(MarginMouseEventArgs args)
        {
            base.MousePressed(args);

            DocumentLine lineSegment = args.LineSegment;

            if (lineSegment != null)
            {
                foreach (TextLineMarker marker in editor.Document.GetMarkers(lineSegment))
                {
                    var marginMarker = marker as MarginMarker;
                    if (marginMarker != null)
                    {
                        marginMarker.InformMousePress(editor, this, args);
                    }
                }
            }
        }
Пример #11
0
        internal protected override void MouseHover(MarginMouseEventArgs args)
        {
            base.MouseHover(args);
            args.Editor.TooltipText = null;
            DocumentLine lineSegment = args.LineSegment;

            if (lineSegment != null)
            {
                foreach (TextLineMarker marker in lineSegment.Markers)
                {
                    var marginMarker = marker as MarginMarker;
                    if (marginMarker != null)
                    {
                        marginMarker.InformMouseHover(editor, this, args);
                    }
                }
            }
        }
Пример #12
0
        internal protected override void MousePressed(MarginMouseEventArgs args)
        {
            base.MousePressed(args);

            if (args.Button != PointerButton.Left || args.LineNumber < DocumentLocation.MinLine)
            {
                return;
            }
            editor.LockedMargin = this;
            int  lineNumber      = args.LineNumber;
            bool extendSelection = (args.ModifierState & ModifierKeys.Shift) == ModifierKeys.Shift;

            if (lineNumber <= editor.Document.LineCount)
            {
                DocumentLocation loc  = new DocumentLocation(lineNumber, DocumentLocation.MinColumn);
                DocumentLine     line = args.LineSegment;
                if (args.RawEvent.MultiplePress == 2)
                {
                    if (line != null)
                    {
                        editor.MainSelection = new Selection(loc, GetLineEndLocation(editor.GetTextEditorData(), lineNumber));
                    }
                }
                else if (extendSelection)
                {
                    if (!editor.IsSomethingSelected)
                    {
                        editor.MainSelection = new Selection(loc, loc);
                    }
                    else
                    {
                        editor.MainSelection = editor.MainSelection.WithLead(loc);
                    }
                }
                else
                {
                    anchorLocation = loc;
                    editor.ClearSelection();
                }
                editor.Caret.PreserveSelection = true;
                editor.Caret.Location          = loc;
                editor.Caret.PreserveSelection = false;
            }
        }
Пример #13
0
        internal protected override void MouseHover(MarginMouseEventArgs args)
        {
            base.MouseHover(args);

            LineSegment lineSegment = null;

            if (args.LineSegment != null)
            {
                lineSegment = args.LineSegment;
                if (lineHover != lineSegment)
                {
                    lineHover = lineSegment;
                    editor.RedrawMargin(this);
                }
            }
            lineHover = lineSegment;
            bool found = false;

            foreach (FoldSegment segment in editor.Document.GetFoldingContaining(lineSegment))
            {
                if (segment.StartLine.Offset == lineSegment.Offset)
                {
                    found = true;
                    break;
                }
            }
            StopTimer();
            if (found)
            {
                foldings = editor.Document.GetFoldingContaining(lineSegment);
                if (editor.TextViewMargin.BackgroundRenderer == null)
                {
                    timerId = GLib.Timeout.Add(150, SetBackgroundRenderer);
                }
                else
                {
                    SetBackgroundRenderer();
                }
            }
            else
            {
                RemoveBackgroundRenderer();
            }
        }
Пример #14
0
        internal protected override void MousePressed(MarginMouseEventArgs args)
        {
            base.MousePressed(args);

            if (args.Button != 1 || args.LineNumber < DocumentLocation.MinLine)
            {
                return;
            }
            editor.LockedMargin = this;
            int  lineNumber      = args.LineNumber;
            bool extendSelection = (args.ModifierState & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask;

            if (lineNumber <= editor.Document.LineCount)
            {
                DocumentLocation loc  = new DocumentLocation(lineNumber, DocumentLocation.MinColumn);
                DocumentLine     line = args.LineSegment;
                if (args.Type == EventType.TwoButtonPress)
                {
                    if (line != null)
                    {
                        editor.MainSelection = new MonoDevelop.Ide.Editor.Selection(loc, GetLineEndLocation(editor.GetTextEditorData(), lineNumber));
                    }
                }
                else if (extendSelection)
                {
                    if (!editor.IsSomethingSelected)
                    {
                        editor.MainSelection = new MonoDevelop.Ide.Editor.Selection(loc, loc);
                    }
                    else
                    {
                        editor.MainSelection = editor.MainSelection.WithLead(loc);
                    }
                }
                else
                {
                    anchorLocation = loc;
                    editor.ClearSelection();
                }
                editor.Caret.PreserveSelection = true;
                editor.Caret.Location          = loc;
                editor.Caret.PreserveSelection = false;
            }
        }
Пример #15
0
		void IActionTextLineMarker.MouseHover (Mono.TextEditor.MonoTextEditor editor, MarginMouseEventArgs args, TextLineMarkerHoverResult result)
		{
			if (args.Button != 0)
				return;
			var line = editor.GetLine (loc.Line);
			if (line == null)
				return;
			var x = editor.ColumnToX (line, loc.Column) - editor.HAdjustment.Value + editor.TextViewMargin.TextStartPosition;
			//var y = editor.LineToY (line.LineNumber + 1) - editor.VAdjustment.Value;
			const double xAdditionalSpace = tagMarkerWidth;
			if (args.X - x >= -xAdditionalSpace * editor.Options.Zoom && 
				args.X - x < (tagMarkerWidth + xAdditionalSpace) * editor.Options.Zoom /*&& 
				    args.Y - y < (editor.LineHeight / 2) * editor.Options.Zoom*/) {
				result.Cursor = null;
				ShowPopup?.Invoke (null, null);
			} else {
				CancelPopup?.Invoke (null, null);
			}
		}
Пример #16
0
        internal protected override void MouseHover(MarginMouseEventArgs args)
        {
            base.MouseHover(args);

            DocumentLine lineSegment = null;

            if (args.LineSegment != null)
            {
                lineSegment = args.LineSegment;
                if (lineHover != lineSegment)
                {
                    lineHover = lineSegment;
                    editor.RedrawMargin(this);
                }
            }
            lineHover = lineSegment;

            hoverSegment = GetSelectedSegment(args.LineNumber);
            bool found = hoverSegment != null;

            StopTimer();
            if (found)
            {
                var list = new List <FoldSegment>(editor.Document.GetFoldingContaining(lineSegment));
                list.Sort((x, y) => x.Offset.CompareTo(y.Offset));
                foldings = list;
                if (editor.TextViewMargin.BackgroundRenderer == null)
                {
                    timerId = GLib.Timeout.Add(150, SetBackgroundRenderer);
                }
                else
                {
                    SetBackgroundRenderer();
                }
            }
            else
            {
                RemoveBackgroundRenderer();
            }
        }
Пример #17
0
        internal protected override void MouseReleased(MarginMouseEventArgs args)
        {
            base.MouseReleased(args);

            DocumentLine lineSegment = args.LineSegment;

            if (lineSegment != null)
            {
                foreach (TextLineMarker marker in lineSegment.Markers)
                {
                    var marginMarker = marker as MarginMarker;
                    if (marginMarker != null)
                    {
                        marginMarker.InformMouseRelease(editor, this, args);
                    }

                    if (marker is IIconBarMarker)
                    {
                        ((IIconBarMarker)marker).MouseRelease(args);
                    }
                }
            }
        }
Пример #18
0
		protected internal override void MouseReleased (MarginMouseEventArgs args)
		{
			if (args.Button != 2 && !InSelectionDrag)
				textEditor.ClearSelection ();
			InSelectionDrag = false;
			if (inDrag)
				Caret.Location = clickLocation;
			base.MouseReleased (args);
		}
Пример #19
0
		protected internal override void MouseReleased (MarginMouseEventArgs args)
		{
			if (args.Button != 2 && !InSelectionDrag)
				textEditor.ClearSelection ();

			DocumentLine line = Document.GetLine (clickLocation.Line);
			bool isHandled = false;
			if (line != null) {
				foreach (TextLineMarker marker in line.Markers) {
					if (marker is IActionTextLineMarker) {
						isHandled |= ((IActionTextLineMarker)marker).MouseReleased(textEditor, args);
						if (isHandled)
							break;
					}
				}
				var locNotSnapped = PointToLocation (args.X, args.Y, snapCharacters: false);
				foreach (var marker in Document.GetTextSegmentMarkersAt (Document.GetOffset (locNotSnapped)).Where (m => m.IsVisible)) {
					if (marker is IActionTextLineMarker) {
						isHandled |= ((IActionTextLineMarker)marker).MouseReleased (textEditor, args);
						if (isHandled)
							break;
					}
				}
			}


			InSelectionDrag = false;
			if (inDrag)
				Caret.Location = clickLocation;
			base.MouseReleased (args);
		}
Пример #20
0
		protected internal override void MousePressed (MarginMouseEventArgs args)
		{
			base.MousePressed (args);
			
			if (args.TriggersContextMenu ())
				return;
			
			InSelectionDrag = false;
			inDrag = false;
			Selection selection = textEditor.MainSelection;
			int oldOffset = textEditor.Caret.Offset;

			string link = GetLink != null ? GetLink (args) : null;
			if (!String.IsNullOrEmpty (link)) {
				textEditor.FireLinkEvent (link, args.Button, args.ModifierState);
				return;
			}

			if (args.Button == 1) {
				if (!CalculateClickLocation (args.X, args.Y, out clickLocation))
					return;

				DocumentLine line = Document.GetLine (clickLocation.Line);
				bool isHandled = false;
				if (line != null) {
					foreach (TextLineMarker marker in line.Markers) {
						if (marker is IActionTextLineMarker) {
							isHandled |= ((IActionTextLineMarker)marker).MousePressed (textEditor, args);
							if (isHandled)
								break;
						}
					}
					foreach (var marker in Document.GetTextSegmentMarkersAt (line).Where (m => m.IsVisible)) {
						if (marker is IActionTextLineMarker) {
							isHandled |= ((IActionTextLineMarker)marker).MousePressed (textEditor, args);
							if (isHandled)
								break;
						}
					}
				}
				if (isHandled)
					return;

				int offset = Document.LocationToOffset (clickLocation);
				if (offset < 0) {
					textEditor.RunAction (CaretMoveActions.ToDocumentEnd);
					return;
				}
				if (args.Button == 2 && !selection.IsEmpty && selection.Contains (Document.OffsetToLocation (offset))) {
					textEditor.ClearSelection ();
					return;
				}

				if (args.Type == EventType.TwoButtonPress) {
					var data = textEditor.GetTextEditorData ();
					mouseWordStart = data.FindCurrentWordStart (offset);
					mouseWordEnd = data.FindCurrentWordEnd (offset);
					Caret.Offset = mouseWordEnd;
					textEditor.MainSelection = new Selection (textEditor.Document.OffsetToLocation (mouseWordStart), textEditor.Document.OffsetToLocation (mouseWordEnd));
					InSelectionDrag = true;
					mouseSelectionMode = MouseSelectionMode.Word;

					// folding marker
					int lineNr = args.LineNumber;
					foreach (var shownFolding in GetFoldRectangles (lineNr)) {
						if (shownFolding.Item1.Contains ((int)(args.X + this.XOffset), (int)args.Y)) {
							shownFolding.Item2.IsFolded = false;
							return;
						}
					}
					return;
				} else if (args.Type == EventType.ThreeButtonPress) {
					int lineNr = Document.OffsetToLineNumber (offset);
					textEditor.SetSelectLines (lineNr, lineNr);

					var range = textEditor.SelectionRange;
					mouseWordStart = range.Offset;
					mouseWordEnd = range.EndOffset;

					InSelectionDrag = true;
					mouseSelectionMode = MouseSelectionMode.WholeLine;
					return;
				}
				mouseSelectionMode = MouseSelectionMode.SingleChar;

				if (textEditor.IsSomethingSelected && textEditor.SelectionRange.Offset <= offset && offset < textEditor.SelectionRange.EndOffset && clickLocation != textEditor.Caret.Location) {
					inDrag = true;
				} else {
					if ((args.ModifierState & Gdk.ModifierType.ShiftMask) == ModifierType.ShiftMask) {
						InSelectionDrag = true;
						Caret.PreserveSelection = true;
						if (!textEditor.IsSomethingSelected) {
							textEditor.MainSelection = new Selection (Caret.Location, clickLocation);
							Caret.Location = clickLocation;
						} else {
							Caret.Location = clickLocation;
							textEditor.ExtendSelectionTo (clickLocation);
						}
						Caret.PreserveSelection = false;
					} else {
						textEditor.ClearSelection ();
						Caret.Location = clickLocation;
						InSelectionDrag = true;
						textEditor.SetSelection (clickLocation, clickLocation);
					}
					textEditor.RequestResetCaretBlink ();
				}
			}

			DocumentLocation docLocation = PointToLocation (args.X, args.Y);
			if (docLocation.Line < DocumentLocation.MinLine || docLocation.Column < DocumentLocation.MinColumn)
				return;
			
			// disable middle click on windows.
			if (!Platform.IsWindows && args.Button == 2 && this.textEditor.CanEdit (docLocation.Line)) {
				TextSegment selectionRange = TextSegment.Invalid;
				int offset = Document.LocationToOffset (docLocation);
				if (!selection.IsEmpty)
					selectionRange = selection.GetSelectionRange (this.textEditor.GetTextEditorData ());
				var oldVersion = textEditor.Document.Version;

				bool autoScroll = textEditor.Caret.AutoScrollToCaret;
				textEditor.Caret.AutoScrollToCaret = false;
				if (!selection.IsEmpty && selectionRange.Contains (offset)) {
					textEditor.ClearSelection ();
					textEditor.Caret.Offset = selectionRange.EndOffset;
					return;
				}

				ClipboardActions.PasteFromPrimary (textEditor.GetTextEditorData (), offset);
				textEditor.Caret.Offset = oldOffset;
				if (!selectionRange.IsInvalid)
					textEditor.SelectionRange = new TextSegment (oldVersion.MoveOffsetTo (Document.Version, selectionRange.Offset), selectionRange.Length);

				if (autoScroll)
					textEditor.Caret.ActivateAutoScrollWithoutMove ();
			}
		}
Пример #21
0
		void OnIconButtonPress (object s, MarginMouseEventArgs args)
		{
			if (args.TriggersContextMenu ()) {
				TextEditor.Caret.Line = args.LineNumber;
				TextEditor.Caret.Column = 1;
				IdeApp.CommandService.ShowContextMenu (WorkbenchWindow.ExtensionContext, "/MonoDevelop/SourceEditor2/IconContextMenu/Editor");
			} else if (args.Button == 1) {
				if (!string.IsNullOrEmpty (this.Document.FileName)) {
					if (args.LineSegment != null)
						DebuggingService.Breakpoints.Toggle (this.Document.FileName, args.LineNumber);
				}
			}
		}
Пример #22
0
 public void MouseHover(MarginMouseEventArgs args)
 {
 }
		public bool MousePressed (TextEditor editor, MarginMouseEventArgs args)
		{
			return false;
		}
		internal protected override void MousePressed (MarginMouseEventArgs args)
		{
			base.MousePressed (args);
			
			if (lineHover == null)
				return;
			foreach (FoldSegment segment in editor.Document.GetStartFoldings (lineHover)) {
				segment.IsFolded = !segment.IsFolded; 
			}
			editor.SetAdjustments ();
			editor.Caret.MoveCaretBeforeFoldings ();
			editor.QueueDraw ();
		}
			void IActionTextLineMarker.MouseHover (TextEditor editor, MarginMouseEventArgs args, TextLineMarkerHoverResult result)
			{
				if (args.Button != 0)
					return;
				var line = editor.GetLine (loc.Line);
				if (line == null)
					return;
				var x = editor.ColumnToX (line, loc.Column) - editor.HAdjustment.Value + editor.TextViewMargin.TextStartPosition;
				var y = editor.LineToY (line.LineNumber + 1) - editor.VAdjustment.Value;
				if (args.X - x >= 0 * editor.Options.Zoom && 
				    args.X - x < tagMarkerWidth * editor.Options.Zoom && 
				    args.Y - y < (editor.LineHeight / 2) * editor.Options.Zoom) {
					result.Cursor = null;
					Popup ();
				} else {
					codeActionEditorExtension.CancelSmartTagPopupTimeout ();
				}
			}
Пример #26
0
		public bool MousePressed (TextEditor editor, MarginMouseEventArgs args)
		{
			if (MouseIsOverMarker (editor, args)) {
				CollapseExtendedErrors = !CollapseExtendedErrors;
				editor.QueueDraw ();
				return true;
			}
			MouseIsOverMarker (editor, args);
			return false;
		}
Пример #27
0
		/// <summary>
		/// Informs the margin marker of a mouse hover event.
		/// </summary>
		/// <param name="editor">The text editor in which the event press occured.</param>
		/// <param name="margin">The margin in which the event occured.</param>
		/// <param name="args">The event arguments.</param>
		public virtual void InformMouseHover (TextEditor editor, Margin margin, MarginMouseEventArgs args)
		{
		}
			bool IActionTextLineMarker.MousePressed (TextEditor editor, MarginMouseEventArgs args)
			{
				return false;
			}
Пример #29
0
 /// <summary>
 /// Informs the margin marker of a mouse hover event.
 /// </summary>
 /// <param name="editor">The text editor in which the event press occured.</param>
 /// <param name="margin">The margin in which the event occured.</param>
 /// <param name="args">The event arguments.</param>
 public virtual void InformMouseHover(TextEditor editor, Margin margin, MarginMouseEventArgs args)
 {
 }
Пример #30
0
		public void MousePress (MarginMouseEventArgs args)
		{
		}
Пример #31
0
 public void MousePress(MarginMouseEventArgs args)
 {
 }
Пример #32
0
		protected internal override void MouseHover (MarginMouseEventArgs args)
		{
			var loc = PointToLocation (args.X, args.Y);
			if (loc.Line < DocumentLocation.MinLine || loc.Column < DocumentLocation.MinColumn)
				return;
			var line = Document.GetLine (loc.Line);
			var oldHoveredLine = HoveredLine;
			HoveredLine = line;
			OnHoveredLineChanged (new LineEventArgs (oldHoveredLine));

			var hoverResult = new TextLineMarkerHoverResult ();
			oldMarkers.ForEach (m => m.MouseHover (textEditor, args, hoverResult));

			if (line != null) {
				newMarkers.Clear ();
				newMarkers.AddRange (line.Markers.Where (m => m is IActionTextLineMarker).Cast <IActionTextLineMarker> ());
				var extraMarker = Document.GetExtendingTextMarker (loc.Line) as IActionTextLineMarker;
				if (extraMarker != null && !oldMarkers.Contains (extraMarker))
					newMarkers.Add (extraMarker);
				foreach (var marker in newMarkers.Where (m => !oldMarkers.Contains (m))) {
					marker.MouseHover (textEditor, args, hoverResult);
				}
				oldMarkers.Clear ();
				var tmp = oldMarkers;
				oldMarkers = newMarkers;
				newMarkers = tmp;
				foreach (var marker in Document.GetTextSegmentMarkersAt (line).Where (m => m.IsVisible)) {
					if (marker is IActionTextLineMarker) {
						((IActionTextLineMarker)marker).MouseHover (textEditor, args, hoverResult);
					}
				}
			} else {
				oldMarkers.Clear ();
			}
			base.cursor = hoverResult.HasCursor ? hoverResult.Cursor : xtermCursor;
			if (textEditor.TooltipMarkup != hoverResult.TooltipMarkup) {
				textEditor.TooltipMarkup = null;
				textEditor.TriggerTooltipQuery ();
			}
			if (!textEditor.GetTextEditorData ().SuppressTooltips)
				textEditor.TooltipMarkup = hoverResult.TooltipMarkup;
			if (args.Button != 1 && args.Y >= 0 && args.Y <= this.textEditor.Allocation.Height) {
				// folding marker
				int lineNr = args.LineNumber;
				foreach (var shownFolding in GetFoldRectangles (lineNr)) {
					if (shownFolding.Item1.Contains ((int)(args.X + this.XOffset), (int)args.Y)) {
						ShowTooltip (shownFolding.Item2.Segment, shownFolding.Item1);
						return;
					}
				}

				ShowTooltip (TextSegment.Invalid, Gdk.Rectangle.Zero);
				string link = GetLink != null ? GetLink (args) : null;

				if (!String.IsNullOrEmpty (link)) {
					base.cursor = textLinkCursor;
				} else {
					base.cursor = hoverResult.HasCursor ? hoverResult.Cursor : xtermCursor;
				}
				return;
			}

			if (inDrag)
				return;
			Caret.PreserveSelection = true;

			switch (this.mouseSelectionMode) {
			case MouseSelectionMode.SingleChar:
				if (loc.Line != Caret.Line || !textEditor.GetTextEditorData ().IsCaretInVirtualLocation) {
					if (!InSelectionDrag) {
						textEditor.SetSelection (loc, loc);
					} else {
						textEditor.ExtendSelectionTo (loc);
					}
					Caret.Location = loc;
				}
				break;
			case MouseSelectionMode.Word:
				if (loc.Line != Caret.Line || !textEditor.GetTextEditorData ().IsCaretInVirtualLocation) {
					int offset = textEditor.Document.LocationToOffset (loc);
					int start;
					int end;
//					var data = textEditor.GetTextEditorData ();
					if (offset < textEditor.SelectionAnchor) {
						start = ScanWord (Document, offset, false);
						end = ScanWord (Document,  textEditor.SelectionAnchor, true);
						Caret.Offset = start;
					} else {
						start = ScanWord (Document, textEditor.SelectionAnchor, false);
						end = ScanWord (Document, offset, true);
						Caret.Offset = end;
					}
					if (!textEditor.MainSelection.IsEmpty) {
						if (Caret.Offset < mouseWordStart) {
							textEditor.MainSelection = new Selection (Document.OffsetToLocation (mouseWordEnd), Caret.Location, textEditor.MainSelection.SelectionMode);
						} else {
							textEditor.MainSelection = new Selection (Document.OffsetToLocation (mouseWordStart), Caret.Location, textEditor.MainSelection.SelectionMode);
						}
					}
				}
				break;
			case MouseSelectionMode.WholeLine:
				//textEditor.SetSelectLines (loc.Line, textEditor.MainSelection.Anchor.Line);
				DocumentLine line1 = textEditor.Document.GetLine (loc.Line);
				DocumentLine line2 = textEditor.Document.GetLineByOffset (textEditor.SelectionAnchor);
				var o2 = line1.Offset < line2.Offset ? line1.Offset : line1.EndOffsetIncludingDelimiter;
				Caret.Offset = o2;
				if (!textEditor.MainSelection.IsEmpty) {
					if (mouseWordStart < o2) {
						textEditor.MainSelection = new Selection (textEditor.OffsetToLocation (mouseWordStart), Caret.Location, textEditor.MainSelection.SelectionMode);
					} else {
						textEditor.MainSelection = new Selection (textEditor.OffsetToLocation (mouseWordEnd), Caret.Location, textEditor.MainSelection.SelectionMode);
					}
				}

				break;
			}
			Caret.PreserveSelection = false;

			//HACK: use cmd as Mac block select modifier because GTK currently makes it impossible to access alt/mod1
			//NOTE: Mac cmd seems to be mapped as ControlMask from mouse events on older GTK, mod1 on newer
			var blockSelModifier = !Platform.IsMac ? ModifierType.Mod1Mask
				: (ModifierType.ControlMask | ModifierType.Mod1Mask);

			//NOTE: also allow super for block select on X11 because most window managers use the alt modifier already
			if (Platform.IsX11)
				blockSelModifier |= (ModifierType.SuperMask | ModifierType.Mod4Mask);

			if ((args.ModifierState & blockSelModifier) != 0) {
				textEditor.SelectionMode = SelectionMode.Block;
			} else {
				if (textEditor.SelectionMode == SelectionMode.Block)
					Document.CommitMultipleLineUpdate (textEditor.MainSelection.MinLine, textEditor.MainSelection.MaxLine);
				textEditor.SelectionMode = SelectionMode.Normal;
			}
			InSelectionDrag = true;
			base.MouseHover (args);

		}
Пример #33
0
		bool MouseIsOverMarker (TextEditor editor, MarginMouseEventArgs args)
		{
			int ew = 0, eh = 0;
			int lineNumber = editor.Document.OffsetToLineNumber (lineSegment.Offset);
			double y = editor.LineToY (lineNumber) - editor.VAdjustment.Value;
			if (fitsInSameLine) {
				if (args.Y < y + 2 || args.Y > y + editor.LineHeight - 2)
					return false;
			} else {
				if (args.Y < y + editor.LineHeight + 2 || args.Y > y + editor.LineHeight * 2 - 2)
					return false;
			}
			
			if (errors.Count > 1 && errorCountLayout != null) {
				errorCountLayout.GetPixelSize (out ew, out eh);
				int errorCounterWidth = ew + 10;
				if (editor.Allocation.Width - args.X - editor.TextViewMargin.XOffset <= errorCounterWidth)
					return true;
			}
			return false;
		}
Пример #34
0
 /// <summary>
 /// Informs the margin marker of a mouse release event.
 /// </summary>
 /// <param name="editor">The text editor in which the event press occurred.</param>
 /// <param name="margin">The margin in which the event occurred.</param>
 /// <param name="args">The event arguments.</param>
 public virtual void InformMouseRelease(MonoTextEditor editor, Margin margin, MarginMouseEventArgs args)
 {
 }
Пример #35
0
		int MouseIsOverError (TextEditor editor, MarginMouseEventArgs args)
		{
			if (layouts == null)
				return -1;
			int lineNumber = editor.Document.OffsetToLineNumber (lineSegment.Offset);
			double y = editor.LineToY (lineNumber) - editor.VAdjustment.Value;
			double height = editor.LineHeight * errors.Count;
			if (!fitsInSameLine)
				y += editor.LineHeight;
//			Console.WriteLine (lineNumber +  ": height={0}, y={1}, args={2}", height, y, args.Y);
			if (y > args.Y || args.Y > y + height)
				return -1;
			int error = (int)((args.Y - y) / editor.LineHeight);
//			Console.WriteLine ("error:" + error);
			if (error >= layouts.Count)
				return -1;
			int errorCounterWidth = 0;
			
			int ew = 0, eh = 0;
			if (error == 0 && errors.Count > 1 && errorCountLayout != null) {
				errorCountLayout.GetPixelSize (out ew, out eh);
				errorCounterWidth = ew + 10;
			}
			
			double labelWidth = LayoutWidth + border + (ShowIconsInBubble ? errorPixbuf.Width : 0) + errorCounterWidth + editor.LineHeight / 2;
			
			if (editor.Allocation.Width - editor.TextViewMargin.XOffset - args.X < labelWidth)
				return error;
			
			return -1;
		}
		public void MouseHover (TextEditor editor, MarginMouseEventArgs args, TextLineMarkerHoverResult result)
		{
			if (!IsVisible)
				return;
			if (LineSegment == null)
				return;
			if (bubbleDrawX < args.X && args.X < bubbleDrawX + bubbleWidth) {
				editor.HideTooltip ();
				result.Cursor = null;
				cache.StartHover (this, bubbleDrawX, bubbleDrawY, bubbleWidth, bubbleIsReduced);
			}
		}
Пример #37
0
		public void MouseHover (TextEditor editor, MarginMouseEventArgs args, TextMarkerHoverResult result)
		{
			bool isOver = MouseIsOverMarker (editor, args);
			if (isOver != oldIsOver)
				editor.Document.CommitLineUpdate (this.LineSegment);
			oldIsOver = isOver;
			
			int errorNumber = MouseIsOverError (editor, args);
			if (errorNumber >= 0) {
				result.Cursor = arrowCursor;
				if (!isOver)
					// don't show tooltip when hovering over error counter layout.
					result.TooltipMarkup = GLib.Markup.EscapeText (errors[errorNumber].ErrorMessage);
			}
			
		}
		internal protected override void MouseHover (MarginMouseEventArgs args)
		{
			base.MouseHover (args);
			
			LineSegment lineSegment = null;
			if (args.LineSegment != null) {
				lineSegment = args.LineSegment;
				if (lineHover != lineSegment) {
					lineHover = lineSegment;
					editor.RedrawMargin (this);
				}
			} 
			lineHover = lineSegment;
			bool found = false;
			foreach (FoldSegment segment in editor.Document.GetFoldingContaining (lineSegment)) {
				if (segment.StartLine.Offset == lineSegment.Offset) {
					found = true;
					break;
				}
			}
			
			delayTimer.Stop ();
			if (found) {
				foldings = editor.Document.GetFoldingContaining (lineSegment);
				if (editor.TextViewMargin.BackgroundRenderer == null) {
					delayTimer.Start ();
				} else {
					DelayTimerElapsed (this, null);
				}
			} else {
				RemoveBackgroundRenderer ();
			}
		}
Пример #39
0
 internal protected override void MouseReleased(MarginMouseEventArgs args)
 {
     editor.LockedMargin = null;
     base.MouseReleased(args);
 }
Пример #40
0
		public void MouseHover (MarginMouseEventArgs args)
		{
		}
Пример #41
0
 public void MouseRelease(MarginMouseEventArgs args)
 {
 }
Пример #42
0
		public void MouseRelease (MarginMouseEventArgs args)
		{
		}
			void IActionTextLineMarker.MouseHover (TextEditor editor, MarginMouseEventArgs args, TextLineMarkerHoverResult result)
			{
				if (args.Button != 0)
					return;
				var line = editor.GetLine (loc.Line);
				var x = editor.ColumnToX (line, loc.Column) - editor.HAdjustment.Value;
				var y = editor.LineToY (line.LineNumber) - editor.VAdjustment.Value;
				if (args.X - x >= 0 * editor.Options.Zoom && 
				    args.X - x < tagMarkerWidth * editor.Options.Zoom && 
				    y - args.Y < (tagMarkerHeight) * editor.Options.Zoom) {
					result.Cursor = arrowCursor;
					Popup ();
				} else {
					codeActionEditorExtension.CancelSmartTagPopupTimeout ();
				}
			}