diff options
Diffstat (limited to 'src/Editor/Text/Def/TextUI')
18 files changed, 221 insertions, 16 deletions
diff --git a/src/Editor/Text/Def/TextUI/Commanding/CommandExecutionContext.cs b/src/Editor/Text/Def/TextUI/Commanding/CommandExecutionContext.cs index 72efbf0..235e8d9 100644 --- a/src/Editor/Text/Def/TextUI/Commanding/CommandExecutionContext.cs +++ b/src/Editor/Text/Def/TextUI/Commanding/CommandExecutionContext.cs @@ -7,7 +7,7 @@ namespace Microsoft.VisualStudio.Commanding /// Represents a command execution context, which is set up by a command handler service /// and provided to each command handler. /// </summary> - public sealed class CommandExecutionContext + public sealed class CommandExecutionContext : IPropertyOwner { /// <summary> /// Creates new instance of the <see cref="CommandExecutionContext"/>. @@ -15,6 +15,7 @@ namespace Microsoft.VisualStudio.Commanding public CommandExecutionContext(IUIThreadOperationContext operationContext) { this.OperationContext = operationContext ?? throw new ArgumentNullException(nameof(operationContext)); + this.Properties = new PropertyCollection(); } /// <summary> @@ -22,6 +23,10 @@ namespace Microsoft.VisualStudio.Commanding /// enables two way shared cancellability and wait indication. /// </summary> public IUIThreadOperationContext OperationContext { get; } + + /// <summary> + /// A collection of properties. + /// </summary> + public PropertyCollection Properties { get; } } } - diff --git a/src/Editor/Text/Def/TextUI/Commanding/CommandState.cs b/src/Editor/Text/Def/TextUI/Commanding/CommandState.cs index a6de4a3..3a264aa 100644 --- a/src/Editor/Text/Def/TextUI/Commanding/CommandState.cs +++ b/src/Editor/Text/Def/TextUI/Commanding/CommandState.cs @@ -15,11 +15,22 @@ namespace Microsoft.VisualStudio.Commanding public bool IsUnspecified { get; } /// <summary> - /// If true, the command should be visible and enabled in the UI. + /// If true, the command should be available for execution. + /// <see cref="IsEnabled"/> and <see cref="IsVisible"/> properties control how the command should be represented in the UI. /// </summary> public bool IsAvailable { get; } /// <summary> + /// If true, the command should be enabled in the UI. + /// </summary> + public bool IsEnabled { get; } + + /// <summary> + /// If true, the command should be visible in the UI. + /// </summary> + public bool IsVisible { get; } + + /// <summary> /// If true, the command should appear as checked (i.e. toggled) in the UI. /// </summary> public bool IsChecked { get; } @@ -30,22 +41,39 @@ namespace Microsoft.VisualStudio.Commanding public string DisplayText { get; } public CommandState(bool isAvailable = false, bool isChecked = false, string displayText = null, bool isUnspecified = false) + : this(isAvailable: isAvailable, isUnspecified: isUnspecified, isChecked: isChecked, isEnabled: isAvailable, isVisible: isAvailable, displayText: displayText) { - if (isUnspecified && (isAvailable || isChecked || displayText != null)) - { - throw new ArgumentException("Unspecified command state cannot be combined with other states or command text."); - } + } + + public CommandState(bool isAvailable, bool isChecked, bool isEnabled, bool isVisible, string displayText = null) + : this(isAvailable: isAvailable, isUnspecified: false, isChecked: isChecked, isEnabled: isEnabled, isVisible: isVisible, displayText: displayText) + { + } + + public CommandState(bool isAvailable, bool isUnspecified, bool isChecked, bool isEnabled, bool isVisible, string displayText) + { + Validate(isAvailable, isChecked, isUnspecified, isEnabled, isVisible, displayText); this.IsAvailable = isAvailable; this.IsChecked = isChecked; this.IsUnspecified = isUnspecified; + this.IsEnabled = isEnabled; + this.IsVisible = isVisible; this.DisplayText = displayText; } + private static void Validate(bool isAvailable, bool isChecked, bool isUnspecified, bool isEnabled, bool isVisible, string displayText) + { + if (isUnspecified && (isAvailable || isChecked || isEnabled || isVisible || displayText != null)) + { + throw new ArgumentException("Unspecified command state cannot be combined with other states or command text."); + } + } + /// <summary> - /// A helper singleton representing an available command state. + /// A helper singleton representing an available (supported, enabled and visible) command state. /// </summary> - public static CommandState Available { get; } = new CommandState(isAvailable: true); + public static CommandState Available { get; } = new CommandState(isAvailable: true, isChecked: false, isEnabled: true, isVisible: true); /// <summary> /// A helper singleton representing an unavailable command state. diff --git a/src/Editor/Text/Def/TextUI/Commanding/Commands/CollapseTagCommandArgs.cs b/src/Editor/Text/Def/TextUI/Commanding/Commands/CollapseTagCommandArgs.cs new file mode 100644 index 0000000..d6e130a --- /dev/null +++ b/src/Editor/Text/Def/TextUI/Commanding/Commands/CollapseTagCommandArgs.cs @@ -0,0 +1,9 @@ +namespace Microsoft.VisualStudio.Text.Editor.Commanding.Commands +{ + public sealed class CollapseTagCommandArgs : EditorCommandArgs + { + public CollapseTagCommandArgs(ITextView textView, ITextBuffer subjectBuffer) : base(textView, subjectBuffer) + { + } + } +} diff --git a/src/Editor/Text/Def/TextUI/Commanding/Commands/FormatAndValidationCommandArgs.cs b/src/Editor/Text/Def/TextUI/Commanding/Commands/FormatAndValidationCommandArgs.cs new file mode 100644 index 0000000..df7ba63 --- /dev/null +++ b/src/Editor/Text/Def/TextUI/Commanding/Commands/FormatAndValidationCommandArgs.cs @@ -0,0 +1,10 @@ +namespace Microsoft.VisualStudio.Text.Editor.Commanding.Commands +{ + public sealed class FormatAndValidationCommandArgs : EditorCommandArgs + { + public FormatAndValidationCommandArgs(ITextView textView, ITextBuffer subjectBuffer) : base(textView, subjectBuffer) + { + } + } + +} diff --git a/src/Editor/Text/Def/TextUI/Commanding/Commands/GotoBraceCommandArgs.cs b/src/Editor/Text/Def/TextUI/Commanding/Commands/GotoBraceCommandArgs.cs new file mode 100644 index 0000000..d8ff50e --- /dev/null +++ b/src/Editor/Text/Def/TextUI/Commanding/Commands/GotoBraceCommandArgs.cs @@ -0,0 +1,10 @@ +namespace Microsoft.VisualStudio.Text.Editor.Commanding.Commands +{ + public sealed class GotoBraceCommandArgs : EditorCommandArgs + { + public GotoBraceCommandArgs(ITextView textView, ITextBuffer subjectBuffer) : base(textView, subjectBuffer) + { + } + } + +} diff --git a/src/Editor/Text/Def/TextUI/Commanding/Commands/GotoBraceExtCommandArgs.cs b/src/Editor/Text/Def/TextUI/Commanding/Commands/GotoBraceExtCommandArgs.cs new file mode 100644 index 0000000..80d618e --- /dev/null +++ b/src/Editor/Text/Def/TextUI/Commanding/Commands/GotoBraceExtCommandArgs.cs @@ -0,0 +1,10 @@ +namespace Microsoft.VisualStudio.Text.Editor.Commanding.Commands +{ + public sealed class GotoBraceExtCommandArgs : EditorCommandArgs + { + public GotoBraceExtCommandArgs(ITextView textView, ITextBuffer subjectBuffer) : base(textView, subjectBuffer) + { + } + } + +} diff --git a/src/Editor/Text/Def/TextUI/Commanding/Commands/HelpCommandArgs.cs b/src/Editor/Text/Def/TextUI/Commanding/Commands/HelpCommandArgs.cs new file mode 100644 index 0000000..caf281d --- /dev/null +++ b/src/Editor/Text/Def/TextUI/Commanding/Commands/HelpCommandArgs.cs @@ -0,0 +1,9 @@ +namespace Microsoft.VisualStudio.Text.Editor.Commanding.Commands +{ + public sealed class HelpCommandArgs : EditorCommandArgs + { + public HelpCommandArgs(ITextView textView, ITextBuffer subjectBuffer) : base(textView, subjectBuffer) + { + } + } +} diff --git a/src/Editor/Text/Def/TextUI/Commanding/Commands/OutlineCollapseToDefinitionsCommandArgs.cs b/src/Editor/Text/Def/TextUI/Commanding/Commands/OutlineCollapseToDefinitionsCommandArgs.cs new file mode 100644 index 0000000..ac16bde --- /dev/null +++ b/src/Editor/Text/Def/TextUI/Commanding/Commands/OutlineCollapseToDefinitionsCommandArgs.cs @@ -0,0 +1,9 @@ +namespace Microsoft.VisualStudio.Text.Editor.Commanding.Commands +{ + public sealed class OutlineCollapseToDefinitionsCommandArgs : EditorCommandArgs + { + public OutlineCollapseToDefinitionsCommandArgs(ITextView textView, ITextBuffer subjectBuffer) : base(textView, subjectBuffer) + { + } + } +} diff --git a/src/Editor/Text/Def/TextUI/Commanding/Commands/OutlineHideSelectionCommandArgs.cs b/src/Editor/Text/Def/TextUI/Commanding/Commands/OutlineHideSelectionCommandArgs.cs new file mode 100644 index 0000000..188522e --- /dev/null +++ b/src/Editor/Text/Def/TextUI/Commanding/Commands/OutlineHideSelectionCommandArgs.cs @@ -0,0 +1,9 @@ +namespace Microsoft.VisualStudio.Text.Editor.Commanding.Commands +{ + public sealed class OutlineHideSelectionCommandArgs : EditorCommandArgs + { + public OutlineHideSelectionCommandArgs(ITextView textView, ITextBuffer subjectBuffer) : base(textView, subjectBuffer) + { + } + } +} diff --git a/src/Editor/Text/Def/TextUI/Commanding/Commands/OutlineStopHidingAllCommandArgs.cs b/src/Editor/Text/Def/TextUI/Commanding/Commands/OutlineStopHidingAllCommandArgs.cs new file mode 100644 index 0000000..a52ebe3 --- /dev/null +++ b/src/Editor/Text/Def/TextUI/Commanding/Commands/OutlineStopHidingAllCommandArgs.cs @@ -0,0 +1,9 @@ +namespace Microsoft.VisualStudio.Text.Editor.Commanding.Commands +{ + public sealed class OutlineStopHidingAllCommandArgs : EditorCommandArgs + { + public OutlineStopHidingAllCommandArgs(ITextView textView, ITextBuffer subjectBuffer) : base(textView, subjectBuffer) + { + } + } +} diff --git a/src/Editor/Text/Def/TextUI/Commanding/Commands/OutlineStopHidingCurrentCommandArgs.cs b/src/Editor/Text/Def/TextUI/Commanding/Commands/OutlineStopHidingCurrentCommandArgs.cs new file mode 100644 index 0000000..170a2b9 --- /dev/null +++ b/src/Editor/Text/Def/TextUI/Commanding/Commands/OutlineStopHidingCurrentCommandArgs.cs @@ -0,0 +1,9 @@ +namespace Microsoft.VisualStudio.Text.Editor.Commanding.Commands +{ + public sealed class OutlineStopHidingCurrentCommandArgs : EditorCommandArgs + { + public OutlineStopHidingCurrentCommandArgs(ITextView textView, ITextBuffer subjectBuffer) : base(textView, subjectBuffer) + { + } + } +} diff --git a/src/Editor/Text/Def/TextUI/Commanding/Commands/OutlineToggleAllCommandArgs.cs b/src/Editor/Text/Def/TextUI/Commanding/Commands/OutlineToggleAllCommandArgs.cs new file mode 100644 index 0000000..11926f4 --- /dev/null +++ b/src/Editor/Text/Def/TextUI/Commanding/Commands/OutlineToggleAllCommandArgs.cs @@ -0,0 +1,9 @@ +namespace Microsoft.VisualStudio.Text.Editor.Commanding.Commands +{ + public sealed class OutlineToggleAllCommandArgs : EditorCommandArgs + { + public OutlineToggleAllCommandArgs(ITextView textView, ITextBuffer subjectBuffer) : base(textView, subjectBuffer) + { + } + } +} diff --git a/src/Editor/Text/Def/TextUI/Commanding/Commands/OutlineToggleCurrentCommandArgs.cs b/src/Editor/Text/Def/TextUI/Commanding/Commands/OutlineToggleCurrentCommandArgs.cs new file mode 100644 index 0000000..8bf39b0 --- /dev/null +++ b/src/Editor/Text/Def/TextUI/Commanding/Commands/OutlineToggleCurrentCommandArgs.cs @@ -0,0 +1,9 @@ +namespace Microsoft.VisualStudio.Text.Editor.Commanding.Commands +{ + public sealed class OutlineToggleCurrentCommandArgs : EditorCommandArgs + { + public OutlineToggleCurrentCommandArgs(ITextView textView, ITextBuffer subjectBuffer) : base(textView, subjectBuffer) + { + } + } +} diff --git a/src/Editor/Text/Def/TextUI/Commanding/Commands/PasteAsHTMLCommandArgs.cs b/src/Editor/Text/Def/TextUI/Commanding/Commands/PasteAsHTMLCommandArgs.cs new file mode 100644 index 0000000..fc3377b --- /dev/null +++ b/src/Editor/Text/Def/TextUI/Commanding/Commands/PasteAsHTMLCommandArgs.cs @@ -0,0 +1,10 @@ +namespace Microsoft.VisualStudio.Text.Editor.Commanding.Commands +{ + public sealed class PasteAsHTMLCommandArgs : EditorCommandArgs + { + public PasteAsHTMLCommandArgs(ITextView textView, ITextBuffer subjectBuffer) : base(textView, subjectBuffer) + { + } + } + +} diff --git a/src/Editor/Text/Def/TextUI/Commanding/Commands/ShowContextMenuCommandArgs.cs b/src/Editor/Text/Def/TextUI/Commanding/Commands/ShowContextMenuCommandArgs.cs new file mode 100644 index 0000000..9ee198f --- /dev/null +++ b/src/Editor/Text/Def/TextUI/Commanding/Commands/ShowContextMenuCommandArgs.cs @@ -0,0 +1,35 @@ +using Microsoft.VisualStudio.Commanding; + +namespace Microsoft.VisualStudio.Text.Editor.Commanding.Commands +{ + public sealed class ShowContextMenuCommandArgs : EditorCommandArgs + { + /// <summary> + /// X coordinate for the context menu, optionally provided by the caller of the command. + /// </summary> + public double? X { get; } + + /// <summary> + /// Y coordinate for the context menu, optionally provided by the caller of the command. + /// </summary> + public double? Y { get; } + + /// <summary> + /// Creates an empty instance of the <see cref="ShowContextMenuCommandArgs"/>, for the + /// purpose of passing to the <see cref="IChainedCommandHandler{T}.GetCommandState(T, System.Func{CommandState})"/> + /// to determine the state of the command. + /// </summary> + public ShowContextMenuCommandArgs(ITextView textView, ITextBuffer subjectBuffer) : base(textView, subjectBuffer) + { + } + + /// <summary> + /// Creates an instance of the <see cref="ShowContextMenuCommandArgs"/> to execute the command. + /// </summary> + public ShowContextMenuCommandArgs(ITextView textView, ITextBuffer subjectBuffer, double x, double y) : base(textView, subjectBuffer) + { + X = x; + Y = y; + } + } +} diff --git a/src/Editor/Text/Def/TextUI/Commanding/Commands/ToggleCompletionListFilterCommandArgs.cs b/src/Editor/Text/Def/TextUI/Commanding/Commands/ToggleCompletionListFilterCommandArgs.cs new file mode 100644 index 0000000..00509be --- /dev/null +++ b/src/Editor/Text/Def/TextUI/Commanding/Commands/ToggleCompletionListFilterCommandArgs.cs @@ -0,0 +1,15 @@ +namespace Microsoft.VisualStudio.Text.Editor.Commanding.Commands +{ + public sealed class ToggleCompletionListFilterCommandArgs : EditorCommandArgs + { + public string AccessKey { get; } + + public ToggleCompletionListFilterCommandArgs( + ITextView textView, + ITextBuffer subjectBuffer, + string accessKey) : base(textView, subjectBuffer) + { + AccessKey = accessKey; + } + } +}
\ No newline at end of file diff --git a/src/Editor/Text/Def/TextUI/Commanding/Commands/UncollapseTagCommandArgs.cs b/src/Editor/Text/Def/TextUI/Commanding/Commands/UncollapseTagCommandArgs.cs new file mode 100644 index 0000000..674e8d7 --- /dev/null +++ b/src/Editor/Text/Def/TextUI/Commanding/Commands/UncollapseTagCommandArgs.cs @@ -0,0 +1,9 @@ +namespace Microsoft.VisualStudio.Text.Editor.Commanding.Commands +{ + public sealed class UncollapseTagCommandArgs : EditorCommandArgs + { + public UncollapseTagCommandArgs(ITextView textView, ITextBuffer subjectBuffer) : base(textView, subjectBuffer) + { + } + } +} diff --git a/src/Editor/Text/Def/TextUI/Commanding/IEditorCommandHandlerService.cs b/src/Editor/Text/Def/TextUI/Commanding/IEditorCommandHandlerService.cs index 2516bd7..f1601df 100644 --- a/src/Editor/Text/Def/TextUI/Commanding/IEditorCommandHandlerService.cs +++ b/src/Editor/Text/Def/TextUI/Commanding/IEditorCommandHandlerService.cs @@ -7,7 +7,7 @@ namespace Microsoft.VisualStudio.Text.Editor.Commanding /// A service to execute commands on a text view. /// </summary> /// <remarks> - /// Instance of this service are created by <see cref="IEditorCommandHandlerServiceFactory"/>. + /// Instances of this service are created by <see cref="IEditorCommandHandlerServiceFactory"/>. /// </remarks> public interface IEditorCommandHandlerService { @@ -15,9 +15,9 @@ namespace Microsoft.VisualStudio.Text.Editor.Commanding /// Get the <see cref="CommandState"/> for command handlers of a given command. /// </summary> /// <param name="argsFactory">A factory of <see cref="EditorCommandArgs"/> that specifies what kind of command is being queried.</param> - /// <param name="nextCommandHandler">A next command handler to be called if no command handlers were - /// able to determine a command state.</param> - /// <typeparam name="T">Tehe </typeparam> + /// <param name="nextCommandHandler">The next command handler to be called if no command handlers were + /// able to determine the command state.</param> + /// <typeparam name="T">The type of the command being queried.</typeparam> /// <returns>The command state of a given command.</returns> CommandState GetCommandState<T>(Func<ITextView, ITextBuffer, T> argsFactory, Func<CommandState> nextCommandHandler) where T : EditorCommandArgs; @@ -25,8 +25,9 @@ namespace Microsoft.VisualStudio.Text.Editor.Commanding /// Execute a given command on the <see cref="ITextView"/> associated with this <see cref="IEditorCommandHandlerService"/> instance. /// </summary> /// <param name="argsFactory">A factory of <see cref="EditorCommandArgs"/> that specifies what kind of command is being executed. - /// <paramref name="nextCommandHandler">>A next command handler to be called if no command handlers were - /// able to handle a command.</paramref> + /// <param name="nextCommandHandler">The next command handler to be called if no command handlers were + /// able to handle the command.</param> + /// <typeparam name="T">The type of the command being executed.</typeparam> void Execute<T>(Func<ITextView, ITextBuffer, T> argsFactory, Action nextCommandHandler) where T : EditorCommandArgs; - } + } } |