12345678910111213141516171819202122232425262728293031323334353637383940 |
- #nullable enable
- namespace Terminal.Gui;
- /// <summary>
- /// When implemented in a derived class, allows watching an input stream of characters
- /// (i.e. console input) for ANSI response sequences.
- /// </summary>
- public interface IAnsiResponseParser
- {
- /// <summary>
- /// Current state of the parser based on what sequence of characters it has
- /// read from the console input stream.
- /// </summary>
- AnsiResponseParserState State { get; }
- /// <summary>
- /// Notifies the parser that you are expecting a response to come in
- /// with the given <paramref name="terminator"/> (i.e. because you have
- /// sent an ANSI request out).
- /// </summary>
- /// <param name="terminator">The terminator you expect to see on response.</param>
- /// <param name="response">Callback to invoke when the response is seen in console input.</param>
- void ExpectResponse (string terminator, Action<string> response);
- /// <summary>
- /// Returns true if there is an existing expectation (i.e. we are waiting a response
- /// from console) for the given <paramref name="requestTerminator"/>.
- /// </summary>
- /// <param name="requestTerminator"></param>
- /// <returns></returns>
- bool IsExpecting (string requestTerminator);
- /// <summary>
- /// Removes callback and expectation that we will get a response for the
- /// given <pararef name="requestTerminator"/>. Use to give up on very old
- /// requests e.g. if you want to send a different one with the same terminator.
- /// </summary>
- /// <param name="requestTerminator"></param>
- void StopExpecting (string requestTerminator);
- }
|