Rawline.readline broken on ruby 1.9.1
-
h3rald (at h3rald)
- 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)
- Milestone changed from 0.3.0 to 0.3.2
-
Ravil Bayramgalin
$ 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)
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
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)
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_characterAt 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
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)
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.