Plan 9 from Bell Labs’s /usr/web/sources/contrib/gabidiaz/root/sys/src/cmd/perl/h2pl/cbreak.pl

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


$sgttyb_t   = 'C4 S';

sub cbreak {
    &set_cbreak(1);
}

sub cooked {
    &set_cbreak(0);
}

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

    require 'sizeof.ph';
    require 'sys/ioctl.ph';

    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;

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.