mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
console.c: default by stty raw
* ext/io/console/console.c (rawmode_opt): use default values by `stty raw`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e29e4b55ab
commit
490f1fc009
3 changed files with 24 additions and 8 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Tue Feb 5 13:27:53 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* ext/io/console/console.c (rawmode_opt): use default values by `stty
|
||||||
|
raw`.
|
||||||
|
|
||||||
Tue Feb 5 12:50:47 2013 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
Tue Feb 5 12:50:47 2013 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
||||||
|
|
||||||
* range.c: Use div instead of / for bsearch
|
* range.c: Use div instead of / for bsearch
|
||||||
|
|
|
@ -105,7 +105,8 @@ rawmode_opt(int argc, VALUE *argv, rawmode_arg_t *opts)
|
||||||
if (!NIL_P(vopts)) {
|
if (!NIL_P(vopts)) {
|
||||||
VALUE vmin = rb_hash_aref(vopts, ID2SYM(rb_intern("min")));
|
VALUE vmin = rb_hash_aref(vopts, ID2SYM(rb_intern("min")));
|
||||||
VALUE vtime = rb_hash_aref(vopts, ID2SYM(rb_intern("time")));
|
VALUE vtime = rb_hash_aref(vopts, ID2SYM(rb_intern("time")));
|
||||||
opts->vmin = 0;
|
/* default values by `stty raw` */
|
||||||
|
opts->vmin = 1;
|
||||||
opts->vtime = 0;
|
opts->vtime = 0;
|
||||||
if (!NIL_P(vmin)) {
|
if (!NIL_P(vmin)) {
|
||||||
opts->vmin = NUM2INT(vmin);
|
opts->vmin = NUM2INT(vmin);
|
||||||
|
|
|
@ -29,14 +29,21 @@ class TestIO_Console < Test::Unit::TestCase
|
||||||
len = 0
|
len = 0
|
||||||
th = nil
|
th = nil
|
||||||
helper {|m, s|
|
helper {|m, s|
|
||||||
|
assert_equal([nil, 0], [s.getch(min: 0), len])
|
||||||
|
main = Thread.current
|
||||||
|
go = false
|
||||||
th = Thread.start {
|
th = Thread.start {
|
||||||
m.print("a")
|
|
||||||
len += 1
|
len += 1
|
||||||
sleep 2
|
m.print("a")
|
||||||
m.print("1234567890")
|
m.flush
|
||||||
|
sleep 0.01 until go and main.stop?
|
||||||
len += 10
|
len += 10
|
||||||
|
m.print("1234567890")
|
||||||
|
m.flush
|
||||||
}
|
}
|
||||||
assert_equal(["a", 1], [s.getch(min: 1), len])
|
assert_equal(["a", 1], [s.getch(min: 1), len])
|
||||||
|
go = true
|
||||||
|
assert_equal(["1", 11], [s.getch, len])
|
||||||
}
|
}
|
||||||
ensure
|
ensure
|
||||||
th.kill if th and th.alive?
|
th.kill if th and th.alive?
|
||||||
|
@ -46,12 +53,15 @@ class TestIO_Console < Test::Unit::TestCase
|
||||||
len = 0
|
len = 0
|
||||||
th = nil
|
th = nil
|
||||||
helper {|m, s|
|
helper {|m, s|
|
||||||
|
assert_equal([nil, 0], [s.getch(min: 0, time: 0.1), len])
|
||||||
|
main = Thread.current
|
||||||
th = Thread.start {
|
th = Thread.start {
|
||||||
sleep 2
|
sleep 0.01 until main.stop?
|
||||||
m.print("a")
|
len += 2
|
||||||
len += 1
|
m.print("ab")
|
||||||
}
|
}
|
||||||
assert_equal([nil, 0], [s.getch(time: 0.1), len])
|
assert_equal(["a", 2], [s.getch(min: 1, time: 1), len])
|
||||||
|
assert_equal(["b", 2], [s.getch(time: 1), len])
|
||||||
}
|
}
|
||||||
ensure
|
ensure
|
||||||
th.kill if th and th.alive?
|
th.kill if th and th.alive?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue