Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 4eb81ef279
Fetching contributors…

Cannot retrieve contributors at this time

file 33 lines (25 sloc) 0.549 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
$sgttyb_t = 'C4 S';

sub cbreak {
    &set_cbreak(1);
}

sub cooked {
    &set_cbreak(0);
}

sub set_cbreak {
    local($on) = @_;

    require 'sys/ioctl.pl';

    ioctl(STDIN,$TIOCGETP,$sgttyb)
        || die "Can't ioctl TIOCGETP: $!";

    @ary = unpack($sgttyb_t,$sgttyb);
    if ($on) {
        $ary[4] |= $CBREAK;
        $ary[4] &= ~$ECHO;
    } else {
        $ary[4] &= ~$CBREAK;
        $ary[4] |= $ECHO;
    }
    $sgttyb = pack($sgttyb_t,@ary);
    ioctl(STDIN,$TIOCSETP,$sgttyb)
            || die "Can't ioctl TIOCSETP: $!";

}

1;
Something went wrong with that request. Please try again.