Tested on Mac OS X 10.4 (Tiger) and Ubuntu 8.04 with ruby 1.8.6
using ruby-ffi (>= 0.2.0) and JRuby 1.1.6.
The API is a transliteration of the C API rather than an attempt to
provide an idiomatic Ruby object-oriented API. The intent is to
provide a ‘close to the metal’ wrapper around the ncurses library upon
which you can build your own abstractions.
This is still very much a work-in-progress, so expect some rough
edges. Having said that, you can do quite a lot with it as it is. The
main things left to be done are documentation, tests and access to
global variables in JRuby.
I don’t have an issue tracker set up yet but I’m happy to receive
feedback
via email.
See the examples directory for real working examples.
== INSTALL
$ sudo gem install ffi-ncurses
== CHANGES
Features
Use FFI::NCurses rather than NCurses
Removed dependency on rubygems
Reorganised library layout
From the README:
== Usage
Load the library with:
require ‘ffi-ncurses’
FFI::NCurses methods can be called as module methods:
begin
stdscr = FFI::NCurses.initscr
FFI::NCurses.clear
FFI::NCurses.addstr(“Hello world!”)
FFI::NCurses.refresh
FFI::NCurses.getch
ensure
FFI::NCurses.endwin
end
or as included methods:
require ‘ffi-ncurses’
include FFI::NCurses
begin
stdscr = initscr
start_color
curs_set 0
raw
cbreak
noecho
clear
move 10, 10
standout
addstr(“Hi!”)
standend
refresh
getch
ensure
endwin
end
There’s more in the README and examples, including how to create
windows, use
the mouse and how to interpret keypresses.
I noticed this tries to install the ruby-ffi gem on JRuby. Perhaps we
need to have a dummy ffi gem for JRuby that does nothing more than turn
on our built-in support, so that gem authors can depend on ‘ffi’?
On Mon, Feb 16, 2009 at 12:57 AM, Charles Oliver N. [email protected] wrote:
I noticed this tries to install the ruby-ffi gem on JRuby. Perhaps we need
to have a dummy ffi gem for JRuby that does nothing more than turn on our
built-in support, so that gem authors can depend on ‘ffi’?
Ouch! Didn’t try installing it as a gem in JRuby.
Is it possible to specify different gem dependencies by platform?
On Mon, Feb 16, 2009 at 8:25 AM, Sean O’Halpin [email protected]
wrote:
Regards,
Sean
That isn’t enough - I have to remove the dependency altogether. Hmmm.
A dummy FFI gem looks like the only solution at the moment.
In the meantime, I’ve released a new version of the gem without the
dependency on ffi.
Excuse the question, but what exactly is ffi-ncurses advantage over
the already existing ncurses bindings for ruby?
I admit that I dont really know much about the benefits of ffi.
On Tue, Feb 17, 2009 at 1:24 PM, Dominik H. [email protected]
wrote:
Excuse the question, but what exactly is ffi-ncurses advantage over
the already existing ncurses bindings for ruby?
I admit that I dont really know much about the benefits of ffi.
The same code runs under both ruby 1.8.6 and JRuby 1.1.6
The FFI implementation doesn’t need a compiler on the target machine
(not such a big deal on Linux, but handy on a Mac without XTools)
I intend to build a cross-platform text console library on top of
this and didn’t want to use the existing Ncurses implementation which
hasn’t been updated for a while and is a little idiosyncratic in its
mapping of the C API to ruby
That isn’t enough - I have to remove the dependency altogether. Hmmm.
A dummy FFI gem looks like the only solution at the moment.
In the meantime, I’ve released a new version of the gem without the
dependency on ffi.
Great, thanks…we’ll see about getting a dummy gem for JRuby; it might
be a good way to share some code with the MRI version too.
Charlie
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.