summaryrefslogtreecommitdiff
path: root/sample/cbreak.rb
blob: 5d2d849512b59dad324d1ccdca53683e834ecbdc (plain)
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
34
35
36
# ioctl example works on Sun

CBREAK = 0x00000002
ECHO = 0x00000008
TIOCGETP = 0x40067408
TIOCSETP = 0x80067409

def cbreak ()
  set_cbreak(TRUE)
end

def cooked ()
  set_cbreak(FALSE)
end

def set_cbreak (on)
  tty = "\0" * 256
  $stdin.ioctl(TIOCGETP, tty)
  ttys = tty.unpack("C4 S")
  if on
    ttys[4] |= CBREAK
    ttys[4] &= ~ECHO
  else
    ttys[4] &= ~CBREAK
    ttys[4] |= ECHO
  end
  tty = ttys.pack("C4 S")
  $stdin.ioctl(TIOCSETP, tty)
end
cbreak();

print("this is no-echo line: ");
readline().print
cooked();
print("this is echo line: ");
readline()
1-09internal.h: remove dependecy on ruby/encoding.hnobu 2017-12-28`$SAFE` as a process global state. [Feature #14250]ko1 2016-08-16* lib/net/http/header.rb: Fix typo. [ci skip][fix GH-1407]hsbt 2016-05-27transcode.c: scrub in the given encodingnobu 2016-05-22transcode.c: GC guardsnobu 2015-12-17transcode.c: infectionnobu 2015-12-09* *.c (*_memsize): do not check ptr.ko1 2015-11-11* transcode.c: fix a typohsbt 2015-08-05transcode.c: GC guardsnobu 2015-08-05transcode.c: fix dangling pointersnobu 2015-07-03transcode.c: empty encoding namenobu 2015-06-26transcode.c: fix race conditionnobu 2014-12-01use 0 for reservednobu 2014-11-15* internal.h: Include ruby.h and ruby/encoding.h to beakr 2014-08-03transcode.c: use stringnobu 2014-07-30* process.c (rlimit_resource_type, rlimit_resource_value):ktsj 2014-07-20rb_econv_t: reduce to 184 bytes from 200 on 64-bitnormal 2014-07-03Init functions don't need ID cachesnobu