AnsiEscapeSequenceRequest.cs 1.1 KB

123456789101112131415161718192021222324252627282930
  1. #nullable enable
  2. namespace Terminal.Gui;
  3. /// <summary>
  4. /// Describes an ongoing ANSI request sent to the console.
  5. /// Use <see cref="ResponseReceived"/> to handle the response
  6. /// when console answers the request.
  7. /// </summary>
  8. public class AnsiEscapeSequenceRequest : AnsiEscapeSequence
  9. {
  10. /// <summary>
  11. /// Invoked when the console responds with an ANSI response code that matches the
  12. /// <see cref="AnsiEscapeSequence.Terminator"/>
  13. /// </summary>
  14. public required Action<string?> ResponseReceived { get; init; }
  15. /// <summary>
  16. /// Invoked if the console fails to responds to the ANSI response code
  17. /// </summary>
  18. public Action? Abandoned { get; init; }
  19. /// <summary>
  20. /// Sends the <see cref="AnsiEscapeSequence.Request"/> to the raw output stream of the current <see cref="ConsoleDriver"/>.
  21. /// Only call this method from the main UI thread. You should use <see cref="AnsiRequestScheduler"/> if
  22. /// sending many requests.
  23. /// </summary>
  24. public void Send () { Application.Driver?.WriteRaw (Request); }
  25. }