Module: Termios
- Defined in:
- ext/termios.c,
lib/termios.rb,
lib/termios/version.rb,
ext/termios.c
Overview
Description
Termios module is simple wrapper of termios(3). It can be included into IO-family classes and can extend IO-family objects. In addition, the methods can use as module function.
You can call termios(3) function as module methods. Or you can use these methods as instance method by including Termios module to the target IO object.
Constants
Many constants which are derived from “termios.h” are defined on Termios module. You can use these constants as the same name in “termios.h” basically.
IFLAGS, OFLAGS, CFLAGS and LFLAGS are Hash object. They contains Symbols of constants for c_iflag, c_oflag, c_cflag and c_lflag. CCINDEX and BAUDS are Hash object too. They contains Symbols of constats for c_cc or ispeed and ospeed.
See also
termios(3)
Defined Under Namespace
Classes: Termios
Constant Summary collapse
- VISIBLE_CHAR =
{}
- VERSION =
'1.1.0'
- NCCS =
number of control characters
INT2FIX(NCCS)
- POSIX_VDISABLE =
INT2FIX(_POSIX_VDISABLE)
- CCINDEX =
Hash of control character index and control character names
ccindex
- CCINDEX_NAMES =
List of control character names
ccindex_names
- IFLAGS =
Hash of input mode names and values
iflags
- IFLAG_NAMES =
List of input mode names
iflags_names
- OFLAGS =
Hash of output mode names and values
oflags
- OFLAG_NAMES =
List of output mode names
oflags_names
- OFLAG_CHOICES =
oflags_choices
- CFLAGS =
Hash of control mode names and values
cflags
- CFLAG_NAMES =
List of control mode names
cflags_names
- CFLAG_CHOICES =
cflags_choices
- LFLAGS =
Hash of local mode names and values
lflags
- LFLAG_NAMES =
List of local mode names
lflags_names
- BAUDS =
List of baud rates
bauds
- BAUD_NAMES =
List of baud rate names
bauds_names
- SETATTR_OPTS =
List of tcsetattr options
tcsetattr_opt
- FLUSH_QSELECTORS =
List of tcflush qselectors
tcflush_qs
- FLOW_ACTIONS =
List of tcflow actions
tcflow_act
- IOCTL_COMMANDS =
ioctl_commands
- IOCTL_COMMAND_NAMES =
ioctl_commands_names
- MODEM_SIGNALS =
modem_signals
- MODEM_SIGNAL_NAMES =
modem_signals_names
- PTY_PACKET_OPTIONS =
- PTY_PACKET_OPTION_NAMES =
- LINE_DISCIPLINES =
line_disciplines
- LINE_DISCIPLINE_NAMES =
line_disciplines_names
Class Method Summary collapse
- .drain ⇒ Object
- .flow ⇒ Object
- .flush ⇒ Object
- .getattr ⇒ Object
- .getpgrp ⇒ Object
-
.new_termios ⇒ Object
Returns new Termios::Termios object.
- .sendbreak ⇒ Object
- .setattr ⇒ Object
- .setpgrp ⇒ Object
- .tcdrain ⇒ Object
- .tcflow ⇒ Object
- .tcflush ⇒ Object
- .tcgetattr ⇒ Object
- .tcgetpgrp ⇒ Object
- .tcsendbreak ⇒ Object
- .tcsetattr ⇒ Object
- .tcsetpgrp ⇒ Object
Instance Method Summary collapse
-
#tcdrain ⇒ Object
Waits until all output to the object has been sent.
-
#tcflow ⇒ Object
Suspends write or read of data on the object.
-
#tcflush ⇒ Object
Cancels data written to the object but not send or data received but not read.
-
#tcgetattr ⇒ Object
Returns new Termios::Termios object which stores termios parameters associated with the io.
-
#tcgetpgrp ⇒ Object
Returns the process group ID of the foreground process group the terminal associated to the object.
-
#tcsendbreak ⇒ Object
Sends a continuous stream of 0-bits for a specific duration.
-
#tcsetattr ⇒ Object
Sets the Termios::Termios object as the termios paramter to the io and returns the old termios parameter.
-
#tcsetpgrp ⇒ Object
Makes the process group with pgrpid the foreground process group on the terminal associated to the object.
Class Method Details
.drain ⇒ Object
460 461 462 |
# File 'ext/termios.c', line 460 static VALUE termios_s_tcdrain(obj, io) VALUE obj, io; |
.flow ⇒ Object
539 540 541 |
# File 'ext/termios.c', line 539 static VALUE termios_s_tcflow(obj, io, act) VALUE obj, io, act; |
.flush ⇒ Object
500 501 502 |
# File 'ext/termios.c', line 500 static VALUE termios_s_tcflush(obj, io, qs) VALUE obj, io, qs; |
.getattr ⇒ Object
322 323 324 |
# File 'ext/termios.c', line 322 static VALUE termios_s_tcgetattr(obj, io) VALUE obj, io; |
.getpgrp ⇒ Object
572 573 574 |
# File 'ext/termios.c', line 572 static VALUE termios_s_tcgetpgrp(obj, io) VALUE obj, io; |
.new_termios ⇒ Object
Returns new Termios::Termios object.
620 621 622 |
# File 'ext/termios.c', line 620 static VALUE termios_s_newtermios(argc, argv, klass) int argc; |
.sendbreak ⇒ Object
428 429 430 |
# File 'ext/termios.c', line 428 static VALUE termios_s_tcsendbreak(obj, io, duration) VALUE obj, io, duration; |
.setattr ⇒ Object
395 396 397 |
# File 'ext/termios.c', line 395 static VALUE termios_s_tcsetattr(obj, io, opt, param) VALUE obj, io, opt, param; |
.setpgrp ⇒ Object
607 608 609 |
# File 'ext/termios.c', line 607 static VALUE termios_s_tcsetpgrp(obj, io, pgrpid) VALUE obj, io, pgrpid; |
.tcdrain ⇒ Object
460 461 462 |
# File 'ext/termios.c', line 460 static VALUE termios_s_tcdrain(obj, io) VALUE obj, io; |
.tcflow ⇒ Object
539 540 541 |
# File 'ext/termios.c', line 539 static VALUE termios_s_tcflow(obj, io, act) VALUE obj, io, act; |
.tcflush ⇒ Object
500 501 502 |
# File 'ext/termios.c', line 500 static VALUE termios_s_tcflush(obj, io, qs) VALUE obj, io, qs; |
.tcgetattr ⇒ Object
322 323 324 |
# File 'ext/termios.c', line 322 static VALUE termios_s_tcgetattr(obj, io) VALUE obj, io; |
.tcgetpgrp ⇒ Object
572 573 574 |
# File 'ext/termios.c', line 572 static VALUE termios_s_tcgetpgrp(obj, io) VALUE obj, io; |
.tcsendbreak ⇒ Object
428 429 430 |
# File 'ext/termios.c', line 428 static VALUE termios_s_tcsendbreak(obj, io, duration) VALUE obj, io, duration; |
.tcsetattr ⇒ Object
395 396 397 |
# File 'ext/termios.c', line 395 static VALUE termios_s_tcsetattr(obj, io, opt, param) VALUE obj, io, opt, param; |
.tcsetpgrp ⇒ Object
607 608 609 |
# File 'ext/termios.c', line 607 static VALUE termios_s_tcsetpgrp(obj, io, pgrpid) VALUE obj, io, pgrpid; |
Instance Method Details
#tcdrain(io) ⇒ Object #tcdrain ⇒ Object
Waits until all output to the object has been sent.
See also: tcdrain(3)
444 445 446 |
# File 'ext/termios.c', line 444 static VALUE termios_tcdrain(io) VALUE io; |
#tcflow(io, action) ⇒ Object #tcflow(action) ⇒ Object
Suspends write or read of data on the object.
See also: tcflow(3)
516 517 518 |
# File 'ext/termios.c', line 516 static VALUE termios_tcflow(io, act) VALUE io, act; |
#tcflush(io, qs) ⇒ Object #tcflush(qs) ⇒ Object
Cancels data written to the object but not send or data received but not read.
See also: tcflush(3)
477 478 479 |
# File 'ext/termios.c', line 477 static VALUE termios_tcflush(io, qs) VALUE io, qs; |
#tcgetattr(io) ⇒ Object #tcgetattr ⇒ Object
Returns new Termios::Termios object which stores termios parameters associated with the io.
require 'termios'
Termios.tcgetattr($stdin)
#=> #<Termios::Termios speed 38400 baud; intr=^C ... >
$stdout.extend(Termios)
$stdout.tcgetattr
#=> #<Termios::Termios speed 38400 baud; intr=^C ... >
See also: tcgetattr(3)
306 307 308 |
# File 'ext/termios.c', line 306 static VALUE termios_tcgetattr(io) VALUE io; |
#tcgetpgrp(io) ⇒ Object #tcgetpgrp ⇒ Object
Returns the process group ID of the foreground process group the terminal associated to the object.
See also: tcgetpgrp(3)
556 557 558 |
# File 'ext/termios.c', line 556 static VALUE termios_tcgetpgrp(io) VALUE io; |
#tcsendbreak(io, duration) ⇒ Object #tcsendbreak(duration) ⇒ Object
Sends a continuous stream of 0-bits for a specific duration.
See also: tcsendbreak(3)
411 412 413 |
# File 'ext/termios.c', line 411 static VALUE termios_tcsendbreak(io, duration) VALUE io, duration; |
#tcsetattr(io, option, termios) ⇒ Object #tcsetattr(option, termios) ⇒ Object
Sets the Termios::Termios object as the termios paramter to the io and returns the old termios parameter.
Option are specifies when the parameter is changed. What option are available is plathome dependent, but usually Termios::TCSANOW, Termios::TCSADRAIN and Termios::TCSAFLUSH are provided.
require 'termios'
oldt = Termios.tcgetattr($stdin)
newt = oldt.dup
newt.lflag &= ~Termios::ECHO
secret = nil
begin
Termios.tcsetattr($stdin, Termios::TCSANOW, newt)
print "noecho> "
secret = $stdin.gets
print "\n"
ensure
Termios.tcsetattr($stdin, Termios::TCSANOW, oldt)
end
puts secret
See also: tcsetattr(3)
361 362 363 |
# File 'ext/termios.c', line 361 static VALUE termios_tcsetattr(io, opt, param) VALUE io, opt, param; |
#tcsetpgrp(io, pgrpid) ⇒ Object #tcsetpgrp(pgrpid) ⇒ Object
Makes the process group with pgrpid the foreground process group on the terminal associated to the object.
See also: tcsetpgrp(3)
589 590 591 |
# File 'ext/termios.c', line 589 static VALUE termios_tcsetpgrp(io, pgrpid) VALUE io, pgrpid; |