U
Unnsse Khan
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
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