From b9b507b8c9df9b55582caa660841821eb3d821ec Mon Sep 17 00:00:00 2001 From: Aaron Bockover Date: Wed, 9 Oct 2019 12:20:50 -0400 Subject: Sync with vs-editor-core@d2d414ba --- .../TextUI/AdornmentPositioningBehavior2.cs | 38 ++++++++++ .../Def/Internal/TextUI/IPreviewTextViewModel.cs | 20 ++++++ .../TextUIWpf/IViewSynchronizationManager.cs | 22 ------ src/Editor/Text/Def/TextLogic/AssemblyInfo.cs | 21 ++++++ .../BaseLeftBufferChangedEventArgs.cs | 24 +++++++ .../DifferenceBuffer/DifferenceBufferProperties.cs | 20 ++++++ .../DifferenceBuffer/IDifferenceBuffer2.cs | 39 ++++++---- .../DifferenceBuffer/IDifferenceBuffer3.cs | 16 +++++ .../IDifferenceBufferFactoryService.cs | 2 +- .../IDifferenceBufferFactoryService2.cs | 59 +++++++++++++++ src/Editor/Text/Def/TextUI/AssemblyInfo.cs | 2 + .../DifferenceViewer/DifferenceViewerOptions.cs | 7 +- .../DifferenceViewer/DifferenceViewerRoles.cs | 28 ++++++-- .../TextUI/DifferenceViewer/IDifferenceViewer2.cs | 23 +++++- .../TextUI/DifferenceViewer/IDifferenceViewer3.cs | 20 ++++++ .../IDifferenceViewerTextViewModel.cs | 49 +++++++++++++ src/Editor/Text/Def/TextUI/Editor/ITextView3.cs | 2 + .../TextUI/Editor/IViewSynchronizationManager.cs | 22 ++++++ .../Def/TextUI/EditorOptions/InternalOptions.cs | 30 ++++++++ .../DifferenceViewer/CreateTextViewHostCallback.cs | 30 ++++++++ .../DifferenceViewer/ICocoaDifferenceViewer.cs | 84 ++++++++++++++++++++++ .../ICocoaDifferenceViewerFactoryService.cs | 60 ++++++++++++++++ .../DifferenceViewer/IDifferenceTextViewModel.cs | 25 +++++++ .../IDifferenceTextViewModelProvider.cs | 30 ++++++++ .../Text/Impl/Outlining/OutliningManagerService.cs | 10 +++ .../DispatcherOperation.cs | 8 +-- 26 files changed, 644 insertions(+), 47 deletions(-) create mode 100644 src/Editor/Text/Def/Internal/TextUI/AdornmentPositioningBehavior2.cs create mode 100644 src/Editor/Text/Def/Internal/TextUI/IPreviewTextViewModel.cs delete mode 100644 src/Editor/Text/Def/Internal/TextUIWpf/IViewSynchronizationManager.cs create mode 100644 src/Editor/Text/Def/TextLogic/DifferenceBuffer/BaseLeftBufferChangedEventArgs.cs create mode 100644 src/Editor/Text/Def/TextLogic/DifferenceBuffer/DifferenceBufferProperties.cs create mode 100644 src/Editor/Text/Def/TextLogic/DifferenceBuffer/IDifferenceBuffer3.cs create mode 100644 src/Editor/Text/Def/TextLogic/DifferenceBuffer/IDifferenceBufferFactoryService2.cs create mode 100644 src/Editor/Text/Def/TextUI/DifferenceViewer/IDifferenceViewer3.cs create mode 100644 src/Editor/Text/Def/TextUI/DifferenceViewer/IDifferenceViewerTextViewModel.cs create mode 100644 src/Editor/Text/Def/TextUI/Editor/IViewSynchronizationManager.cs create mode 100644 src/Editor/Text/Def/TextUI/EditorOptions/InternalOptions.cs create mode 100644 src/Editor/Text/Def/TextUICocoa/DifferenceViewer/CreateTextViewHostCallback.cs create mode 100644 src/Editor/Text/Def/TextUICocoa/DifferenceViewer/ICocoaDifferenceViewer.cs create mode 100644 src/Editor/Text/Def/TextUICocoa/DifferenceViewer/ICocoaDifferenceViewerFactoryService.cs create mode 100644 src/Editor/Text/Def/TextUICocoa/DifferenceViewer/IDifferenceTextViewModel.cs create mode 100644 src/Editor/Text/Def/TextUICocoa/DifferenceViewer/IDifferenceTextViewModelProvider.cs diff --git a/src/Editor/Text/Def/Internal/TextUI/AdornmentPositioningBehavior2.cs b/src/Editor/Text/Def/Internal/TextUI/AdornmentPositioningBehavior2.cs new file mode 100644 index 0000000..8991855 --- /dev/null +++ b/src/Editor/Text/Def/Internal/TextUI/AdornmentPositioningBehavior2.cs @@ -0,0 +1,38 @@ +// +// 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. +// +namespace Microsoft.VisualStudio.Text.Editor +{ + /// + /// Defines the positioning of adornments. + /// + /// + /// This enum adds a mode to the AdornmentPositioningBehavior needed for diff but we don't want to expose. + /// + public enum AdornmentPositioningBehavior2 + { + /// + /// The adornment is not moved automatically. + /// + OwnerControlled = XPlatAdornmentPositioningBehavior.OwnerControlled, + + /// + /// The adornment is positioned relative to the top left corner of the view. + /// + ViewportRelative = XPlatAdornmentPositioningBehavior.ViewportRelative, + + /// + /// The adornment is positioned relative to the text in the view. + /// + TextRelative = XPlatAdornmentPositioningBehavior.TextRelative, + + /// + /// Behaves like a AdornmentPositioningBehavior.TextRelative adornment but only scrolls vertically. + /// + TextRelativeVerticalOnly + } +} \ No newline at end of file diff --git a/src/Editor/Text/Def/Internal/TextUI/IPreviewTextViewModel.cs b/src/Editor/Text/Def/Internal/TextUI/IPreviewTextViewModel.cs new file mode 100644 index 0000000..e562367 --- /dev/null +++ b/src/Editor/Text/Def/Internal/TextUI/IPreviewTextViewModel.cs @@ -0,0 +1,20 @@ +// +// 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. +// +namespace Microsoft.VisualStudio.Text.Editor +{ + /// + /// used by the view shown when hovering over the scroll bar (which will have the role). + /// + public interface IPreviewTextViewModel : ITextViewModel + { + /// + /// Pointer to the view for which this is a preview. + /// + ITextView SourceView { get; } + } +} diff --git a/src/Editor/Text/Def/Internal/TextUIWpf/IViewSynchronizationManager.cs b/src/Editor/Text/Def/Internal/TextUIWpf/IViewSynchronizationManager.cs deleted file mode 100644 index 70eddaa..0000000 --- a/src/Editor/Text/Def/Internal/TextUIWpf/IViewSynchronizationManager.cs +++ /dev/null @@ -1,22 +0,0 @@ -// -// 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.Formatting -{ - using Microsoft.VisualStudio.Text.Editor; - - /// - /// Manage the simultaneous layout to two . - /// - public interface IViewSynchronizationManager - { - ITextView GetSubordinateView(ITextView masterView); - - bool TryGetAnchorPointInSubordinateView(SnapshotPoint anchorPoint, out SnapshotPoint correspondingAnchorPoint); - - SnapshotPoint GetAnchorPointAboveInSubordinateView(SnapshotPoint anchorPoint); - - void WhichPairedLinesShouldBeDisplayed(SnapshotPoint masterAnchorPoint, SnapshotPoint subordinateAnchorPoint, out bool layoutMaster, out bool layoutSubordinate, bool goingUp); - } -} \ No newline at end of file diff --git a/src/Editor/Text/Def/TextLogic/AssemblyInfo.cs b/src/Editor/Text/Def/TextLogic/AssemblyInfo.cs index 9f96b01..5c9cc55 100644 --- a/src/Editor/Text/Def/TextLogic/AssemblyInfo.cs +++ b/src/Editor/Text/Def/TextLogic/AssemblyInfo.cs @@ -26,7 +26,28 @@ using System.Security.Permissions; [assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.Commanding.Implementation, PublicKey=" + ThisAssembly.PublicKey)] [assembly: InternalsVisibleTo("Microsoft.VisualStudio.Platform.VSEditor, PublicKey=" + ThisAssembly.PublicKey)] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.Implementation, PublicKey=" + ThisAssembly.PublicKey)] [assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.Implementation, PublicKey=" + ThisAssembly.PublicKey)] [assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.UI.Utilities, PublicKey=" + ThisAssembly.PublicKey)] [assembly: InternalsVisibleTo("Microsoft.VisualStudio.Language.Implementation, PublicKey=" + ThisAssembly.PublicKey)] [assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.TextViewUnitTestHelper, PublicKey=" + ThisAssembly.PublicKey)] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Logic.Text.BufferUndoManager.Implementation, PublicKey=" + ThisAssembly.PublicKey)] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.EditorOptions.Implementation, PublicKey=" + ThisAssembly.PublicKey)] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.DifferenceViewer.Implementation, PublicKey=" + ThisAssembly.PublicKey)] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.Wpf.View.Implementation, PublicKey=" + ThisAssembly.PublicKey)] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.Cocoa.View.Implementation, PublicKey=" + ThisAssembly.PublicKey)] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Logic.Text.Tagging.Aggregator.Implementation, PublicKey=" + ThisAssembly.PublicKey)] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.UI.WPF.Utilities, PublicKey=" + ThisAssembly.PublicKey)] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Language.Intellisense.Implementation, PublicKey=" + ThisAssembly.PublicKey)] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.DeferCreation.Implementation.UnitTests, PublicKey=" + ThisAssembly.PublicKey)] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Logic.Text.Find.Implementation, PublicKey=" + ThisAssembly.PublicKey)] +[assembly: InternalsVisibleTo("Logic.Text.Find.Implementation.UnitTests, PublicKey=" + ThisAssembly.PublicKey)] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.Outlining.Implementation, PublicKey=" + ThisAssembly.PublicKey)] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.Wpf.OutliningMargin.Implementation, PublicKey=" + ThisAssembly.PublicKey)] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.UnitTests, PublicKey=" + ThisAssembly.PublicKey)] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.Implementation.StandaloneUndo, PublicKey=" + ThisAssembly.PublicKey)] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Logic.Text.BufferUndoManager.UnitTests, PublicKey=" + ThisAssembly.PublicKey)] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.Internal.UnitTests, PublicKey=" + ThisAssembly.PublicKey)] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.IndentationManager.Implementation, PublicKey=" + ThisAssembly.PublicKey)] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.EditorOperations.UnitTests, PublicKey=" + ThisAssembly.PublicKey)] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.Find.Implementation, PublicKey=" + ThisAssembly.PublicKey)] diff --git a/src/Editor/Text/Def/TextLogic/DifferenceBuffer/BaseLeftBufferChangedEventArgs.cs b/src/Editor/Text/Def/TextLogic/DifferenceBuffer/BaseLeftBufferChangedEventArgs.cs new file mode 100644 index 0000000..2a4ddc8 --- /dev/null +++ b/src/Editor/Text/Def/TextLogic/DifferenceBuffer/BaseLeftBufferChangedEventArgs.cs @@ -0,0 +1,24 @@ +// +// 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.Differencing +{ + using System; + + /// + /// Raised whenever the left buffer of an changes. This can only + /// happen if is false. + /// + public class BaseLeftBufferChangedEventArgs : EventArgs + { + public BaseLeftBufferChangedEventArgs(ITextBuffer oldBuffer, ITextBuffer newBuffer) + { + this.OldBuffer = oldBuffer; + this.NewBuffer = newBuffer; + } + + public ITextBuffer OldBuffer { get; } + public ITextBuffer NewBuffer { get; } + } +} diff --git a/src/Editor/Text/Def/TextLogic/DifferenceBuffer/DifferenceBufferProperties.cs b/src/Editor/Text/Def/TextLogic/DifferenceBuffer/DifferenceBufferProperties.cs new file mode 100644 index 0000000..abd4b7d --- /dev/null +++ b/src/Editor/Text/Def/TextLogic/DifferenceBuffer/DifferenceBufferProperties.cs @@ -0,0 +1,20 @@ +// +// 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.Differencing +{ + public static class DifferenceBufferProperties + { + /// + /// Add this property to an to prevent a difference buffer from computing differences when the buffer + /// is used as the left buffer. + /// + /// + /// This is intended for situations where you want to open a difference buffer but have not, yet, loaded the baseline. You can set the + /// to this and then change it to the correct buffer once it is available. + /// + public const string PlaceholderBuffer = "PlaceholderBuffer"; + } +} diff --git a/src/Editor/Text/Def/TextLogic/DifferenceBuffer/IDifferenceBuffer2.cs b/src/Editor/Text/Def/TextLogic/DifferenceBuffer/IDifferenceBuffer2.cs index ebfecb6..6370508 100644 --- a/src/Editor/Text/Def/TextLogic/DifferenceBuffer/IDifferenceBuffer2.cs +++ b/src/Editor/Text/Def/TextLogic/DifferenceBuffer/IDifferenceBuffer2.cs @@ -9,22 +9,35 @@ namespace Microsoft.VisualStudio.Text.Differencing public interface IDifferenceBuffer2 : IDifferenceBuffer { /// - /// The source of the left buffer in the difference. Can be set to null. + /// True if the BaseLeftBuffer can never change. If false, the BaseLeftBuffer can change (via setting the InnerLeftDataModel) and + /// can be null. /// - new ITextBuffer BaseLeftBuffer { get; set; } + bool HasFixedBaseLeftBuffer { get; } - event EventHandler BaseLeftBufferChanged; - } + /// + /// Raised whenever the is changed to a different buffer. + /// + event EventHandler BaseLeftBufferChanged; - public class BufferChangedEventArgs : EventArgs - { - public BufferChangedEventArgs(ITextBuffer oldBuffer, ITextBuffer newBuffer) - { - this.OldBuffer = oldBuffer; - this.NewBuffer = newBuffer; - } + /// + /// The for the BaseLeftBuffer. This can be created even if is null. + /// + ITextDataModel LeftDataModel { get; } + + /// + /// The actual ITextDataModel for the BaseLeftBuffer. This value is only meaningful if is + /// false. Set InnerLeftDataModel to null to set the difference buffer's BaseLeftBuffer to null. + /// + ITextDataModel InnerLeftDataModel { get; set; } - public ITextBuffer OldBuffer { get; } - public ITextBuffer NewBuffer { get; } + /// + /// The for the right buffer. + /// + ITextDataModel RightDataModel { get; } + + /// + /// The for the inline buffer. This can be created even if is null. + /// + ITextDataModel InlineDataModel { get; } } } diff --git a/src/Editor/Text/Def/TextLogic/DifferenceBuffer/IDifferenceBuffer3.cs b/src/Editor/Text/Def/TextLogic/DifferenceBuffer/IDifferenceBuffer3.cs new file mode 100644 index 0000000..ce3ef4b --- /dev/null +++ b/src/Editor/Text/Def/TextLogic/DifferenceBuffer/IDifferenceBuffer3.cs @@ -0,0 +1,16 @@ +// +// 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.Differencing +{ + using System; + + public interface IDifferenceBuffer3 : IDifferenceBuffer2 + { + /// + /// Raised whenever the is about to change to a different buffer. + /// + event EventHandler BaseLeftBufferChanging; + } +} diff --git a/src/Editor/Text/Def/TextLogic/DifferenceBuffer/IDifferenceBufferFactoryService.cs b/src/Editor/Text/Def/TextLogic/DifferenceBuffer/IDifferenceBufferFactoryService.cs index 5e5d61c..aaaeb26 100644 --- a/src/Editor/Text/Def/TextLogic/DifferenceBuffer/IDifferenceBufferFactoryService.cs +++ b/src/Editor/Text/Def/TextLogic/DifferenceBuffer/IDifferenceBufferFactoryService.cs @@ -19,7 +19,7 @@ namespace Microsoft.VisualStudio.Text.Differencing /// /// The left (old, before) buffer. /// The right (new, after) buffer. - /// This is equivalent to calling CreateDifferenceBuffer(left, right, new StringDifferenceOptions());. + /// This is equivalent to calling CreateDifferenceBuffer(left, right, new StringDifferenceOptions());. IDifferenceBuffer CreateDifferenceBuffer(ITextBuffer leftBaseBuffer, ITextBuffer rightBaseBuffer); /// diff --git a/src/Editor/Text/Def/TextLogic/DifferenceBuffer/IDifferenceBufferFactoryService2.cs b/src/Editor/Text/Def/TextLogic/DifferenceBuffer/IDifferenceBufferFactoryService2.cs new file mode 100644 index 0000000..10cf48c --- /dev/null +++ b/src/Editor/Text/Def/TextLogic/DifferenceBuffer/IDifferenceBufferFactoryService2.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +using Microsoft.VisualStudio.Text.Projection; + +namespace Microsoft.VisualStudio.Text.Differencing +{ + /// + /// A factory for creating instances. + /// + /// + /// This is a MEF service and can be imported. + /// + public interface IDifferenceBufferFactoryService2 : IDifferenceBufferFactoryService + { + /// + /// Create an for the given left and right buffers and with the given difference options. + /// + /// The left (old, before) buffer. + /// The right (new, after) buffer. + /// The options to use in computing differences between the buffers. + /// If true, disable editing in the right and inlines views. + /// If true, create a read-only projection of (which will prevent + /// that buffer from being modified through the difference buffers). + /// If true and editing is disabled, create a read-only projection of (which will prevent + /// that buffer from being modified through the difference buffers). + /// Allows, if false, the can be changed. + /// + /// If is false, then is ignored (and the right buffer will not be wrapped). + /// If is false, then the caller of this method is responsible for making sure is read-only. + /// If is true and is false, then the caller of this method is responsible for making sure is read-only. + /// If is false, then is ignored and can be null. + /// + IDifferenceBuffer2 CreateDifferenceBuffer(ITextBuffer leftBaseBuffer, ITextBuffer rightBaseBuffer, StringDifferenceOptions options, + bool disableEditing, bool wrapLeftBuffer, bool wrapRightBuffer, bool fixedBaseLeftBuffer); + + /// + /// Create an for the given left and right buffers and with the given difference options. + /// + /// The data model for the left buffer. This can be null. + /// The right (new, after) buffer. + /// The options to use in computing differences between the buffers. + /// If true, disable editing in the right and inlines views. + /// If true, create a read-only projection of (which will prevent + /// that buffer from being modified through the difference buffers). + /// If true and editing is disabled, create a read-only projection of (which will prevent + /// that buffer from being modified through the difference buffers). + /// Allows, if false, the can be changed. + /// + /// If is false, then is ignored (and the right buffer will not be wrapped). + /// If is false, then the caller of this method is responsible for making sure is read-only. + /// If is true and is false, then the caller of this method is responsible for making sure is read-only. + /// If is false, then is ignored and can be null. + /// + IDifferenceBuffer2 CreateDifferenceBuffer(ITextDataModel innerLeftDataModel, ITextDataModel rightDataModel, StringDifferenceOptions options, + bool disableEditing, bool wrapLeftBuffer, bool wrapRightBuffer, bool fixedBaseLeftBuffer); + } +} diff --git a/src/Editor/Text/Def/TextUI/AssemblyInfo.cs b/src/Editor/Text/Def/TextUI/AssemblyInfo.cs index e404e66..b904d55 100644 --- a/src/Editor/Text/Def/TextUI/AssemblyInfo.cs +++ b/src/Editor/Text/Def/TextUI/AssemblyInfo.cs @@ -16,6 +16,8 @@ using System.Security.Permissions; [assembly: InternalsVisibleTo("Microsoft.VisualStudio.UI.Text.Commanding.Implementation.UnitTests, PublicKey=" + ThisAssembly.PublicKey)] [assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.UI.Utilities, PublicKey=" + ThisAssembly.PublicKey)] [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)] // InternalsVisibleTo for VS for Mac implementation assembly: [assembly: InternalsVisibleTo("Microsoft.VisualStudio.Text.Implementation, PublicKey=0024000004800000940000000602000000240000525341310004000001000100e57febc1f220077550a65e338d3d15d7cbd189cf4f62f7c3829dcb2f8441a6c40631d172e3deb4dc0bb7237b44ec9daeb9bd7d72c3d64c4f52b968795443cb58bc341583c29440345b8c35f72f6a31aecb2903376136f8fc35779bb422eb643f8668fa6605c697bff927e3bb10745328ff878bd1b7e42bbcb839f04baa8460bd")] diff --git a/src/Editor/Text/Def/TextUI/DifferenceViewer/DifferenceViewerOptions.cs b/src/Editor/Text/Def/TextUI/DifferenceViewer/DifferenceViewerOptions.cs index d4b0ba3..21ae0f9 100644 --- a/src/Editor/Text/Def/TextUI/DifferenceViewer/DifferenceViewerOptions.cs +++ b/src/Editor/Text/Def/TextUI/DifferenceViewer/DifferenceViewerOptions.cs @@ -35,12 +35,17 @@ namespace Microsoft.VisualStudio.Text.Differencing public static readonly EditorOptionKey SynchronizeSideBySideViewsId = new EditorOptionKey(DifferenceViewerOptions.SynchronizeSideBySideViewsName); public const string SynchronizeSideBySideViewsName = "Diff/View/SynchronizeSideBySideViews"; - /// /// If true, show the difference overview margin. /// public static readonly EditorOptionKey ShowDiffOverviewMarginId = new EditorOptionKey(DifferenceViewerOptions.ShowDiffOverviewMarginName); public const string ShowDiffOverviewMarginName = "Diff/View/ShowDiffOverviewMargin"; + + /// + /// If this is false, then the difference viewer will, even if a baseline has been specified, not show any differences. + /// + public static readonly EditorOptionKey ShowDifferencesId = new EditorOptionKey(DifferenceViewerOptions.ShowDifferencesName); + public const string ShowDifferencesName = "ShowDifferences"; } /// diff --git a/src/Editor/Text/Def/TextUI/DifferenceViewer/DifferenceViewerRoles.cs b/src/Editor/Text/Def/TextUI/DifferenceViewer/DifferenceViewerRoles.cs index 77b7fa8..44e19c3 100644 --- a/src/Editor/Text/Def/TextUI/DifferenceViewer/DifferenceViewerRoles.cs +++ b/src/Editor/Text/Def/TextUI/DifferenceViewer/DifferenceViewerRoles.cs @@ -10,23 +10,43 @@ namespace Microsoft.VisualStudio.Text.Differencing public static class DifferenceViewerRoles { /// - /// The text view role for any view owned by an . + /// The text view role for any view owned by an when the underlying difference buffer will never have a null . /// public const string DiffTextViewRole = "DIFF"; /// - /// The text view role for the . + /// The text view role for the when the underlying difference buffer will never have a null . /// public const string LeftViewTextViewRole = "LEFTDIFF"; /// - /// The text view role for the . + /// The text view role for the when the underlying difference buffer will never have a null . /// public const string RightViewTextViewRole = "RIGHTDIFF"; /// - /// The text view role for the . + /// The text view role for the when the underlying difference buffer will never have a null . /// public const string InlineViewTextViewRole = "INLINEDIFF"; + + /// + /// The text view role for any view owned by an when the underlying difference buffer supports a null . + /// + public const string UbiquitousDiffTextViewRole = "UBIDIFF"; + + /// + /// The text view role for the when the underlying difference buffer supports a null . + /// + public const string UbiquitousLeftViewTextViewRole = "UBILEFTDIFF"; + + /// + /// The text view role for the when the underlying difference buffer supports a null . + /// + public const string UbiquitousRightViewTextViewRole = "UBIRIGHTDIFF"; + + /// + /// The text view role for the when the underlying difference buffer supports a null . + /// + public const string UbiquitousInlineViewTextViewRole = "UBIINLINEDIFF"; } } diff --git a/src/Editor/Text/Def/TextUI/DifferenceViewer/IDifferenceViewer2.cs b/src/Editor/Text/Def/TextUI/DifferenceViewer/IDifferenceViewer2.cs index 3b9a4a8..e1e1055 100644 --- a/src/Editor/Text/Def/TextUI/DifferenceViewer/IDifferenceViewer2.cs +++ b/src/Editor/Text/Def/TextUI/DifferenceViewer/IDifferenceViewer2.cs @@ -9,8 +9,27 @@ namespace Microsoft.VisualStudio.Text.Differencing public interface IDifferenceViewer2 : IDifferenceViewer { /// - /// Raised when the difference viewer is fully initialized. + /// Does the right view exist? /// - event EventHandler Initialized; + /// + /// Differences views are created lazily will create the view if it does not already exist. + /// + bool RightViewExists { get; } + + /// + /// Does the left view exist? + /// + /// + /// Differences views are created lazily will create the view if it does not already exist. + /// + bool LeftViewExists { get; } + + /// + /// Does the Inline view exist? + /// + /// + /// Differences views are created lazily will create the view if it does not already exist. + /// + bool InlineViewExists { get; } } } diff --git a/src/Editor/Text/Def/TextUI/DifferenceViewer/IDifferenceViewer3.cs b/src/Editor/Text/Def/TextUI/DifferenceViewer/IDifferenceViewer3.cs new file mode 100644 index 0000000..517a5b0 --- /dev/null +++ b/src/Editor/Text/Def/TextUI/DifferenceViewer/IDifferenceViewer3.cs @@ -0,0 +1,20 @@ +// +// 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.Differencing +{ + using System; + + public interface IDifferenceViewer3 : IDifferenceViewer2 + { + /// + /// Should the differences be displayed? + /// + /// + /// This will be true if and only if there is a baseline and if the option is true. + /// will be raised whenever this value changes. + /// + bool DisplayDifferences { get; } + } +} diff --git a/src/Editor/Text/Def/TextUI/DifferenceViewer/IDifferenceViewerTextViewModel.cs b/src/Editor/Text/Def/TextUI/DifferenceViewer/IDifferenceViewerTextViewModel.cs new file mode 100644 index 0000000..fa5a33a --- /dev/null +++ b/src/Editor/Text/Def/TextUI/DifferenceViewer/IDifferenceViewerTextViewModel.cs @@ -0,0 +1,49 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +using Microsoft.VisualStudio.Text.Editor; + +namespace Microsoft.VisualStudio.Text.Differencing +{ + /// + /// A used by . + /// + internal interface IDifferenceViewerTextViewModel + { + /// + /// The view type for a view created by an . + /// + DifferenceViewType ViewType { get; } + + /// + /// The currently-used snapshot difference that matches up with the current snapshot + /// of the inline buffer. + /// + /// Will be null before the first snapshot difference is computed. + ISnapshotDifference CurrentSnapshotDifference { get; } + + /// + /// Are the left and right views are synchronized in the side by side view. + /// + /// + /// In the side by side view, the left and right views are, normally, synchronized so that so that matching text always shown in each view. + /// If this synchronization is turned off, then each view will scroll independently. + /// + bool AreViewsSynchronized { get; } + + /// + /// The view for displaying the left buffer for differences. + /// + /// Will never be null, but will only be visible when view mode + /// is set to . + ITextView LeftView { get; } + + /// + /// The view for displaying the right buffer for differences. + /// + /// Will never be null, but will only be visible when view mode + /// is set to . + ITextView RightView { get; } + } +} diff --git a/src/Editor/Text/Def/TextUI/Editor/ITextView3.cs b/src/Editor/Text/Def/TextUI/Editor/ITextView3.cs index b4a6a0f..f7b5b64 100644 --- a/src/Editor/Text/Def/TextUI/Editor/ITextView3.cs +++ b/src/Editor/Text/Def/TextUI/Editor/ITextView3.cs @@ -24,5 +24,7 @@ namespace Microsoft.VisualStudio.Text.Editor 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/TextUI/Editor/IViewSynchronizationManager.cs new file mode 100644 index 0000000..70eddaa --- /dev/null +++ b/src/Editor/Text/Def/TextUI/Editor/IViewSynchronizationManager.cs @@ -0,0 +1,22 @@ +// +// 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.Formatting +{ + using Microsoft.VisualStudio.Text.Editor; + + /// + /// Manage the simultaneous layout to two . + /// + public interface IViewSynchronizationManager + { + ITextView GetSubordinateView(ITextView masterView); + + bool TryGetAnchorPointInSubordinateView(SnapshotPoint anchorPoint, out SnapshotPoint correspondingAnchorPoint); + + SnapshotPoint GetAnchorPointAboveInSubordinateView(SnapshotPoint anchorPoint); + + void WhichPairedLinesShouldBeDisplayed(SnapshotPoint masterAnchorPoint, SnapshotPoint subordinateAnchorPoint, out bool layoutMaster, out bool layoutSubordinate, bool goingUp); + } +} \ No newline at end of file diff --git a/src/Editor/Text/Def/TextUI/EditorOptions/InternalOptions.cs b/src/Editor/Text/Def/TextUI/EditorOptions/InternalOptions.cs new file mode 100644 index 0000000..3c23800 --- /dev/null +++ b/src/Editor/Text/Def/TextUI/EditorOptions/InternalOptions.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. +// +// This file contain internal APIs that are subject to change without notice. +// Use at your own risk. +// +namespace Microsoft.VisualStudio.Text.Editor +{ + /// + /// Various editor options that we shouldn't be made public. + /// + internal static class InternalOptions + { + public const string SuppressOutliningOptionName = "SuppressOutlining"; + public readonly static EditorOptionKey SuppressOutliningOptionId = new EditorOptionKey(SuppressOutliningOptionName); + + /// + /// The option definition that determines the vertical scroll sensitivity in Editor. + /// + internal static readonly EditorOptionKey EditorVerticalScrollSensitivityId = new EditorOptionKey(EditorVerticalScrollSensitivityName); + internal const string EditorVerticalScrollSensitivityName = "EditorVerticalScrollSensitivity"; + + /// + /// The option definition that determines the horizontal scroll sensitivity in Editor. + /// + internal static readonly EditorOptionKey EditorHorizontalScrollSensitivityId = new EditorOptionKey(EditorHorizontalScrollSensitivityName); + internal const string EditorHorizontalScrollSensitivityName = "EditorHorizontalScrollSensitivity"; + } +} diff --git a/src/Editor/Text/Def/TextUICocoa/DifferenceViewer/CreateTextViewHostCallback.cs b/src/Editor/Text/Def/TextUICocoa/DifferenceViewer/CreateTextViewHostCallback.cs new file mode 100644 index 0000000..8afd865 --- /dev/null +++ b/src/Editor/Text/Def/TextUICocoa/DifferenceViewer/CreateTextViewHostCallback.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. +// +using System.Windows; +using AppKit; +using Microsoft.VisualStudio.Text.Editor; + +namespace Microsoft.VisualStudio.Text.Differencing +{ + /// + /// Callback used with to create a text view host. + /// + /// The text view model to use in creating the text view. + /// The roles specific to this view. + /// The options to use in creating the text view. + /// The top-level visual element for this host. + /// The created text view host. + /// + /// + /// To get standard text view roles, the implementation of this method should concatenate the given with + /// . + /// + /// + /// In most cases, the visual element can just be the 's . + /// + /// + public delegate void CreateTextViewHostCallback(IDifferenceTextViewModel textViewModel, ITextViewRoleSet roles, IEditorOptions options, + out NSView visualElement, out ICocoaTextViewHost textViewHost); +} diff --git a/src/Editor/Text/Def/TextUICocoa/DifferenceViewer/ICocoaDifferenceViewer.cs b/src/Editor/Text/Def/TextUICocoa/DifferenceViewer/ICocoaDifferenceViewer.cs new file mode 100644 index 0000000..cb5dd97 --- /dev/null +++ b/src/Editor/Text/Def/TextUICocoa/DifferenceViewer/ICocoaDifferenceViewer.cs @@ -0,0 +1,84 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +using System.Windows; +using AppKit; +using Microsoft.VisualStudio.Text.Editor; + +namespace Microsoft.VisualStudio.Text.Differencing +{ + /// + /// A Cocoa-specific version of an , which provides access to the + /// used to host the viewer and the various text view hosts as . + /// + public interface ICocoaDifferenceViewer : IDifferenceViewer + { + /// + /// Initialize the DifferenceViewer, hooking it to the specified buffer and using the callback to create the text view hosts. + /// + /// + /// + /// + /// + /// This method should only be called if the CreateUninitializedDifferenceView method on the is used. Otherwise, it is + /// called by the factory. + /// The viewer does not have to be initialized immediately. You can wait until the Loaded event on the VisualElement. + /// + void Initialize(IDifferenceBuffer differenceBuffer, + CreateTextViewHostCallback createTextViewHost, + IEditorOptions parentOptions = null); + + /// + /// Has this viewer been initialized? + /// + bool IsInitialized { get; } + + /// + /// The view for displaying differences. + /// + /// Will never be null, but will only be visible when + /// is set to . + new ICocoaTextView InlineView { get; } + + /// + /// The view for displaying the left buffer for differences. + /// + /// Will never be null, but will only be visible when + /// is set to . + new ICocoaTextView LeftView { get; } + + /// + /// The view for displaying the right buffer for differences. + /// + /// Will never be null, but will only be visible when + /// is set to . + new ICocoaTextView RightView { get; } + + /// + /// The host for displaying differences. + /// + /// Will never be null, but will only be visible when + /// is set to . + ICocoaTextViewHost InlineHost { get; } + + /// + /// The host for displaying the left buffer for differences. + /// + /// Will never be null, but will only be visible when + /// is set to . + ICocoaTextViewHost LeftHost { get; } + + /// + /// The host for displaying the right buffer for differences. + /// + /// Will never be null, but will only be visible when + /// is set to . + ICocoaTextViewHost RightHost { get; } + + /// + /// The visual element of this viewer. + /// + NSView VisualElement { get; } + } +} diff --git a/src/Editor/Text/Def/TextUICocoa/DifferenceViewer/ICocoaDifferenceViewerFactoryService.cs b/src/Editor/Text/Def/TextUICocoa/DifferenceViewer/ICocoaDifferenceViewerFactoryService.cs new file mode 100644 index 0000000..2fda646 --- /dev/null +++ b/src/Editor/Text/Def/TextUICocoa/DifferenceViewer/ICocoaDifferenceViewerFactoryService.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +using Microsoft.VisualStudio.Text.Editor; + +namespace Microsoft.VisualStudio.Text.Differencing +{ + /// + /// A service for creating s. + /// + /// + /// This is a MEF service to be imported. + /// + public interface ICocoaDifferenceViewerFactoryService + { + /// + /// Create an over the given . + /// + /// The difference buffer to display. + /// The parent of the editor options for the difference viewer (if null, the global options are the parent). + /// A difference viewer. + ICocoaDifferenceViewer CreateDifferenceView(IDifferenceBuffer buffer, IEditorOptions parentOptions = null); + + /// + /// Create an over the given with the given set of roles. + /// + /// The difference buffer to display. + /// The text view roles to use for the created views. + /// The parent of the editor options for the difference viewer (if null, the global options are the parent). + /// A difference viewer. + ICocoaDifferenceViewer CreateDifferenceView(IDifferenceBuffer buffer, ITextViewRoleSet roles, IEditorOptions parentOptions = null); + + /// + /// Create an over the given , using the given + /// callback to create the individual views (inline, left, and right). + /// + /// The difference buffer to display. + /// The callback to use to create individual views. + /// The parent of the editor options for the difference viewer (if null, the global options are the parent). + /// A difference viewer. + ICocoaDifferenceViewer CreateDifferenceView(IDifferenceBuffer buffer, CreateTextViewHostCallback callback, IEditorOptions parentOptions = null); + + /// + /// Create an over the given , without initializing it. + /// + /// A difference viewer. + /// + /// The only legitimate property call on an uninitialized viwer is the VisualElement property. + /// + ICocoaDifferenceViewer CreateUninitializedDifferenceView(); + + /// + /// If the given text view is owned by a difference viewer, retrieve that difference viewer. + /// + /// The view to find the difference viewer for. + /// A difference viewer, if one exists. Otherwise, null. + ICocoaDifferenceViewer TryGetViewerForTextView(ITextView textView); + } +} diff --git a/src/Editor/Text/Def/TextUICocoa/DifferenceViewer/IDifferenceTextViewModel.cs b/src/Editor/Text/Def/TextUICocoa/DifferenceViewer/IDifferenceTextViewModel.cs new file mode 100644 index 0000000..e8a788f --- /dev/null +++ b/src/Editor/Text/Def/TextUICocoa/DifferenceViewer/IDifferenceTextViewModel.cs @@ -0,0 +1,25 @@ +// +// 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.Differencing +{ + using Microsoft.VisualStudio.Text.Editor; + + /// + /// Represents a set of zero or more objects that are unique to the presentation of text + /// in a particular . + /// + public interface IDifferenceTextViewModel : ITextViewModel + { + /// + /// A pointer to the difference viewer that created the view that uses this IDifferenceTextViewModel. + /// + ICocoaDifferenceViewer Viewer { get; } + + /// + /// The type of the view that uses this IDifferenceTextViewModel. + /// + DifferenceViewType ViewType { get; } + } +} diff --git a/src/Editor/Text/Def/TextUICocoa/DifferenceViewer/IDifferenceTextViewModelProvider.cs b/src/Editor/Text/Def/TextUICocoa/DifferenceViewer/IDifferenceTextViewModelProvider.cs new file mode 100644 index 0000000..cce4075 --- /dev/null +++ b/src/Editor/Text/Def/TextUICocoa/DifferenceViewer/IDifferenceTextViewModelProvider.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. +// + +using Microsoft.VisualStudio.Text.Editor; + +namespace Microsoft.VisualStudio.Text.Differencing +{ + /// + /// Provides objects. + /// + /// This is a MEF component part, and should be exported with the following attribute: + /// [Export(NameSource=typeof(ITextViewModelProvider))] + /// Component exporters must specify at least one ContentTypeAttribute characterizing the data + /// models to which they apply. + /// + public interface IDifferenceTextViewModelProvider + { + /// + /// Creates an for the given . + /// + /// The in which the views are being created. + /// The of the view being created. + /// The for which to create the . + /// The created for , + /// or null if the text view model cannot be created. + IDifferenceTextViewModel CreateTextViewModel(ICocoaDifferenceViewer viewer, DifferenceViewType viewType, ITextDataModel dataModel); + } +} diff --git a/src/Editor/Text/Impl/Outlining/OutliningManagerService.cs b/src/Editor/Text/Impl/Outlining/OutliningManagerService.cs index 081672e..57e5dd5 100644 --- a/src/Editor/Text/Impl/Outlining/OutliningManagerService.cs +++ b/src/Editor/Text/Impl/Outlining/OutliningManagerService.cs @@ -12,6 +12,7 @@ namespace Microsoft.VisualStudio.Text.Outlining using Microsoft.VisualStudio.Text.Editor; using Microsoft.VisualStudio.Text.Tagging; using Microsoft.VisualStudio.Threading; + using Microsoft.VisualStudio.Utilities; using Microsoft.Win32; [Export(typeof(IOutliningManagerService))] @@ -41,5 +42,14 @@ namespace Microsoft.VisualStudio.Text.Outlining return manager; }); } + + [Export(typeof(EditorOptionDefinition))] + [Name(InternalOptions.SuppressOutliningOptionName)] + internal sealed class SuppressOutliningOption : EditorOptionDefinition + { + public override bool Default => false; + + public override EditorOptionKey Key => InternalOptions.SuppressOutliningOptionId; + } } } diff --git a/src/FPF/WindowsBase/System.Windows.Threading/DispatcherOperation.cs b/src/FPF/WindowsBase/System.Windows.Threading/DispatcherOperation.cs index 4fd9847..256ccb8 100644 --- a/src/FPF/WindowsBase/System.Windows.Threading/DispatcherOperation.cs +++ b/src/FPF/WindowsBase/System.Windows.Threading/DispatcherOperation.cs @@ -7,6 +7,7 @@ using System.Threading; using System.Threading.Tasks; using CoreFoundation; +using Foundation; namespace System.Windows.Threading { @@ -56,7 +57,7 @@ namespace System.Windows.Threading internal DispatcherOperation BeginInvoke() { - DispatchQueue.MainQueue.DispatchAsync(() => + NSRunLoop.Main.BeginInvokeOnMainThread(() => { CoreInvoke(beginInvokeBehavior: true); if (exception != null) @@ -71,7 +72,7 @@ namespace System.Windows.Threading if (taskSource == null) throw new InvalidOperationException(); - DispatchQueue.MainQueue.DispatchAsync(() => + NSRunLoop.Main.BeginInvokeOnMainThread(() => { try { @@ -102,8 +103,7 @@ namespace System.Windows.Threading var mainQueue = DispatchQueue.MainQueue; if (DispatchQueue.CurrentQueue != mainQueue) - mainQueue.DispatchSync( - () => CoreInvoke(beginInvokeBehavior: false)); + NSRunLoop.Main.InvokeOnMainThread(() => CoreInvoke(beginInvokeBehavior: false)); else CoreInvoke(beginInvokeBehavior: false); -- cgit v1.2.3