404 Commits

Author SHA1 Message Date
Mari Imaizumi
be6d23646f [ruby/reline] Prevent a warning for `warning: literal string will be
frozen in the future`
(https://github.com/ruby/reline/pull/744)

https://github.com/ruby/reline/commit/69c95c8b6a
2024-09-05 12:22:34 +00:00
Mari Imaizumi
0889f64021 [ruby/reline] Add test for reset_variables in Reline::Config
(https://github.com/ruby/reline/pull/741)

* Fix reset variables

* Add assertion for reload

* Add helper method to get instance variable value of Reline::Config

https://github.com/ruby/reline/commit/386f619ff5
2024-09-03 15:32:29 +00:00
tomoya ishida
ad9d2c6435 [ruby/reline] Fix redisplay/insert_text called from pre_input_hook
(https://github.com/ruby/reline/pull/742)

* Fix redisplay/insert_text called from pre_input_hook

* Rename insert_pasted_text to insert_multiline_text

It is now used from Reline.insert_text which is not inserting pasted text

https://github.com/ruby/reline/commit/694a540939
2024-09-03 15:19:44 +00:00
Mari Imaizumi
a2b3cb65ea [ruby/reline] Implement re-read-init-file
(https://github.com/ruby/reline/pull/740)

https://github.com/ruby/reline/commit/59e4ade807
2024-08-31 03:26:50 +00:00
Mari Imaizumi
a431f4ecc4 [ruby/reline] Remove unused variables
(https://github.com/ruby/reline/pull/739)

https://github.com/ruby/reline/commit/14784eddee
2024-08-27 12:46:45 +00:00
tomoya ishida
dbd36e1c23 [ruby/reline] Accept colon-style hash in test assertion
(https://github.com/ruby/reline/pull/732)

Hash#inspect is proposed to change to {key: value, non_symbol_key => value} in https://bugs.ruby-lang.org/issues/20433#note-10

https://github.com/ruby/reline/commit/1fd73b358a
2024-08-05 15:53:45 +00:00
tomoya ishida
17a4c7cfcf [ruby/reline] Fix rendering bug of nomultiline prompt
(https://github.com/ruby/reline/pull/730)

Fix bug of `print('a'*10); Reline.readline('>')` wrong rendering

https://github.com/ruby/reline/commit/c0469a12b9
2024-07-12 12:21:26 +00:00
tomoya ishida
691d85d342 [ruby/reline] Rerender and enter raw mode again by SIGCONT
(https://github.com/ruby/reline/pull/727)

https://github.com/ruby/reline/commit/be45660c83
2024-06-25 00:55:07 +00:00
tomoya ishida
c2e2c5975d [ruby/reline] Fix vi_yank or vi_delete_meta copies nil bug
(https://github.com/ruby/reline/pull/726)

https://github.com/ruby/reline/commit/46b30b07c9
2024-06-18 14:57:19 +00:00
tomoya ishida
f465045dd6 [ruby/reline] Remove instance variable @first_char
(https://github.com/ruby/reline/pull/717)

When Reline reads EOF, Reline.readline should return nil if and only if input is empty

https://github.com/ruby/reline/commit/cc74b3686a
2024-06-06 11:20:29 +00:00
tomoya ishida
f567633a16 [ruby/reline] Refactor input key reading
(https://github.com/ruby/reline/pull/712)

* Add key binding matching status :matching_matched

* Simplify read_2nd_character

* Add a comment of matching status and EOF

* Matching status to a constant

* Expand complicated ternary operators to case-when

https://github.com/ruby/reline/commit/64deec100b
2024-06-05 04:04:09 +00:00
tomoya ishida
932ecd3a1c [ruby/reline] Ensure no escape sequence before printing prompt
(https://github.com/ruby/reline/pull/716)

https://github.com/ruby/reline/commit/f9227b5c89
2024-06-04 18:35:03 +00:00
Takashi Kokubun
5ea843f9b2 Revert "Revert "[ruby/reline] Reline::ANSI is general io. Reline::GeneralIO is not.""
This reverts commit 6e84ac2359c8fc8cb686ef4644b9cae26cd5ab9e.

Now that the rubygems spec change has been merged, let's try reverting
this and fixing it with tompng's new patch.
2024-06-04 11:33:12 -07:00
Takashi Kokubun
6e84ac2359 Revert "[ruby/reline] Reline::ANSI is general io. Reline::GeneralIO is not."
This reverts commit ba01d15cf5db96933905d669c68f5cc0cd6910b8.

It seems to be failing test-bundler-parallel. Reverting it to normalize
the CI. We should revert this revert once we figure it out.
2024-06-03 16:11:54 -07:00
tomoya ishida
ba01d15cf5 [ruby/reline] Reline::ANSI is general io. Reline::GeneralIO is not.
(https://github.com/ruby/reline/pull/659)

Reline::ANSI has a partial non-tty supporting code. It should be a general io.
Reline::Dumb should be only used in testing.

https://github.com/ruby/reline/commit/2d6828473d
2024-06-03 14:28:33 +00:00
Hiroaki Osawa
5d33ff36dc [ruby/reline] In ed_search_[prev|next]_history, make the cursor come
to the end of the line when there is no search substr
(https://github.com/ruby/reline/pull/714)

* In ed_search_prev_history, make the cursor come to the end of the line when there is no search substr

* In ed_search_next_history, make the cursor come to the end of the line when there is no search substr

* Implemented ActionState to search with empty substr if the previous operation was search with empty string.

* Use a simple 2-element array to represent action_state

https://github.com/ruby/reline/commit/95ee80bd70
2024-06-03 14:05:51 +00:00
tomoya ishida
91d4a7ae0c [ruby/reline] Improve key binding match/matching check
(https://github.com/ruby/reline/pull/709)

* Improve key binding match/matching check

* Rename key_actors to default_key_bindings

* Make key_stroke.expand always return a value

* Update add_default_key_binding to use a add_default_key_binding_by_keymap internally

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

---------

https://github.com/ruby/reline/commit/353ec236e2

Co-authored-by: Stan Lo <stan001212@gmail.com>
2024-06-03 13:15:05 +00:00
Stan Lo
cda69b5910 [ruby/reline] Overhaul io gate structure
(https://github.com/ruby/reline/pull/666)

* Overhaul IO gate structure

1. Move IO related classes to `lib/reline/io/` directory.
2. Rename `GeneralIO` to `Dumb`.
3. Use IO classes as instances instead of classes.

* Update lib/reline/io/ansi.rb

Co-authored-by: tomoya ishida <tomoyapenguin@gmail.com>

---------

https://github.com/ruby/reline/commit/dc1518e1ac

Co-authored-by: tomoya ishida <tomoyapenguin@gmail.com>
2024-06-01 10:28:08 +00:00
verdy89
7c6e4bc7ca [ruby/reline] Implement the redo command
(https://github.com/ruby/reline/pull/707)

* Implement the redo command

* Commented out a test that does not pass

* Changed key assignment for redo from "\C-[" to "\C-g"

* Changed redo key assignment from `\C-g` to `\M-\C-_`

* Revert the first implemantation

* Implemented redo by sharing `@past_lines` between undo and redo

* Fixed the index of past_lines that is updated when the cursor is moved

* Fixed deletion of the redo history in regular input

* Renamed variables: past_lines -> input_lines

* Rename @position to @input_lines_position

* Deleted unused variables: `@old_byte_pointer` and `@old_line_index`

https://github.com/ruby/reline/commit/0b2d9fab5f
2024-05-27 16:38:22 +00:00
Go
508f331048 [ruby/reline] allow space in config value
(https://github.com/ruby/reline/pull/705)

* allow space in config value

fix https://github.com/ruby/reline/pull/657

* remove inline comments

* Revert "remove inline comments"

This reverts commit https://github.com/ruby/reline/commit/2438347c1a10.

* refactoring

* remove unnecessary comment handling

https://github.com/ruby/reline/commit/d60f1e1e39
2024-05-26 08:28:25 +00:00
Mari Imaizumi
9d01f657b3 [ruby/reline] Implement the undo command
(https://github.com/ruby/reline/pull/701)

* Refactor send

* Implement the undo command

* Fix @past_lines initialization

* Improve assertion

* Hide to save buffer in insert_pasted_text

* Replace @using_delete_command with @undoing

* Refactor `@past_lines`

https://github.com/ruby/reline/commit/4ab72f9cbd
2024-05-14 01:58:31 +00:00
tomoya ishida
68b6fe7048 [ruby/reline] Avoid STDIN.winsize called in require "reline"
(https://github.com/ruby/reline/pull/703)

https://github.com/ruby/reline/commit/21891c47c4
2024-05-10 17:19:42 +00:00
tomoya ishida
26446cccc9 [ruby/reline] Implement bracketed paste insert
(https://github.com/ruby/reline/pull/655)

https://github.com/ruby/reline/commit/e92dcbf514
2024-05-08 16:00:30 +00:00
tomoya ishida
d679afe9f9 [ruby/reline] Add name defined in readline to completion key
bindings C-i C-p C-n
(https://github.com/ruby/reline/pull/698)

https://github.com/ruby/reline/commit/1314787bbb
2024-05-05 07:09:52 +00:00
tomoya ishida
c78cebb469 [ruby/reline] Fix default and additional key bindings vanish bug
(https://github.com/ruby/reline/pull/697)

https://github.com/ruby/reline/commit/fc9b4d2274
2024-05-02 14:41:07 +00:00
tomoya ishida
eb82ea6218 [ruby/reline] Fix prompt width calculation bug. Test with colored
prompt
(https://github.com/ruby/reline/pull/695)

https://github.com/ruby/reline/commit/24aab01cbc
2024-05-02 06:06:31 +00:00
tomoya ishida
614187f8c2 [ruby/reline] Fix completion dialog position when completed part is
wordwrapped
(https://github.com/ruby/reline/pull/692)

https://github.com/ruby/reline/commit/2d9acd16fe
2024-04-30 16:51:25 +00:00
tomoya ishida
814d4b5e2c [ruby/reline] Input with eof and no newline bugfix
(https://github.com/ruby/reline/pull/671)

https://github.com/ruby/reline/commit/0d66c335a1
2024-04-29 13:23:03 +00:00
tomoya ishida
ae701031f5 [ruby/reline] Completely support full-width characters in
differential rendering
(https://github.com/ruby/reline/pull/654)

* Add a cut variation of Reline::Unicode.take_range method take_mbchar_range

* Consider fullwidth take_range in differential rendering

https://github.com/ruby/reline/commit/29714df09f
2024-04-29 12:08:59 +00:00
Mari Imaizumi
018c5717e5 [ruby/reline] Handle mode condition in inputrc
(https://github.com/ruby/reline/pull/687)

https://github.com/ruby/reline/commit/bed5fb3d77
2024-04-29 12:05:36 +00:00
tomoya ishida
4ff249363d [ruby/reline] Fix inputrc nested $if $else $endif bug
(https://github.com/ruby/reline/pull/689)

https://github.com/ruby/reline/commit/0d8aea26ec
2024-04-25 16:12:50 +00:00
tomoya ishida
cf24a0483e [ruby/reline] Long line performance
(https://github.com/ruby/reline/pull/688)

* Improve C-e (ed_move_to_end) performance for long line

* Reline::Unicode.split_by_width optimization for RESET_SGR

https://github.com/ruby/reline/commit/0c8d3c827a
2024-04-24 17:33:40 +00:00
Mari Imaizumi
604c29e8a2 [ruby/reline] Implement show-all-if-ambiguous feature
(https://github.com/ruby/reline/pull/683)

https://github.com/ruby/reline/commit/0fe4fdc794
2024-04-19 12:08:22 +00:00
tomoya ishida
15b659ca93 [ruby/reline] Refactor nomultiline and multiline mode difference
(https://github.com/ruby/reline/pull/653)

* Support multiline input in Reline.readline internally, reduce multiline-singleline branch

* Add readline(singleline) prompt test with force inserting multiline text

https://github.com/ruby/reline/commit/97846095d7
2024-04-17 16:12:20 +00:00
Mari Imaizumi
639449fe8d [ruby/reline] Implement changing editing mode
(https://github.com/ruby/reline/pull/681)

https://github.com/ruby/reline/commit/501b9a6c5f
2024-04-16 11:58:49 +00:00
tomoya ishida
43f4da3ebf [ruby/reline] Fix vi_to_column which was broken
(https://github.com/ruby/reline/pull/679)

https://github.com/ruby/reline/commit/9e93ad52e7
2024-04-15 13:15:58 +00:00
tomoya ishida
1648c4436e [ruby/reline] Refactor waiting_proc and waiting_operator_proc
(https://github.com/ruby/reline/pull/649)

* Fix waiting_proc precedence

* Fix waiting_operator bugs

* Add waiting_proc and vi_waiting_operator test

* Fix vi waiting operator arg number

vi_arg and vi_waiting_operator_arg should be multiplied

* Implement `yy` copies whole line in vi_command mode

* Simplify incremental search cancel test

* Add complex vi test with waiting_proc and vi_waiting_operator, split test input

https://github.com/ruby/reline/commit/777dffae1c
2024-04-14 14:28:15 +00:00
Michael J. Giarlo
76b10f2ee1 [ruby/reline] Support menu-complete-backward command for upward
navigation
(https://github.com/ruby/reline/pull/677)

Fixes https://github.com/ruby/reline/pull/675

This commit extracts the upward navigation condition in `LineEditor#input_key` to a new private method, and adds a new alias. This change allows Reline to support upward navigation in when a user has configured `inputrc` to map Shift-Tab to `menu-complete-backward`, a common setting in Bash (>= 4.x).

Instead of special-casing upward navigation in `LineEditor#input_key`, we now allow it to be processed by the branch that calls `process_key`. The extracted method no longer includes the editing mode check since this check is already made by `#wrap_method_call` by the time `#completion_journey_up` (or `#menu_complete_backward`) is called. Since upward navigation is happening in a method other than `#input_key` now, the `completion_occurs` variable that used to be local to `#input_key` is changed to an instance variable so that the new method can change its value. (I see many examples of mutating such instance variables in `LineEditor`, so I assumed this would be an uncontroversial change consistent with the coding practices already in place.)

Test coverage of this change has been added to the emacs and vi `KeyActor` tests.

Many thanks to @ima1zumi for their very helpful comments on #675 which encouraged me to contribute this work!

https://github.com/ruby/reline/commit/2ccdb374a4
2024-04-14 09:13:20 +00:00
Mari Imaizumi
c2d02a6ac2 [ruby/reline] Continue processing even if terminfo database couldn't
be found
(https://github.com/ruby/reline/pull/673)

Fix https://github.com/ruby/reline/issues/447 https://github.com/ruby/reline/issues/543

This problem occurs when Fiddle can be loaded, curses can be loaded, and TERM is not registered in Terminfo.
It should also occur at hardcopy terminals and when Terminfo information is low, but no such reports have been received.

Reline should not abort the process because of missing Terminfo.
Reline proceeds with `Reline::Terminfo.enabled? == false` when fiddle or curses cannot be loaded.
And does the same when Terminfo is present but TERM is not.
ebab2875f1/lib/reline/terminfo.rb (L156-L160)

You can check the operation with `TERM=foo bundle exec bin/console`.

https://github.com/ruby/reline/commit/4ce247ce2b
2024-04-06 09:24:53 +00:00
tomoya ishida
4e48d2724e
[ruby/reline] Thread safe readline
(https://github.com/ruby/reline/pull/669)

Block until other Reline.readline or Reline.readmultiline finish

https://github.com/ruby/reline/commit/ebab2875f1
2024-04-05 09:34:28 +09:00
tomoya ishida
8088c88d01
[ruby/reline] Handle INT signal correctly, remove handle_cleared
because clear(C-l) is not a signal
(https://github.com/ruby/reline/pull/646)

https://github.com/ruby/reline/commit/3debb0ae2f
2024-04-04 17:18:47 +09:00
tomoya ishida
80e31663f3
[ruby/reline] Fix audoindent including "\v", escape "\v" for
rendering
(https://github.com/ruby/reline/pull/648)

https://github.com/ruby/reline/commit/9c51c577ca
2024-04-04 17:18:47 +09:00
tomoya ishida
a531cac335 [ruby/reline] Refactor completion
(https://github.com/ruby/reline/pull/647)

* Refactor completion: split autocompletion and tabcompletion logic and state

* Move completion candidate listup logic from dialog proc to LineEditor

https://github.com/ruby/reline/commit/c3c09ac9c2
2024-04-01 18:12:27 +00:00
tomoya ishida
508bddc865 [ruby/reline] Align completion menu items
(https://github.com/ruby/reline/pull/613)

https://github.com/ruby/reline/commit/a622704f62
2024-04-01 16:25:26 +00:00
Stan Lo
5f334b67d2 [ruby/reline] Remove useless tests
(https://github.com/ruby/reline/pull/665)

The pasting tests hadn't been working since as early as v0.2.0. Since
what it tried to cover is already gone for such a long time, I think it's
better to write new ones if needed then to keep them around.

And since these tests are gone, the helper methods for just them are also gone.

https://github.com/ruby/reline/commit/0eedf0e4a0
2024-03-25 11:06:39 +00:00
tomoya ishida
b0eda83ee0 [ruby/reline] Add mode_string to prompt calculation dependencies
(https://github.com/ruby/reline/pull/658)

* Add mode_string to prompt calculation dependencies

* Update vi show-mode-in-prompt test

https://github.com/ruby/reline/commit/a0cee06ec5
2024-03-24 10:47:22 +00:00
tomoya ishida
b03705dbaf [ruby/reline] Refactor key actor test
(https://github.com/ruby/reline/pull/645)

* Add assertion assert_cursor_line to test helper

* Autofix key_actor test to use assert_cursor_line

* Rename the assertion to assert_line_around_cursor and remove other assertions for line and cursor

https://github.com/ruby/reline/commit/e4773800c6
2024-03-24 10:45:32 +00:00
tomoya ishida
3adaba0e81 [ruby/reline] Do not send color reset sequence when GeneralIO is
used
(https://github.com/ruby/reline/pull/661)

https://github.com/ruby/reline/commit/3719702808
2024-03-23 23:00:21 +00:00
Stan Lo
f46b77596d [ruby/reline] Make mutated string in yamatanooroti explicitly
mutable
(https://github.com/ruby/reline/pull/662)

This avoids the frozen literal warning in Ruby 3.4.

https://github.com/ruby/reline/commit/cccb985804
2024-03-23 22:50:57 +00:00
tomoya ishida
d7bc6f0eff [ruby/reline] Reline 0.5.0.pre
(https://github.com/ruby/reline/pull/614)

* Re-architecture LineEditor's internal state and rendering

* Fix test related to LineEditor re-architecture

* Bump to 0.5.0.pre.1

* Hide cursor only when updating screen. Frequent hide&show makes cursor flickering.

* Simplify rerender call from reline.rb

* Simplify handle_cleared

It only need to clear screen. line_editor.rerender will be called later.

* Add description of updating pasting_state inserts continuous_insertion_buffer

* Use meaningful block parameter

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

* Fix use of `@cursor_y`

Fix bug updating `@cursor_y`. Do not use `@cursor_y` while updating dialog because it is not current cursor position but cursor position at last rendered time.

* Remove useless instance_variable_set in test

These instance variables are already removed from LineEditor

* Always initialize instance variables to avoid ruby 2.7 warning, remove unused instance variable

* Call update_dialogs from reline.rb before first render

* Combine state representing rendered screen information into `@rendered_screen`

* Rename editor_cursor_ to wrapped_cursor

It represents cursor position of word wrapped whole content

* Remove unused code, tweak, add comment

---------

https://github.com/ruby/reline/commit/3fa376217d

Co-authored-by: Stan Lo <stan001212@gmail.com>
2024-03-19 14:17:26 +00:00