OxO pHz.60 wrote:
> hi when i try to run this ruby script (a mud client for angalon) y get the
> following error
>
> rorschach@pirata ~/Sources/ainamc $ ruby ainamc.rb
> ainamc.rb:125: syntax error
> Gtk.main
> ^
>

Might it be that your Ruby installation does not have the
Gtk libraries available?




> i have no idea what the error might be, i with post all code here:
>
> require 'gtk2'
> require 'net/telnet'
>
> class Mud
>
> attr_accessor :host, :port, :mud
>
> def initialize( host, port = 23 )
> @host = host
> @port = port
> end
>
> def add_mud( host , port )
> if @host != nil
> @mud = Net::Telnet::new( { "host" => @host , "port" => @port } )
> end
> end
>
> end
>
> #todo: poner todo lo referente a la gui en bajo la clase gui.
> Gtk.init
>
>
> #Widget Definitions
> main_window = Gtk::Window.new
> vbox = Gtk::VBox.new( false, 0)
> hbox = Gtk::HBox.new( true , 0)
>
> scroll = Gtk::ScrolledWindow.new
> output = Gtk::TextView.new
> input = Gtk::Entry.new
>
> button_connect = Gtk::Button.new( "Connect" , use_underline=false )
> button_disconnect = Gtk::Button.new( "Disconnect" , use_underline=false )
>
> scroll.set_policy( Gtk::POLICY_NEVER , Gtk::POLICY_AUTOMATIC )
>
> #need to chomp input every n lines so window doesn't expand on its own.
> scroll.add( output )
>
> main_window.add( vbox )
> vbox.pack_start( hbox , false , false , 0 )
>
> hbox.pack_start( button_connect , true , true , 0 )
> hbox.pack_start( button_disconnect , true , true , 0 )
>
> vbox.pack_start( scroll , true , true, 0 ) #output or scroll
> vbox.pack_start( input , false , false, 0 )
> output.editable = false
> output.set_wrap_mode(Gtk::TextTag::WRAP_WORD)
>
> #Signals
> main_window.signal_connect("delete_event") { Gtk.main_quit
> false
> }
>
> input.signal_connect("activate") do output.buffer.insert(
> output.buffer.end_iter, input.text + "\n")
> angalon.mud.puts( input.text )
> output.scroll_to_iter( output.buffer.end_iter , 0 , false , 0 , 0 )
> input.text=""
> end
>
> begin
> button_connect.signal_connect("clicked") {
> angalon = Mud.new( "angalon.tamu.edu <http://angalon.tamu.edu>" , 3011 )
> angalon.add_mud
> }
>
> button_disconnect.signal_connect("clicked") do
> angalon.mud.close()
> end
>
> main_window.set_default_size( 512, 512 )
> main_window.show_all
>
> Gtk.idle_add{
> output.scroll_to_iter( output.buffer.end_iter , 0 , false , 0 , 0 )
> }
>
> Gdk::Input.add( mud , Gdk::Input::READ ) {
> data = angalon.mud.recv( 32 )
> data = angalon.mud.preprocess( data )
> output.buffer.insert( output.buffer.end_iter , data )
> output.scroll_to_iter( output.buffer.end_iter , 0 , false , 0 , 0 )
> }
>
> Gtk.main
> 
> 
> -- 
> Rorschach el Pirata
> I eat pokemon with scars