diff --git a/src/Eto.DevExtension.VisualStudio.Windows/Editor/EtoPreviewPane.cs b/src/Eto.DevExtension.VisualStudio.Windows/Editor/EtoPreviewPane.cs index 5fa67c7..e7a0b9a 100755 --- a/src/Eto.DevExtension.VisualStudio.Windows/Editor/EtoPreviewPane.cs +++ b/src/Eto.DevExtension.VisualStudio.Windows/Editor/EtoPreviewPane.cs @@ -27,6 +27,7 @@ using Microsoft.VisualStudio.Utilities; using Microsoft.VisualStudio.PlatformUI; using Microsoft.VisualStudio.Editor; +using Microsoft.VisualStudio.Editor.Internal; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Editor; using System.Windows.Media; @@ -43,7 +44,11 @@ public sealed class EtoPreviewPane : Microsoft.VisualStudio.Shell.WindowPane, IVsTextLinesEvents, IOleCommandTarget, IVsCodeWindow, // support setting breakpoints - IVsCodeWindowEx + IVsCodeWindowEx, + IVsFindTarget, // find in the embedded editor + IVsFindTarget2, + IVsFindTarget3, // enables the quick find bar instead of only the find dialog + IVsFindTarget4 { IVsTextLines textBuffer; CodeEditorHost editor; @@ -546,5 +551,48 @@ public override int LoadUIState(Stream stateStream) int IVsCodeWindowEx.Initialize(uint grfCodeWindowBehaviorFlags, VSUSERCONTEXTATTRIBUTEUSAGE usageAuxUserContext, string szNameAuxUserContext, string szValueAuxUserContext, uint InitViewFlags, INITVIEW[] pInitView) => ((IVsCodeWindowEx)editor.codeWindow).Initialize(grfCodeWindowBehaviorFlags, usageAuxUserContext, szNameAuxUserContext, szValueAuxUserContext, InitViewFlags, pInitView); int IVsCodeWindowEx.IsReadOnly() => ((IVsCodeWindowEx)editor.codeWindow).IsReadOnly(); + + IVsFindTarget FindTarget => editor.viewAdapter as IVsFindTarget; + + int IVsFindTarget.GetCapabilities(bool[] pfImage, uint[] pgrfOptions) => FindTarget?.GetCapabilities(pfImage, pgrfOptions) ?? VSConstants.E_FAIL; + int IVsFindTarget.GetProperty(uint propid, out object pvar) + { + pvar = null; + return FindTarget?.GetProperty(propid, out pvar) ?? VSConstants.E_FAIL; + } + int IVsFindTarget.GetSearchImage(uint grfOptions, IVsTextSpanSet[] ppSpans, out IVsTextImage ppTextImage) + { + ppTextImage = null; + return FindTarget?.GetSearchImage(grfOptions, ppSpans, out ppTextImage) ?? VSConstants.E_FAIL; + } + int IVsFindTarget.Find(string pszSearch, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out uint pResult) + { + pResult = 0; + return FindTarget?.Find(pszSearch, grfOptions, fResetStartPoint, pHelper, out pResult) ?? VSConstants.E_FAIL; + } + int IVsFindTarget.Replace(string pszSearch, string pszReplace, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out int pfReplaced) + { + pfReplaced = 0; + return FindTarget?.Replace(pszSearch, pszReplace, grfOptions, fResetStartPoint, pHelper, out pfReplaced) ?? VSConstants.E_FAIL; + } + int IVsFindTarget.GetMatchRect(RECT[] prc) => FindTarget?.GetMatchRect(prc) ?? VSConstants.E_FAIL; + int IVsFindTarget.NavigateTo(TextSpan[] pts) => FindTarget?.NavigateTo(pts) ?? VSConstants.E_FAIL; + int IVsFindTarget.GetCurrentSpan(TextSpan[] pts) => FindTarget?.GetCurrentSpan(pts) ?? VSConstants.E_FAIL; + int IVsFindTarget.SetFindState(object pUnk) => FindTarget?.SetFindState(pUnk) ?? VSConstants.E_FAIL; + int IVsFindTarget.GetFindState(out object ppunk) + { + ppunk = null; + return FindTarget?.GetFindState(out ppunk) ?? VSConstants.E_FAIL; + } + int IVsFindTarget.NotifyFindTarget(uint notification) => FindTarget?.NotifyFindTarget(notification) ?? VSConstants.E_FAIL; + int IVsFindTarget.MarkSpan(TextSpan[] pts) => FindTarget?.MarkSpan(pts) ?? VSConstants.E_FAIL; + + int IVsFindTarget2.NavigateTo2(IVsTextSpanSet pSpans, TextSelMode iSelMode) => (editor.viewAdapter as IVsFindTarget2)?.NavigateTo2(pSpans, iSelMode) ?? VSConstants.E_FAIL; + + int IVsFindTarget3.IsNewUISupported => (editor.viewAdapter as IVsFindTarget3)?.IsNewUISupported ?? 0; + int IVsFindTarget3.NotifyShowingNewUI() => (editor.viewAdapter as IVsFindTarget3)?.NotifyShowingNewUI() ?? VSConstants.E_FAIL; + + int IVsFindTarget4.IsAutonomous => (editor.viewAdapter as IVsFindTarget4)?.IsAutonomous ?? 0; + int IVsFindTarget4.IsIncrementalSearchSupported => (editor.viewAdapter as IVsFindTarget4)?.IsIncrementalSearchSupported ?? 0; } } diff --git a/src/Eto.DevExtension.VisualStudio.Windows/Editor/IVsFindTarget3.cs b/src/Eto.DevExtension.VisualStudio.Windows/Editor/IVsFindTarget3.cs new file mode 100644 index 0000000..d6fe296 --- /dev/null +++ b/src/Eto.DevExtension.VisualStudio.Windows/Editor/IVsFindTarget3.cs @@ -0,0 +1,23 @@ +using System.Runtime.InteropServices; + +// Not in the public SDK; VS asks a document for these to decide between the quick find bar and the find dialog. +// Namespace, names and TypeIdentifier must match VS's own declarations so casts to and from the editor's view succeed. +namespace Microsoft.VisualStudio.Editor.Internal +{ + [ComImport, TypeIdentifier, Guid("A2F0D62B-D0DD-4C59-AAB8-79CD20785451"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + public interface IVsFindTarget3 + { + int IsNewUISupported { [PreserveSig] get; } + + [PreserveSig] + int NotifyShowingNewUI(); + } + + [ComImport, TypeIdentifier, Guid("47AB8522-6BB1-4C85-BA88-E4B4513F8BE1"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + public interface IVsFindTarget4 + { + int IsAutonomous { [PreserveSig] get; } + + int IsIncrementalSearchSupported { [PreserveSig] get; } + } +} diff --git a/src/Eto.DevExtension.VisualStudio.Windows/Eto.DevExtension.VisualStudio.Windows.csproj b/src/Eto.DevExtension.VisualStudio.Windows/Eto.DevExtension.VisualStudio.Windows.csproj index 1f009c1..de483f5 100755 --- a/src/Eto.DevExtension.VisualStudio.Windows/Eto.DevExtension.VisualStudio.Windows.csproj +++ b/src/Eto.DevExtension.VisualStudio.Windows/Eto.DevExtension.VisualStudio.Windows.csproj @@ -85,6 +85,7 @@ +