[ANN] ffi-ncurses version 0.3.0

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

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'?

Sean O'Halpin wrote:

···

ffi-ncurses version 0.3.0
    by Sean O'Halpin
    GitHub - seanohalpin/ffi-ncurses: Interface to ncurses using Ruby FFI (Foreign Function Interface)

== 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

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.

···

--
Dominik Honnef
dominikho@gmx.net

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

Is it possible to specify different gem dependencies by platform?

Regards,
Sean

···

On Mon, Feb 16, 2009 at 12:57 AM, Charles Oliver Nutter <charles.nutter@sun.com> 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'?

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 :slight_smile:

Regards,
Sean

···

On Tue, Feb 17, 2009 at 1:24 PM, Dominik Honnef <dominikho@gmx.net> 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.
--
Dominik Honnef
dominikho@gmx.net

Sean O'Halpin wrote:

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

Thank you for the fast answer.
And: I'm especially looking forward to that console library.

···

--
Dominik Honnef
dominikho@gmx.net

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

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

Regards,
Sean

···

On Mon, Feb 16, 2009 at 2:50 AM, Charles Oliver Nutter <charles.nutter@sun.com> wrote:

Sean O'Halpin wrote:

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

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

···

On Mon, Feb 16, 2009 at 8:25 AM, Sean O'Halpin <sean.ohalpin@gmail.com> wrote:

On Mon, Feb 16, 2009 at 2:50 AM, Charles Oliver Nutter > <charles.nutter@sun.com> wrote:

Sean O'Halpin wrote:

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

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

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

Regards,
Sean

Sean O'Halpin wrote:

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