JEG2 / highline

A higher level command-line oriented interface.
Other
1.29k stars 137 forks source link

Issue #236 - Handle Ctrl-C when Question#echo = false (raw_no_echo_mode) #259

Closed abinoam closed 1 year ago

abinoam commented 1 year ago

Fix #236

Hi @Fahhetah,

I've set the author's commit to your e-mail to honor your suggestion. But I've changed exit 130 to raise Interrupt so it stays in line with Ruby standard behavior when receiving ctrl-C. I'll not merge it yet as I'm investigating a little further if I could have a better more complete approach. Because treating all ctrl codes one by one seems not a good way for the long run.

cc: @Faheetah @Thalagyrt @aspyct


Of note, this commit message:

Handle interrupts directly at io/console was possible with the introduction of intr option to getch.

Added to io/console at commit at 24, September, 2019

Released in Ruby 2.7.0, released at 25, December, 2019

Documented at 17, February, 2020

Documented in Ruby 2.7.1, released at 31, March, 2020

We should review all the code for other instances of handling control inputs like getch when echo is not false. And, we will probably have to think about deprecating rubies older than 2.7 because they will have a different behavior. (Although the tests are passing because we use a mock with StringIO objects, not the actual consoles.