[ANN] ffi-ncurses 0.3.3

I've just released version 0.3.3 of the ffi-ncurses gem. This fixes
the long-standing issue of not being compatible with ffi version
0.6.x. Apologies to all who requested this change months ago.

= What is ffi-ncurses?

A wrapper for ncurses 5.x. Tested on Ubuntu 8.04 to 10.04 and Mac OS X
10.4 (Tiger) with ruby 1.8.6, 1.8.7 and 1.9.x using ffi (>= 0.6.3) and
JRuby 1.5.1.

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.

github repo: http://github.com/seanohalpin/ffi-ncurses

= Changes in 0.3.3 / 2010-08-24

* Depends on ffi again (>= 0.6.3)
* Now compatible with ffi-0.6.3
* Included keydefs.rb by default
* Examples have been tested with:
  - jruby-1.5.1
  - ree-1.8.7-2010.02
  - ruby-1.8.6-p399
    Note: the examples require "ffi-ncurses/ord-shim" to add
    Integer#ord
  - ruby-1.8.7-p302
  - ruby-1.9.2-p0
* Sadly not compatible with Rubinius (rbx-1.0.0-20100514)
* Removed attempt to load XCurses (PDCurses)
* Removed dependency on bones
  - no Rakefile any more - just use
      gem build ffi-ncurses.gemspec

uver cool. thanks sean.
best regards -botp

···

On Wed, Aug 25, 2010 at 8:11 AM, Sean O'Halpin <sean.ohalpin@gmail.com> wrote:

A wrapper for ncurses 5.x. Tested on Ubuntu 8.04 to 10.04 and Mac OS X
10.4 (Tiger) with ruby 1.8.6, 1.8.7 and 1.9.x using ffi (>= 0.6.3) and
JRuby 1.5.1.

Sean O'halpin wrote:

I've just released version 0.3.3 of the ffi-ncurses gem. This fixes
the long-standing issue of not being compatible with ffi version
0.6.x. Apologies to all who requested this change months ago.

thanks sean
the earlier version of ff-ncurses was not working on snow leopard, this
one is. :slight_smile:

Any idea how to get the mouse to work on ncurses ?
(rvm ruby 1.9.2, OS X 10.6 Intel, bash)

···

--
Posted via http://www.ruby-forum.com/\.

Sure - it's documented in the README at

and there's an example that's shipped with the gem:
http://github.com/seanohalpin/ffi-ncurses/blob/master/examples/example-mouse.rb

If you were using this from a Linux console, you'd have to have gpm
running first. Don't know if there's anything special you have to do
for Snow Leopard.

Regards,
Sean

···

On Thu, Aug 26, 2010 at 11:20 AM, R.. Kumar 1.9.1 OSX <sentinel1879@gmail.com> wrote:

Any idea how to get the mouse to work on ncurses ?
(rvm ruby 1.9.2, OS X 10.6 Intel, bash)

it would be great if ffi curses portability gets integrated w rbcurses
form & menu features.
best regards -botp

···

On Fri, Aug 27, 2010 at 10:05 PM, Sean O'Halpin <sean.ohalpin@gmail.com> wrote:

Sure - it's documented in the README at
GitHub - seanohalpin/ffi-ncurses: Interface to ncurses using Ruby FFI (Foreign Function Interface)
and there's an example that's shipped with the gem:
http://github.com/seanohalpin/ffi-ncurses/blob/master/examples/example-mouse.rb

it would be great if ffi curses portability gets integrated w rbcurses
form & menu features.
best regards -botp

Not clear what this implies. rbcurse does *not* use ncurses form or
menu. It implements forms and fields and menus in pure ruby, since
ncurses forms and fields are extremely painful, restricted and limited.
rbcurse uses only ncurses Window and Panel.

Or are you asking that ffi should implement _ncurses_ form and menu ?

···

--
Posted via http://www.ruby-forum.com/\.

Not clear what this implies. rbcurse does *not* use ncurses form or
menu. It implements forms and fields and menus in pure ruby, since
ncurses forms and fields are extremely painful, restricted and limited.
rbcurse uses only ncurses Window and Panel.

i was wrong then. i thought* rbcurse required ruby-ncurses... wc i
have had difficulty installing then especially when i shifted to 1.9
...

Or are you asking that ffi should implement _ncurses_ form and menu ?

ffi-ncurses just runs without a need for ruby-ncurses... i was
thinking if rbcurse could go thru/require ffi-ncurses instead of
ruby-ncurses.. apologies if i am wrong again on these
assumptions...

kind regards -botp

···

On Sat, Aug 28, 2010 at 2:34 PM, Rahul Kumar <sentinel1879@gmail.com> wrote:

Not clear what this implies. rbcurse does *not* use ncurses form or
menu. It implements forms and fields and menus in pure ruby, since
ncurses forms and fields are extremely painful, restricted and limited.
rbcurse uses only ncurses Window and Panel.

i was wrong then. i thought* rbcurse required ruby-ncurses... wc i
have had difficulty installing then especially when i shifted to 1.9

It does. (I think the 1.9.x difficulties with Ruby's ncurses have been
overcome - see http://totalrecall.wordpress.com/2010/08/22/ncurses-working-with-ruby-1-9-2-snow-leopard/\).

Or are you asking that ffi should implement _ncurses_ form and menu ?

I'm personally not keen to do this. I would rather work on a common
console abstraction for both ncurses and Win32 Console, then build
widgets on top of that. I'm planning to use rbcurse as a baseline for
what such an abstraction would have to support.

ffi-ncurses just runs without a need for ruby-ncurses... i was
thinking if rbcurse could go thru/require ffi-ncurses instead of
ruby-ncurses.. apologies if i am wrong again on these
assumptions...

Your assumptions are correct but ffi-ncurses is not a drop-in
replacement for ruby-ncurses so there would be some work to convert
rbcurse to use it.

Regards,
Sean

···

On Sat, Aug 28, 2010 at 9:47 AM, botp <botpena@gmail.com> wrote:

On Sat, Aug 28, 2010 at 2:34 PM, Rahul Kumar <sentinel1879@gmail.com> wrote:

very nics.
thanks Sean

best regards -botp

···

On Sat, Aug 28, 2010 at 10:28 PM, Sean O'Halpin <sean.ohalpin@gmail.com> wrote:

I would rather work on a common
console abstraction for both ncurses and Win32 Console, then build
widgets on top of that. I'm planning to use rbcurse as a baseline for
what such an abstraction would have to support.

botp et al
There seems to be a little confusion on what i said regarding "ncurses".
rbcurse does depend on ruby-ncurses but not for forms and menus.
The purpose of writing rbcurse was to be free of ncurses forms and
fields which are very restrictive.
Yes, i understand that ffi-ncurses goes directly to native ncurses and
not to ruby-ncurses.

Yes, I understand that ffi is not a drop in replacement. My problem in
converting is only that testing is very difficult, its a completely
manual process. I have not been able to automate, since most errors were
usually visual errors.

Also, sadly it seems no one is really using console apps today. All app
development has shifted to the web. So i don't know if the effort of
shifting to ffi-nc is worth it. Sadly, no one is maintaining
ruby-ncurses as a gem. (Even after installing the gem on 1.8.7 yesterday
i still had to run make/make install since the bundle files were not
installed.)

If there is a need, and people find ncurses-ruby to be a pain, i will
gladly work to shift rbcurse to ffi.

···

--
Posted via http://www.ruby-forum.com/.

Hi Rahul, rbcurse is cool; your work is cool. It's the install
barrier of the ruby-ncurses that is keeping a lot of us fr using it
both in *nix and windows. If you and sean can pull this thru, i'd vote
to make it to ruby's std lib and possibly req a rename of it to ruby
console... fwiw.

thanks for rbcurse and best regards -botp

···

On Mon, Aug 30, 2010 at 1:01 PM, Rahul Kumar <sentinel1879@gmail.com> wrote:

If there is a need, and people find ncurses-ruby to be a pain, i will
gladly work to shift rbcurse to ffi.

Yes, I understand that ffi is not a drop in replacement. My problem in
converting is only that testing is very difficult, its a completely
manual process. I have not been able to automate, since most errors were
usually visual errors.

I have the same issue. I've been thinking about how to automate visual
tests and have so far drawn a blank.

Also, sadly it seems no one is really using console apps today. All app
development has shifted to the web.

Well, think of it this way: we're both doing our little bit to help
keep console apps alive.

Best regards,
Sean

···

On Mon, Aug 30, 2010 at 6:01 AM, Rahul Kumar <sentinel1879@gmail.com> wrote:

botp wrote:

If there is a need, and people find ncurses-ruby to be a pain, i will
gladly work to shift rbcurse to ffi.

Hi Rahul, rbcurse is cool; your work is cool. It's the install
barrier of the ruby-ncurses that is keeping a lot of us fr using it
both in *nix and windows. If you and sean can pull this thru, i'd vote
to make it to ruby's std lib and possibly req a rename of it to ruby
console... fwiw.

thanks for rbcurse and best regards -botp

What platform are you on ? While we work on moving rbcurse to ffi, can
someone not take over maintaining ruby-ncurses. My 'C' is poor or else i
would have, and i have access to only one laptop.

I have released a gem named "snowleopard-ncurses"
(http://rubygems.org/gems/snowleopard-ncurses\) recently, thanks to Ralf
Papenkordt. It is for ruby 1.9.2 (STR2CSTR change), and may work on
other platforms, too.

···

On Mon, Aug 30, 2010 at 1:01 PM, Rahul Kumar <sentinel1879@gmail.com> > wrote:

--
Posted via http://www.ruby-forum.com/\.

Believe it or not, I do not any GUI application.
So any contribution you make is appreciated.

bbiker

···

On Aug 30, 10:41 am, Sean O'Halpin <sean.ohal...@gmail.com> wrote:

On Mon, Aug 30, 2010 at 6:01 AM, Rahul Kumar <sentinel1...@gmail.com> wrote:

> Yes, I understand that ffi is not a drop in replacement. My problem in
> converting is only that testing is very difficult, its a completely
> manual process. I have not been able to automate, since most errors were
> usually visual errors.

I have the same issue. I've been thinking about how to automate visual
tests and have so far drawn a blank.

> Also, sadly it seems no one is really using console apps today. All app
> development has shifted to the web.

Well, think of it this way: we're both doing our little bit to help
keep console apps alive.

Best regards,
Sean

Wanted to confirm. Seems ffi-ncurses does not support panels. Panels are
critical when we need to have multiple windows. e.g. one screen leads to
another, and then closing a screen brings one back to previous. IIRC,
its also required for dialog boxes, popups etc.

Is it possible to have panel support. There are only a few methods:

Ncurses::Panel.del_panel
Ncurses::Panel.hide_panel
Ncurses::Panel.new_panel
Ncurses::Panel.show_panel
Ncurses::Panel.top_panel
Ncurses::Panel.update_panels

Also, window should return its panel with window.panel().

thx
rahul

···

--
Posted via http://www.ruby-forum.com/.

Indeed it is possible. I've added it to my roadmap which now looks like this:

0.3.4: tidy up wide character support (almost ready to ship)
0.4.0: convert function signatures to semantic types (including using
:bool which will require existing apps to change) (half-done)
0.4.1: include Panel support
0.4.2: ruby-ncurses compatibility layer (investigating)

I'll get onto 0.4.1 as soon as I've done 0.4.0 which should be some
time in the next week.

Unfortunate that I'm going to have to break API-compatibility to use
bools, but I don't envisage any further changes that will break
backward-compatibility from 0.4.0 on.

Regards,
Sean

···

On Mon, Aug 30, 2010 at 9:24 AM, Rahul Kumar <sentinel1879@gmail.com> wrote:

Wanted to confirm. Seems ffi-ncurses does not support panels. Panels are
critical when we need to have multiple windows. e.g. one screen leads to
another, and then closing a screen brings one back to previous. IIRC,
its also required for dialog boxes, popups etc.

Is it possible to have panel support. There are only a few methods:

Ncurses::Panel.del_panel
Ncurses::Panel.hide_panel
Ncurses::Panel.new_panel
Ncurses::Panel.show_panel
Ncurses::Panel.top_panel
Ncurses::Panel.update_panels

Also, window should return its panel with window.panel().

thx
rahul

Sean O'halpin wrote:

0.4.2: ruby-ncurses compatibility layer (investigating)

Regards,
Sean

I noticed in ncurses-example.rb that you've created a module and WINDOW
classes that makes your example exactly like the ruby-ncurses one, so no
change is required in the user's code. That was great.
However, should that class not go into the main project at some time ?

Thanks for the great work, Sean.

···

--
Posted via http://www.ruby-forum.com/\.

Wanted to confirm. Seems ffi-ncurses does not support panels. Panels are
critical when we need to have multiple windows. e.g. one screen leads to
another, and then closing a screen brings one back to previous. IIRC,
its also required for dialog boxes, popups etc.

Is it possible to have panel support. There are only a few methods:

Ncurses::Panel.del_panel
Ncurses::Panel.hide_panel
Ncurses::Panel.new_panel
Ncurses::Panel.show_panel
Ncurses::Panel.top_panel
Ncurses::Panel.update_panels

Also, window should return its panel with window.panel().

thx
rahul

Indeed it is possible. I've added it to my roadmap which now looks like this:

0.3.4: tidy up wide character support (almost ready to ship)
0.4.0: convert function signatures to semantic types (including using
:bool which will require existing apps to change) (half-done)
0.4.1: include Panel support

I can provide that, all the code exists already at:

···

On Mon, Aug 30, 2010 at 11:31 PM, Sean O'Halpin <sean.ohalpin@gmail.com> wrote:

On Mon, Aug 30, 2010 at 9:24 AM, Rahul Kumar <sentinel1879@gmail.com> wrote:

0.4.2: ruby-ncurses compatibility layer (investigating)

I'll get onto 0.4.1 as soon as I've done 0.4.0 which should be some
time in the next week.

Unfortunate that I'm going to have to break API-compatibility to use
bools, but I don't envisage any further changes that will break
backward-compatibility from 0.4.0 on.

Regards,
Sean

--
Michael Fellinger
CTO, The Rubyists, LLC
I check email a couple times daily; to reach me sooner, use:
http://awayfind.com/manveru

Yes, it will but it's not exactly quite there yet.
I need to convert the functions which take booleans, e.g. keypad.
For example, in ffi-ncurses at the moment, you write:

  keypad stdscr, 1 # or FFI::NCurses::TRUE which is extra fugly

I'll be changing that so you write

  keypad stdscr, true

That will break backward compatibility, but I think it's worth it.
It means I won't have to add translation functions for the ruby ncurses layer.
I think it's also more in the spirit of ffi type handling.

Thank you for rbcurse - it's one of the things spurring me on to
improve ffi-ncurses.

Regards,
Sean

···

On Mon, Aug 30, 2010 at 5:54 PM, Rahul Kumar <sentinel1879@gmail.com> wrote:

Sean O'halpin wrote:

0.4.2: ruby-ncurses compatibility layer (investigating)

Regards,
Sean

I noticed in ncurses-example.rb that you've created a module and WINDOW
classes that makes your example exactly like the ruby-ncurses one, so no
change is required in the user's code. That was great.
However, should that class not go into the main project at some time ?

Wow. That looks great. Would you mind if I included it in my 0.4.1
release of ffi-ncurses?

Regards,
Sean

···

On Mon, Aug 30, 2010 at 6:55 PM, Michael Fellinger <m.fellinger@gmail.com> wrote:

On Mon, Aug 30, 2010 at 11:31 PM, Sean O'Halpin <sean.ohalpin@gmail.com> wrote:

0.4.1: include Panel support

I can provide that, all the code exists already at:
ver/lib/ver/ncurses/panel.rb at 6d2a59191532976f3fd234b66085b8b9a2d67e03 · manveru/ver · GitHub
ver/lib/ver/ncurses/window.rb at 6d2a59191532976f3fd234b66085b8b9a2d67e03 · manveru/ver · GitHub

--
Michael Fellinger
CTO, The Rubyists, LLC
I check email a couple times daily; to reach me sooner, use:
http://awayfind.com/manveru