Closed xoofx closed 2 years ago
Note that these methods sort of exist already on TerminalReader
, they just lack convenience wrappers on Terminal
and VirtualTerminal
.
namespace System.IO;
public abstract class TerminalReader : TerminalHandle
{
public int Read(Span<byte> value, CancellationToken cancellationToken = default);
public async ValueTask<int> ReadAsync(Memory<byte> value, CancellationToken cancellationToken = default);
}
They will read as many bytes as you request or return at EOF (or cancellation).
Alternatively, if you want it to return at any non-zero amount of bytes or EOF, use ReadBuffer{Async}
.
I do plan to add convenience wrappers for these, and also to get rid of ReadRaw
in its current form. Will get around to it soon.
Would it be ok to add the following? When processing input in raw mode, you can receive a batch of bytes at once that is more suited for span parsing (e.g mouse events, paste of printable text...etc.)
I can make a PR if you want.