Skip to content

Commit

Permalink
Support inserting C-c C-z C-\ with quoted_insert
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng committed Dec 31, 2024
1 parent d643499 commit c761cde
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/reline/io/ansi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,13 @@ def set_winch_handler(&handler)
# 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?
Expand Down
1 change: 1 addition & 0 deletions lib/reline/unicode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions test/reline/yamatanooroti/test_rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1724,6 +1724,26 @@ def test_exit_with_ctrl_d
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.'
Expand Down

0 comments on commit c761cde

Please sign in to comment.