[ANN] ffi-ncurses 0.3.3

S

Sean O'Halpin

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.

=3D 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 (>=3D 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 =91close to the metal=92 wrapper around the ncurses library upon
which you can build your own abstractions.

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

=3D Changes in 0.3.3 / 2010-08-24

* Depends on ffi again (>=3D 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
 
B

botp

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.

uver cool. thanks sean.
best regards -botp
 
R

R.. Kumar 1.9.1 OSX

Sean said:
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. :)

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

Sean O'Halpin

R

Rahul Kumar

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

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.

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
 
S

Sean O'Halpin

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/).

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 =A0without a need for ruby-ncurses... =A0i was
thinking if rbcurse =A0could go thru/require ffi-ncurses instead of
ruby-ncurses.. =A0 apologies if i am =A0wrong 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
 
B

botp

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.

very nics.
thanks Sean

best regards -botp
 
R

Rahul Kumar

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.
 
B

botp

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
 
R

Rahul Kumar

botp said:
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.
 
R

Rahul Kumar

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
 
S

Sean O'Halpin

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

Sean O'Halpin

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
 
R

Rahul Kumar

Sean said:
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.
 
M

Michael Fellinger

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:
http://github.com/manveru/ver/blob/6d2a59191532976f3fd234b66085b8b9a2d67e03/lib/ver/ncurses/panel.rb
http://github.com/manveru/ver/blob/...4b66085b8b9a2d67e03/lib/ver/ncurses/window.rb
 
B

bbiker

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




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

Best regards,
Sean

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

bbiker
 
S

Sean O'Halpin

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 ?

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
 
S

Sean O'Halpin

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

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top