[ANN] ffi-ncurses version 0.3.0

S

Sean O'Halpin

ffi-ncurses version 0.3.0
by Sean O'Halpin
http://github.com/seanohalpin/ffi-ncurses

== DESCRIPTION

ffi-ncurses is an FFI wrapper for ncurses 5.x.

This is the first release of a gem on rubyforge.

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.

Regards,
Sean
 
C

Charles Oliver Nutter

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
 
S

Sean O'Halpin

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?

Regards,
Sean
 
C

Charles Oliver Nutter

Sean said:
Ouch! Didn't try installing it as a gem in JRuby.

Is it possible to specify different gem dependencies by platform?

No, it's not. RubyGems dependency mechanism is pretty simplistic. I
think the only option with current RubyGems would be to have a dummy FFI
gem.

Granted, I'd love to see RubyGems handle this better; we get people
asking us about it every other day.

- Charlie
 
S

Sean O'Halpin

No, it's not. RubyGems dependency mechanism is pretty simplistic. I think
the only option with current RubyGems would be to have a dummy FFI gem.

Granted, I'd love to see RubyGems handle this better; we get people asking
us about it every other day.

- Charlie

Shame. I'll document this way to install ffi-ncurses for the moment:

$ jruby -S gem install ffi-ncurses --ignore-dependencies

Regards,
Sean
 
S

Sean O'Halpin

Shame. I'll document this way to install ffi-ncurses for the moment:

$ jruby -S gem install ffi-ncurses --ignore-dependencies

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.

To install:

ruby 1.8.6:

$ sudo gem install ffi ffi-ncurses

jruby 1.1.6:

$ jruby -S gem install ffi-ncurses


Regards,
Sean
 
C

Charles Oliver Nutter

Sean said:
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
 
S

Sean O'Halpin

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.

Hi Dominik,

In order of importance:

- 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
- I wanted to learn to use the FFI :)

Regards,
Sean
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,829
Messages
2,569,737
Members
45,525
Latest member
RosalindSa

Latest Threads

Top