diff options
Diffstat (limited to 'ext/io')
-rw-r--r-- | ext/io/console/console.c | 23 | ||||
-rw-r--r-- | ext/io/console/extconf.rb | 9 | ||||
-rw-r--r-- | ext/io/console/io-console.gemspec | 4 |
3 files changed, 23 insertions, 13 deletions
diff --git a/ext/io/console/console.c b/ext/io/console/console.c index 3688fd4240..9baad2bf17 100644 --- a/ext/io/console/console.c +++ b/ext/io/console/console.c @@ -111,6 +111,9 @@ rawmode_opt(int *argcp, VALUE *argv, int min_argc, int max_argc, rawmode_arg_t * int argc = *argcp; rawmode_arg_t *optp = NULL; VALUE vopts = Qnil; +#ifdef RB_SCAN_ARGS_PASS_CALLED_KEYWORDS + argc = rb_scan_args(argc, argv, "*:", NULL, &vopts); +#else if (argc > min_argc) { vopts = rb_check_hash_type(argv[argc-1]); if (!NIL_P(vopts)) { @@ -120,6 +123,7 @@ rawmode_opt(int *argcp, VALUE *argv, int min_argc, int max_argc, rawmode_arg_t * if (!vopts) vopts = Qnil; } } +#endif rb_check_arity(argc, min_argc, max_argc); if (!NIL_P(vopts)) { VALUE vmin = rb_hash_aref(vopts, ID2SYM(id_min)); @@ -188,7 +192,7 @@ set_rawmode(conmode *t, void *arg) #endif #ifdef ISIG if (r->intr) { - t->c_iflag |= BRKINT|IXON; + t->c_iflag |= BRKINT; t->c_lflag |= ISIG; t->c_oflag |= OPOST; } @@ -356,9 +360,9 @@ ttymode_with_io(VALUE io, VALUE (*func)(VALUE, VALUE), VALUE farg, void (*setter /* * call-seq: - * io.raw(min: nil, time: nil) {|io| } + * io.raw(min: nil, time: nil, intr: nil) {|io| } * - * Yields +self+ within raw mode. + * Yields +self+ within raw mode, and returns the result of the block. * * STDIN.raw(&:gets) * @@ -370,6 +374,9 @@ ttymode_with_io(VALUE io, VALUE (*func)(VALUE, VALUE), VALUE farg, void (*setter * The parameter +time+ specifies the timeout in _seconds_ with a * precision of 1/10 of a second. (default: 0) * + * If the parameter +intr+ is +true+, enables break, interrupt, quit, + * and suspend special characters. + * * Refer to the manual page of termios for further details. * * You must require 'io/console' to use this method. @@ -383,11 +390,11 @@ console_raw(int argc, VALUE *argv, VALUE io) /* * call-seq: - * io.raw!(min: nil, time: nil) + * io.raw!(min: nil, time: nil, intr: nil) -> io * - * Enables raw mode. + * Enables raw mode, and returns +io+. * - * If the terminal mode needs to be back, use io.raw { ... }. + * If the terminal mode needs to be back, use <code>io.raw { ... }</code>. * * See IO#raw for details on the parameters. * @@ -483,7 +490,7 @@ nogvl_getch(void *p) /* * call-seq: - * io.getch(min: nil, time: nil) -> char + * io.getch(min: nil, time: nil, intr: nil) -> char * * Reads and returns a character in raw mode. * @@ -1490,7 +1497,7 @@ console_dev(int argc, VALUE *argv, VALUE klass) /* * call-seq: - * io.getch(min: nil, time: nil) -> char + * io.getch(min: nil, time: nil, intr: nil) -> char * * See IO#getch. */ diff --git a/ext/io/console/extconf.rb b/ext/io/console/extconf.rb index a6049da667..3d7e75e2af 100644 --- a/ext/io/console/extconf.rb +++ b/ext/io/console/extconf.rb @@ -1,7 +1,7 @@ # frozen_string_literal: false require 'mkmf' -ok = true +ok = true if RUBY_ENGINE == "ruby" hdr = nil case when macro_defined?("_WIN32", "") @@ -14,8 +14,9 @@ when have_header(hdr = "sgtty.h") %w"stty gtty".each {|f| have_func(f, hdr)} else ok = false -end -if ok +end if ok +case ok +when true have_header("sys/ioctl.h") if hdr # rb_check_hash_type: 1.9.3 # rb_io_get_write_io: 1.9.1 @@ -27,4 +28,6 @@ if ok create_makefile("io/console") {|conf| conf << "\n""VK_HEADER = #{vk_header}\n" } +when nil + File.write("Makefile", dummy_makefile($srcdir).join("")) end diff --git a/ext/io/console/io-console.gemspec b/ext/io/console/io-console.gemspec index fac9bff9b7..814bd4ef7d 100644 --- a/ext/io/console/io-console.gemspec +++ b/ext/io/console/io-console.gemspec @@ -1,5 +1,5 @@ # -*- ruby -*- -_VERSION = "0.5.3" +_VERSION = "0.5.6" date = %w$Date:: $[1] Gem::Specification.new do |s| @@ -9,7 +9,7 @@ Gem::Specification.new do |s| s.summary = "Console interface" s.email = "nobu@ruby-lang.org" s.description = "add console capabilities to IO instances." - s.required_ruby_version = ">= 2.2.0" + s.required_ruby_version = ">= 2.4.0" s.homepage = "https://github.com/ruby/io-console" s.metadata["source_code_url"] = s.homepage s.authors = ["Nobu Nakada"] |