Hello again,
I am a Ruby newbie... I am using the following version on Mac OS X Tiger:
Raven:/Developer/DevResources/Ruby/Draw untz$ ruby --version
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]
Raven:/Developer/DevResources/Ruby/Draw untz$ which ruby
/usr/bin/ruby
I am experiencing several problems....
1. My irb doesn't support tab completion (the same version of Ruby
on WinXP does support tab completion)...
For example:
Raven:/Developer/DevResources/Ruby/Draw untz$ irb
irb(main):001:0> a = "Hello Ruby Group"
=> "Hello Ruby Group"
irb(main):002:0> a.rev
When I click on the tab key right after rev, it doesn't complete it by
printing out the remaining characters belonging to the word 'reverse'.
Is there a way to check and see if this functionality is turned on for irb?
2. How do I use similar functionality in irb to clear the buffer, as one would
do in Unix using "clear" and WinXP, using "cls"?
3. I copied a simple Draw coding sample and when I tried to run it,
I got an error...
The code for Draw.rb:
Raven:/Developer/DevResources/Ruby/Draw untz$ cat Draw.rb
#!/usr/bin/ruby -w
require 'tk'
class Draw
聽聽聽聽聽聽聽聽聽def initialize(parent)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽@canvas = TkCanvas.new(parent)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽@canvas.pack
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽@start_x = @start_y = 0
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽@canvas.bind("1", lambda {|e| do_press(e.x, e.y)})
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽@canvas.bind("B1-Motion", lambda {|x, y| do_motion(x,y)}, "%x %y")
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽@canvas.bind("Button-Release-1", lambda {|x, y| do_release(x,y)}, "%x %y")
聽聽聽聽聽聽聽聽聽end
聽聽聽聽聽聽聽聽聽def do_press(x,y)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽@start_x = x
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽@start_y = y
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽@current_line = TkcLine.new(@canvas, x, y, x,y)
聽聽聽聽聽聽聽聽聽end
聽聽聽聽聽聽聽聽聽def do_motion(x,y)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽if @current_line
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽@current_line.coords @start_x, @start_y, x, y
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽end
聽聽聽聽聽聽聽聽聽end
聽聽聽聽聽聽聽聽聽def do_release(x,y)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽if @current_line
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽@current_line.coords @start_x, @start_y, x, y
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽@current_line.fill 'black'
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽@current_line = nil
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽end
聽聽聽聽聽聽聽聽聽end
end
root = TkRoot.new { title 'Canvas' }
Draw.new(root)
Tk.mainloop
The error message:
Raven:/Developer/DevResources/Ruby/Draw untz$ ./Draw.rb
/usr/lib/ruby/1.8/tk.rb:1496:in `_invoke_without_enc': bad event type or keysym "Release" (RuntimeError)
聽聽聽聽聽聽聽聽聽from /usr/lib/ruby/1.8/tk.rb:1496:in `_ip_invoke_core'
聽聽聽聽聽聽聽聽聽from /usr/lib/ruby/1.8/tk.rb:1532:in `_tk_call_core'
聽聽聽聽聽聽聽聽聽from /usr/lib/ruby/1.8/tk.rb:1560:in `tk_call_without_enc'
聽聽聽聽聽聽聽聽聽from /usr/lib/ruby/1.8/tk.rb:831:in `_bind_core'
聽聽聽聽聽聽聽聽聽from /usr/lib/ruby/1.8/tk.rb:839:in `_bind'
聽聽聽聽聽聽聽聽聽from /usr/lib/ruby/1.8/tk.rb:921:in `bind'
聽聽聽聽聽聽聽聽聽from /usr/lib/ruby/1.8/tk.rb:2139:in `bind'
聽聽聽聽聽聽聽聽聽from ./Draw.rb:13:in `initialize'
聽聽聽聽聽聽聽聽聽from ./Draw.rb:39:in `new'
聽聽聽聽聽聽聽聽聽from ./Draw.rb:39
4. What is the *BEST* free Ruby IDE in the world?
Thank you for your time and I hope who ever can help me can try to duplicate this problem using
OS X Tiger and the same version of Ruby as me.
Many, many thanks!
-Unnsse