123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #nullable enable
- namespace Terminal.Gui;
- /// <summary>
- /// Describes an ongoing ANSI request sent to the console.
- /// Use <see cref="ResponseReceived"/> to handle the response
- /// when console answers the request.
- /// </summary>
- public class AnsiEscapeSequenceRequest
- {
- /// <summary>
- /// Request to send e.g. see
- /// <see>
- /// <cref>EscSeqUtils.CSI_SendDeviceAttributes.Request</cref>
- /// </see>
- /// </summary>
- public required string Request { get; init; }
- /// <summary>
- /// Invoked when the console responds with an ANSI response code that matches the
- /// <see cref="Terminator"/>
- /// </summary>
- public Action<string> ResponseReceived;
- /// <summary>
- /// <para>
- /// The terminator that uniquely identifies the type of response as responded
- /// by the console. e.g. for
- /// <see>
- /// <cref>EscSeqUtils.CSI_SendDeviceAttributes.Request</cref>
- /// </see>
- /// the terminator is
- /// <see>
- /// <cref>EscSeqUtils.CSI_SendDeviceAttributes.Terminator</cref>
- /// </see>
- /// .
- /// </para>
- /// <para>
- /// After sending a request, the first response with matching terminator will be matched
- /// to the oldest outstanding request.
- /// </para>
- /// </summary>
- public required string Terminator { get; init; }
- /// <summary>
- /// Sends the <see cref="Request"/> to the raw output stream of the current <see cref="ConsoleDriver"/>.
- /// Only call this method from the main UI thread. You should use <see cref="AnsiRequestScheduler"/> if
- /// sending many requests.
- /// </summary>
- public void Send ()
- {
- Application.Driver?.RawWrite (Request);
- }
- }
|