Reading Standard Input
Ali Çehreli
acehreli at yahoo.com
Wed Jan 23 10:07:02 PST 2013
On 01/23/2013 09:59 AM, Kenneth Sills wrote:
> I'm having trouble with input. You see, I need
> nonblocking (which I've set up) input that can read character by
> character (so when the user presses r, it immediately takes it
> in, not waiting for an enter) and I need to be able to see things
> like arrow keys, shift keys, and control keys.
Not possible with standard input.
Standard input is a character stream that is bound to the program by the
environment that has started the program. The program has been written
in the D language (or C, etc.) but it has no control on how that
character stream is filled in by the environment.
There isn't even the concept of a keyboard nor a monitor.
> I know it's quite possible in C
It is exactly the same story in C. :) You must have been relying on
special libraries.
> but again, half the point of this project is
> being pure D.So how would I go about implementing this?
You must use a library like ncurses, which is aware of the keyboard (or
write one yourself. (I don't know how. :))).
I had captured some of these ideas here:
http://ddili.org/ders/d.en/io.html
http://ddili.org/ders/d.en/stream_redirect.html
Ali
More information about the Digitalmars-d-learn
mailing list