Hello,
I wonder if it’s possible to read a character from the keyboard
without pressing enter…
Thank you in advance,
André
···
–
© André Wagner - 2003 - All rights reserved
Hello,
I wonder if it’s possible to read a character from the keyboard
without pressing enter…
Thank you in advance,
André
–
© André Wagner - 2003 - All rights reserved
It’s possible:
c = STDIN.getc
On 2003-08-13 05:18:50 +0900, André Wagner wrote:
I wonder if it’s possible to read a character from the keyboard
without pressing enter…
–
Don’t you see that the whole aim of Newspeak is to narrow the range of
thought? In the end we shall make thoughtcrime literally impossible,
because there will be no words in which to express it.
– George Orwell, 1984
Hi,
At Wed, 13 Aug 2003 05:18:50 +0900, André Wagner wrote:
I wonder if it’s possible to read a character from the keyboard
without pressing enter…
It is completely system dependent issue. Which platform do you
use?
On Unixes, you can disable tty input canononical mode or
setting it raw mode, and read 1 byte.
–
Nobu Nakada
I don’t think that will work.
There are tricks for it. They differ on
Windows and Unix – on the latter you’d
set the tty mode to raw or some such.
See ch 4 of The Ruby Way.
Hal
----- Original Message -----
From: “Florian Frank” flori@nixe.ping.de
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Tuesday, August 12, 2003 6:50 PM
Subject: Re: Read character from keyboard
On 2003-08-13 05:18:50 +0900, André Wagner wrote:
I wonder if it’s possible to read a character from the keyboard
without pressing enter…It’s possible:
c = STDIN.getc
–
Hal Fulton
hal9000@hypermetrics.com
Or use curses, and Curses::getch.
In article 200308130039.h7D0dNPL010332@sharui.nakada.kanuma.tochigi.jp, nobu.nokada@softhome.net wrote:
I wonder if it’s possible to read a character from the keyboard
without pressing enter…On Unixes, you can disable tty input canononical mode or
setting it raw mode, and read 1 byte.
In Tuesday, August 12, 2003 you wrote:
I wonder if it’s possible to read a character from the keyboard
without pressing enter…
It is completely system dependent issue. Which platform do you
use?
Hmmm… I’m using Windows now, but I wish my application to be
platform independent.
What I’m trying to write is a server on which you can type commands
(like a prompt). So I would have two threads: one for the server
processing (the socket) and another one for the prompt. The problem is
that the socket thread won’t write anything on the screen (like a
warning message) if the prompt thread is waiting for a input.
I’m not sure if I made myself clear… but is there any other way I
can do that?
Thank you in advance.
–
© André Wagner - 2003 - All rights reserved
I don’t think that will work.
Oops, I seem to have skipped the “without pressing enter” part in the
question. I should really stop writing answers if I get that tired in
the middle of the night.
See ch 4 of The Ruby Way.
Yes, I have also bought your book. BTW: Thanks for writing it!
On 2003-08-13 08:55:07 +0900, Hal E. Fulton wrote:
–
The light that burns twice as bright burns half as long… and you have
burned so very, very brightly, Roy.
– Harry Tyrell, Bladerunner
I’ve been trying to do something similar. It would appear that there is
a bug in the windows implementation of gets which causes it to block the
entire process instead of the thread.
In article 1751979702.20030813103416@syspoint.com.br, André Wagner"
andre@syspoint.com.br says…
In Tuesday, August 12, 2003 you wrote:
I wonder if it’s possible to read a character from the keyboard
without pressing enter…It is completely system dependent issue. Which platform do you
use?Hmmm… I’m using Windows now, but I wish my application to be
platform independent.What I’m trying to write is a server on which you can type commands
(like a prompt). So I would have two threads: one for the server
processing (the socket) and another one for the prompt. The problem is
that the socket thread won’t write anything on the screen (like a
warning message) if the prompt thread is waiting for a input.I’m not sure if I made myself clear… but is there any other way I
can do that?Thank you in advance.
One way might be to use “select” on your socket and stdin.
In article 1751979702.20030813103416@syspoint.com.br, André Wagner wrote:
What I’m trying to write is a server on which you can type commands
(like a prompt). So I would have two threads: one for the server
processing (the socket) and another one for the prompt. The problem is
that the socket thread won’t write anything on the screen (like a
warning message) if the prompt thread is waiting for a input.