descriptionThe Rubyist's interface to Ncurses.
homepage URL
last changeTue, 17 Mar 2009 01:51:14 +0000 (16 17:51 -0800)
content tags


The Rubyist's interface to Ncurses.


As in, "Ncurses, Nfoiled Nagain!". Nfoiled is an object-oriented Ruby wrapper for ncurses-ruby, and therefore, Ncurses. I really got tired of the idiosyncrasies of Ncurses' API (it's written in a C style, not very clean, and definitely not object-oriented)... since ncurses-ruby does nothing more than make the C API available to Ruby as methods, it's no better. While working on rat, I set out to abstract the ncurses-ruby API to a system of objects and classes, in the truly Ruby style I'm used to. Now I've decided to abstract this code out and make it available separately... hence Nfoiled!


You can install Nfoiled as a pre-built gem, or as a gem generated directly from the source.

The easiest way to install Nfoiled is to use RubyGems to acquire the latest 'release' version from RubyForge, using the gem command line tool:

sudo gem install nfoiled # You'll be asked for your account password.

Alternatively, you can acquire it (possibly slightly more up-to-date, depending on how often I update the gemspec) from GitHub as follows:

# If you've ever done this before, you don't need to do it now - see
gem sources -a
sudo gem install elliottcable-nfoiled # You'll be asked for your account password.

Finally, you can build a gem from the latest source yourself. You need git, as well as [rake][]:

git clone git://
cd nfoiled
rake install # You'll be asked for your account password.


You can contribute bug fixes or new features to Nfoiled by forking the project on GitHub (you'll need to register for an account first), and sending me a pull request once you've committed your changes.

Goals & Todo

  1. Manage tiling, to some extent, for the user:
    1. Automatically align windows to the proper locations
    2. Automatically resize existing windows to accomodate newly created ones
    3. Manage the handling window resizing, and allow user to specify how each window should handle resizing
  2. Manage efficient updating as much as possible:
    1. Maintain an "event loop" of updates, and ensure that quickly-sequential window updates correspond to a single update! call
    2. Allow users actions' to schedule updates in sequence
  3. Handle keys/input for the user:
    1. Run a loop that tracks all input, automatically handling key sequences without Ncurses' signature blocking delay bullshit
    2. Provide default callbacks for common operations, such as navigating in an input area
    3. Allow user to override callbacks with their own blocks, to be run on the input of specific keys
  4. Never, ever touch Ncurses' horrid GUI-emulation bits (mouse handling, overlapping panels, window borders, widgets). People who want that retarded shit can call directly out to Ncurses, or even just suck it. Seriously, people, stop trying to emulate GUIs in a terminal! Textmode UI is a totally different art. Learn it, take a look at irssi or rat some time. </rant>


Nfoiled is copyright 2008 by elliott cable.

Nfoiled is released under the GNU General Public License v3.0, which allows you to freely utilize, modify, and distribute all Nfoiled's source code (subject to the terms of the aforementioned license).

2009-03-17 elliottcableMerge branch 'master' of master
2009-03-15 elliottcableRevert "Mis-handled the uber-long Unicode"
2009-03-15 elliottcableMoved `Key::Names` into constants under `Key::ASCII...
2009-03-15 elliottcableBreaking instead of out-right exiting when `Nfoiled...
2009-03-15 elliottcableWrapped `Nfoiled::read!`'s contents in a block so that...
2009-03-15 elliottcableAdded a really fragile UTF-8 parser. Really needs a...
2009-03-15 elliottcableRe-named `Key.process` to `Key.ascii`
2009-03-15 elliottcableDuck punching stringish on `Window#print`
2009-03-15 elliottcableIgnoring the 'logs' folder.
2009-03-14 elliottcableMis-handled the uber-long Unicode
2009-03-14 elliottcableAdded more examples of key sequences to thoughts.txt
2009-03-14 elliottcableAdded a temporary thoughts-file to keep track of all...
2009-03-14 elliottcableAdded a basic input example. Really messy right now.
2009-03-14 elliottcableGot started on a read loop. Not really very good atm.
2009-03-13 elliottcableRe-worked `Key.process` some more.
2009-03-13 elliottcableCleaned up some documentation on `Key`, and working...
9 years ago master
9 years ago mini_attr_splat
10 years ago mob