-
Notifications
You must be signed in to change notification settings - Fork 234
/
Copy pathEditorWindow.cs
78 lines (62 loc) · 2.87 KB
/
EditorWindow.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
namespace Microsoft.PowerShell.EditorServices.Extensions
{
/// <summary>
/// Provides a PowerShell-facing API which allows scripts to
/// interact with the editor's window.
/// </summary>
public sealed class EditorWindow
{
#region Private Fields
private readonly IEditorOperations editorOperations;
#endregion
#region Public Properties
/// <summary>
/// Gets the terminal interface for the editor API.
/// </summary>
public EditorTerminal Terminal { get; }
#endregion
#region Constructors
/// <summary>
/// Creates a new instance of the EditorWindow class.
/// </summary>
/// <param name="editorOperations">An IEditorOperations implementation which handles operations in the host editor.</param>
internal EditorWindow(IEditorOperations editorOperations)
{
this.editorOperations = editorOperations;
Terminal = new EditorTerminal(editorOperations);
}
#endregion
#region Public Methods
#pragma warning disable VSTHRD002 // These are public APIs that use async internal methods.
/// <summary>
/// Shows an informational message to the user.
/// </summary>
/// <param name="message">The message to be shown.</param>
public void ShowInformationMessage(string message) => editorOperations.ShowInformationMessageAsync(message).Wait();
/// <summary>
/// Shows an error message to the user.
/// </summary>
/// <param name="message">The message to be shown.</param>
public void ShowErrorMessage(string message) => editorOperations.ShowErrorMessageAsync(message).Wait();
/// <summary>
/// Shows a warning message to the user.
/// </summary>
/// <param name="message">The message to be shown.</param>
public void ShowWarningMessage(string message) => editorOperations.ShowWarningMessageAsync(message).Wait();
/// <summary>
/// Sets the status bar message in the editor UI (if applicable).
/// </summary>
/// <param name="message">The message to be shown.</param>
public void SetStatusBarMessage(string message) => editorOperations.SetStatusBarMessageAsync(message, null).Wait();
/// <summary>
/// Sets the status bar message in the editor UI (if applicable).
/// </summary>
/// <param name="message">The message to be shown.</param>
/// <param name="timeout">A timeout in milliseconds for how long the message should remain visible.</param>
public void SetStatusBarMessage(string message, int timeout) => editorOperations.SetStatusBarMessageAsync(message, timeout).Wait();
#pragma warning restore VSTHRD002
#endregion
}
}