On 09/10/2017 09:32 PM, ToddAndMargo wrote:
Hi All,

I am trying to dump the input buffer and exit when it
finds nothing left. This test code will read binary input
and it parks itself waiting for me to press "q".

How would I modify this to do dump everything and not wait
for a "q"?

#!/usr/bin/env perl6

# Reference: https://github.com/ab5tract/Terminal-Print/blob/1c05a17dd0390447d5a26da29467729d5803bea8/examples/raw-input.p6
# # zef install use Terminal::Print::RawInput

use Terminal::Print::RawInput;

my @z = qw[z zz zzz zzzz snore];
say "Sleeping for ", @z.elems, " seconds.  Press some keys.";
for @z { sleep 1; print "$_ " }; print "\n";

# Display character stream, exiting the program when 'q' is pressed
my $in-supply = raw-input-supply;
react {
     whenever $in-supply -> $c {
         my $char = $c.ord < 32 ?? '^' ~ ($c.ord + 64).chr !! $c;
         printf "got: %3d  %2s  %2s\r\n", $c.ord, $c.ord.base(16), $char;

         done if $c eq 'q';

# Give the input supply enough time to restore the TTY state
sleep .1;


Figured it out.  It will take me a little bit to clean up my example.
In the mean time, no one do any research for me.

Computers are like air conditioners.
They malfunction when you open windows

Reply via email to