private void OnIsVisibleChanged(bool nowVisible) #pragma warning restore IDE0051 // Remove unused private members { if (nowVisible) { EnsureContentCreated(); } else { if (this.Subviews.Length > 0) { this.Subviews[0].RemoveFromSuperview(); } _createdView.Close(); _createdView = null; // If a projection buffer has a source span from another buffer, the projection buffer is held alive by the other buffer too. // This means that a one-off projection buffer created for a tooltip would be kept alive as long as the underlying file // is still open. Removing the source spans from the projection buffer ensures the projection buffer can be GC'ed. if (_createdTextBuffer is IProjectionBuffer projectionBuffer) { projectionBuffer.DeleteSpans(0, projectionBuffer.CurrentSnapshot.SpanCount); } _createdTextBuffer = null; } }
public PinnedWatchAdornmentManager(ICocoaViewFactory cocoaViewFactory, ICocoaTextView textView) { path = textView.TextBuffer.GetFilePathOrNull(); if (path == null) { return; } DebuggingService.PinnedWatches.WatchAdded += OnWatchAdded; DebuggingService.PinnedWatches.WatchChanged += OnWatchChanged; DebuggingService.PinnedWatches.WatchRemoved += OnWatchRemoved; DebuggingService.DebugSessionStarted += OnDebugSessionStarted; DebuggingService.StoppedEvent += OnDebuggingSessionStopped; this.layer = textView.GetXPlatAdornmentLayer("PinnedWatch"); this.cocoaViewFactory = cocoaViewFactory; this.textView = textView; //this.textView.LayoutChanged += OnTextViewLayoutChanged; if (DebuggingService.IsDebugging) { RenderAllAdornments(); debugging = true; } }
internal LineNumbersCalculator(ICocoaTextView textView, IVimLocalSettings localSettings) { _textView = textView ?? throw new ArgumentNullException(nameof(textView)); _localSettings = localSettings ?? throw new ArgumentNullException(nameof(localSettings)); }
private void EnsureContentCreated() { if (this.Subviews.Length == 0) { EnsureBufferCreated(); _createdView = _createView(_createdTextBuffer); this.AddSubview(_createdView.VisualElement); } }
public MdMouseProcessor( IEditorCommandHandlerService commandServiceFactory, ICocoaTextView textView) { this.commandServiceFactory = commandServiceFactory ?? throw new ArgumentNullException(nameof(commandServiceFactory)); this.textView = textView ?? throw new ArgumentNullException(nameof(textView)); }
CGPoint GetMouseLocationInTextView(MouseEvent e) { ICocoaTextView textView = textViewHost.TextView; var pt = textView.VisualElement.ConvertPointFromView(e.Event.LocationInWindow, null); pt.Y += (nfloat)textView.ViewportTop; pt.X += (nfloat)textView.ViewportLeft; return(pt); }
public KeyProcessor GetAssociatedProcessor(ICocoaTextView cocoaTextView) { if (!_vim.VimHost.ShouldCreateVimBuffer(cocoaTextView)) { return(null); } var vimTextBuffer = _vim.GetOrCreateVimBuffer(cocoaTextView); return(new VimKeyProcessor(vimTextBuffer, _keyUtil, _completionBroker, _signatureHelpBroker, _inlineRenameListenerFactory)); }
public void ZoomTo(ITextView textView, double zoomLevel) { if (textView is null) { throw new ArgumentNullException(nameof(textView)); } ICocoaTextView cocoaTextView = textView as ICocoaTextView; if (cocoaTextView != null && cocoaTextView.Roles.Contains(PredefinedTextViewRoles.Zoomable)) { cocoaTextView.Options.GlobalOptions.SetOptionValue(DefaultTextViewOptions.ZoomLevelId, zoomLevel); } }
/// <summary> /// Constructs a <see cref="DropHandlerBase"/>. /// </summary> /// <param name="cocoaTextView">The <see cref="ICocoaTextView"/> over which this drop handler operates on.</param> /// <param name="editorOperations">The <see cref="IEditorOperations"/> used to insert text into the editor.</param> protected DropHandlerBase(ICocoaTextView cocoaTextView, IEditorOperations editorOperations) { if (cocoaTextView == null) { throw new System.ArgumentNullException(nameof(cocoaTextView)); } if (editorOperations == null) { throw new System.ArgumentNullException(nameof(editorOperations)); } _cocoaTextView = cocoaTextView; _editorOperations = editorOperations; }
ITextViewLine GetTextViewLine(double y) { ICocoaTextView textView = textViewHost.TextView; // Establish line for point ITextViewLine textViewLine = textView.TextViewLines.GetTextViewLineContainingYCoordinate(y); if (textViewLine == null) { textViewLine = y <= textView.TextViewLines [0].Top ? textView.TextViewLines.FirstVisibleLine : textView.TextViewLines.LastVisibleLine; } return(textViewLine); }
/// <summary> /// Creates a default Line Number Provider for a Text Editor /// </summary> /// <param name="textView"> /// The Text Editor with which this line number provider is associated /// </param> /// <param name="classificationFormatMap">Used for getting/setting the format of the line number classification</param> /// <param name="classificationTypeRegistry">Used for retrieving the "line number" classification</param> public RelativeLineNumbersMargin( ICocoaTextView textView, ICocoaClassificationFormatMap classificationFormatMap, IClassificationTypeRegistryService classificationTypeRegistry, IVimLocalSettings vimLocalSettings) { _textView = textView; _classificationFormatMap = classificationFormatMap; _classificationTypeRegistry = classificationTypeRegistry; _translatedCanvas = this; _oldViewportTop = 0.0; _lineNumbersCalculator = new LineNumbersCalculator(textView, vimLocalSettings); _localSettings = vimLocalSettings; WantsLayer = true; Hidden = false; }
public void ZoomOut(ITextView textView) { if (textView is null) { throw new ArgumentNullException(nameof(textView)); } ICocoaTextView cocoaTextView = textView as ICocoaTextView; if (cocoaTextView != null && cocoaTextView.Roles.Contains(PredefinedTextViewRoles.Zoomable)) { double zoomLevel = cocoaTextView.ZoomLevel / ZoomConstants.ScalingFactor; if (zoomLevel > ZoomConstants.MinZoom || Math.Abs(zoomLevel - ZoomConstants.MinZoom) < 0.00001) { cocoaTextView.Options.GlobalOptions.SetOptionValue(DefaultTextViewOptions.ZoomLevelId, zoomLevel); } } }
public static void MoveCaretToPosition(this ICocoaTextView textView, NSEvent theEvent) { var mousePosition = GetViewRelativeMousePosition(textView, theEvent); mousePosition.X += (nfloat)textView.ViewportLeft; mousePosition.Y += (nfloat)textView.ViewportTop; // Set the caret at the closest mouse location (if there is no selection surrounding the clicked location) ITextViewLine textViewLine = textView.TextViewLines.GetTextViewLineContainingYCoordinate(mousePosition.Y); if (textViewLine != null) { VirtualSnapshotPoint clickedBufferPosition = textViewLine.GetInsertionBufferPositionFromXCoordinate(mousePosition.X); // What we're trying to determine is: if the caret were to be placed by this // click, would it still be inside the current selection? bool insideSelection; // If neither virtual space is enabled nor the selection mode is box, check the non-virtual buffer point if (!(textView.Options.GetOptionValue(DefaultTextViewOptions.UseVirtualSpaceId) || (textView.Selection.Mode == TextSelectionMode.Box))) { SnapshotPoint nonVirtualPoint = clickedBufferPosition.Position; insideSelection = textView.Selection.SelectedSpans.Any(selectionSpan => selectionSpan.Contains(nonVirtualPoint)); } else { insideSelection = textView.Selection.VirtualSelectedSpans.Any(selectionSpan => selectionSpan.Contains(clickedBufferPosition)); } // If this is outside of the selection, move the caret. if (!insideSelection) { textView.Caret.MoveTo(textViewLine, mousePosition.X); textView.Selection.Clear(); textView.Caret.EnsureVisible(); } } else { textView.Caret.MoveTo(new SnapshotPoint(textView.TextSnapshot, textView.TextSnapshot.Length)); } }
public BraceCompletionAdornmentService(ITextView textView, IEditorFormatMap editorFormatMap) { _textView = (ICocoaTextView)textView; _editorFormatMap = editorFormatMap; if (_textView == null) { throw new ArgumentNullException(nameof(textView)); } if (_editorFormatMap == null) { throw new ArgumentNullException(nameof(editorFormatMap)); } _adornmentLayer = _textView.GetXPlatAdornmentLayer(PredefinedAdornmentLayers.BraceCompletion); SetBrush(); RegisterEvents(); }
public ExceptionCaughtAdornmentManager(ICocoaViewFactory cocoaViewFactory, ICocoaTextView textView) { filePath = textView.TextBuffer.GetFilePathOrNull(); if (filePath == null) { return; } IdeServices.TextEditorService.FileExtensionAdded += FileExtensionAdded; IdeServices.TextEditorService.FileExtensionRemoved += FileExtensionRemoved; _exceptionCaughtLayer = textView.GetXPlatAdornmentLayer("ExceptionCaught"); this.cocoaViewFactory = cocoaViewFactory; this.textView = textView; this.textView.LayoutChanged += TextView_LayoutChanged; foreach (var ext in IdeServices.TextEditorService.GetFileExtensions(filePath)) { FileExtensionAdded(null, new FileExtensionEventArgs { Extension = ext }); } }
public void TextViewCreated(ICocoaTextView textView) { var manager = new PinnedWatchAdornmentManager(cocoaViewFactory, textView); textView.Closed += (s, e) => manager.Dispose(); }
public void TextViewCreated(ICocoaTextView textView) { var manager = new ExceptionCaughtAdornmentManager(cocoaViewFactory, textView); textView.Closed += (s, e) => manager.Dispose(); }
public static CGPoint GetViewRelativeMousePosition(this ICocoaTextView textView, NSEvent theEvent) => textView.VisualElement.ConvertPointFromView(theEvent.LocationInWindow, null);
public MacDebuggerObjectNameView(MacObjectValueTreeView treeView) : base(treeView, "name") { ImageView = new NSImageView { TranslatesAutoresizingMaskIntoConstraints = false }; TextField = new MacDebuggerTextField(this) { TranslatesAutoresizingMaskIntoConstraints = false, LineBreakMode = NSLineBreakMode.Clipping, MaximumNumberOfLines = 1, DrawsBackground = false, Bordered = false, Editable = false }; AddSubview(ImageView); AddSubview(TextField); AddNewExpressionButton = new NSButton { TranslatesAutoresizingMaskIntoConstraints = false, AccessibilityTitle = GettextCatalog.GetString("Add item to watch"), Image = GetImage("gtk-add", Gtk.IconSize.Menu), BezelStyle = NSBezelStyle.Inline, Bordered = false }; AddNewExpressionButton.Activated += OnAddNewExpressionButtonClicked; PreviewButton = new NSButton { TranslatesAutoresizingMaskIntoConstraints = false, AccessibilityTitle = GettextCatalog.GetString("Open Preview Visualizer"), Image = GetImage("md-empty", Gtk.IconSize.Menu), BezelStyle = NSBezelStyle.Inline, Bordered = false }; PreviewButton.Activated += OnPreviewButtonClicked; var contentTypeRegistry = CompositionManager.Instance.GetExportedValue <IContentTypeRegistryService> (); textBufferFactory = CompositionManager.Instance.GetExportedValue <ITextBufferFactoryService> (); var factory = CompositionManager.Instance.GetExportedValue <ICocoaTextEditorFactoryService> (); contentType = contentTypeRegistry.GetContentType(DebuggerCompletion.ContentType); var editorFormatMapService = CompositionManager.Instance.GetExportedValue <IEditorFormatMapService> (); var appearanceCategory = Guid.NewGuid().ToString(); var editorFormat = editorFormatMapService.GetEditorFormatMap(appearanceCategory); var resourceDictionary = editorFormat.GetProperties("Plain Text"); resourceDictionary [ClassificationFormatDefinition.TypefaceId] = TextField.Font; resourceDictionary [ClassificationFormatDefinition.FontRenderingSizeId] = TextField.Font.PointSize - 1; editorFormat.SetProperties("Plain Text", resourceDictionary); var textBuffer = textBufferFactory.CreateTextBuffer("", contentType); editor = factory.CreateTextView(textBuffer); editor.Options.SetOptionValue(DefaultTextViewOptions.UseVisibleWhitespaceId, false); editor.Options.SetOptionValue(DefaultTextViewOptions.AppearanceCategory, appearanceCategory); editor.VisualElement.TranslatesAutoresizingMaskIntoConstraints = false; editorTextView = new NSView { TranslatesAutoresizingMaskIntoConstraints = false, WantsLayer = true }; editorTextView.Layer.BackgroundColor = NSColor.White.CGColor; editorTextView.AddSubview(editor.VisualElement); editor.VisualElement.TopAnchor.ConstraintEqualToAnchor(editorTextView.TopAnchor).Active = true; editor.VisualElement.LeftAnchor.ConstraintEqualToAnchor(editorTextView.LeftAnchor).Active = true; editor.VisualElement.RightAnchor.ConstraintEqualToAnchor(editorTextView.RightAnchor).Active = true; editor.VisualElement.BottomAnchor.ConstraintEqualToAnchor(editorTextView.BottomAnchor).Active = true; editor.LostAggregateFocus += OnEditorLostFocus; }
public IGlyphFactory GetGlyphFactory(ICocoaTextView view, ICocoaTextViewMargin margin) { return(new ImageSourceGlyphFactory <ReturnStatementGlyphTag> (imageId, imageService)); }
public EvenOddMargin(ICocoaTextView textView) { this.textView = textView; this.textView.LayoutChanged += OnTextViewLayoutChanged; }
public ICocoaMouseProcessor GetAssociatedProcessor(ICocoaTextView cocoaTextView) => new MdMouseProcessor( CommandServiceFactory.GetService(cocoaTextView), cocoaTextView);
public IGlyphFactory GetGlyphFactory(ICocoaTextView view, ICocoaTextViewMargin margin) { return(new ImageSourceGlyphFactory <BreakpointDisabledGlyphTag> (imageId, imageService)); }
public MonoDevelopToolBoxDropHandler(ICocoaTextView cocoaTextView) { this.cocoaTextView = cocoaTextView; }
public IGlyphFactory GetGlyphFactory(ICocoaTextView view, ICocoaTextViewMargin margin) { return(new ImageSourceGlyphFactory <TracepointInvalidGlyphTag> (imageId, imageService)); }
public IDropHandler GetAssociatedDropHandler(ICocoaTextView cocoaTextView) { return(new MonoDevelopToolBoxDropHandler(cocoaTextView)); }