termios 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,158 @@
1
+ =begin
2
+
3
+ = ruby-termios
4
+
5
+ Ruby-termios enables you to use termios(3) interface.
6
+
7
+
8
+ == Termios module
9
+
10
+ Termios module are simple wrapper for termios(3). It can be included
11
+ into IO-family classes and can extend IO-family objects. In addition,
12
+ the methods can use as module function.
13
+
14
+ === Module Functions
15
+
16
+ --- Termios.tcdrain(io)
17
+ --- Termios.drain(io)
18
+ It calls tcdrain(3) for ((|io|)).
19
+
20
+ --- Termios.tcflow(io, action)
21
+ --- Termios.flow(io, action)
22
+ It calls tcflow(3) for ((|io|)).
23
+
24
+ --- Termios.tcflush(io, queue_selector)
25
+ --- Termios.flush(io, queue_selector)
26
+ It calls tcflush(3) for ((|io|)).
27
+
28
+ --- Termios.tcgetattr(io)
29
+ --- Termios.getattr(io)
30
+ It calls tcgetattr(3) for ((|io|)).
31
+
32
+ --- Termios.tcgetpgrp(io)
33
+ --- Termios.getpgrp(io)
34
+ It calls tcgetpgrp(3) for ((|io|)).
35
+
36
+ --- Termios.tcsendbreak(io, duration)
37
+ --- Termios.sendbreak(io, duration)
38
+ It calls tcsendbreak(3) for ((|io|)).
39
+
40
+ --- Termios.tcsetattr(io, flag, termios)
41
+ --- Termios.setattr(io, flag, termios)
42
+ It calls tcsetattr(3) for ((|io|)).
43
+
44
+ --- Termios.tcsetpgrp(io, pgrpid)
45
+ --- Termios.setpgrp(io, pgrpid)
46
+ It calls tcsetpgrp(3) for ((|io|)).
47
+
48
+ --- Termios.new_termios
49
+ It is alias of ((<Termios::Termios.new>)).
50
+
51
+ === Methods
52
+
53
+ The methods can use for objects which include Termios module or are
54
+ extended by Termios module.
55
+
56
+ --- tcdrain
57
+ It calls tcdrain(3) for ((|self|)).
58
+
59
+ --- tcflow
60
+ It calls tcflow(3) for ((|self|)).
61
+
62
+ --- tcflush(queue_selector)
63
+ It calls tcflush(3) for ((|self|)).
64
+
65
+ --- tcgetattr
66
+ It calls tcgetattr(3) for ((|self|)).
67
+
68
+ --- tcgetpgrp
69
+ It calls tcgetpgrp(3) for ((|self|)).
70
+
71
+ --- tcsendbreak(duratiofn)
72
+ It calls tcsendbreak(3) for ((|self|)).
73
+
74
+ --- tcsetattr(flag, termios)
75
+ It calls tcsetattr(3) for ((|self|)).
76
+
77
+ --- tcsetpgrp(pgrpid)
78
+ It calls tcsetpgrp(3) for ((|self|)).
79
+
80
+ === Constants
81
+
82
+ Many constants which are derived from "termios.h" are defined on Termios
83
+ module.
84
+
85
+ IFLAGS, OFLAGS, CFLAGS and LFLAGS are Hash object. They contains Symbols of
86
+ constants for c_iflag, c_oflag, c_cflag and c_lflag.
87
+
88
+ CCINDEX and BAUDS are Hash object too. They contains Symbols of constats for
89
+ c_cc or ispeed and ospeed.
90
+
91
+ == Termios::Termios class
92
+
93
+ A wrapper class for "struct termios" in C.
94
+
95
+ === Class Methods
96
+
97
+ --- Termios::Termios.new
98
+ It creates a new Termios::Termios object.
99
+
100
+ === Instance Methods
101
+
102
+ --- iflag
103
+ --- c_iflag
104
+ It returns value of c_iflag.
105
+
106
+ --- iflag=(flag)
107
+ --- c_iflag=(flag)
108
+ It sets flag to c_iflag.
109
+
110
+ --- oflag
111
+ --- c_oflag
112
+ It returns value of c_oflag.
113
+
114
+ --- oflag=(flag)
115
+ --- c_oflag=(flag)
116
+ It sets flag to c_oflag.
117
+
118
+ --- cflag
119
+ --- c_cflag
120
+ It returns value of c_cflag.
121
+
122
+ --- cflag=(flag)
123
+ --- c_cflag=(flag)
124
+ It sets flag to c_cflag.
125
+
126
+ --- lflag
127
+ --- c_lflag
128
+ It returns value of c_lflag.
129
+
130
+ --- lflag=(flag)
131
+ --- c_lflag=(flag)
132
+ It sets flag to c_lflag.
133
+
134
+ --- cc
135
+ --- c_cc
136
+ It returns values of c_cc.
137
+
138
+ --- cc=(cc_ary)
139
+ --- c_cc=(cc_ary)
140
+ It sets cc_ary to c_cc.
141
+
142
+ --- ispeed
143
+ --- c_ispeed
144
+ It returns c_ispeeed.
145
+
146
+ --- ispeed=(speed)
147
+ --- c_ispeed=(speed)
148
+ It sets speed to c_ispeed.
149
+
150
+ --- ospeed
151
+ --- c_ospeed
152
+ It returns c_ospeeed.
153
+
154
+ --- ospeed=(speed)
155
+ --- c_ospeed=(speed)
156
+ It sets speed to c_ospeed.
157
+
158
+ =end
@@ -0,0 +1,29 @@
1
+ require 'termios'
2
+
3
+ def dump_termios(tio, banner)
4
+ puts banner
5
+ puts " ispeed = #{Termios::BAUDS[tio.ispeed]}, ospeed = #{Termios::BAUDS[tio.ospeed]}"
6
+ ["iflag", "oflag", "cflag", "lflag"].each do |x|
7
+ flag = tio.send(x)
8
+ flags = []
9
+ eval("Termios::#{x.upcase}S").each do |f, sym|
10
+ flags << sym.to_s if flag & f != 0
11
+ end
12
+ puts " #{x} = #{flags.sort.join(' | ')}"
13
+ end
14
+ print " cc ="
15
+ cc = tio.cc
16
+ cc.each_with_index do |x, idx|
17
+ print " #{Termios::CCINDEX[idx]}=#{x}" if Termios::CCINDEX.include?(idx)
18
+ end
19
+ puts
20
+ end
21
+
22
+ tio = Termios::getattr($stdin)
23
+ dump_termios(tio, "STDIN:")
24
+ Termios::setattr($stdin, Termios::TCSANOW, tio)
25
+ dump_termios(tio, "STDIN:")
26
+
27
+ puts
28
+ puts " pid = #{$$}"
29
+ puts "pgrp = #{Termios::getpgrp($stdin)}"
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.1
3
+ specification_version: 1
4
+ name: termios
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.9.4
7
+ date: 2004-09-24
8
+ summary: "Termios module are simple wrapper for 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."
9
+ require_paths:
10
+ - lib
11
+ - "."
12
+ author: Akira Yamada and Goto Kentaro
13
+ email: akira@ruby-lang.org
14
+ homepage: http://arika.org/ruby/termios
15
+ rubyforge_project:
16
+ description:
17
+ autorequire: termios
18
+ default_executable:
19
+ bindir: bin
20
+ has_rdoc: false
21
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
22
+ requirements:
23
+ -
24
+ - ">"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.0
27
+ version:
28
+ platform: ruby
29
+ files:
30
+ - ChangeLog
31
+ - extconf.rb
32
+ - README
33
+ - TODO.ja
34
+ - termios.c
35
+ - termios.rd
36
+ - MANIFEST
37
+ - test/test0.rb
38
+ - examples/modem_check0.rb
39
+ - examples/modem_check1.rb
40
+ - examples/modem_check2.rb
41
+ - examples/secret_input1.rb
42
+ - examples/secret_input2.rb
43
+ test_files: []
44
+ rdoc_options: []
45
+ extra_rdoc_files:
46
+ - README
47
+ - termios.rd
48
+ executables: []
49
+ extensions:
50
+ - extconf.rb
51
+ requirements: []
52
+ dependencies: []