Commit graph

376 commits

Author SHA1 Message Date
tomoya ishida
02f9b685e8 [ruby/reline] Ignore unhandled escape sequences
(https://github.com/ruby/reline/pull/522)

* Add unassigned escape sequence matcher to KeyStroke

* Do not insert ESC and unassigned ESC+key to input buffer
2023-07-08 08:41:30 +00:00
Stan Lo
24d9e21f84 [ruby/reline] Reduce direct references to Reline::IOGate
(https://github.com/ruby/reline/pull/566)

* Avoid referencing IOGate from IOGate classes

The only time those classes being used is when themselves being the IOGate.
So when referencing to IOGate, it's better to use `self` instead.

* Avoid referencing to IOGate from LineEditor directly

* Avoid referencing to IOGate from Core directly

* Reference to Reline.core directly

* Replace Reline::IOGate with Reline.core.io_gate
2023-07-07 17:27:25 +00:00
tomoya ishida
cd7166cc8f [ruby/reline] Fix wrong byte_pointer passed to auto_indent_proc
(https://github.com/ruby/reline/pull/562)

4348354604
2023-07-05 16:33:46 +00:00
Yuta Kusuno
9ce6e09637 [ruby/reline] Omit constant under Struct
(https://github.com/ruby/reline/pull/554)

8761a11fa5
2023-06-20 14:02:58 +00:00
tomoya ishida
cf0b9e0db0 [ruby/reline] Fix scrolldown condition in dialog rendering
(https://github.com/ruby/reline/pull/541)

ad6faada3f
2023-05-27 15:07:29 +00:00
tomoya ishida
5d137a7f77 [ruby/reline] Use appropriate dialog height and reduce screen pushup
problem
(https://github.com/ruby/reline/pull/542)

* Provide preferred_dialog_height for dialog positioning

* Fix rendering test
2023-05-27 14:48:50 +00:00
tomoya ishida
5eca327fc5 [ruby/reline] Fix dialog corrupts rendering by pushing up input line
too much
(https://github.com/ruby/reline/pull/524)

* Do not render dialog where it overflows screen

* Dialog rendering should Scroll down only when needed

* Refactor screen_y_range calculation

Co-authored-by: Stan Lo <stan001212@gmail.com>

---------

bc0e3d1310

Co-authored-by: Stan Lo <stan001212@gmail.com>
2023-05-07 13:18:13 +00:00
tomoya ishida
13dfbcf7bf [ruby/reline] Rewrite dialog rendering
(https://github.com/ruby/reline/pull/492)

* Rewrite dialog rendering

* Fix failing test of dialog with small screen

* Add multiple-dialog rendering test

* Add description comments for each part of render_dialog_changes
2023-05-01 12:20:20 +00:00
Carl Brasic
8a132358d7 [ruby/reline] Revert #335 (Trap TSTP to handle C-z)
(https://github.com/ruby/reline/pull/535)

This PR was an effort to address #321 (ed_quoted_insert doesn't work
properly) but per the reporter it did not work correctly.

Moreover, it introduced a major regression: Shell job control stopped
working in all applications that use reline, notably IRB.

Bash and other shells send SIGTSTP in response to C-z to implement job
suspension. Handling SIGSTP opts out of this functionality. For a
line oriented terminal program this should be avoided (not to mention,
this behavior diverges from readline's)

26383d25b8

Co-authored-by: Carl Brasic <cbrasic@drwholdings.com>
2023-04-24 16:31:13 +00:00
Étienne Barrié
52ff2ce9da
Use em_delete in key_delete (#504)
* Test existing behavior

Typing Ctrl-D ends editing but typing <Del> does not.

Also renamed a test that is not testing ed_delete_next_char but
key_delete.

* Check if line empty first in em_delete

By distributivity of AND over OR, we can factor out this condition. This
will make the next commit simpler.

* Use em_delete in key_delete

When the editing mode is emacs, use `em_delete` in `key_delete`. We need
to add a condition though to `em_delete`, because it implements both
`delete-char` and `end-of-file`. We only want the `end-of-file` behavior
is the key is really Ctrl-D.

This matches the behavior of the <Del> key with readline, i.e. deleting
the next character if there is one, but not moving the cursor, while not
finishing the editing if there are no characters.
2023-04-05 08:59:12 +09:00
Stan Lo
b168141c78 [ruby/reline] Drop Dialog#scrollbar_pos as we can store it in a
local variable
(https://github.com/ruby/reline/pull/529)

d0139975fd

Co-authored-by: tomoya ishida <tomoyapenguin@gmail.com>
2023-03-29 13:51:27 +00:00
tomoya ishida
8f569d41cb [ruby/reline] Fix cursor position overrun
(https://github.com/ruby/reline/pull/515)

* Fix cursor position overrun

* Remove unnecessary local variable

Co-authored-by: Stan Lo <stan001212@gmail.com>

---------

d4ad9b96c8

Co-authored-by: Stan Lo <stan001212@gmail.com>
2023-03-27 13:57:16 +00:00
tomoya ishida
e8e7ff1333 [ruby/reline] Fix: line longer than terminal width breaks rendering
(https://github.com/ruby/reline/pull/516)

ae5f9b87ab
2023-03-18 14:37:10 +00:00
tomoya ishida
6f81e38d1d [ruby/reline] Fix completion with multiline
(https://github.com/ruby/reline/pull/513)

d76c482c5f
2023-03-04 05:56:00 +00:00
tomoya ishida
4f611df3f7 [ruby/reline] Fix wrong indent number in prompt. whole_lines has
duplicated line.
(https://github.com/ruby/reline/pull/460)

* whole_lines should consider prev_line_index, and must not duplicate last_line

* Add test for lines passed to dynamic prompt proc

* Refactor whole_lines parameters used in test helper

* Remove whole_line's arguments
2023-02-27 10:21:30 +00:00
tomoya ishida
92ed8e6f3f [ruby/reline] Fix the cause of test_yamatanooroti randomly failing
(https://github.com/ruby/reline/pull/474)

* Add repeated input-delete test that fails on HEAD

* Use raw mode while readmultiline
2023-02-27 08:44:02 +00:00
tompng
91f353b1c3 [ruby/reline] Fix line rendering when newline is added at the end of the buffer
7d61b3df9a
2023-02-06 14:23:59 +00:00
tompng
4241b3cf2d [ruby/reline] accept new_indent > cursor_max
61cc580da4
2023-01-20 13:40:15 +00:00
tompng
8e53f09baa [ruby/reline] Add constant MINIMUM_SCROLLBAR_HEIGHT for scrollbar rendering when dialog content is very long
d4c95f89ec
2023-01-18 14:49:29 +00:00
tompng
a712f2a2a0 [ruby/reline] Fix dialog scrollbar rendering position and disappearing bug
e21b69ade4
2023-01-18 14:49:28 +00:00
tomoya ishida
0abb4b6348 [ruby/reline] Pass unmodifined lines(that does not include escape
sequence) to check_multiline_prompt
(https://github.com/ruby/reline/pull/458)

* pass unmodified lines to check_multiline_prompt

* Add test to check that output modified by output_modifier_proc is not passed to prompt_proc
2023-01-12 00:14:53 +00:00
Otávio Schwanck dos Santos
696e8914b7 [ruby/reline] PR changes
e8e8d81f47
2022-09-22 22:28:38 +09:00
Otávio Schwanck dos Santos
9fb18e6314 [ruby/reline] fix vi-operator-arg
d42cdb8f91
2022-09-22 22:28:36 +09:00
Nobuyoshi Nakada
1b8a644b44 [ruby/reline] Fix a typo [ci skip]
33bf80e757
2022-09-03 03:27:58 +09:00
Hiroshi SHIBATA
0d2422cf63 [ruby/reline] Workaround for padding width with Aracritty on macOS
fb4136c8a7
2022-09-02 16:09:51 +09:00
Mau Magnaguagno
941e9be0d9 [ruby/reline] Remove loose operation in Dialog#render_each_dialog
a6d1c917ce
2022-09-01 14:01:37 +09:00
pocari
8c6c3e30f3 [ruby/reline] Enable to change the background color of dialogs. (https://github.com/ruby/reline/pull/413)
bd49537964
2022-06-27 22:28:49 +09:00
aycabta
f5e3913737 [ruby/reline] Fix incremental search to work correctly even if not last line
21d75f6d4c
2022-01-16 22:09:31 +09:00
aycabta
921ff739df [ruby/reline] Insert newline in the middle of buffer just after dialog
0c76631132
2022-01-16 22:09:31 +09:00
aycabta
2bc6b07a8d [ruby/reline] Combine common logic into one
5db9738f17
2022-01-16 22:09:29 +09:00
aycabta
f94a2adf6a [ruby/reline] Clear dialog when adding new line to end of buffer
7d38454327
2022-01-16 22:09:28 +09:00
aycabta
9e79ae539b [ruby/reline] Clear dialog when just_move_cursor is called with dialog at last line
05024b968e
2022-01-11 06:10:37 +09:00
aycabta
c815c0be46 [ruby/reline] Escape newline(s) in dynamic prompt
9b209ee1ea
2021-12-25 00:32:58 +09:00
aycabta
b0db420b0e [ruby/reline] Escape newline(s) in prompt
b545459fca
2021-12-25 00:32:57 +09:00
aycabta
22cc2243f9 [ruby/reline] Remove unnecessary parameter
20fcd22564
2021-12-25 00:32:56 +09:00
aycabta
4fccefef05 [ruby/reline] Revert "Change aliased methods to be parivete"
Ruby 2.5 doesn't support "private alias_method" idiom  but Ruby on Rails
6.x still support 2.5. 😢

This reverts commit 0f075f562b.

4ecaa63b26
2021-12-24 18:23:28 +09:00
aycabta
fc5bc378e5 [ruby/reline] Change aliased methods to be parivete
0f075f562b
2021-12-24 18:23:28 +09:00
aycabta
a9c59b13da [ruby/reline] Add doc about em-kill-line macro
2e46493aff
2021-12-24 18:23:28 +09:00
aycabta
bad1e153d4 [ruby/reline] Implement em_kill_line
9fca6ceb45
2021-12-24 18:23:28 +09:00
aycabta
6c3cc9c58a [ruby/reline] Rename the wrong name "em-kill-line" with the correct name "unix-line-discard"
da7af35d1f
2021-12-24 18:23:28 +09:00
aycabta
fd60a235f5 [ruby/reline] Add doc about ed-kill-line, kill-line, em-kill-line, and unix-line-discard
586a48ffe0
2021-12-24 18:23:28 +09:00
aycabta
4bb65ee4fe [ruby/reline] Character merging may increase the character width
Even if the number of graphemes doesn't change owing to character
merging, the character width may increase.

fbcd5f56a7
2021-12-24 00:51:48 +09:00
aycabta
daf4a8884b [ruby/reline] Add comment for a following char of combined char
d465667f57
2021-12-24 00:51:46 +09:00
aycabta
37aea9d798 [ruby/reline] Finalize when exception occurred
1f8a3aee43

Co-authored-by: Alex Gittemeier <me@a.lexg.dev>
2021-12-21 00:49:03 +09:00
aycabta
c3a3f65b45 [ruby/reline] Split off set_signal_handler method
In some tests, the LineEditor#reset method is always called, but doesn't
need to set the signal handlers there, so cuts it out to a separate
method.

b143c4f5f9
2021-12-21 00:13:19 +09:00
aycabta
145c1e0691 [ruby/reline] Add support for overwriting dialog proc with the same name
16aa20c380
2021-12-20 14:54:42 +09:00
aycabta
7159af3491 [ruby/reline] Clear dialog in pasting
dabf5313e0
2021-12-19 11:19:50 +09:00
aycabta
8411e8449b [ruby/reline] Remove unnecessary variables, lower_space
The number of lines below the cursor position was known by
"@rest_height" alone, but the problem was caused by adding
"lower_space". Remove "lower_space" as it is unnecessary.

a575cef6a3
2021-12-13 20:44:21 +09:00
ima1zumi
f5829e2935 [ruby/reline] Correct padding space calculation
fix https://github.com/ruby/irb/issues/308

This bug occurred when `dialog.width - calculate_width(s, true)` was negative.

When `dialog.width` is shorter than `old_dialog.width`, it calculates how much padding it has to do. However, there are cases where `s` is longer than `dialog.width`, as in the issue. In that case, `padding_space_with_escape_sequences` will crash.

Here, `old_dialog.width` is longer than `dialog.width`, so I changed the padding width to `old_dialog.width - dialog.width`.

c581c31e0f
2021-11-21 13:56:26 +09:00
Nobuyoshi Nakada
1009fd7ee3 [ruby/reline] Revert "Fix zero division when the screen width is not available"
This reverts commit 0dce9da083541f42c31822a91c72f339934c3986.

f71471cdde
2021-10-12 13:19:24 +09:00