How do I create an interactive menu in a terminal?

I'm trying to build an terminal application that, when started, will take the user away from their prompt and present them with a screen with an interactive menu. I would like the user to be able to interact with it in the following way:

  1. They will start the application by running my_app from the terminal. This will start the application and present them with the root menu.
  2. They will use the cursor keys to navigate around the menu and use the [ENTER] key to make a selection.
  3. When they make a selection, they will be presented with another screen/menu when they will do some work. When they are finished this work, they will press a key that will take them back to the root menu.

The key thing I'm after is for it to not be a scrolling view that just adds more information to the end. I'd like it to have distinct, encapsulated views with a navigation hierarchy. My problem is that I don't know how to produce such a view and present it to the user, and then dismiss it again once they're done. If someone could give me some kind of design pattern for this kind of application, I'll be able to take it from there.

FWIW, I'm using Ruby and would like the app to be cross-platform. If that's too much to ask, then Windows will suffice.


I'm a Linux guy and I want to suggest ncurses library for you. there's an ongoing effort to port this also to Windows. AFAIK it's going pretty well, please check this question.

Need Your Help

how to keep Go webservice running

linux web-services service webserver go

I am writing some webservices in Go on a linux machine, so the Go executable needs to keep running

Re-sizing matplotlib markers

python matplotlib graph markers

I see a ton of questing on re-sizing marker relative to the window and or position, but all I want to do is make the markers bigger.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.