The operating system does line buffering, so you'll need to turn that off. The function is tcssetattr() on Posix and SetConsoleMode on Windows.

My terminal.d does this in struct ctors and dtors:

https://github.com/adamdruppe/arsd/blob/master/terminal.d

example usage:
http://arsdnet.net/dcode/book/chapter_12/07/input.d

The RealTimeConsoleInput struct turns off buffering and has functions like getch() and kbhit() to fetch individual characters from it.

That's not quite the same as getting everything that's available, but might be useful to you.



Most efficient way I think though is to turn off buffering with the OS calls, then you can set stdin to be nonblocking and read chunks off it with ordinary read() or ReadFile calls.

Reply via email to