PageRenderTime 23ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/Common/Product/ReplWindow/Repl/IReplWindow.cs

https://gitlab.com/SplatoonModdingHub/PTVS
C# | 182 lines | 49 code | 24 blank | 109 comment | 0 complexity | 4da4b7d1086d817565d86f0861b73399 MD5 | raw file
  1. /* ****************************************************************************
  2. *
  3. * Copyright (c) Microsoft Corporation.
  4. *
  5. * This source code is subject to terms and conditions of the Apache License, Version 2.0. A
  6. * copy of the license can be found in the License.html file at the root of this distribution. If
  7. * you cannot locate the Apache License, Version 2.0, please send an email to
  8. * vspython@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
  9. * by the terms of the Apache License, Version 2.0.
  10. *
  11. * You must not remove this notice, or any other, from this software.
  12. *
  13. * ***************************************************************************/
  14. using System;
  15. using System.Collections.Generic;
  16. using System.Diagnostics.CodeAnalysis;
  17. using System.Threading.Tasks;
  18. using Microsoft.VisualStudio.Text;
  19. using Microsoft.VisualStudio.Text.Editor;
  20. using Microsoft.VisualStudio.Utilities;
  21. #if NTVS_FEATURE_INTERACTIVEWINDOW
  22. namespace Microsoft.NodejsTools.Repl {
  23. #else
  24. namespace Microsoft.VisualStudio.Repl {
  25. #endif
  26. /// <summary>
  27. /// An implementation of a Read Eval Print Loop Window for iteratively developing code.
  28. ///
  29. /// Instances of the repl window can be created by using MEF to import the IReplWindowProvider interface.
  30. /// </summary>
  31. public interface IReplWindow {
  32. /// <summary>
  33. /// Gets the IWpfTextView in which the REPL window is executing.
  34. /// </summary>
  35. IWpfTextView TextView {
  36. get;
  37. }
  38. /// <summary>
  39. /// Returns the current language buffer.
  40. /// </summary>
  41. ITextBuffer CurrentLanguageBuffer {
  42. get;
  43. }
  44. /// <summary>
  45. /// The language evaluator used in Repl Window
  46. /// </summary>
  47. IReplEvaluator Evaluator {
  48. get;
  49. }
  50. /// <summary>
  51. /// Title of the Repl Window
  52. /// </summary>
  53. string Title {
  54. get;
  55. }
  56. /// <summary>
  57. /// Clears the REPL window screen.
  58. /// </summary>
  59. void ClearScreen();
  60. /// <summary>
  61. /// Clears the input history.
  62. /// </summary>
  63. void ClearHistory();
  64. /// <summary>
  65. /// Focuses the window.
  66. /// </summary>
  67. void Focus();
  68. /// <summary>
  69. /// Clears the current input.
  70. /// </summary>
  71. void Cancel();
  72. /// <summary>
  73. /// Insert the specified text to the active code buffer at the current caret position.
  74. /// </summary>
  75. /// <param name="text">Text to insert.</param>
  76. /// <remarks>
  77. /// Overwrites the current selection.
  78. ///
  79. /// If the REPL is in the middle of code execution the text is inserted at the end of a pending input buffer.
  80. /// When the REPL is ready for input the pending input is inserted into the active code input.
  81. /// </remarks>
  82. void InsertCode(string text);
  83. /// <summary>
  84. /// Submits a sequence of inputs one by one.
  85. /// </summary>
  86. /// <param name="inputs">
  87. /// Code snippets or REPL commands to submit.
  88. /// </param>
  89. /// <remarks>
  90. /// Enques given code snippets for submission at the earliest time the REPL is prepared to accept submissions.
  91. /// Any submissions are postponed until execution of the current submission (if there is any) is finished or aborted.
  92. ///
  93. /// The REPL processes the given inputs one by one creating a prompt, input span and possibly output span for each input.
  94. /// This method may be reentered if any of the inputs evaluates to a command that invokes this method.
  95. /// </remarks>
  96. void Submit(IEnumerable<string> inputs);
  97. /// <summary>
  98. /// Resets the execution context clearing all variables.
  99. /// </summary>
  100. Task<ExecutionResult> Reset();
  101. /// <summary>
  102. /// Aborts the current command which is executing.
  103. /// </summary>
  104. void AbortCommand();
  105. /// <summary>
  106. /// Writes a line into the output buffer as if it was outputted by the program.
  107. /// </summary>
  108. /// <param name="text"></param>
  109. void WriteLine(string text);
  110. /// <summary>
  111. /// Writes output to the REPL window.
  112. /// </summary>
  113. /// <param name="value"></param>
  114. void WriteOutput(object value);
  115. /// <summary>
  116. /// Writes error output to the REPL window.
  117. /// </summary>
  118. /// <param name="value"></param>
  119. void WriteError(object value);
  120. /// <summary>
  121. /// Reads input from the REPL window.
  122. /// </summary>
  123. /// <returns>The entered input or null if cancelled.</returns>
  124. string ReadStandardInput();
  125. /// <summary>
  126. /// Sets the current value for the specified option.
  127. ///
  128. /// It is safe to call this method from any thread.
  129. /// </summary>
  130. void SetOptionValue(ReplOptions option, object value);
  131. /// <summary>
  132. /// Gets the current value for the specified option.
  133. ///
  134. /// It is safe to call this method from any thread.
  135. /// </summary>
  136. object GetOptionValue(ReplOptions option);
  137. /// <summary>
  138. /// Event triggered when the REPL is ready to accept input.
  139. /// </summary>
  140. [SuppressMessage("Microsoft.Design", "CA1009:DeclareEventHandlersCorrectly", Justification = "back compat")]
  141. event Action ReadyForInput;
  142. }
  143. public interface IReplWindow2 : IReplWindow {
  144. /// <summary>
  145. /// Executes a special REPL command as if it were submitted as an input.
  146. /// </summary>
  147. /// <remarks>
  148. /// This method can only execute special (prefixed) commands. To evaluate code snippers, use <see cref="Evaluator"/>.
  149. /// </remarks>
  150. Task<ExecutionResult> ExecuteCommand(string text);
  151. }
  152. public interface IReplWindow3 : IReplWindow2 {
  153. /// <summary>
  154. /// Storage
  155. /// </summary>
  156. PropertyCollection Properties { get; }
  157. }
  158. }