-
Notifications
You must be signed in to change notification settings - Fork 93
Add key binding for Delete (save Insert, PgUp, PgDn for later) #434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| require_relative 'helper' | ||
| require 'reline/ansi' | ||
|
|
||
| class Reline::ANSI::TestWithTerminfo < Reline::TestCase | ||
| def setup | ||
| Reline.send(:test_mode, ansi: true) | ||
| @config = Reline::Config.new | ||
| Reline::IOGate.set_default_key_bindings(@config, allow_terminfo: true) | ||
| end | ||
|
|
||
| def teardown | ||
| Reline.test_reset | ||
| end | ||
|
|
||
| # Home key | ||
| def test_khome | ||
| assert_key_binding(Reline::Terminfo.tigetstr('khome'), :ed_move_to_beg) | ||
| rescue Reline::Terminfo::TerminfoError => e | ||
| omit e.message | ||
| end | ||
|
|
||
| # End key | ||
| def test_kend | ||
| assert_key_binding(Reline::Terminfo.tigetstr('kend'), :ed_move_to_end) | ||
| rescue Reline::Terminfo::TerminfoError => e | ||
| omit e.message | ||
| end | ||
|
|
||
| # Delete key | ||
| def test_kdch1 | ||
| assert_key_binding(Reline::Terminfo.tigetstr('kdch1'), :key_delete) | ||
| rescue Reline::Terminfo::TerminfoError => e | ||
| omit e.message | ||
| end | ||
|
|
||
| # Up arrow key | ||
| def test_kcuu1 | ||
| assert_key_binding(Reline::Terminfo.tigetstr('kcuu1'), :ed_prev_history) | ||
| rescue Reline::Terminfo::TerminfoError => e | ||
| omit e.message | ||
| end | ||
|
|
||
| # Down arrow key | ||
| def test_kcud1 | ||
| assert_key_binding(Reline::Terminfo.tigetstr('kcud1'), :ed_next_history) | ||
| rescue Reline::Terminfo::TerminfoError => e | ||
| omit e.message | ||
| end | ||
|
|
||
| # Right arrow key | ||
| def test_kcuf1 | ||
| assert_key_binding(Reline::Terminfo.tigetstr('kcuf1'), :ed_next_char) | ||
| rescue Reline::Terminfo::TerminfoError => e | ||
| omit e.message | ||
| end | ||
|
|
||
| # Left arrow key | ||
| def test_kcub1 | ||
| assert_key_binding(Reline::Terminfo.tigetstr('kcub1'), :ed_prev_char) | ||
| rescue Reline::Terminfo::TerminfoError => e | ||
| omit e.message | ||
| end | ||
|
|
||
| # Ctrl+arrow and Meta+arrow; always mapped regardless of terminfo enabled or not | ||
| def test_extended | ||
| assert_key_binding("\e[1;5C", :em_next_word) # Ctrl+→ | ||
| assert_key_binding("\e[1;5D", :ed_prev_word) # Ctrl+← | ||
| assert_key_binding("\e[1;3C", :em_next_word) # Meta+→ | ||
| assert_key_binding("\e[1;3D", :ed_prev_word) # Meta+← | ||
| end | ||
|
|
||
| # Shift-Tab; always mapped regardless of terminfo enabled or not | ||
| def test_shift_tab | ||
| assert_key_binding("\e[Z", :completion_journey_up, [:emacs, :vi_insert]) | ||
| end | ||
|
|
||
| # A few emacs bindings that are always mapped regardless of terminfo enabled or not | ||
| def test_more_emacs | ||
| assert_key_binding("\e ", :em_set_mark, [:emacs]) | ||
| assert_key_binding("\C-x\C-x", :em_exchange_mark, [:emacs]) | ||
| end | ||
| end if Reline::Terminfo.enabled? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| require_relative 'helper' | ||
| require 'reline/ansi' | ||
|
|
||
| class Reline::ANSI::TestWithoutTerminfo < Reline::TestCase | ||
| def setup | ||
| Reline.send(:test_mode, ansi: true) | ||
| @config = Reline::Config.new | ||
| Reline::IOGate.set_default_key_bindings(@config, allow_terminfo: false) | ||
| end | ||
|
|
||
| def teardown | ||
| Reline.test_reset | ||
| end | ||
|
|
||
| def test_home | ||
| assert_key_binding("\e[1~", :ed_move_to_beg) # Console (80x25) | ||
| assert_key_binding("\e[H", :ed_move_to_beg) # KDE | ||
| assert_key_binding("\e[7~", :ed_move_to_beg) # urxvt / exoterm | ||
| assert_key_binding("\eOH", :ed_move_to_beg) # GNOME | ||
| end | ||
|
|
||
| def test_end | ||
| assert_key_binding("\e[4~", :ed_move_to_end) # Console (80x25) | ||
| assert_key_binding("\e[F", :ed_move_to_end) # KDE | ||
| assert_key_binding("\e[8~", :ed_move_to_end) # urxvt / exoterm | ||
| assert_key_binding("\eOF", :ed_move_to_end) # GNOME | ||
| end | ||
|
|
||
| def test_delete | ||
| assert_key_binding("\e[3~", :key_delete) | ||
| end | ||
|
|
||
| def test_up_arrow | ||
| assert_key_binding("\e[A", :ed_prev_history) # Console (80x25) | ||
| assert_key_binding("\eGA", :ed_prev_history) # KDE | ||
| assert_key_binding("\eOA", :ed_prev_history) | ||
| end | ||
|
|
||
| def test_down_arrow | ||
| assert_key_binding("\e[B", :ed_next_history) # Console (80x25) | ||
| assert_key_binding("\eGB", :ed_next_history) # KDE | ||
| assert_key_binding("\eOB", :ed_next_history) | ||
| end | ||
|
|
||
| def test_right_arrow | ||
| assert_key_binding("\e[C", :ed_next_char) # Console (80x25) | ||
| assert_key_binding("\eGC", :ed_next_char) # KDE | ||
| assert_key_binding("\eOC", :ed_next_char) | ||
| end | ||
|
|
||
| def test_left_arrow | ||
| assert_key_binding("\e[D", :ed_prev_char) # Console (80x25) | ||
| assert_key_binding("\eGD", :ed_prev_char) # KDE | ||
| assert_key_binding("\eOD", :ed_prev_char) | ||
| end | ||
|
|
||
| # Ctrl+arrow and Meta+arrow; always mapped regardless of terminfo enabled or not | ||
| def test_extended | ||
| assert_key_binding("\e[1;5C", :em_next_word) # Ctrl+→ | ||
| assert_key_binding("\e[1;5D", :ed_prev_word) # Ctrl+← | ||
| assert_key_binding("\e[1;3C", :em_next_word) # Meta+→ | ||
| assert_key_binding("\e[1;3D", :ed_prev_word) # Meta+← | ||
| end | ||
|
|
||
| # Shift-Tab; always mapped regardless of terminfo enabled or not | ||
| def test_shift_tab | ||
| assert_key_binding("\e[Z", :completion_journey_up, [:emacs, :vi_insert]) | ||
| end | ||
|
|
||
| # A few emacs bindings that are always mapped regardless of terminfo enabled or not | ||
| def test_more_emacs | ||
| assert_key_binding("\e ", :em_set_mark, [:emacs]) | ||
| assert_key_binding("\C-x\C-x", :em_exchange_mark, [:emacs]) | ||
| end | ||
| end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.