Граф коммитов

410 Коммитов

Автор SHA1 Сообщение Дата
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
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 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 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
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
tomoya ishida 53a67efc9a [ruby/reline] Separate prompt and input line in rendering
(https://github.com/ruby/reline/pull/652)

* Separate prompt and input line in rendering

Often, only one of prompt and input changes.
Split prompt+input_line to a separate rendering item will improve differential rendering performance.

* Rename method wrapped_prompt_lines to more descriptive name

https://github.com/ruby/reline/commit/16d82f1f23
2024-04-23 14:45:22 +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
Kenichi Kamiya a3b7a7bc21
[ruby/reline] Remove unused variable
(https://github.com/ruby/reline/pull/684)

https://github.com/ruby/reline/commit/ce30c23730
2024-04-18 11:07:09 +09: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
tomoya ishida 79df0f135e [ruby/reline] Refactor history move and history search
(https://github.com/ruby/reline/pull/651)

https://github.com/ruby/reline/commit/90e43e01d4
2024-04-16 14:06:22 +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
Mari Imaizumi 0a4e3f23e6 [ruby/reline] Remove not implemented method
(https://github.com/ruby/reline/pull/680)

https://github.com/ruby/reline/commit/84762fc588
2024-04-15 13:31:38 +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
Mari Imaizumi 339128b190 [ruby/reline] Refactored Default Key Bindings
(https://github.com/ruby/reline/pull/678)

* Reduce duplicate method

* Configured default key mapping with Readline when the method exists

* Remove undefined methods

https://github.com/ruby/reline/commit/155f7047bb
2024-04-14 17:33:51 +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
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
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 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
tomoya ishida aa2cdaa263 [ruby/reline] Change rendered_screen.lines to non-nil
(https://github.com/ruby/reline/pull/650)

https://github.com/ruby/reline/commit/9685db55f1
2024-03-20 01:39:12 +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
Jean byroot Boussier 161545d55d [ruby/reline] Ensure compatibility with frozen string literals
(https://github.com/ruby/reline/pull/643)

Ref: https://bugs.ruby-lang.org/issues/20205

Ruby is moving forward with enabling frozen string literals
in the future.

Reline being part of the ruby-core test suite should work when
ruby is ran with `--enable-frozen-string-literal`.

https://github.com/ruby/reline/commit/7e2de64cf0

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2024-03-14 16:09:12 +00:00
Otávio Schwanck dos Santos e848848b58
[ruby/reline] C for vi mode
(https://github.com/ruby/reline/pull/472)

https://github.com/ruby/reline/commit/d197be7c44
2024-02-13 18:57:17 +09:00
tomoya ishida 542011ff68 [ruby/reline] Fix pasting tab-indented code crash
(https://github.com/ruby/reline/pull/630)

https://github.com/ruby/reline/commit/90155fd0d9
2024-01-04 11:53:06 +00:00
HASUMI Hitoshi 16403f41ab [ruby/reline] Introduce a new class Reline::Face to configure
character attributes
(https://github.com/ruby/reline/pull/552)

* Reine::Face

* fix test_yamatanooroti

* Define singleton methods to make accessors to attributes of a face

* s/display/foreground/

* s/default/default_style/ && s/normal_line/default/ && s/enhanced_line/enhanced/

* fix typo

* FaceConfig.new now takes keyword arguments

* Update lib/reline/face.rb

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

* Update test/reline/test_face.rb

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

* Fix to correspond to frozen_string_literal

* Face::FaceConfig -> Face::Config

* ref https://github.com/ruby/reline/pull/552#pullrequestreview-1677282576

* delete unused ivar

* ref https://github.com/ruby/reline/pull/552#discussion_r1358783723

* insert "\e[0m" into all SGR

* tiny fix

* ESSENTIAL_DEFINE_NAMES

ref https://github.com/ruby/reline/pull/552#discussion_r1367722247

* Change to Hash-accessor style

- Reline::Face[:completion_dialog].enhanced ->
  Reline::Face[:completion_dialog][:enhanced]
- Reline::Face.configs shows all defined values

* Cache array method call in local variable

* Tests for Face configuration variations

* resolve https://github.com/ruby/reline/pull/552#pullrequestreview-1710938154

* amend  to

* check invalid SGR parameter in :style

* The order of define values should be preserved

* Update test/reline/test_face.rb

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

* Update test/reline/test_face.rb

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

* Add methods: load_initial_config and reset_to_initial_config. And teardown in tests

* omission in amending "style: :default" to "style: :reset"

* refs https://github.com/ruby/reline/issues/598

* Fix link

* amend method name

* Update lib/reline/face.rb

Co-authored-by: ima1zumi <52617472+ima1zumi@users.noreply.github.com>

---------

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

Co-authored-by: Stan Lo <stan001212@gmail.com>
Co-authored-by: ima1zumi <52617472+ima1zumi@users.noreply.github.com>
2023-11-06 14:40:42 +00:00
osyo-manga ccca097cb5 [ruby/reline] Add `kill-word` and `backward-kill-word` keymapping
support.
(https://github.com/ruby/reline/pull/570)

Fix it
https://github.com/ruby/reline/issues/558

https://github.com/ruby/reline/commit/0f8000443e

Co-authored-by: Stan Lo <stan001212@gmail.com>
2023-07-27 09:08:24 +00:00
osyo-manga 45fd006185 [ruby/reline] Fix [nil] is passed to auto_indent_proc when exit with
CTRL+d
(https://github.com/ruby/reline/pull/571)

* Fix [nil] is passed to auto_indent_proc when exit with CTRL+d

Fix it https://github.com/ruby/reline/issues/556

* not call auto_indent_proc when Ctrl+d.

see: https://github.com/ruby/reline/pull/571#issuecomment-1637183195

https://github.com/ruby/reline/commit/0924f2a075
2023-07-18 20:33:39 +00:00
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)

https://github.com/ruby/reline/commit/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)

https://github.com/ruby/reline/commit/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)

https://github.com/ruby/reline/commit/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>

---------

https://github.com/ruby/reline/commit/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)

https://github.com/ruby/reline/commit/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)

https://github.com/ruby/reline/commit/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>

---------

https://github.com/ruby/reline/commit/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)

https://github.com/ruby/reline/commit/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)

https://github.com/ruby/reline/commit/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