Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vs-editor-api.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandy Armstrong <sandy@xamarin.com>2019-12-18 20:50:10 +0300
committerSandy Armstrong <sandy@xamarin.com>2019-12-18 20:50:10 +0300
commit109220f5a283245ed9ffb70f82ca061d4d6d3dad (patch)
tree04cb46d499ca38f9f5e81b4c7c518fa4d569c9a5
parent95fbc6cd5cd27fe623036c0c453e707d919e7bc6 (diff)
Sync with vs-editor-core@2b5d751fb
-rw-r--r--build/Project.props3
-rw-r--r--global.json4
-rw-r--r--src/Editor/FPF/PresentationCore/System.Windows.UIElement.cs27
-rw-r--r--src/Editor/Language/Def/Intellisense/IPopupIntellisensePresenter.cs2
-rw-r--r--src/Editor/Text/Def/TextUI/AssemblyInfo.cs5
-rw-r--r--src/Editor/Text/Def/TextUI/Editor/ITextView3.cs30
-rw-r--r--src/Editor/Text/Def/TextUI/Editor/ITextViewFactoryService.cs174
-rw-r--r--src/Editor/Text/Def/TextUI/Editor/ITextViewZoomManager.cs46
-rw-r--r--src/Editor/Text/Def/TextUI/Editor/IViewScroller2.cs30
-rw-r--r--src/Editor/Text/Def/TextUI/Operations/IEditorOperations4.cs23
-rw-r--r--src/Editor/Text/Def/TextUICocoa/Editor/ICocoaTextView.cs20
-rw-r--r--src/Editor/Text/Def/TextUICocoa/Editor/IViewSynchronizationManager.cs (renamed from src/Editor/Text/Def/TextUI/Editor/IViewSynchronizationManager.cs)0
-rw-r--r--src/Editor/Text/Def/TextUICocoa/Snippet/CodeSnippet.cs (renamed from src/Editor/Language/Def/Intellisense/Snippet/CodeSnippet.cs)0
-rw-r--r--src/Editor/Text/Def/TextUICocoa/Snippet/ExpansionField.cs (renamed from src/Editor/Language/Def/Intellisense/Snippet/ExpansionField.cs)0
-rw-r--r--src/Editor/Text/Def/TextUICocoa/Snippet/ExpansionTemplate.cs (renamed from src/Editor/Language/Def/Intellisense/Snippet/ExpansionTemplate.cs)0
-rw-r--r--src/Editor/Text/Def/TextUICocoa/Snippet/IExpansionClient.cs (renamed from src/Editor/Language/Def/Intellisense/Snippet/IExpansionClient.cs)0
-rw-r--r--src/Editor/Text/Def/TextUICocoa/Snippet/IExpansionFunction.cs (renamed from src/Editor/Language/Def/Intellisense/Snippet/IExpansionFunction.cs)0
-rw-r--r--src/Editor/Text/Def/TextUICocoa/Snippet/IExpansionManager.cs (renamed from src/Editor/Language/Def/Intellisense/Snippet/IExpansionManager.cs)0
-rw-r--r--src/Editor/Text/Def/TextUICocoa/Snippet/IExpansionService.cs (renamed from src/Editor/Language/Def/Intellisense/Snippet/IExpansionService.cs)0
-rw-r--r--src/Editor/Text/Def/TextUICocoa/Snippet/IExpansionServiceProvider.cs (renamed from src/Editor/Language/Def/Intellisense/Snippet/IExpansionServiceProvider.cs)0
-rw-r--r--src/Editor/Text/Def/TextUICocoa/Snippet/IExpansionSession.cs (renamed from src/Editor/Language/Def/Intellisense/Snippet/IExpansionSession.cs)0
-rw-r--r--src/Editor/Text/Impl/BraceCompletion/BraceCompletionAdornmentService.cs6
-rw-r--r--src/Editor/Text/Impl/BraceCompletion/BraceCompletionAdornmentServiceFactory.cs2
-rw-r--r--src/Editor/Text/Impl/BraceCompletion/BraceCompletionImpl.csproj2
-rw-r--r--src/Editor/Text/Impl/EditorOperations/EditorOperations.cs82
-rw-r--r--src/Editor/Text/Impl/EditorOperations/EditorOperationsFactoryService.cs7
-rw-r--r--src/Editor/Text/Util/TextDataUtil/AssemblyInfo.cs1
-rw-r--r--src/Editor/Text/Util/TextUICocoaUtil/AssemblyInfo.cs48
-rw-r--r--src/Editor/Text/Util/TextUICocoaUtil/CocoaTextViewZoomManager.cs65
-rw-r--r--src/Editor/Text/Util/TextUICocoaUtil/DifferenceBrushManager.cs (renamed from src/Editor/Text/Util/TextUIUtil/DifferenceBrushManager.cs)8
-rw-r--r--src/Editor/Text/Util/TextUICocoaUtil/IDragDropMouseProcessor.cs (renamed from src/Editor/Text/Util/TextUIUtil/IDragDropMouseProcessor.cs)0
-rw-r--r--src/Editor/Text/Util/TextUICocoaUtil/TelemetryLogger.cs (renamed from src/Editor/Text/Util/TextUIUtil/TelemetryLogger.cs)0
-rw-r--r--src/Editor/Text/Util/TextUICocoaUtil/TextUICocoaUtil.csproj35
-rw-r--r--src/Editor/Text/Util/TextUIUtil/DefaultTextViewZoomManager.cs27
-rw-r--r--src/Editor/Text/Util/TextUIUtil/ExtensionMethods.cs85
-rw-r--r--src/Editor/Text/Util/TextUIUtil/TextViewZoomManager.cs35
-rw-r--r--src/OpenSource.Impl.projitems16
37 files changed, 472 insertions, 311 deletions
diff --git a/build/Project.props b/build/Project.props
index fcbd918..a575b49 100644
--- a/build/Project.props
+++ b/build/Project.props
@@ -13,6 +13,9 @@
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
+ <FullNETFrameworkVersion>net472</FullNETFrameworkVersion>
+ <PortableTargetFrameworks>netstandard2.0;net472</PortableTargetFrameworks>
+ <NetStandardVersion>netstandard2.0</NetStandardVersion>
<LangVersion>8.0</LangVersion>
<DefineConstants Condition="$([MSBuild]::IsOSPlatform('OSX')) == 'true'">__MACOS__;$(DefineConstants)</DefineConstants>
</PropertyGroup>
diff --git a/global.json b/global.json
index 575257f..a39754e 100644
--- a/global.json
+++ b/global.json
@@ -1,7 +1,7 @@
{
"msbuild-sdks": {
"Microsoft.Build.Traversal": "1.0.45",
- "Xamarin.MSBuild.Sdk": "0.29.0",
- "Xamarin.Mac.Sdk": "0.29.0"
+ "Xamarin.MSBuild.Sdk": "0.31.0",
+ "Xamarin.Mac.Sdk": "0.31.0"
}
} \ No newline at end of file
diff --git a/src/Editor/FPF/PresentationCore/System.Windows.UIElement.cs b/src/Editor/FPF/PresentationCore/System.Windows.UIElement.cs
new file mode 100644
index 0000000..b659184
--- /dev/null
+++ b/src/Editor/FPF/PresentationCore/System.Windows.UIElement.cs
@@ -0,0 +1,27 @@
+using System;
+using AppKit;
+
+namespace System.Windows
+{
+ public class UIElement
+ {
+#pragma warning disable CS3003 // Type is not CLS-compliant
+ public NSView NSView { get; }
+#pragma warning restore CS3003 // Type is not CLS-compliant
+
+ public UIElement(NSView view)
+ {
+ NSView = view;
+ }
+
+ public static implicit operator UIElement(NSView view)
+ {
+ return new UIElement(view);
+ }
+
+ public static implicit operator NSView(UIElement uiElement)
+ {
+ return uiElement.NSView;
+ }
+ }
+}
diff --git a/src/Editor/Language/Def/Intellisense/IPopupIntellisensePresenter.cs b/src/Editor/Language/Def/Intellisense/IPopupIntellisensePresenter.cs
index 8b00604..498c3d0 100644
--- a/src/Editor/Language/Def/Intellisense/IPopupIntellisensePresenter.cs
+++ b/src/Editor/Language/Def/Intellisense/IPopupIntellisensePresenter.cs
@@ -19,7 +19,7 @@ namespace Microsoft.VisualStudio.Language.Intellisense
/// Gets the WPF <see cref="UIElement"/> that the presenter wants to be displayed inside a
/// <see cref="Microsoft.VisualStudio.Text.Editor.ITextView"/> popup.
/// </summary>
- object SurfaceElement { get; }
+ UIElement SurfaceElement { get; }
/// <summary>
/// Occurs when the WPF SurfaceElement is changed.
diff --git a/src/Editor/Text/Def/TextUI/AssemblyInfo.cs b/src/Editor/Text/Def/TextUI/AssemblyInfo.cs
index b904d55..174963d 100644
--- a/src/Editor/Text/Def/TextUI/AssemblyInfo.cs
+++ b/src/Editor/Text/Def/TextUI/AssemblyInfo.cs
@@ -18,10 +18,15 @@ using System.Security.Permissions;
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Platform.VSEditor, PublicKey=" + ThisAssembly.PublicKey)]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.DifferenceViewer.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.Outlining.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.EditorOperations.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
// InternalsVisibleTo for VS for Mac implementation assembly:
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.Implementation, PublicKey=0024000004800000940000000602000000240000525341310004000001000100e57febc1f220077550a65e338d3d15d7cbd189cf4f62f7c3829dcb2f8441a6c40631d172e3deb4dc0bb7237b44ec9daeb9bd7d72c3d64c4f52b968795443cb58bc341583c29440345b8c35f72f6a31aecb2903376136f8fc35779bb422eb643f8668fa6605c697bff927e3bb10745328ff878bd1b7e42bbcb839f04baa8460bd")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.Cocoa.View.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.AdornmentLibrary.VisibleWhitespace.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.UI.Cocoa.Utilities, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("MonoDevelop.TextEditor, PublicKey=002400000c800000940000000602000000240000525341310004000001000100e1290d741888d13312c0cd1f72bb843236573c80158a286f11bb98de5ee8acc3142c9c97b472684e521ae45125d7414558f2e70ac56504f3e8fe80830da2cdb1cda8504e8d196150d05a214609234694ec0ebf4b37fc7537e09d877c3e65000f7467fa3adb6e62c82b10ada1af4a83651556c7d949959817fed97480839dd39b")]
+
//
// General Information about an assembly is controlled through the following
diff --git a/src/Editor/Text/Def/TextUI/Editor/ITextView3.cs b/src/Editor/Text/Def/TextUI/Editor/ITextView3.cs
deleted file mode 100644
index f7b5b64..0000000
--- a/src/Editor/Text/Def/TextUI/Editor/ITextView3.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-//
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-//
-
-using System;
-
-using Microsoft.VisualStudio.Text.Formatting;
-
-namespace Microsoft.VisualStudio.Text.Editor
-{
- public interface ITextView3 : ITextView2
- {
- /// <summary>
- /// Gets or sets the Zoom level for the <see cref="ITextView3"/> between 20% to 400%
- /// </summary>
- double ZoomLevel { get; set; }
-
- IXPlatAdornmentLayer GetXPlatAdornmentLayer(string name);
-
- ITextViewLineSource FormattedLineSource { get; }
-
- void Focus();
-
- bool IsKeyboardFocused { get; }
- event EventHandler IsKeyboardFocusedChanged;
-
- IViewSynchronizationManager SynchronizationManager { get; set; }
- }
-} \ No newline at end of file
diff --git a/src/Editor/Text/Def/TextUI/Editor/ITextViewFactoryService.cs b/src/Editor/Text/Def/TextUI/Editor/ITextViewFactoryService.cs
deleted file mode 100644
index 6ceea3b..0000000
--- a/src/Editor/Text/Def/TextUI/Editor/ITextViewFactoryService.cs
+++ /dev/null
@@ -1,174 +0,0 @@
-//
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-//
-// This file contain internal APIs that are subject to change without notice.
-// Use at your own risk.
-//
-
-using System;
-using System.Collections.Generic;
-
-using Microsoft.VisualStudio.Utilities;
-
-namespace Microsoft.VisualStudio.Text.Editor
-{
- public interface ITextViewFactoryService
- {
- /// <summary>
- /// Creates an <see cref="ITextView"/> that displays the contents of <paramref name="viewModel"/>.
- /// </summary>
- /// <param name="viewModel">The <see cref="ITextViewModel"/> that provides the text buffers for the view.</param>
- /// <param name="roles">The set of roles filled by the view.</param>
- /// <param name="parentOptions">The options environment for the text view.</param>
- /// <returns>An <see cref="ITextView"/>.</returns>
- /// <exception cref="ArgumentNullException"><paramref name="viewModel"/> or <paramref name="roles"/> or <paramref name="parentOptions"/> is null.</exception>
- ITextView CreateTextView(ITextViewModel viewModel, ITextViewRoleSet roles, IEditorOptions parentOptions);
-
- /// <summary>
- /// Creates an <see cref="ITextView"/> that displays the contents of <paramref name="dataModel"/>.
- /// </summary>
- /// <param name="dataModel">The <see cref="ITextDataModel"/> that provides the text buffers over which an <see cref="ITextViewModel"/>
- /// will be built for the view.</param>
- /// <param name="roles">The set of roles filled by the view.</param>
- /// <param name="parentOptions">The options environment for the text view.</param>
- /// <returns>An <see cref="ITextView"/>.</returns>
- /// <remarks>
- /// An <see cref="ITextDataModel"/> can be displayed in multiple views. An <see cref="ITextViewModel"/> will be constructed based on
- /// the <see cref="IContentType"/> of the <paramref name="dataModel"/> and the <paramref name="roles"/>.
- /// </remarks>
- /// <exception cref="ArgumentNullException"><paramref name="dataModel"/> or <paramref name="roles"/> or <paramref name="parentOptions"/> is null.</exception>
- ITextView CreateTextView(ITextDataModel dataModel, ITextViewRoleSet roles, IEditorOptions parentOptions);
-
- /// <summary>
- /// Creates an <see cref="ITextView"/> that displays the contents of <paramref name="textBuffer"/>.
- /// </summary>
- /// <param name="textBuffer">The <see cref="ITextBuffer"/> that provides the text for the view.</param>
- /// <param name="roles">The set of roles filled by the view.</param>
- /// <param name="parentOptions">The options environment for the text view.</param>
- /// <returns>An <see cref="ITextView"/>.</returns>
- /// <remarks>
- /// An <see cref="ITextBuffer"/> can be displayed in multiple views. A trivial <see cref="ITextDataModel"/> will be constructed and
- /// an <see cref="ITextViewModel"/> will be constructed based on
- /// the <see cref="IContentType"/> of the <paramref name="textBuffer"/> and the <paramref name="roles"/>.
- /// </remarks>
- /// <exception cref="ArgumentNullException"><paramref name="textBuffer"/> or <paramref name="roles"/> or <paramref name="parentOptions"/> is null.</exception>
- ITextView CreateTextView(ITextBuffer textBuffer, ITextViewRoleSet roles, IEditorOptions parentOptions);
-
- /// <summary>
- /// Creates an <see cref="ITextView"/> that displays the contents of <paramref name="textBuffer"/>.
- /// </summary>
- /// <param name="textBuffer">The <see cref="ITextBuffer"/> that provides the text for the view.</param>
- /// <param name="roles">The set of roles filled by the view.</param>
- /// <returns>An <see cref="ITextView"/>.</returns>
- /// <remarks>
- /// An <see cref="ITextBuffer"/> can be displayed in multiple views. A trivial <see cref="ITextDataModel"/> will be constructed and
- /// an <see cref="ITextViewModel"/> will be constructed based on
- /// the <see cref="IContentType"/> of the <paramref name="textBuffer"/> and the <paramref name="roles"/>.
- /// </remarks>
- /// <exception cref="ArgumentNullException"><paramref name="textBuffer"/> or <paramref name="roles"/> is null.</exception>
- ITextView CreateTextView(ITextBuffer textBuffer, ITextViewRoleSet roles);
-
- /// <summary>
- /// Creates an <see cref="ITextView"/> that displays the contents of <paramref name="textBuffer"/>.
- /// </summary>
- /// <param name="textBuffer">The <see cref="ITextBuffer"/> that provides the text for the view.</param>
- /// <returns>An <see cref="ITextView"/> having the default set of text view roles.</returns>
- /// <remarks>
- /// An <see cref="ITextBuffer"/> can be displayed in multiple views. A trivial <see cref="ITextDataModel"/> will be constructed and
- /// an <see cref="ITextViewModel"/> will be constructed based on
- /// the <see cref="IContentType"/> of the <paramref name="textBuffer"/>.
- /// </remarks>
- /// <exception cref="ArgumentNullException"><paramref name="textBuffer"/> is null.</exception>
- ITextView CreateTextView(ITextBuffer textBuffer);
-
- /// <summary>
- /// Creates an <see cref="ITextView"/> on a newly created <see cref="ITextBuffer"/> having
- /// content type <code>Text</code>.
- /// </summary>
- /// <returns>A <see cref="ITextView"/>.</returns>
- ITextView CreateTextView();
-
- ///// <summary>
- ///// Creates a host for the text view.
- ///// </summary>
- ///// <param name="wpfTextView">The text view to host.</param>
- ///// <param name="setFocus"><c>true</c> if the <see cref="IWpfTextViewHost"/> should take focus after it is initialized, <c>false</c> otherwise.</param>
- ///// <returns>An <see cref="IWpfTextViewHost"/>.</returns>
- ///// <exception cref="ArgumentNullException"><paramref name="wpfTextView"/> is null.</exception>
- //IWpfTextViewHost CreateTextViewHost(ITextView wpfTextView, bool setFocus);
-
- /// <summary>
- /// The empty ITextViewRoleSet.
- /// </summary>
- ITextViewRoleSet NoRoles { get; }
-
- /// <summary>
- /// The set of all predefined text view roles.
- /// </summary>
- ITextViewRoleSet AllPredefinedRoles { get; }
-
- /// <summary>
- /// The set of roles that are used when creating a text view without specifying text view roles.
- /// </summary>
- ITextViewRoleSet DefaultRoles { get; }
-
- /// <summary>
- /// Creates a <see cref="ITextViewRoleSet"/> containing the given roles.
- /// </summary>
- /// <param name="roles">The roles of interest.</param>
- /// <returns>The text view role set.</returns>
- /// <exception cref="ArgumentNullException"> roles is null.</exception>
- ITextViewRoleSet CreateTextViewRoleSet(IEnumerable<string> roles);
-
- /// <summary>
- /// Creates a <see cref="ITextViewRoleSet"/> containing the given roles.
- /// </summary>
- /// <param name="roles">The roles of interest.</param>
- /// <returns>The text view role set.</returns>
- ITextViewRoleSet CreateTextViewRoleSet(params string[] roles);
-
- /// <summary>
- /// Raised when any <see cref="ITextView"/> is created.
- /// </summary>
- event EventHandler<TextViewCreatedEventArgs> TextViewCreated;
-
- /// <summary>
- /// Creates an <see cref="ITextView"/> that displays the contents of <paramref name="dataModel"/> without initializing it.
- /// </summary>
- /// <param name="dataModel">The <see cref="ITextDataModel"/> that provides the text buffers over which an <see cref="ITextViewModel"/>
- /// will be built for the view.</param>
- /// <param name="roles">The set of roles filled by the view.</param>
- /// <param name="parentOptions">The options environment for the text view.</param>
- /// <returns>An <see cref="ITextView"/>.</returns>
- /// <remarks>
- /// <para>An <see cref="ITextDataModel"/> can be displayed in multiple views. An <see cref="ITextViewModel"/> will be constructed based on
- /// the <see cref="IContentType"/> of the <paramref name="dataModel"/> and the <paramref name="roles"/>.</para>
- /// <para>ITextEditorFactoryService2.InitializeTextView(view) must be called on the view returned by this funtion.</para>
- /// </remarks>
- /// <exception cref="ArgumentNullException"><paramref name="dataModel"/> or <paramref name="roles"/> or <paramref name="parentOptions"/> is null.</exception>
- ITextView CreateTextViewWithoutInitialization(ITextDataModel dataModel, ITextViewRoleSet roles, IEditorOptions parentOptions);
-
- ///// <summary>
- ///// Creates a host for the text view without initializing it.
- ///// </summary>
- ///// <param name="wpfTextView">The text view to host.</param>
- ///// <param name="setFocus"><c>true</c> if the <see cref="IWpfTextViewHost"/> should take focus after it is initialized, <c>false</c> otherwise.</param>
- ///// <returns>An <see cref="IWpfTextViewHost"/>.</returns>
- ///// <remarks>
- ///// <para>ITextEditorFactoryService2.InitializeTextViewHost(host) must be called on the host returned by this funtion.</para>
- ///// </remarks>
- ///// <exception cref="ArgumentNullException"><paramref name="wpfTextView"/> is null.</exception>
- //IWpfTextViewHost CreateTextViewHostWithoutInitialization(IWpfTextView wpfTextView, bool setFocus);
-
- /// <summary>
- /// Initialize a view created using CreateTextViewWithoutInitialization.
- /// </summary>
- void InitializeTextView(ITextView view);
-
- ///// <summary>
- ///// Initialize a view created using CreateTextViewHostWithoutInitialization.
- ///// </summary>
- //void InitializeTextViewHost(IWpfTextViewHost host);
- }
-}
diff --git a/src/Editor/Text/Def/TextUI/Editor/ITextViewZoomManager.cs b/src/Editor/Text/Def/TextUI/Editor/ITextViewZoomManager.cs
new file mode 100644
index 0000000..eb4974b
--- /dev/null
+++ b/src/Editor/Text/Def/TextUI/Editor/ITextViewZoomManager.cs
@@ -0,0 +1,46 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+//
+
+namespace Microsoft.VisualStudio.Text.Editor
+{
+ /// <summary>
+ /// Provides methods to manipulate zoom level of text views.
+ /// </summary>
+ /// <remarks>This is a MEF Component, and should be imported as follows:
+ /// <code>
+ /// [Import]
+ /// ITextViewZoomManager zoomManager = null;
+ /// </code>
+ /// </remarks>
+ internal interface ITextViewZoomManager
+ {
+ /// <summary>
+ /// Zooms in to the text view by a scaling factor of 10%.
+ /// </summary>
+ /// <remarks>
+ /// The maximum zooming scale is 400%.
+ /// </remarks>
+ void ZoomIn(ITextView textView);
+
+ /// <summary>
+ /// Zooms out of the text view by a scaling factor of 10%.
+ /// </summary>
+ /// <remarks>
+ /// The minimum zooming scale is 20%.
+ /// </remarks>
+ void ZoomOut(ITextView textView);
+
+ /// <summary>
+ /// Applies the given zoomLevel to the text view.
+ /// </summary>
+ /// <param name="zoomLevel">The zoom level to apply between 20% to 400%.</param>
+ void ZoomTo(ITextView textView, double zoomLevel);
+
+ /// <summary>
+ /// Gets ZoomLevel between 20% to 400% of text view.
+ /// </summary>
+ double ZoomLevel(ITextView textView);
+ }
+}
diff --git a/src/Editor/Text/Def/TextUI/Editor/IViewScroller2.cs b/src/Editor/Text/Def/TextUI/Editor/IViewScroller2.cs
new file mode 100644
index 0000000..0856fcb
--- /dev/null
+++ b/src/Editor/Text/Def/TextUI/Editor/IViewScroller2.cs
@@ -0,0 +1,30 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+//
+namespace Microsoft.VisualStudio.Text.Editor
+{
+ internal interface IViewScroller2 : IViewScroller
+ {
+ /// <summary>
+ /// Gets the width of a column in pixels.
+ /// </summary>
+ double ColumnWidth { get; }
+
+ /// <summary>
+ /// Scrolls the view one column to the left.
+ /// </summary>
+ /// <remarks>
+ /// A column is the width of a space in the default font.
+ /// </remarks>
+ void ScrollColumnLeft();
+
+ /// <summary>
+ /// Scrolls the view one column to the right.
+ /// </summary>
+ /// <remarks>
+ /// A column is the width of a space in the default font.
+ /// </remarks>
+ void ScrollColumnRight();
+ }
+}
diff --git a/src/Editor/Text/Def/TextUI/Operations/IEditorOperations4.cs b/src/Editor/Text/Def/TextUI/Operations/IEditorOperations4.cs
index 1cbfd40..c6cd992 100644
--- a/src/Editor/Text/Def/TextUI/Operations/IEditorOperations4.cs
+++ b/src/Editor/Text/Def/TextUI/Operations/IEditorOperations4.cs
@@ -1,15 +1,26 @@
-//
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License. See License.txt in the project root for license information.
-//
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.VisualStudio.Text.Operations;
+
namespace Microsoft.VisualStudio.Text.Operations
{
/// <summary>
/// Defines operations relating to the editor, in addition to operations defined by <see cref="IEditorOperations3"/>.
/// </summary>
- public interface IEditorOperations4 : IEditorOperations3
+ internal interface IEditorOperations4 : IEditorOperations3
{
/// <summary>
+ /// Returns a string with the original content except for newlines, which are replaced to match the document
+ /// </summary>
+ /// <param name="text">Text to normalize newlines</param>
+ /// <returns>The normalized string, if the document has enough information to normalize with. The original string otherwise.</returns>
+ /// <remarks>This method uses the newline state associated with the document buffer.</remarks>
+ string NormalizeNewlinesInString(string text);
+
+ /// <summary>
/// Determines whether zooming operations are possible.
/// </summary>
bool CanZoomTo { get; }
@@ -44,4 +55,4 @@ namespace Microsoft.VisualStudio.Text.Operations
/// </summary>
void JoinSelectedLines();
}
-} \ No newline at end of file
+}
diff --git a/src/Editor/Text/Def/TextUICocoa/Editor/ICocoaTextView.cs b/src/Editor/Text/Def/TextUICocoa/Editor/ICocoaTextView.cs
index f7fe9e5..7a3160b 100644
--- a/src/Editor/Text/Def/TextUICocoa/Editor/ICocoaTextView.cs
+++ b/src/Editor/Text/Def/TextUICocoa/Editor/ICocoaTextView.cs
@@ -7,10 +7,11 @@ using System;
using AppKit;
using CoreGraphics;
+using Microsoft.VisualStudio.Text.Formatting;
namespace Microsoft.VisualStudio.Text.Editor
{
- public interface ICocoaTextView : ITextView3
+ public interface ICocoaTextView : ITextView2
{
/// <summary>
/// Gets the <see cref="NSView"/> that renders the view.
@@ -35,5 +36,22 @@ namespace Microsoft.VisualStudio.Text.Editor
void PushCursor(object context, NSCursor cursor);
void PopCursor(object context);
+
+
+ /// <summary>
+ /// Gets or sets the Zoom level for the <see cref="ITextView3"/> between 20% to 400%
+ /// </summary>
+ double ZoomLevel { get; set; }
+
+ IXPlatAdornmentLayer GetXPlatAdornmentLayer(string name);
+
+ ITextViewLineSource FormattedLineSource { get; }
+
+ void Focus();
+
+ bool IsKeyboardFocused { get; }
+ event EventHandler IsKeyboardFocusedChanged;
+
+ IViewSynchronizationManager SynchronizationManager { get; set; }
}
} \ No newline at end of file
diff --git a/src/Editor/Text/Def/TextUI/Editor/IViewSynchronizationManager.cs b/src/Editor/Text/Def/TextUICocoa/Editor/IViewSynchronizationManager.cs
index 70eddaa..70eddaa 100644
--- a/src/Editor/Text/Def/TextUI/Editor/IViewSynchronizationManager.cs
+++ b/src/Editor/Text/Def/TextUICocoa/Editor/IViewSynchronizationManager.cs
diff --git a/src/Editor/Language/Def/Intellisense/Snippet/CodeSnippet.cs b/src/Editor/Text/Def/TextUICocoa/Snippet/CodeSnippet.cs
index e5f0fa1..e5f0fa1 100644
--- a/src/Editor/Language/Def/Intellisense/Snippet/CodeSnippet.cs
+++ b/src/Editor/Text/Def/TextUICocoa/Snippet/CodeSnippet.cs
diff --git a/src/Editor/Language/Def/Intellisense/Snippet/ExpansionField.cs b/src/Editor/Text/Def/TextUICocoa/Snippet/ExpansionField.cs
index 9bdef92..9bdef92 100644
--- a/src/Editor/Language/Def/Intellisense/Snippet/ExpansionField.cs
+++ b/src/Editor/Text/Def/TextUICocoa/Snippet/ExpansionField.cs
diff --git a/src/Editor/Language/Def/Intellisense/Snippet/ExpansionTemplate.cs b/src/Editor/Text/Def/TextUICocoa/Snippet/ExpansionTemplate.cs
index 356d2bd..356d2bd 100644
--- a/src/Editor/Language/Def/Intellisense/Snippet/ExpansionTemplate.cs
+++ b/src/Editor/Text/Def/TextUICocoa/Snippet/ExpansionTemplate.cs
diff --git a/src/Editor/Language/Def/Intellisense/Snippet/IExpansionClient.cs b/src/Editor/Text/Def/TextUICocoa/Snippet/IExpansionClient.cs
index f04d13c..f04d13c 100644
--- a/src/Editor/Language/Def/Intellisense/Snippet/IExpansionClient.cs
+++ b/src/Editor/Text/Def/TextUICocoa/Snippet/IExpansionClient.cs
diff --git a/src/Editor/Language/Def/Intellisense/Snippet/IExpansionFunction.cs b/src/Editor/Text/Def/TextUICocoa/Snippet/IExpansionFunction.cs
index af945a5..af945a5 100644
--- a/src/Editor/Language/Def/Intellisense/Snippet/IExpansionFunction.cs
+++ b/src/Editor/Text/Def/TextUICocoa/Snippet/IExpansionFunction.cs
diff --git a/src/Editor/Language/Def/Intellisense/Snippet/IExpansionManager.cs b/src/Editor/Text/Def/TextUICocoa/Snippet/IExpansionManager.cs
index 077b20b..077b20b 100644
--- a/src/Editor/Language/Def/Intellisense/Snippet/IExpansionManager.cs
+++ b/src/Editor/Text/Def/TextUICocoa/Snippet/IExpansionManager.cs
diff --git a/src/Editor/Language/Def/Intellisense/Snippet/IExpansionService.cs b/src/Editor/Text/Def/TextUICocoa/Snippet/IExpansionService.cs
index 193edf5..193edf5 100644
--- a/src/Editor/Language/Def/Intellisense/Snippet/IExpansionService.cs
+++ b/src/Editor/Text/Def/TextUICocoa/Snippet/IExpansionService.cs
diff --git a/src/Editor/Language/Def/Intellisense/Snippet/IExpansionServiceProvider.cs b/src/Editor/Text/Def/TextUICocoa/Snippet/IExpansionServiceProvider.cs
index cead20d..cead20d 100644
--- a/src/Editor/Language/Def/Intellisense/Snippet/IExpansionServiceProvider.cs
+++ b/src/Editor/Text/Def/TextUICocoa/Snippet/IExpansionServiceProvider.cs
diff --git a/src/Editor/Language/Def/Intellisense/Snippet/IExpansionSession.cs b/src/Editor/Text/Def/TextUICocoa/Snippet/IExpansionSession.cs
index 9845f93..9845f93 100644
--- a/src/Editor/Language/Def/Intellisense/Snippet/IExpansionSession.cs
+++ b/src/Editor/Text/Def/TextUICocoa/Snippet/IExpansionSession.cs
diff --git a/src/Editor/Text/Impl/BraceCompletion/BraceCompletionAdornmentService.cs b/src/Editor/Text/Impl/BraceCompletion/BraceCompletionAdornmentService.cs
index 430e947..c6a1704 100644
--- a/src/Editor/Text/Impl/BraceCompletion/BraceCompletionAdornmentService.cs
+++ b/src/Editor/Text/Impl/BraceCompletion/BraceCompletionAdornmentService.cs
@@ -24,7 +24,7 @@ namespace Microsoft.VisualStudio.Text.BraceCompletion.Implementation
#region Private Members
private ITrackingPoint _trackingPoint;
- private ITextView3 _textView;
+ private ICocoaTextView _textView;
private IXPlatAdornmentLayer _adornmentLayer;
private readonly IEditorFormatMap _editorFormatMap;
private Brush _brush;
@@ -33,9 +33,9 @@ namespace Microsoft.VisualStudio.Text.BraceCompletion.Implementation
#region Constructors
- public BraceCompletionAdornmentService(ITextView3 textView, IEditorFormatMap editorFormatMap)
+ public BraceCompletionAdornmentService(ITextView textView, IEditorFormatMap editorFormatMap)
{
- _textView = textView;
+ _textView = (ICocoaTextView)textView;
_editorFormatMap = editorFormatMap;
if (_textView == null)
diff --git a/src/Editor/Text/Impl/BraceCompletion/BraceCompletionAdornmentServiceFactory.cs b/src/Editor/Text/Impl/BraceCompletion/BraceCompletionAdornmentServiceFactory.cs
index 6938df8..d5c0b62 100644
--- a/src/Editor/Text/Impl/BraceCompletion/BraceCompletionAdornmentServiceFactory.cs
+++ b/src/Editor/Text/Impl/BraceCompletion/BraceCompletionAdornmentServiceFactory.cs
@@ -29,7 +29,7 @@ namespace Microsoft.VisualStudio.Text.BraceCompletion.Implementation
{
// Get the service from the view's property bag
return textView.Properties.GetOrCreateSingletonProperty<IBraceCompletionAdornmentService>(
- () => new BraceCompletionAdornmentService((ITextView3)textView, _editorFormatMapService.GetEditorFormatMap(textView)));
+ () => new BraceCompletionAdornmentService(textView, _editorFormatMapService.GetEditorFormatMap(textView)));
}
#endregion
diff --git a/src/Editor/Text/Impl/BraceCompletion/BraceCompletionImpl.csproj b/src/Editor/Text/Impl/BraceCompletion/BraceCompletionImpl.csproj
index bb50037..d8eb0fc 100644
--- a/src/Editor/Text/Impl/BraceCompletion/BraceCompletionImpl.csproj
+++ b/src/Editor/Text/Impl/BraceCompletion/BraceCompletionImpl.csproj
@@ -28,7 +28,7 @@
<ProjectReference Include="..\..\Def\TextData\TextData.csproj" />
<ProjectReference Include="..\..\Def\TextLogic\TextLogic.csproj" />
<ProjectReference Include="..\..\Def\TextUI\TextUI.csproj" />
- <ProjectReference Include="..\..\Def\TextUIWpf\TextUIWpf.csproj" />
+ <ProjectReference Include="..\..\Def\TextUICocoa\TextUICocoa.csproj" />
<ProjectReference Include="..\..\Util\TextDataUtil\TextDataUtil.csproj" />
<ProjectReference Include="..\..\Def\Internal\Internal.csproj" />
</ItemGroup>
diff --git a/src/Editor/Text/Impl/EditorOperations/EditorOperations.cs b/src/Editor/Text/Impl/EditorOperations/EditorOperations.cs
index 3f6107d..3a2c915 100644
--- a/src/Editor/Text/Impl/EditorOperations/EditorOperations.cs
+++ b/src/Editor/Text/Impl/EditorOperations/EditorOperations.cs
@@ -27,6 +27,7 @@ namespace Microsoft.VisualStudio.Text.Operations.Implementation
using Microsoft.VisualStudio.Text.Tagging;
using Microsoft.VisualStudio.Language.Intellisense.Utilities;
using Microsoft.VisualStudio.Text.Utilities;
+ using Microsoft.VisualStudio.Text.Data.Utilities;
/// <summary>
/// Provides a default operations set on top of the text editor
@@ -56,7 +57,7 @@ namespace Microsoft.VisualStudio.Text.Operations.Implementation
#region Private Members
- readonly ITextView3 _textView;
+ readonly ITextView _textView;
readonly EditorOperationsFactoryService _factory;
readonly ITextDocument _textDocument;
readonly ITextStructureNavigator _textStructureNavigator;
@@ -96,7 +97,7 @@ namespace Microsoft.VisualStudio.Text.Operations.Implementation
if (factory == null)
throw new ArgumentNullException(nameof(factory));
- _textView = (Microsoft.VisualStudio.Text.Editor.ITextView3) textView;
+ _textView = textView;
_factory = factory;
_multiSelectionBroker = _textView.GetMultiSelectionBroker();
_editorPrimitives = factory.EditorPrimitivesProvider.GetViewPrimitives(textView);
@@ -3188,14 +3189,20 @@ namespace Microsoft.VisualStudio.Text.Operations.Implementation
public void ScrollColumnLeft()
{
- // A column is defined as the width of a space in the default font
- _textView.ViewScroller.ScrollViewportHorizontallyByPixels(_textView.FormattedLineSource.ColumnWidth * -1.0);
+ if (_textView.ViewScroller is IViewScroller2 viewScroller)
+ {
+ // A column is defined as the width of a space in the default font
+ viewScroller.ScrollColumnLeft();
+ }
}
public void ScrollColumnRight()
{
- // A column is defined as the width of a space in the default font
- _textView.ViewScroller.ScrollViewportHorizontallyByPixels(_textView.FormattedLineSource.ColumnWidth);
+ if (_textView.ViewScroller is IViewScroller2 viewScroller)
+ {
+ // A column is defined as the width of a space in the default font
+ viewScroller.ScrollColumnRight();
+ }
}
public void ScrollLineBottom()
@@ -3229,54 +3236,35 @@ namespace Microsoft.VisualStudio.Text.Operations.Implementation
_undoHistory.CurrentTransaction.AddUndo(beforeTextBufferChangeUndoPrimitive);
}
- public bool CanZoomIn => CanZoomTo && _textView.ZoomLevel < _textView.Options.GlobalOptions.MaxZoom();
+ public bool CanZoomIn => CanZoomTo && _factory.ZoomManager.ZoomLevel(_textView) < _textView.Options.GlobalOptions.MaxZoom();
- public void ZoomIn()
- {
- if (CanZoomIn)
- {
- var maxZoom = _textView.Options.GlobalOptions.MaxZoom();
- double zoomLevel = Math.Min(_textView.ZoomLevel * ZoomConstants.ScalingFactor, maxZoom);
- if (zoomLevel < maxZoom || Math.Abs(zoomLevel - maxZoom) < 0.00001)
- {
- _textView.Options.GlobalOptions.SetOptionValue(DefaultTextViewOptions.ZoomLevelId, zoomLevel);
- }
- }
- }
+ public bool CanZoomOut => CanZoomTo && _factory.ZoomManager.ZoomLevel(_textView) > _textView.Options.GlobalOptions.MinZoom();
- public bool CanZoomOut => CanZoomTo && _textView.ZoomLevel > _textView.Options.GlobalOptions.MinZoom();
+ public bool CanZoomTo => _textView.Roles.Contains(PredefinedTextViewRoles.Zoomable);
- public void ZoomOut()
+ public bool CanZoomReset => CanZoomTo && _factory.ZoomManager.ZoomLevel(_textView) != ZoomConstants.DefaultZoom;
+
+ public void ZoomReset()
{
- if (CanZoomOut)
+ if (CanZoomReset)
{
- var minZoom = _textView.Options.GlobalOptions.MinZoom();
- double zoomLevel = Math.Max(_textView.ZoomLevel / ZoomConstants.ScalingFactor, minZoom);
- if (zoomLevel > minZoom || Math.Abs(zoomLevel - minZoom) < 0.00001)
- {
- _textView.Options.GlobalOptions.SetOptionValue(DefaultTextViewOptions.ZoomLevelId, zoomLevel);
- }
+ ZoomTo(ZoomConstants.DefaultZoom);
}
}
- public bool CanZoomTo => _textView.Roles.Contains(PredefinedTextViewRoles.Zoomable);
-
- public void ZoomTo(double zoomLevel)
+ public void ZoomIn()
{
- if (CanZoomTo)
- {
- _textView.Options.GlobalOptions.SetZoomLevel(zoomLevel);
- }
+ _factory.ZoomManager.ZoomIn(_textView);
}
- public bool CanZoomReset => CanZoomTo && _textView.ZoomLevel != ZoomConstants.DefaultZoom;
+ public void ZoomOut()
+ {
+ _factory.ZoomManager.ZoomOut(_textView);
+ }
- public void ZoomReset()
+ public void ZoomTo(double zoomLevel)
{
- if (CanZoomReset)
- {
- ZoomTo(ZoomConstants.DefaultZoom);
- }
+ _factory.ZoomManager.ZoomTo(_textView, zoomLevel);
}
#endregion // IEditorOperations Members
@@ -5350,6 +5338,18 @@ namespace Microsoft.VisualStudio.Text.Operations.Implementation
});
}
}
+
+ public string NormalizeNewlinesInString(string text)
+ {
+ if (_factory.WhitespaceManagerFactory.TryGetExistingWhitespaceManager(_textView.TextDataModel.DocumentBuffer, out var whitespaceManager))
+ {
+ return whitespaceManager.NewlineState.NormalizeNewlines(text);
+ }
+ else
+ {
+ return text;
+ }
+ }
}
/// <summary>
diff --git a/src/Editor/Text/Impl/EditorOperations/EditorOperationsFactoryService.cs b/src/Editor/Text/Impl/EditorOperations/EditorOperationsFactoryService.cs
index b58c2ca..3e39491 100644
--- a/src/Editor/Text/Impl/EditorOperations/EditorOperationsFactoryService.cs
+++ b/src/Editor/Text/Impl/EditorOperations/EditorOperationsFactoryService.cs
@@ -15,6 +15,7 @@ namespace Microsoft.VisualStudio.Text.Operations.Implementation
using Microsoft.VisualStudio.Utilities;
using Microsoft.VisualStudio.Text.Outlining;
using Microsoft.VisualStudio.Language.Intellisense.Utilities;
+ using Microsoft.VisualStudio.Text.Document;
[Export(typeof(IEditorOperationsFactoryService))]
internal sealed class EditorOperationsFactoryService : IEditorOperationsFactoryService
@@ -59,6 +60,12 @@ namespace Microsoft.VisualStudio.Text.Operations.Implementation
[Import(AllowDefault = true)]
internal IOutliningManagerService OutliningManagerService { get; set; }
+ [Import]
+ internal IWhitespaceManagerFactory WhitespaceManagerFactory { get; set; }
+
+ [Import]
+ internal ITextViewZoomManager ZoomManager { get; set; }
+
/// <summary>
/// Provides a operations implementation for a given text view.
/// </summary>
diff --git a/src/Editor/Text/Util/TextDataUtil/AssemblyInfo.cs b/src/Editor/Text/Util/TextDataUtil/AssemblyInfo.cs
index ccc6bf1..4d26ded 100644
--- a/src/Editor/Text/Util/TextDataUtil/AssemblyInfo.cs
+++ b/src/Editor/Text/Util/TextDataUtil/AssemblyInfo.cs
@@ -73,6 +73,7 @@ using System.Runtime.ConstrainedExecution;
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.MultiSelection.Implementation.UI.UnitTests, PublicKey=" + ThisAssembly.PublicKey)]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.Cocoa.View.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Platform.VSEditor, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.EditorOperations.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
diff --git a/src/Editor/Text/Util/TextUICocoaUtil/AssemblyInfo.cs b/src/Editor/Text/Util/TextUICocoaUtil/AssemblyInfo.cs
new file mode 100644
index 0000000..04d474d
--- /dev/null
+++ b/src/Editor/Text/Util/TextUICocoaUtil/AssemblyInfo.cs
@@ -0,0 +1,48 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+//
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.ConstrainedExecution;
+using System.Security.Permissions;
+
+[assembly: InternalsVisibleTo("EditorTestApp, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Language.Intellisense.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.DifferenceViewer.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.Differencing.DifferenceViewer.UnitTests, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.Editor.PrintingService.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.MultiCaret.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.MultiCaret.Implementation.UI, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.OverviewMargin.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.TextViewUnitTestHelper, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.UI.Utilities.UnitTests, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.AdornmentLibrary.TextMarker.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.AdornmentLibrary.ToolTip.Wpf.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.Commanding.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.Commanding.Implementation.UnitTests, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.CurrentLineHighlighter.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.TextMarkerAdornment.UnitTests, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.Wpf.Classification.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.Wpf.DragDrop.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.Wpf.GlyphMargin.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.Wpf.Input.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.Wpf.Input.UnitTests, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.Wpf.OverviewMargin.UnitTests, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.Wpf.View.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.Wpf.View.UnitTests, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.Wpf.FileHealthIndicator.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.UI.Utilities.UnitTests, PublicKey=" + ThisAssembly.PublicKey)]
+
+[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.Cocoa.View.Implementation, PublicKey=" + ThisAssembly.PublicKey)]
+
+//
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+//
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: SecurityPermission(SecurityAction.RequestMinimum, Flags = SecurityPermissionFlag.Execution)]
+[assembly: ReliabilityContract(Consistency.MayCorruptProcess, Cer.MayFail)]
diff --git a/src/Editor/Text/Util/TextUICocoaUtil/CocoaTextViewZoomManager.cs b/src/Editor/Text/Util/TextUICocoaUtil/CocoaTextViewZoomManager.cs
new file mode 100644
index 0000000..b245487
--- /dev/null
+++ b/src/Editor/Text/Util/TextUICocoaUtil/CocoaTextViewZoomManager.cs
@@ -0,0 +1,65 @@
+
+using System;
+using Microsoft.VisualStudio.Text.Editor;
+using Microsoft.VisualStudio.Utilities;
+
+namespace Microsoft.VisualStudio.Text.Utilities
+{
+ [ExportImplementation(typeof(ITextViewZoomManager))]
+ [Name("Cocoa zoom manager")]
+ [Order(Before = "default")]
+ internal class CocoaTextViewZoomManager : ITextViewZoomManager
+ {
+ public double ZoomLevel(ITextView textView) => ((ICocoaTextView)textView).ZoomLevel;
+
+ public void ZoomIn(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.MaxZoom || Math.Abs(zoomLevel - ZoomConstants.MaxZoom) < 0.00001)
+ {
+ cocoaTextView.Options.GlobalOptions.SetOptionValue(DefaultTextViewOptions.ZoomLevelId, zoomLevel);
+ }
+ }
+ }
+
+ 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 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);
+ }
+ }
+ }
+}
diff --git a/src/Editor/Text/Util/TextUIUtil/DifferenceBrushManager.cs b/src/Editor/Text/Util/TextUICocoaUtil/DifferenceBrushManager.cs
index 8773c20..929e29c 100644
--- a/src/Editor/Text/Util/TextUIUtil/DifferenceBrushManager.cs
+++ b/src/Editor/Text/Util/TextUICocoaUtil/DifferenceBrushManager.cs
@@ -15,12 +15,12 @@ namespace Microsoft.VisualStudio.Text.Utilities
{
class DifferenceBrushManager
{
- public static DifferenceBrushManager GetBrushManager(ITextView3 view, IEditorFormatMapService formatMapService)
+ public static DifferenceBrushManager GetBrushManager(ITextView view, IEditorFormatMapService formatMapService)
{
return view.Properties.GetOrCreateSingletonProperty(() => new DifferenceBrushManager(view, formatMapService.GetEditorFormatMap(view)));
}
- public static DifferenceBrushManager GetBrushManager(ITextView3 view, IEditorFormatMap formatMap)
+ public static DifferenceBrushManager GetBrushManager(ITextView view, IEditorFormatMap formatMap)
{
return view.Properties.GetOrCreateSingletonProperty(() => new DifferenceBrushManager(view, formatMap));
}
@@ -53,14 +53,14 @@ namespace Microsoft.VisualStudio.Text.Utilities
#endregion
- internal DifferenceBrushManager(ITextView3 view, IEditorFormatMap formatMap)
+ internal DifferenceBrushManager(ITextView view, IEditorFormatMap formatMap)
{
_formatMap = formatMap;
InitializeBrushes();
_formatMap.FormatMappingChanged += FormatMapChanged;
- view.Closed += (s,a) => { _formatMap.FormatMappingChanged -= FormatMapChanged; };
+ view.Closed += (s, a) => { _formatMap.FormatMappingChanged -= FormatMapChanged; };
}
void InitializeBrushes()
diff --git a/src/Editor/Text/Util/TextUIUtil/IDragDropMouseProcessor.cs b/src/Editor/Text/Util/TextUICocoaUtil/IDragDropMouseProcessor.cs
index 185f0a8..185f0a8 100644
--- a/src/Editor/Text/Util/TextUIUtil/IDragDropMouseProcessor.cs
+++ b/src/Editor/Text/Util/TextUICocoaUtil/IDragDropMouseProcessor.cs
diff --git a/src/Editor/Text/Util/TextUIUtil/TelemetryLogger.cs b/src/Editor/Text/Util/TextUICocoaUtil/TelemetryLogger.cs
index 912930c..912930c 100644
--- a/src/Editor/Text/Util/TextUIUtil/TelemetryLogger.cs
+++ b/src/Editor/Text/Util/TextUICocoaUtil/TelemetryLogger.cs
diff --git a/src/Editor/Text/Util/TextUICocoaUtil/TextUICocoaUtil.csproj b/src/Editor/Text/Util/TextUICocoaUtil/TextUICocoaUtil.csproj
new file mode 100644
index 0000000..ae46b47
--- /dev/null
+++ b/src/Editor/Text/Util/TextUICocoaUtil/TextUICocoaUtil.csproj
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project Sdk="Microsoft.NET.Sdk">
+ <PropertyGroup>
+ <AssemblyName>Microsoft.VisualStudio.Text.UI.Cocoa.Utilities</AssemblyName>
+ <RootNamespace>$(AssemblyName)</RootNamespace>
+
+ <!-- Need to have a TargetFramework tag for VS to recognize this as an SDK project. Just use the shared one. -->
+ <TargetFramework>$(FullNETFrameworkVersion)</TargetFramework>
+
+ <NoWarn>436;$(NoWarn)</NoWarn>
+ <AssemblyAttributeClsCompliant>true</AssemblyAttributeClsCompliant>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.ComponentModel.Composition" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Runtime" />
+ <Reference Include="System.Xaml" />
+ <Reference Include="WindowsBase" />
+ <Reference Include="PresentationCore" />
+ <Reference Include="PresentationFramework" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\Core\Def\CoreUtility.csproj" />
+ <ProjectReference Include="..\..\Def\TextData\TextData.csproj" />
+ <ProjectReference Include="..\..\Def\TextLogic\TextLogic.csproj" />
+ <ProjectReference Include="..\..\Def\TextUI\TextUI.csproj" />
+ <ProjectReference Include="..\..\Def\TextUICocoa\TextUICocoa.csproj" />
+ <ProjectReference Include="..\..\Def\Internal\Internal.csproj" />
+ <ProjectReference Include="..\TextDataUtil\TextDataUtil.csproj" />
+ <ProjectReference Include="..\TextLogicUtil\TextLogicUtil.csproj" />
+ <ProjectReference Include="..\TextUIUtil\TextUIUtil.csproj" />
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/src/Editor/Text/Util/TextUIUtil/DefaultTextViewZoomManager.cs b/src/Editor/Text/Util/TextUIUtil/DefaultTextViewZoomManager.cs
new file mode 100644
index 0000000..92c8820
--- /dev/null
+++ b/src/Editor/Text/Util/TextUIUtil/DefaultTextViewZoomManager.cs
@@ -0,0 +1,27 @@
+using Microsoft.VisualStudio.Text.Editor;
+using Microsoft.VisualStudio.Utilities;
+
+namespace Microsoft.VisualStudio.Text.Utilities
+{
+ [ExportImplementation(typeof(ITextViewZoomManager))]
+ [Name("default")]
+ internal class DefaultTextViewZoomManager : ITextViewZoomManager
+ {
+ public void ZoomIn(ITextView textView)
+ {
+ }
+
+ public double ZoomLevel(ITextView textView)
+ {
+ return 100;
+ }
+
+ public void ZoomOut(ITextView textView)
+ {
+ }
+
+ public void ZoomTo(ITextView textView, double zoomLevel)
+ {
+ }
+ }
+}
diff --git a/src/Editor/Text/Util/TextUIUtil/ExtensionMethods.cs b/src/Editor/Text/Util/TextUIUtil/ExtensionMethods.cs
index 9c1ba00..c22c853 100644
--- a/src/Editor/Text/Util/TextUIUtil/ExtensionMethods.cs
+++ b/src/Editor/Text/Util/TextUIUtil/ExtensionMethods.cs
@@ -7,47 +7,6 @@ namespace Microsoft.VisualStudio.Text.MultiSelection
{
public static class ExtensionMethods
{
- public static VirtualSnapshotPoint NormalizePoint(this ITextView view, VirtualSnapshotPoint point)
- {
- var line = view.GetTextViewLineContainingBufferPosition(point.Position);
-
- //If point is at the end of the line, return it (including any virtual space offset)
- if (point.Position >= line.End)
- {
- return new VirtualSnapshotPoint(line.End, point.VirtualSpaces);
- }
- else
- {
- //Otherwise align it with the begining of the containing text element &
- //return that (losing any virtual space).
- SnapshotSpan element = line.GetTextElementSpan(point.Position);
- return new VirtualSnapshotPoint(element.Start);
- }
- }
-
- public static Selection MapToSnapshot(this Selection region, ITextSnapshot snapshot, ITextView view)
- {
- var newInsertion = view.NormalizePoint(region.InsertionPoint.TranslateTo(snapshot));
- var newActive = view.NormalizePoint(region.ActivePoint.TranslateTo(snapshot));
- var newAnchor = view.NormalizePoint(region.AnchorPoint.TranslateTo(snapshot));
- PositionAffinity positionAffinity;
-
- if (region.Extent.Length == 0)
- {
- // Selection is just a caret, respect the caret's prefered affinity.
- positionAffinity = region.InsertionPointAffinity;
- }
- else
- {
- // Selection is non-zero length, adjust affinity so that it is always toward the body of the selection.
- // This attempts to ensure that the caret is always on the same line as the body of the selection in
- // word wrap scenarios.
- positionAffinity = newAnchor < newActive ? PositionAffinity.Predecessor : PositionAffinity.Successor;
- }
-
- return new Selection(newInsertion, newAnchor, newActive, positionAffinity);
- }
-
/// <summary>
/// Remaps a given x-coordinate to a valid point. If the provided x-coordinate is past the right end of the line, it will
/// be clipped to the correct position depending on the virtual space settings. If the ISmartIndent is providing indentation
@@ -80,8 +39,7 @@ namespace Microsoft.VisualStudio.Text.MultiSelection
{
//The indentation specified by the smart indent service is desired column position of the caret. Find out how much virtual space
//need to be at the end of the line to satisfy that.
- // TODO: need a way to determine column width in xplat scenarios, bug https://devdiv.visualstudio.com/DevDiv/_workitems/edit/637741
- double columnWidth = (textView is ITextView3 textView3) ? textView3.FormattedLineSource.ColumnWidth : throw new NotSupportedException();
+ double columnWidth = (textView.ViewScroller is IViewScroller2 viewScroller) ? viewScroller.ColumnWidth : 7;
indentationWidth = Math.Max(0.0, (((double)indentation.Value) * columnWidth - textLine.TextWidth));
// if the coordinate is specified by the user and the user has selected a coordinate to the left
@@ -98,6 +56,47 @@ namespace Microsoft.VisualStudio.Text.MultiSelection
return xCoordinate;
}
+ public static VirtualSnapshotPoint NormalizePoint(this ITextView view, VirtualSnapshotPoint point)
+ {
+ var line = view.GetTextViewLineContainingBufferPosition(point.Position);
+
+ //If point is at the end of the line, return it (including any virtual space offset)
+ if (point.Position >= line.End)
+ {
+ return new VirtualSnapshotPoint(line.End, point.VirtualSpaces);
+ }
+ else
+ {
+ //Otherwise align it with the begining of the containing text element &
+ //return that (losing any virtual space).
+ SnapshotSpan element = line.GetTextElementSpan(point.Position);
+ return new VirtualSnapshotPoint(element.Start);
+ }
+ }
+
+ public static Selection MapToSnapshot(this Selection region, ITextSnapshot snapshot, ITextView view)
+ {
+ var newInsertion = view.NormalizePoint(region.InsertionPoint.TranslateTo(snapshot));
+ var newActive = view.NormalizePoint(region.ActivePoint.TranslateTo(snapshot));
+ var newAnchor = view.NormalizePoint(region.AnchorPoint.TranslateTo(snapshot));
+ PositionAffinity positionAffinity;
+
+ if (region.Extent.Length == 0)
+ {
+ // Selection is just a caret, respect the caret's prefered affinity.
+ positionAffinity = region.InsertionPointAffinity;
+ }
+ else
+ {
+ // Selection is non-zero length, adjust affinity so that it is always toward the body of the selection.
+ // This attempts to ensure that the caret is always on the same line as the body of the selection in
+ // word wrap scenarios.
+ positionAffinity = newAnchor < newActive ? PositionAffinity.Predecessor : PositionAffinity.Successor;
+ }
+
+ return new Selection(newInsertion, newAnchor, newActive, positionAffinity);
+ }
+
/// <summary>
/// If you are looking at this, you're likely maintaining selection code, and should be aware that
/// virtual whitespace allowances are not simply checking a flag.
diff --git a/src/Editor/Text/Util/TextUIUtil/TextViewZoomManager.cs b/src/Editor/Text/Util/TextUIUtil/TextViewZoomManager.cs
new file mode 100644
index 0000000..fa7abb5
--- /dev/null
+++ b/src/Editor/Text/Util/TextUIUtil/TextViewZoomManager.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.Composition;
+using Microsoft.VisualStudio.Text.Editor;
+using Microsoft.VisualStudio.Utilities;
+
+namespace Microsoft.VisualStudio.Text.Utilities
+{
+ [Export(typeof(ITextViewZoomManager))]
+ internal class TextViewZoomManager : BaseProxyService<ITextViewZoomManager>, ITextViewZoomManager
+ {
+ [ImportImplementations(typeof(ITextViewZoomManager))]
+ protected override IEnumerable<Lazy<ITextViewZoomManager, IOrderable>> UnorderedImplementations { get; set; }
+
+ public void ZoomIn(ITextView textView)
+ {
+ BestImplementation.ZoomIn(textView);
+ }
+
+ public void ZoomOut(ITextView textView)
+ {
+ BestImplementation.ZoomOut(textView);
+ }
+
+ public void ZoomTo(ITextView textView, double zoomLevel)
+ {
+ BestImplementation.ZoomTo(textView, zoomLevel);
+ }
+
+ public double ZoomLevel(ITextView textView)
+ {
+ return BestImplementation.ZoomLevel(textView);
+ }
+ }
+}
diff --git a/src/OpenSource.Impl.projitems b/src/OpenSource.Impl.projitems
index edc92a9..aa6304f 100644
--- a/src/OpenSource.Impl.projitems
+++ b/src/OpenSource.Impl.projitems
@@ -45,10 +45,6 @@
<Private>$(ReferencesVSEditorCopyToOutput)</Private>
<Consolidate>true</Consolidate>
</ProjectReference>
- <ProjectReference Include="$(MSBuildThisFileDirectory)Editor\Text\Impl\BraceCompletion\BraceCompletionImpl.csproj">
- <Private>$(ReferencesVSEditorCopyToOutput)</Private>
- <Consolidate>true</Consolidate>
- </ProjectReference>
<ProjectReference Include="$(MSBuildThisFileDirectory)Editor\Text\Impl\TextBufferUndoManager\TextBufferUndoManagerImpl.csproj">
<Private>$(ReferencesVSEditorCopyToOutput)</Private>
<Consolidate>true</Consolidate>
@@ -122,4 +118,16 @@
<Consolidate>true</Consolidate>
</ProjectReference>
</ItemGroup>
+
+ <!-- Cocoa Projects -->
+ <ItemGroup Condition="$(HaveXamarinMac)">
+ <ProjectReference Include="$(MSBuildThisFileDirectory)Editor\Text\Util\TextUICocoaUtil\TextUICocoaUtil.csproj">
+ <Private>$(ReferencesVSEditorCopyToOutput)</Private>
+ <Consolidate>true</Consolidate>
+ </ProjectReference>
+ <ProjectReference Include="$(MSBuildThisFileDirectory)Editor\Text\Impl\BraceCompletion\BraceCompletionImpl.csproj">
+ <Private>$(ReferencesVSEditorCopyToOutput)</Private>
+ <Consolidate>true</Consolidate>
+ </ProjectReference>
+ </ItemGroup>
</Project> \ No newline at end of file