2
0

UnixInputProcessor.cs 1015 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System.Collections.Concurrent;
  2. namespace Terminal.Gui.Drivers;
  3. /// <summary>
  4. /// Input processor for <see cref="UnixInput"/>, deals in <see cref="char"/> stream.
  5. /// </summary>
  6. internal class UnixInputProcessor : InputProcessor<char>
  7. {
  8. /// <inheritdoc />
  9. public UnixInputProcessor (ConcurrentQueue<char> inputBuffer) : base (inputBuffer, new UnixKeyConverter ())
  10. {
  11. DriverName = "Unix";
  12. }
  13. /// <inheritdoc />
  14. protected override void Process (char input)
  15. {
  16. foreach (Tuple<char, char> released in Parser.ProcessInput (Tuple.Create (input, input)))
  17. {
  18. ProcessAfterParsing (released.Item2);
  19. }
  20. }
  21. /// <inheritdoc />
  22. protected override void ProcessAfterParsing (char input)
  23. {
  24. var key = KeyConverter.ToKey (input);
  25. // If the key is not valid, we don't want to raise any events.
  26. if (IsValidInput (key, out key))
  27. {
  28. OnKeyDown (key);
  29. OnKeyUp (key);
  30. }
  31. }
  32. }