[ruby/reline] Support inserting C-c C-z C-\ with quoted_insert

(https://github.com/ruby/reline/pull/798)

https://github.com/ruby/reline/commit/e6eb5d2d3c
This commit is contained in:
tomoya ishida 2025-01-01 23:41:54 +09:00 committed by git
parent 341503d1a3
commit 3e8f0e5589
3 changed files with 28 additions and 0 deletions

View File

@ -309,6 +309,13 @@ class Reline::ANSI < Reline::IO
# Signal.trap may raise an ArgumentError if the platform doesn't support the signal.
end
def read_single_char(keyseq_timeout)
# Disable intr to read `C-c` `C-z` `C-\` for quoted insert
@input.raw(intr: false) do
super
end
end
def prep
# Enable bracketed paste
write "\e[?2004h" if Reline.core.config.enable_bracketed_paste && both_tty?

View File

@ -28,6 +28,7 @@ class Reline::Unicode
0x19 => '^Y',
0x1A => '^Z', # C-z
0x1B => '^[', # C-[ C-3
0x1C => '^\\', # C-\
0x1D => '^]', # C-]
0x1E => '^^', # C-~ C-6
0x1F => '^_', # C-_ C-7

View File

@ -1724,6 +1724,26 @@ begin
close
end
def test_quoted_insert_intr_keys
omit if Reline.core.io_gate.win?
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
write '"'
write "\C-v"
write "\C-c"
write "\C-v"
write "\C-z"
write "\C-v"
write "\C-\\"
write "\".bytes\n"
assert_screen(<<~EOC)
Multiline REPL.
prompt> "^C^Z^\\\".bytes
=> [3, 26, 28]
prompt>
EOC
close
end
def test_print_before_readline
code = <<~RUBY
puts 'Multiline REPL.'