Commit graph

123 commits

Author SHA1 Message Date
Samuel Williams
f27eb8148f
Sync io-console gem. 2021-12-29 13:27:40 +13:00
Samuel Williams
548c8f5f7a
Prefer to use RTEST when checking result of rb_io_wait. (#5341)
* Prefer to use RTEST when checking result of `rb_io_wait`.

* Consistently use false for signifying no events ready.
2021-12-25 02:26:06 +13:00
Nobuyoshi Nakada
5bfca88f76
[ruby/io-console] Fixed typo 2021-02-09 17:39:00 +09:00
Samuel Williams
5f69a7f604
Expose scheduler as public interface & bug fixes. (#3945)
* Rename `rb_scheduler` to `rb_fiber_scheduler`.

* Use public interface if available.

* Use `rb_check_funcall` where possible.

* Don't use `unblock` unless the fiber was non-blocking.
2021-02-09 19:39:56 +13:00
Nobuyoshi Nakada
83e62d7798 [ruby/io-console] Shrink struct query_args
720be0a3e5
2021-01-05 21:26:15 +09:00
Nobuyoshi Nakada
4272395982 [ruby/io-console] Pre-define chomp! ID
028e1c9497
2021-01-05 21:26:13 +09:00
Nobuyoshi Nakada
ead8d89bd7 [ruby/io-console] Ignore chomp! result and return the modified string
09e5ccc729
2021-01-05 21:26:11 +09:00
Marcus Stollsteimer
451b456051 [ruby/io-console] [DOC] Note that IO#getpass returns a chomped string
IO#getpass uses String#chomp! on the read input line.

1e98c93bc8
2021-01-05 12:59:53 +09:00
Nobuyoshi Nakada
71428ac264 [ruby/io-console] Refined getch warnings
f84e6abcce
2020-10-11 02:00:28 +09:00
Nobuyoshi Nakada
37259e878f [ruby/io-console] Relaxed min: option warning
When `min: 0` is given to `IO#getch` with `time:` option, it is
expected to return nil if timed out, and needed for source code
the compatibility with unixen platforms.

a2afbe72bd
2020-10-11 02:00:26 +09:00
Nobuyoshi Nakada
a79966743c [ruby/io-console] Fix timeout type error (#18)
Fixed TypeError when IO#getch timed out

`rb_io_wait` returns a bit-flags Integer representing available
events, or Qfalse if timed out.  Also the result of `NUM2INT` is
not a `VALUE`.

```
$ ./bin/ruby -v -rio/console -e "p IO.console.getch(intr: true, time: 0.1)"
ruby 3.0.0dev (2020-10-09T20:27:30Z master 5ea2ea74cc) [x64-mingw32]
-e:1:in `getch': no implicit conversion of false into Integer (TypeError)
        from -e:1:in `<main>'
```

3bdfaf62df
2020-10-11 02:00:24 +09:00
Nobuyoshi Nakada
b59640e155
[ruby/io-console] Fixed "Rework console to use rb_io_wait."
* Fixed backward compatibility.
* Added missing `rb_scheduler_timeout` declaration.

813806079f
2020-10-11 01:27:15 +09:00
Samuel Williams
7fca274198 Rework console to use rb_io_wait. 2020-09-14 16:44:09 +12:00
Nobuyoshi Nakada
be575a6eef
[ruby/io-console] Use sys_fail_fptr macro
2b8ba023c8
2020-05-09 17:05:14 +09:00
Nobuyoshi Nakada
0ce45db115 [ruby/io-console] Show path name at error
6a4b1c1a6d
2020-05-09 13:56:55 +09:00
Nobuyoshi Nakada
dec802d8b5 [ruby/io-console] [DOC] Improved about intr:
82b630cd79
2020-02-17 12:05:09 +09:00
Nobuyoshi Nakada
78282d4655
[ruby/io-console] Prefer keyword arguments
5facbfc4c8
2020-02-14 20:30:34 +09:00
Nobuyoshi Nakada
4e56ec4ef7 [ruby/io-console] Set OPOST when intr is true
To enable implementation-defined output processing, for the
compatibility with readline.  [Bug #16509]

https://bugs.ruby-lang.org/issues/16509

8c8b0b6757
2020-01-18 00:15:02 +09:00
Nobuyoshi Nakada
31e2f03512 [ruby/io-console] Enable only interrupt bits on intr: true
baaf929041
2019-12-29 16:26:22 +09:00
Nobuyoshi Nakada
77e3078ede [ruby/io-console] Set raw mode strictly same as cfmakeraw
* Default VMIN and VTIME to minimum input.
* Disable parity check bits explicitly.
* Disable all bits for flow control on input.

Co-Authored-By: NARUSE, Yui <naruse@airemix.jp>

5ce201a686
2019-12-18 10:33:05 +09:00
Yusuke Endoh
b39d5da974
[ruby/io-console] Use TCSANOW to prevent from discarding the input buffer
TCSAFLUSH discards the buffer read before the mode change, which makes
IRB ignore the buffer input immediately after invoked.  TCSANOW
preserves the buffer.

b362920182
2019-12-17 13:55:05 +09:00
Nobuyoshi Nakada
81eb2d16ef
[ruby/io-console] Disable implementation-defined special control characters
In raw mode with interrupt enabled.

e9e8e3ff17
2019-12-17 13:55:04 +09:00
Nobuyoshi Nakada
a9d17af242
[ruby/io-console] Removed dead code
a49462ed97
2019-12-17 13:55:04 +09:00
Nobuyoshi Nakada
2419b3dba6
[ruby/io-console] Suppress an unused-variable warning
ae5c72e481
2019-12-10 16:06:11 +09:00
Nobuyoshi Nakada
f9c0fe77c0
[ruby/io-console] Use rb_thread_call_without_gvl instead of the deprecated function
21338ab287
2019-12-10 16:06:11 +09:00
Nobuyoshi Nakada
09723b98f7
[ruby/io-console] Warn vtime option without intr flag
499ff3de48
2019-12-10 16:06:11 +09:00
Nobuyoshi Nakada
5a404efd29 [ruby/io-console] Fixed intr: false mode on Windows
4c172c01aa
2019-12-04 10:10:45 +09:00
Jeremy Evans
17e8a6eff4 [ruby/io-console] Remove taint support
Ruby 2.7 deprecates taint and it no longer has an effect.
The lack of taint support should not cause a problem in
previous Ruby versions.
2019-11-18 01:00:25 +02:00
Jeremy Evans
ffd0820ab3 Deprecate taint/trust and related methods, and make the methods no-ops
This removes the related tests, and puts the related specs behind
version guards.  This affects all code in lib, including some
libraries that may want to support older versions of Ruby.
2019-11-18 01:00:25 +02:00
Jeremy Evans
c5c05460ac Warn on access/modify of $SAFE, and remove effects of modifying $SAFE
This removes the security features added by $SAFE = 1, and warns for access
or modification of $SAFE from Ruby-level, as well as warning when calling
all public C functions related to $SAFE.

This modifies some internal functions that took a safe level argument
to no longer take the argument.

rb_require_safe now warns, rb_require_string has been added as a
version that takes a VALUE and does not warn.

One public C function that still takes a safe level argument and that
this doesn't warn for is rb_eval_cmd.  We may want to consider
adding an alternative method that does not take a safe level argument,
and warn for rb_eval_cmd.
2019-11-18 01:00:25 +02:00
Nobuyoshi Nakada
5357ceb1ca
[ruby/io-console] Defer creating VT query string
3d69c577a4
2019-09-26 09:59:27 +09:00
Nobuyoshi Nakada
9b10698705
[ruby/io-console] Added IO#console_mode
77ed8d5a06
2019-09-26 09:59:27 +09:00
Kazuhiro NISHIYAMA
ca58e83400
Do not use of non-standard escape character '\e' 2019-09-25 09:48:44 +09:00
Nobuyoshi Nakada
10e3267c31 [ruby/io-console] Made cursor position 0-origin
9377e37295
2019-09-24 16:20:31 +09:00
Nobuyoshi Nakada
244f7ec204 [ruby/io-console] Made cursor position consistent with winsize
To be consistent with `winsize`, changed the cursor position
format from `[x, y]` to `[row, column]`.

d1f5ae9286
2019-09-24 16:20:30 +09:00
Nobuyoshi Nakada
9e4be78ea8 [ruby/io-console] Try fallback to stdout when stdin
b8017509ef
2019-09-23 19:29:36 +09:00
Nobuyoshi Nakada
8487193b10 [ruby/io-console] Try to write DSR query to writable IO
a54b6e4dd1
2019-09-23 19:24:43 +09:00
Nobuyoshi Nakada
6d2dcf9632 [ruby/io-console] Added intr: option to IO#raw
Enters raw-mode but enable interrupts.

7cba76561a
2019-09-14 23:27:53 +09:00
Nobuyoshi Nakada
83ef58f264 [ruby/io-console] Suppress yet another warning on Windows
4e17c90788
2019-09-10 17:29:11 +09:00
Nobuyoshi Nakada
b5ab918d0c [ruby/io-console] Suppress warnings on Windows
About unused variables and a function.

32baf54e7a
2019-09-10 17:29:09 +09:00
Nobuyoshi Nakada
3678c37119 [ruby/io-console] Added IO#check_winsize_changed on Windows
ee648fa8bb
2019-09-10 08:18:03 +09:00
Nobuyoshi Nakada
74790e2dc4 [ruby/io-console] Added scroll methods
83e70de8ab
2019-09-10 08:18:03 +09:00
Nobuyoshi Nakada
c1412bd6d9 [ruby/io-console] Added line/screen erase methods
e6344108a1
2019-09-10 08:18:03 +09:00
Nobuyoshi Nakada
9844a349bf [ruby/io-console] Added IO#goto_column
143a9d5764
2019-09-10 08:18:03 +09:00
Nobuyoshi Nakada
e8be056af9 [ruby/io-console] Added relative cursor move methods
21d340e4a2
2019-09-10 08:18:03 +09:00
Nobuyoshi Nakada
3d9c7c2835 [ruby/io-console] Added IO#goto and IO#cursor= for VT
7f2b1b473d
2019-09-10 08:18:03 +09:00
Nobuyoshi Nakada
53ed4fb376 [ruby/io-console] Added IO#cursor for VT
41a6a6cace
2019-09-10 08:18:03 +09:00
Nobuyoshi Nakada
803dc9e1e4 [ruby/io-console] Added console_vt_response
A function to query console info.

db75a07fa3
2019-09-10 08:18:03 +09:00
Nobuyoshi Nakada
214e2f93aa
Fix the warning in 456586bb23 2019-05-15 18:19:23 +09:00
Nobuyoshi Nakada
29dde62605
io/console: rb_str_cat_conv_enc_opts is not exported 2019-05-14 14:50:21 +09:00