From: Sean O'Halpin Date: 2008-11-03T23:40:24+09:00 Subject: Re: Roguelike project? On Sun, Nov 2, 2008 at 6:32 AM, Nit Khair wrote: > Michael Fellinger wrote: >> On Sun, Nov 2, 2008 at 7:55 AM, Michal Suchanek >> wrote: >>>> >>>> binding. >>> at least link against ncursesw - at least that is how it worked for >>> me. >> >> Could we use the new Ruby FFI to spare us the C mess? > Haah! I read that today and was wondering myself. But i am not clear on > how to link to .so or .a files. The example of getpid seems a little > "magical" to me (*still* a newbie) > > Not to go offtopic, but does it mean we can load ncurse.so and then fire > away. > -- Yes - the FFI interface is really easy to use. You just need to specify which lib you are referencing with the #ffi_lib method. require 'rubygems' require 'ffi' module NCursesFFI extend FFI::Library ffi_lib 'ncurses' attach_function 'clear', [], :int attach_function 'endwin', [], :int attach_function 'getch', [], :int attach_function 'initscr', [], :int attach_function 'printw', [ :string ], :int attach_function 'refresh', [], :int end NCursesFFI.initscr NCursesFFI.printw("Hello again") NCursesFFI.refresh NCursesFFI.getch NCursesFFI.endwin Regards, Sean