Commit graph

59 commits

Author SHA1 Message Date
Étienne Barrié
70eedef32a [ruby/reline] Splat is always an Array
82095bd62b
2023-01-31 09:33:49 +09:00
Stan Lo
16b2e03014 [ruby/reline] Remove unapproved color setting APIs
These APIs/configs are not approved by the Ruby core, so they can't be
released to the public. This means having them in the codebase will
block other fixes/features from being released as well.

So this commit removes those exposed interfaces to unblock the release.

Hopefully when https://bugs.ruby-lang.org/issues/18996 is approved we
can re-implement better APIs.

f7a961c550
2022-12-05 03:14:55 +00:00
st0012
b3be030740 [ruby/reline] Rename dialog_pointer_* to dialog_highlight_*
"Pointer" is not what we usually use to describe a selected item.

"Highlight" is a more common word for the scenario so we should use it instead.

b4279d1557
2022-07-22 23:34:49 +09:00
st0012
36ca0e58b6 [ruby/reline] Use color name instead of code (integer) in dialog color APIs
As pointed out in the
[comment](https://github.com/ruby/reline/pull/413#issuecomment-1168033973),
the code is actually a control sequence and not only for colors.

To make the dialog color APIs safer to use, we should restrict its
usages and extract away the bg/fg concept from the input.

So in this commit, I made these changes:

1. The dialog_*_bg/fg_color APIs only takes and returns color names (symbol):
  - :black
  - :red
  - :green
  - :yellow
  - :blue
  - :magenta
  - :cyan
  - :white
2. Add additional dialog_*_bg/fg_color_sequence APIs to access the raw code.

b32a977766
2022-07-16 02:30:23 +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
Tim Pope
37d5890e49 [ruby/reline] Fix support for emacs-ctlx and emacs-meta keymaps
The existing implementation, given the below .inputrc, erroneously
creates a "C-v" key binding:

	set keymap emacs-ctlx
	"\C-v": "[C-x C-v was pressed]"

This fixes it to instead create a "C-x C-v" keybinding.

719f52d231
2022-02-22 18:52:52 +09:00
ima1zumi
5f1975a454 [ruby/reline] @convert_meta is true unless 8-bit characters
If Reline::IOGate.encoding contains 7-bit characters, convert-meta will set it On.

Because in readline(3):

>  The default is On, but readline will set it to Off if the locale contains eight-bit characters.

As far as I know, 7-bit encoding used in terminals is only US-ASCII.

b71d1fa496
2021-12-10 22:19:14 +09:00
aycabta
b4d9126e43 [ruby/reline] Refactor the merging key bindings to make it more readable
59665a22de
2021-09-07 03:23:33 +09:00
aycabta
2441bc8ea9 [ruby/reline] Change the comment about key bindings to more appropriate
4364d9a386
2021-09-07 03:23:26 +09:00
manga_osyo
97a569c648 [ruby/reline] Memoize path of .inputrc [Ref #319]
When `ENV["HOME"] = "foo"` on irb, an exception is raised when retrieving the path of `.inputrc`.
Memoize the path of `.inputrc` and don't get the path after the second time.

7b90b16165
2021-09-06 07:05:52 +09:00
aycabta
544cd3fb91 [ruby/reline] Support oneshot key bindings config for key_trap of dialog callbacks
5f1141b693
2021-09-06 05:23:06 +09:00
aycabta
62555d7ae6 [ruby/reline] Set autocompletion is false by default
For compatibility with ext/readline.

13d9b936bc
2021-08-30 02:37:23 +09:00
aycabta
11b825076b [ruby/reline] Add config.autocompletion
3d918e4ccb
2021-08-30 02:37:23 +09:00
aycabta
46c6da9c37 [ruby/reline] Check empty .inputrc
b60b3b76cd
2021-07-30 02:27:02 +09:00
aycabta
046fd3ac8c Rescue conversion error of inputrc 2021-06-21 22:12:14 +09:00
aycabta
b0cc46b484 [ruby/reline] The config file must accept any character encoding
In Japan, so many programmers used EUC-JP to write text files that contain
Japanese. Many .inputrc files which contain EUC-JP are still being copied and
used. This commit supports the whole encoding of what user set including UTF-8.

ref. https://github.com/ruby/reline/pull/280

0b45022e16
2021-06-21 17:58:48 +09:00
Mark Delk
a049dfd10a [ruby/reline] ensure reline's encoding is used when reading inputrc character values
This change ensures we use `Reline::IOGate`'s `encoding` when converting
characters from their integer values.

This fixes an issue that may occur if you have UTF characters in your
`.inputrc`, but your default encoding isn't set.

For example:

```
> 127864.ord.chr
RangeError: 127864 out of char range
from (pry):1:in `chr'
> Reline::IOGate.encoding
=> #<Encoding:UTF-8>
> 127864.ord.chr(Reline::IOGate.encoding)
=> "🍸"
```

cf372fc0fc
2021-06-21 17:58:48 +09:00
aycabta
6496c76d2a [ruby/reline] Add calling Reline::Config#reset_default_key_bindings to #reset, which is forgot to call 2021-04-09 11:57:28 +09:00
aycabta
5543695a19
[ruby/reline] Separate keystrokes each editing mode
ee23e6f3f8
2021-04-08 21:41:00 +09:00
aycabta
ea75aed98e [ruby/reline] Correct var names in Reline were different from vi-*-mode-string
8255fc93b9
2021-01-08 13:25:18 +09:00
aycabta
b52bc4a9c2 [ruby/reline] Support isearch-terminators
a7922da16b
2020-12-22 23:45:43 +09:00
aycabta
c2bd5b84d0 [ruby/reline] Support bracketed paste mode
d1a6869322
2020-12-05 02:58:59 +09:00
Nobuyoshi Nakada
f2435c1508 [ruby/reline] Get rid of loading pathname unnecessarily
9bd54b7f1c
2020-08-18 19:09:58 +09:00
aycabta
80a7358cfc [ruby/reline] Keep original characters in inputrc
96583c6336
2020-08-18 19:08:40 +09:00
Mark Delk
44b24ab4c1 [ruby/reline] Support mode icon
Co-authored-by: aycabta <aycabta@gmail.com>

067b618123
2020-08-18 19:08:32 +09:00
aycabta
fc2a121c7c [ruby/reline] If history-size isn't numeric, it should be 500
https://tiswww.case.edu/php/chet/readline/readline.html#IDX25

> If an attempt is made to set history-size to a non-numeric value, the maximum
> number of history entries will be set to 500.

acf0437280
2020-05-17 19:26:53 +09:00
aycabta
009092b04c [ruby/reline] Add URL reference of history-size
13420197b8
2020-04-29 19:13:14 +09:00
aycabta
4859352df6 [ruby/reline] Negative history_size means unlimited
And unlimited is default.

f5149c3ca6
2020-04-29 19:13:14 +09:00
Nobuyoshi Nakada
0ac5009165 [ruby/reline] Ignore non-absolute XDG_CONFIG_HOME
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
> All paths set in these environment variables must be absolute.
> If an implementation encounters a relative path in any of these
> variables it should consider the path invalid and ignore it.

45af6eea77
2020-04-29 19:13:14 +09:00
aycabta
9fb20711fd [ruby/reline] Treat home dir correctly
9b1327d2f4
2020-04-24 16:46:36 +09:00
aycabta
81b0b79197 [ruby/reline] Support XDG_CONFIG_HOME
In the XDG Specification, if ~/.config/readline/inputrc exists, then ~/.inputrc
should not be read, but for compatibility with GNU Readline, if ~/.inputrc
exists, then it is given priority.

97f1e7db04
2020-04-24 16:45:07 +09:00
aycabta
90913bfabe [ruby/reline] Suppress error in case INPUTRC env is empty
bce7e7562b
2020-03-26 17:41:21 +09:00
aycabta
7392083c2f Support history-size in .inputrc correctly 2020-01-06 21:50:48 +09:00
aycabta
0835a971ef Remove TODO comment 2019-12-22 01:57:35 +09:00
aycabta
ad8fbf444a Fix variable catch 2019-12-05 09:02:23 +09:00
Nobuyoshi Nakada
b40589802b
[reline] Do not compile regexp for each line 2019-07-28 09:52:19 +09:00
aycabta
6c2b59f923 Support Control- and Meta- 2019-07-04 20:58:11 +09:00
aycabta
d9f8b88b47 Move a comment to proper place 2019-07-04 19:34:08 +09:00
Nobuyoshi Nakada
265b9a0edf
Parse key sequence more strictly 2019-07-04 18:54:50 +09:00
Nobuyoshi Nakada
12e06d32f5
Use lstrip instead of gsub which can match only once 2019-07-04 18:49:42 +09:00
Nobuyoshi Nakada
ee861e43f7
Skip indented comment lines [Bug #15981] 2019-07-04 18:47:22 +09:00
Nobuyoshi Nakada
f4b060d8d7 Check conditional nestings in INPUTRC
Closes: https://github.com/ruby/ruby/pull/2222
2019-06-02 22:58:05 +09:00
Nobuyoshi Nakada
a1e6e45341 Prefer $INPUTRC over the default in the home
Closes: https://github.com/ruby/ruby/pull/2222
2019-06-02 22:58:05 +09:00
Nobuyoshi Nakada
d04ebc57f2 Add true condition Reline 2019-06-02 20:31:25 +09:00
aycabta
486a2c26d6 Add Reline test for unknown macro 2019-06-02 08:50:01 +09:00
aycabta
e360688c4d Add new test for Reline within pipe 2019-06-02 07:39:12 +09:00
aycabta
28e01f006d Add comments to key bindings vars of Reline::Config 2019-06-02 07:28:26 +09:00
Nobuyoshi Nakada
3034d666e8
Just use File.readlines 2019-06-01 14:57:36 +09:00
aycabta
7df65ef676 Use inputrc data for keystroke setting 2019-06-01 09:06:27 +09:00
aycabta
eb4e774711 Support Meta key in Reline 2019-05-24 23:38:40 +09:00