termios routines for Rakudo Perl 6
Switch branches/tags
Nothing to show
Latest commit c3eb13b Feb 18, 2016 @krunen Merge pull request #5 from zoffixznet/patch-1
Fix Perl version
Failed to load latest commit information.
lib/Term Add "is rw" to public attributes now that it works for CStruct Nov 11, 2015
t deleted old test Sep 11, 2014
.gitignore added lib/.precomp Dec 6, 2015
.travis.yml add .travis.yml Dec 6, 2015
LICENSE Initial commit Sep 11, 2014
META.info Fix version Jan 24, 2016
README.md updated doc Sep 11, 2014



termios routines for Rakudo Perl 6

use Term::termios;

# Save the previous attrs
my $saved_termios := Term::termios.new(fd => 1).getattr;

# Get the existing attrs in order to modify them
my $termios := Term::termios.new(fd => 1).getattr;

# Set the tty to raw mode

# You could also do the same in the old-fashioned way
$termios.unset_iflags(<BRKINT ICRNL ISTRIP IXON>);
$termios.unset_lflags(<ECHO ICANON IEXTEN ISIG>);

# Set the modified atributes, delayed until the buffer is emptied

# Loop on characters from STDIN
loop {
    my $c = $*IN.getc;
    print "got: " ~ $c.ord ~ "\r\n";
    last if $c eq 'q';

# Restore the saved, previous attributes before exit

See the manpage termios(3) for information about the flags.