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

Alt+Enter to forced insert newline doesn't work on macOS #80

Closed
aycabta opened this issue Dec 4, 2019 · 4 comments
Closed

Alt+Enter to forced insert newline doesn't work on macOS #80

aycabta opened this issue Dec 4, 2019 · 4 comments

Comments

@aycabta
Copy link
Member

aycabta commented Dec 4, 2019

No description provided.

@nobu
Copy link
Member

nobu commented Dec 13, 2019

As keyboards of Mac don't have Alt key, option+Enter seems inserting a newline.

@aycabta
Copy link
Member Author

aycabta commented Dec 23, 2019

@JoshCheek
Copy link

Additional context

I'm using iTerm2 and have option set to send ESC+key. For option+return, it sends \e\r

versions

$ ruby -r reline -r readline -e 'p ruby: RUBY_VERSION, readline: Readline::VERSION, reline: Reline::VERSION'
{:ruby=>"2.7.0", :readline=>"8.0", :reline=>"0.1.2"}

inputrc

https://github.com/JoshCheek/dotfiles/blob/149bcb6d74c1aeaef0d5502e2982fc050b8ff9d7/inputrc

Readline

$ ruby -e 'print "abc def\e\r"' | ruby -r readline -e 'p Readline.readline "> "'
> abc def
"abc def"

Reline (via pipe)

$ ruby -e 'print "abc def \e\r"' | ruby -r reline -e 'p Reline.readline "> "'
▽Traceback (most recent call last):
	6: from -e:1:in `<main>'
	5: from /Users/josh/.rubies/ruby-2.7.0/lib/ruby/2.7.0/forwardable.rb:235:in `readline'
	4: from /Users/josh/.gem/ruby/2.7.0/gems/reline-0.1.2/lib/reline.rb:183:in `readline'
	3: from /Users/josh/.gem/ruby/2.7.0/gems/reline-0.1.2/lib/reline.rb:203:in `inner_readline'
	2: from /Users/josh/.gem/ruby/2.7.0/gems/reline-0.1.2/lib/reline.rb:336:in `may_req_ambiguous_char_width'
	1: from /Users/josh/.gem/ruby/2.7.0/gems/reline-0.1.2/lib/reline/ansi.rb:69:in `cursor_pos'
/Users/josh/.gem/ruby/2.7.0/gems/reline-0.1.2/lib/reline/ansi.rb:69:in `raw': Inappropriate ioctl for device (Errno::ENOTTY)
	7: from -e:1:in `<main>'
	6: from /Users/josh/.rubies/ruby-2.7.0/lib/ruby/2.7.0/forwardable.rb:235:in `readline'
	5: from /Users/josh/.gem/ruby/2.7.0/gems/reline-0.1.2/lib/reline.rb:183:in `readline'
	4: from /Users/josh/.gem/ruby/2.7.0/gems/reline-0.1.2/lib/reline.rb:203:in `inner_readline'
	3: from /Users/josh/.gem/ruby/2.7.0/gems/reline-0.1.2/lib/reline.rb:336:in `may_req_ambiguous_char_width'
	2: from /Users/josh/.gem/ruby/2.7.0/gems/reline-0.1.2/lib/reline/ansi.rb:66:in `cursor_pos'
	1: from /Users/josh/.gem/ruby/2.7.0/gems/reline-0.1.2/lib/reline/ansi.rb:83:in `rescue in cursor_pos'
/Users/josh/.gem/ruby/2.7.0/gems/reline-0.1.2/lib/reline/ansi.rb:83:in `pread': not opened for reading (IOError)

Reline (via TTY)

Okay, in the above, we can see it's trying to do tty operations on the pipe, which goes into some failure block where it fails while trying to read from stdout. If we try typing those keys instead of piping them into it, nothing happens. This matches Readline's behaviour, but my understanding was the purpose of the lib was to allow multiline editing, so I would expect it to treat this as a non-submitting newline.

@tompng
Copy link
Member

tompng commented Mar 31, 2024

This is a terminal emulator setting thing.
TTY problem is about another issue #537

@tompng tompng closed this as completed Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants