From: "hsbt (Hiroshi SHIBATA) via ruby-core" <ruby-core@ml.ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Cc: "hsbt (Hiroshi SHIBATA)" <noreply@ruby-lang.org>
Subject: [ruby-core:117413] [Ruby master Feature#13604] Exposing alternative interface of readline
Date: Wed, 03 Apr 2024 03:44:55 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-107592.20240403034455.12262@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-13604.20170527100141.12262@ruby-lang.org
Issue #13604 has been updated by hsbt (Hiroshi SHIBATA).
Status changed from Assigned to Closed
The C wrapper library of libreadline is extracted https://github.com/ruby/readline-ext from Ruby 3.3. If you still interest this, can you submit your proposal to upstream?
----------------------------------------
Feature #13604: Exposing alternative interface of readline
https://bugs.ruby-lang.org/issues/13604#change-107592
* Author: graywolf (Gray Wolf)
* Status: Closed
* Assignee: aycabta (aycabta .)
----------------------------------------
GNU Readline has multiple modes of operation. At the moment, the readline extension only supports typical, `Readline.readline` mode. However, there is also alternative callback-based interface which is also useful.
```ruby
require_relative 'readline'
PROMPT = "rltest$ "
$running = true
$sigwinch_received = false
Readline.handler_install(PROMPT, add_hist: true) do |line|
# Can use ^D (stty eof) or `exit' to exit.
if !line || line == "exit"
puts unless line
puts "exit"
Readline.handler_remove
$running = false
else
puts "input line: #{line}"
end
end
Signal.trap('SIGWINCH') { $sigwinch_received = true }
while $running do
rs = IO.select([$stdin])
if $sigwinch_received
Readline.resize_terminal
$sigwinch_received = false
end
Readline.read_char if r = rs[0]
end
puts "rltest: Event loop has exited"
```
Patch adding support for this is attached. This is my first try at contributing to ruby, so please tell me what I did wrong (I'm sure something, C is not my strong language).
---Files--------------------------------
readline_alternative_interface.diff (7.22 KB)
readline_alternative_interface_example.rb (606 Bytes)
readline_alternative_interface_update1.diff (7.08 KB)
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
parent reply other threads:[~2024-04-03 3:45 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <redmine.issue-13604.20170527100141.12262@ruby-lang.org>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-107592.20240403034455.12262@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
--cc=noreply@ruby-lang.org \
--cc=ruby-core@ml.ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).