Single char input in D
Bruno Medeiros
daiphoenixNO at SPAMlycos.com
Thu Mar 2 07:59:21 PST 2006
Bob W wrote:
> Correct me if I am wrong, but there seems to be
> no native support in D for getting a single char
> from the keyboard.
>
> While 'printf' has been elegantly replaced, nothing
> as simple as a 'getch' or 'getche' equivalent seems
> to exist in D.
>
> The closest I could get to was to rely on Phobos'
> std.cstream and using 'din.getch'. It is
> currently not documented (unlike 'din.getc'),
> but I regarded it as implied that it would work.
>
> Unfortunately 'din.getche' has obviously the
> same bug as its C counterpart in dmc - it
> simply does not do what it should
> (echoed 'getch').
>
> The whole think makes me wondering if I have
> overlooked something or if I am the last person
> here using D console apps which actually expect
> characters from the keyboard without EOLs
> attached to them.
>
> Remaining questions are:
>
> - Can I rely on 'din.getch' being available in future,
> even though it is not explicitly mentioned in the
> Phobos docs?
>
> - Will 'getche' eventually work properly one day?
>
> - Is there any method available/planned in D for
> reading extended keycodes from the keyboard?
>
>
>
getch() and getche() are not ANSI/ISO C (thus not "good ol' C"). They
are Borland extensions if I'm not mistaken.
--
Bruno Medeiros - CS/E student
"Certain aspects of D are a pathway to many abilities some consider to
be... unnatural."
More information about the Digitalmars-d
mailing list