extra code in pp_concat, Take 2
[p5sagit/p5-mst-13.2.git] / h2pl / cbreak.pl
CommitLineData
87250799 1$sgttyb_t = 'C4 S';
2
3sub cbreak {
4 &set_cbreak(1);
5}
6
7sub cooked {
8 &set_cbreak(0);
9}
10
11sub set_cbreak {
12 local($on) = @_;
13
14 require 'sizeof.ph';
15 require 'sys/ioctl.ph';
16
17 ioctl(STDIN,&TIOCGETP,$sgttyb)
18 || die "Can't ioctl TIOCGETP: $!";
19
20 @ary = unpack($sgttyb_t,$sgttyb);
21 if ($on) {
22 $ary[4] |= &CBREAK;
23 $ary[4] &= ~&ECHO;
24 } else {
25 $ary[4] &= ~&CBREAK;
26 $ary[4] |= &ECHO;
27 }
28 $sgttyb = pack($sgttyb_t,@ary);
29 ioctl(STDIN,&TIOCSETP,$sgttyb)
30 || die "Can't ioctl TIOCSETP: $!";
31
32}
33
341;