[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Non blocking user input
- From: Steve Litt <slitt@...>
- Date: Fri, 21 Mar 2014 12:21:00 -0400
On Thu, 20 Mar 2014 16:15:16 +0200
steve donovan <firstname.lastname@example.org> wrote:
> On Thu, Mar 20, 2014 at 4:08 PM, Steve Litt
> <email@example.com> wrote:
> > function getch_unix()
> > os.execute("stty cbreak </dev/tty >/dev/tty 2>&1")
> > local key = io.read(1)
> > os.execute("stty -cbreak </dev/tty >/dev/tty 2>&1");
> > return(key);
> > end
> That is indeed ingenious!
Isn't that brilliant (Litt puffs out his chest).
I'd like to thank the guys who documented it, last century. You can see
Then search for getc, and you'll see where I learned about it, back in
But of course, I'm taking complete credit for it :-)
Since then, I've used this same technique to read a single character,
sans newline, in Perl, Python, Ruby, Lua, and maybe even Bash and maybe
Reading a keyhit without requiring a following Enter is a core
requirement for my UMENU software, which I've written in Perl, Python,
Ruby and Lua.
That getch_unix() I posted was copied and pasted out of the Lua
version of UMENU.
I love computers.
Steve Litt * http://www.troubleshooters.com/
Troubleshooting Training * Human Performance