Rawline.readline broken on ruby 1.9.1
Reported by Ravil Bayramgalin | March 12th, 2009 @ 12:24 PM | in 0.3.2
I'm using ruby 1.9.1 and version 0.3.1 of rawline on mac.
If I call method Rawline.readline '>> ', then i get a prompt to type text, but whatever i'm typing it's not displaying in terminal.
irb(main):002:0> Rawline.readline '>> '
>>
=> ""
If I use ruby 1.8.7 then this works.
Comments and changes to this ticket
-
h3rald (at h3rald) March 12th, 2009 @ 01:10 PM
- Tag set to bug, p3
- State changed from new to open
It seems to be mac specific (which is annoying, as I don't have access to a mac :-/). I tried this on Windows + Ruby 1.9.1 and it works:
D:\>irb irb(main):001:0> require 'rawline' => true irb(main):002:0> Rawline.readline ">> " >> testing... => "testing..." irb(main):003:0>
However, I found a bug in the rawline_irb example. Could you please try to execute the following rawline examples on your system and tell me if they work?
- rawline_shell.rb
- raweline_irb.rb
- readline_emulation.rb
- key_tester.rb
They are in the /examples folder of the rawline gem (or here)
-
h3rald (at h3rald) March 12th, 2009 @ 01:23 PM
- Milestone changed from 0.3.0 to 0.3.2
-
Ravil Bayramgalin March 18th, 2009 @ 05:04 PM
$ gem list rawline LOCAL GEMS rawline (0.3.1)
$ ruby -v ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9]
key_tester.rb - works readline_emulation.rb - works rawline_irb.rb - works rawline_shell.rb - works
$ ruby -v ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-darwin9.6.0]
key_tester.rb - doesn't work (http://gist.github.com/81211) readline_emulation.rb - doesn't work (http://gist.github.com/81213) rawline_irb.rb - doesn't work (http://gist.github.com/81216) rawline_shell.rb - doesn't work (http://gist.github.com/81217)
-
h3rald (at h3rald) March 19th, 2009 @ 09:05 AM
Thanks a lot for the gists!
I have absolutely no idea why this won't work on Mac with Ruby 1.9.1, considering it works with Ruby 1.8.7!
My guess (and it's a wild guess...) is that the get_character method (defined in HighLine::SystemExtensions, which RawLine depends on) doesn't seem to be able to do its job for some reason (it returns nil or something similar, instead of the character's ASCII code, maybe?).
Could you please try to install the Termios library (http://raa.ruby-lang.org/project..., and see if things improve?
I'm terribly sorry for not being able to do any testing myself, but I don't own a Mac... so well, patches are more than welcome!
-
Ravil Bayramgalin March 19th, 2009 @ 10:11 AM
Still no improvements though I installed the latest version arika-ruby-termios (0.9.5) (the previous termios (0.9.4) didn't even want to install)
-
h3rald (at h3rald) March 19th, 2009 @ 12:06 PM
OK, then could you try the following:
irb(main):001:0> require 'highline/system_extensions' => true irb(main):002:0> include HighLine::SystemExtensions => Object irb(main):003:0> get_character
At this point you press a key, and IRB should print the corresponding ASCII character. If it doesn't, then we have a problem...
-
Ravil Bayramgalin March 19th, 2009 @ 02:44 PM
Wow, I think you nailed it - http://gist.github.com/81820
In ruby 1.9 method 'get_character' returns not a corresponding ASCII character but a character itself :-(
-
h3rald (at h3rald) March 19th, 2009 @ 04:45 PM
Well done!!
Then all you have to do is converting the two get_character() calls in editor.rb to:
get_character(@input).ord rescue nil
...then everything should work (except the rawline_irb example, but that's another quick fix: see #11).
I'll push the changes to the central repo tomorrow evening. Thanks a lot!
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
RawLine is a 100% Ruby library able to provide some of the functionality offered by ReadLine, plus additional features such as a more intuitive way to bind characters to specific keys or key sequences.