develooper Front page | perl.perl6.users | Postings from September 2017

Re: What is P6 for P5 `use Term::ReadKey`?

Thread Previous | Thread Next
From:
Timo Paulssen
Date:
September 9, 2017 21:02
Subject:
Re: What is P6 for P5 `use Term::ReadKey`?
Message ID:
29b2b572-e37a-c25b-fc8d-9f5dd4e6a006@wakelift.de
The important part of the page is actually the one titled "Waiting for
potential combiners". You'll want to either use binary encoding instead
of utf8 (the default) or use an encoding that doesn't have combiners,
like latin1 or ascii.


> Problem: also from the link:
>
>     method getc(IO::Handle:D: --> Str:D)
>     multi sub getc (IO::Handle $fh = $*ARGFILES --> Str:D)

my $character = getc();

or

my $character = $*IN.getc();

or

my $character = $my-input-handle.getc();

Since you need to have an encoding that won't wait for combiners after a
key was pressed you'll probably have an open call, for example
"/dev/tty".IO.open(:r);

You are already using termios to make the terminal "raw"; BTW, you only
need either makeraw or the 4 lines of flag setting and unsetting.

Also, the flags you were looking for are in the termios(3) man page. If
your system doesn't have it for some reason, have a look at
https://linux.die.net/man/3/termios

Hope that helps!
  - Timo

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About