Skip to content
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

"①", "だ", "占" are not entered on 0.2.8.pre.8 #357

Closed
tmtm opened this issue Sep 25, 2021 · 4 comments · Fixed by #389 or ruby/irb#311
Closed

"①", "だ", "占" are not entered on 0.2.8.pre.8 #357

tmtm opened this issue Sep 25, 2021 · 4 comments · Fixed by #389 or ruby/irb#311

Comments

@tmtm
Copy link
Contributor

tmtm commented Sep 25, 2021

Description

I cannot enter "①", "だ", "占" on reline 0.2.8.pre.8.

0.2.8.pre.7:

% ruby -rreline -e 'p Reline::VERSION; p Reline.readline'
"0.2.8.pre.7"
おだんご
"おだんご"
% 

0.2.8.pre.8:

% ruby -rreline -e 'p Reline::VERSION; p Reline.readline'
"0.2.8.pre.8"
お

I typed "おだんご", but I can't type anything after "お"

Terminal Emulator

xterm, xfce4-terminal

@tmtm
Copy link
Contributor Author

tmtm commented Sep 25, 2021

on UTF-8:

①: 0xE2 0x91 0xA0
だ: 0xE3 0x81 0xA0
占: 0xE5 0x8D 0xA0

Perhaps last byte 0xA0 is considered M-SPC.

So it is fixed by commenting out this line.
https://github.com/ruby/reline/blob/v0.2.8.pre.9/lib/reline/ansi.rb#L38

@tmtm
Copy link
Contributor Author

tmtm commented Nov 12, 2021

It worked fine after disabling compress_meta_key:

diff --git a/lib/reline/key_stroke.rb b/lib/reline/key_stroke.rb
index 16e5f69..396fa61 100644
--- a/lib/reline/key_stroke.rb
+++ b/lib/reline/key_stroke.rb
@@ -4,6 +4,7 @@ class Reline::KeyStroke
   end
 
   def compress_meta_key(ary)
+    return ary
     ary.inject([]) { |result, key|
       if result.size > 0 and result.last == "\e".ord
         result[result.size - 1] = Reline::Key.new(key, key | 0b10000000, true)

M-SPC is actually entered as 0x1B 0x20, so there is no need to treat 0xA0 specially.

@tmtm
Copy link
Contributor Author

tmtm commented Nov 12, 2021

The behavior of this compress_meta_key method is similar to the behavior of convert-meta=on in readline, but readline turns off convert-meta if the locale contains 8bit characters.

In readline(3):

convert-meta (On)
If set to On, readline will convert characters with the eighth
bit set to an ASCII key sequence by stripping the eighth bit and
prefixing it with an escape character (in effect, using escape
as the meta prefix). The default is On, but readline will set
it to Off if the locale contains eight-bit characters.

@tmtm
Copy link
Contributor Author

tmtm commented Nov 15, 2021

If you want to make it compatible with readline:

diff --git a/lib/reline/key_stroke.rb b/lib/reline/key_stroke.rb
index 16e5f69..c1c6151 100644
--- a/lib/reline/key_stroke.rb
+++ b/lib/reline/key_stroke.rb
@@ -4,6 +4,7 @@ class Reline::KeyStroke
   end
 
   def compress_meta_key(ary)
+    return ary unless @config.convert_meta
     ary.inject([]) { |result, key|
       if result.size > 0 and result.last == "\e".ord
         result[result.size - 1] = Reline::Key.new(key, key | 0b10000000, true)

ima1zumi added a commit to ima1zumi/reline that referenced this issue Nov 22, 2021
Co-authored-by: tmtm <tommy@tmtm.org>

fix ruby#357

When using 8-bit characters, it is better not to use `compress_meta_key`.
I believe not to use `compress_meta_key` unless `set convert-meta on` is written in the `.inputrc`.

The following is a quote from tmtm's comments.

> The behavior of this compress_meta_key method is similar to the behavior of convert-meta=on in readline, but readline turns off convert-meta if the locale contains 8bit characters.

> In readline(3):

> convert-meta (On)
> If set to On, readline will convert characters with the eighth
> bit set to an ASCII key sequence by stripping the eighth bit and
> prefixing it with an escape character (in effect, using escape
> as the meta prefix). The default is On, but readline will set
> it to Off if the locale contains eight-bit characters.
ima1zumi added a commit to ima1zumi/reline that referenced this issue Nov 22, 2021
Co-authored-by: TOMITA Masahiro <tommy@tmtm.org>

fix ruby#357

When using 8-bit characters, it is better not to use `compress_meta_key`.
I believe not to use `compress_meta_key` unless `set convert-meta on` is written in the `.inputrc`.

The following is a quote from tmtm's comments.

> The behavior of this compress_meta_key method is similar to the behavior of convert-meta=on in readline, but readline turns off convert-meta if the locale contains 8bit characters.

> In readline(3):

> convert-meta (On)
> If set to On, readline will convert characters with the eighth
> bit set to an ASCII key sequence by stripping the eighth bit and
> prefixing it with an escape character (in effect, using escape
> as the meta prefix). The default is On, but readline will set
> it to Off if the locale contains eight-bit characters.
ima1zumi added a commit to ima1zumi/reline that referenced this issue Nov 22, 2021
Co-authored-by: TOMITA Masahiro <tommy@tmtm.org>

fix ruby#357

When using 8-bit characters, it is better not to use `compress_meta_key`.
I believe not to use `compress_meta_key` unless `set convert-meta on` is written in the `.inputrc`.

The following is a quote from tmtm's comments.

> The behavior of this compress_meta_key method is similar to the behavior of convert-meta=on in readline, but readline turns off convert-meta if the locale contains 8bit characters.

> In readline(3):

> convert-meta (On)
> If set to On, readline will convert characters with the eighth
> bit set to an ASCII key sequence by stripping the eighth bit and
> prefixing it with an escape character (in effect, using escape
> as the meta prefix). The default is On, but readline will set
> it to Off if the locale contains eight-bit characters.
ima1zumi added a commit to ima1zumi/reline that referenced this issue Nov 22, 2021
fix `ruby#357`

When using 8-bit characters, it is better not to use `compress_meta_key`.
I believe not to use `compress_meta_key` unless `set convert-meta on` is written in the `.inputrc`.

The following is a quote from tmtm's comments.

> The behavior of this compress_meta_key method is similar to the behavior of convert-meta=on in readline, but readline turns off convert-meta if the locale contains 8bit characters.

> In readline(3):

> convert-meta (On)
> If set to On, readline will convert characters with the eighth
> bit set to an ASCII key sequence by stripping the eighth bit and
> prefixing it with an escape character (in effect, using escape
> as the meta prefix). The default is On, but readline will set
> it to Off if the locale contains eight-bit characters.

Co-authored-by: TOMITA Masahiro <tommy@tmtm.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant