diff options
Diffstat (limited to 'gnu/usr.bin/perl/h2pl/cbreak2.pl')
-rw-r--r-- | gnu/usr.bin/perl/h2pl/cbreak2.pl | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/gnu/usr.bin/perl/h2pl/cbreak2.pl b/gnu/usr.bin/perl/h2pl/cbreak2.pl new file mode 100644 index 0000000..8ac55a3 --- /dev/null +++ b/gnu/usr.bin/perl/h2pl/cbreak2.pl @@ -0,0 +1,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; |