12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #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>
- /// Invoked if the console fails to responds to the ANSI response code
- /// </summary>
- public Action? Abandoned;
- /// <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); }
- /// <summary>
- /// The value expected in the response e.g.
- /// <see>
- /// <cref>EscSeqUtils.CSI_ReportTerminalSizeInChars.Value</cref>
- /// </see>
- /// which will have a 't' as terminator but also other different request may return the same terminator with a
- /// different value.
- /// </summary>
- public string? Value { get; init; }
- }
|