AnsiEscapeSequenceRequest.cs 1.1 KB

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