Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Rawline.readline broken on ruby 1.9.1

#10

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.

Reported by Ravil Bayramgalin · March 12th, 2009 @ 12:24 PM

State: open
Milestone: 0.3.2
Assigned to: h3rald (at h3rald) h3rald (at h3rald)

Activity

  1. h3rald (at h3rald)
    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)

    March 12th, 2009 @ 01:10 PM

  2. h3rald (at h3rald)
    h3rald (at h3rald)
    • Milestone changed from 0.3.0 to 0.3.2

    March 12th, 2009 @ 01:23 PM

  3. Ravil Bayramgalin
    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)

    March 18th, 2009 @ 05:04 PM

  4. h3rald (at h3rald)
    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!

    March 19th, 2009 @ 09:05 AM

  5. Ravil Bayramgalin
    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)

    March 19th, 2009 @ 10:11 AM

  6. h3rald (at h3rald)
    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_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...

    March 19th, 2009 @ 12:06 PM

  7. Ravil Bayramgalin
    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 :-(

    March 19th, 2009 @ 02:44 PM

  8. h3rald (at h3rald)
    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!

    March 19th, 2009 @ 04:45 PM

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.