#nullable enable
namespace Terminal.Gui;
///
/// Base class for ANSI keyboard parsing patterns.
///
public abstract class AnsiKeyboardParserPattern
{
///
/// Does this pattern dangerously overlap with other sequences
/// such that it should only be applied at the lsat second after
/// all other sequences have been tried.
///
/// When this pattern will only be used
/// at time.
///
///
public bool IsLastMinute { get; set; }
///
/// Returns if is one
/// of the terminal sequences recognised by this class.
///
///
///
public abstract bool IsMatch (string input);
private readonly string _name;
///
/// Creates a new instance of the class.
///
protected AnsiKeyboardParserPattern () { _name = GetType ().Name; }
///
/// Returns the described by the escape sequence.
///
///
///
public Key? GetKey (string input)
{
Key? key = GetKeyImpl (input);
Logging.Trace ($"{nameof (AnsiKeyboardParser)} interpreted {input} as {key} using {_name}");
return key;
}
///
/// When overriden in a derived class, returns the
/// that matches the input ansi escape sequence.
///
///
///
protected abstract Key? GetKeyImpl (string input);
}