Closed tomdz closed 12 years ago
Turns out JLine is built into JRuby (it uses it for its readline support), so this should work out of the box with a reasonably modern jruby.
I also fixed a bug in the handling of @question.limit in that it would echo one less character than was entered.
Here is a test script that I used to try out the various combinations:
#!/usr/bin/env ruby require 'rubygems' require 'highline/import' puts "CHARACTER_MODE = #{HighLine::SystemExtensions::CHARACTER_MODE}" def ask_and_tell(params) params = { :readline => false, :character => nil, :echo => true, :overwrite => false, :limit => nil }.merge(params) response = ask(params[:prompt]) do |q| q.readline = params[:readline] q.character = params[:character] q.echo = params[:echo] q.overwrite = params[:overwrite] q.limit = params[:limit] end puts "=> " + response end ask_and_tell(:prompt => "Same line, defaults > ") ask_and_tell(:prompt => "Same line, readline > ", :readline => true) ask_and_tell(:prompt => "Same line, :getc > ", :character => :getc) ask_and_tell(:prompt => "Same line, character = true > ", :character => true) ask_and_tell(:prompt => "Same line, no echo > ", :echo => false) ask_and_tell(:prompt => "Same line, echo masked > ", :echo => '*') ask_and_tell(:prompt => "Same line, limit > ", :limit => 5) ask_and_tell(:prompt => "Same line, limit and no echo > ", :limit => 5, :echo => false) ask_and_tell(:prompt => "Same line, limit and masked echo > ", :limit => 5, :echo => '*') ask_and_tell(:prompt => "Same line, overwrite > ", :overwrite => true) ask_and_tell(:prompt => "Same line, overwrite and no echo > ", :overwrite => true, :echo => false) ask_and_tell(:prompt => "Same line, overwrite and masked echo > ", :overwrite => true, :echo => '*') ask_and_tell(:prompt => "Same line, overwrite and limit > ", :overwrite => true, :limit => 5) ask_and_tell(:prompt => "Same line, overwrite and limit and no echo > ", :overwrite => true, :limit => 5, :echo => false) ask_and_tell(:prompt => "Same line, overwrite and limit and masked echo > ", :overwrite => true, :limit => 5, :echo => '*') ask_and_tell(:prompt => "New line, defaults\n") ask_and_tell(:prompt => "New line, readline\n", :readline => true) ask_and_tell(:prompt => "New line, :getc\n", :character => :getc) ask_and_tell(:prompt => "New line, character = true\n", :character => true) ask_and_tell(:prompt => "New line, no echo\n", :echo => false) ask_and_tell(:prompt => "New line, echo masked\n", :echo => '*') ask_and_tell(:prompt => "New line, limit\n", :limit => 5) ask_and_tell(:prompt => "New line, limit and no echo\n", :limit => 5, :echo => false) ask_and_tell(:prompt => "New line, limit and masked echo\n", :limit => 5, :echo => '*') ask_and_tell(:prompt => "New line, overwrite\n", :overwrite => true) ask_and_tell(:prompt => "New line, overwrite and no echo\n", :overwrite => true, :echo => false) ask_and_tell(:prompt => "New line, overwrite and masked echo\n", :overwrite => true, :echo => '*') ask_and_tell(:prompt => "New line, overwrite and limit\n", :overwrite => true, :limit => 5) ask_and_tell(:prompt => "New line, overwrite and limit and no echo\n", :overwrite => true, :limit => 5, :echo => false) ask_and_tell(:prompt => "New line, overwrite and limit and masked echo\n", :overwrite => true, :limit => 5, :echo => '*')
Thanks.
Any chance you could release a new highline version containing this ?
cheers, Tom
I have pushed 1.6.9 with this fix.
Thanks, somehow I didn't notice this :)
Turns out JLine is built into JRuby (it uses it for its readline support), so this should work out of the box with a reasonably modern jruby.
I also fixed a bug in the handling of @question.limit in that it would echo one less character than was entered.
Here is a test script that I used to try out the various combinations: