⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Ruby master
All Projects
Ruby
»
Ruby master
Overview
Activity
Roadmap
Issues
Repository
Like
Download (606 Bytes)
Feature #13604
» readline_alternative_interface_example.rb
How it can be used? -
graywolf (Gray Wolf)
, 05/27/2017 10:00 AM
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"
« Previous
1
2
3
Next »
(2-2/3)
Loading...