summaryrefslogtreecommitdiff
path: root/h2pl
diff options
context:
space:
mode:
authorLarry Wall <lwall@jpl-devvax.jpl.nasa.gov>1990-08-08 17:07:00 +0000
committerLarry Wall <lwall@jpl-devvax.jpl.nasa.gov>1990-08-08 17:07:00 +0000
commit8725079938ea1a29b3c5fc0c6bbda347bc3f7602 (patch)
tree31031e636a9fda1fcb603050ce6e06aa879f77a9 /h2pl
parent79220ce3ebd9c9ac4a99caf508dadef88c26a4e6 (diff)
downloadperl-8725079938ea1a29b3c5fc0c6bbda347bc3f7602.tar.gz
perl 3.0 patch #20 patch #19, continued
See patch #19.
Diffstat (limited to 'h2pl')
-rw-r--r--h2pl/cbreak.pl34
-rw-r--r--h2pl/cbreak2.pl33
2 files changed, 67 insertions, 0 deletions
diff --git a/h2pl/cbreak.pl b/h2pl/cbreak.pl
new file mode 100644
index 0000000000..422185eb7b
--- /dev/null
+++ b/h2pl/cbreak.pl
@@ -0,0 +1,34 @@
+$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;
diff --git a/h2pl/cbreak2.pl b/h2pl/cbreak2.pl
new file mode 100644
index 0000000000..8ac55a3497
--- /dev/null
+++ b/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;