mrdialog is a pure ruby library for the ncurses dialog program. dialog is a command line tool that can present questions, messages, forms using dialog boxes from a shell script. If you compiled linux kernel and typed 'make menuconfig', configured Linux from command line with various configuration managers, you have used 'dialog' like programs.
However, it is painful to program dialog from shell scripts due to lack of data structure. You constantly have to watch if the correct number of items are specified, if the arguments are in correct order for example. It is a lot of fun to program dialog from an object oriented scripting language like ruby. Compare the sample shell scripts of dialog program with the sample ruby scripts of mrdialog in the samples directory, I think you will agree.
MRDialog is based on the rdialog ruby gem http://rdialog.rubyforge.org/ by Aleks Clark.
I did the following:
- Added features and support for all of the missing widgets.
- Fixed the bugs I found.
- Implemented the examples for all the widgets.
If you have bug reports, questions, requests or suggestions, please enter it in the Issues with an appropriate label.
The dialog program must be installed. Note: the dialog program that is available in ubuntu is little old. Check the dialog version by typing
I tested with
dialog Version: 1.2-20130928
dialog HOME: http://invisible-island.net/dialog/dialog.html.
# gem install mrdialog
$ sudo gem install mrdialog
# gem uninstall mrdialog or
$ sudo gem uninstall mrdialog
Run the sample apps
Find out where the mrdialog gem is installed. Example:
$ gem which mrdialog /Library/Ruby/Gems/2.0.0/gems/mrdialog-1.0.1/lib/mrdialog.rb
cd to the
samples directory and run the apps.
$ cd /Library/Ruby/Gems/2.0.0/gems/mrdialog-1.0.1/samples $ ./msgbox.rb
How to use the API
For now, please look at the apps in samples directory to see how the API works.
require 'mrdialog' dialog = MRDialog.new
The various properties of the dialog (shadow, title etc.) can be set by calling the appropriate setters. The supported propertes are shown below:
||Draw a shadow to the right and bottom of each dialog box.||true|
||Specifies a title string to be displayed at the top of the dialog box||N/A|
||Debug messages will be logged to the specified ruby Logger||N/A|
||Clears the widget screen, keeping only the screen_color background.||false|
||Makes the password widget friendlier but less secure, by echoing asterisks for each character.||false|
||Rather than draw graphics lines around boxes, draw ASCII "+" and "-" in the same place. See also "--no-lines".||false|
||Use the specified rc file.||"$HOME/.dialogrc"|
||Use the specified label on the "Yes" button.||"Yes"|
||Use the specified label on the "No" button.||"No"|
||Use the specified label on the "Cancel" button.||"Cancel"|
||Include a "Help" button on the dialog.||false|
||Use the specified label on the "Help" button.||"Help"|
||Include an "Extra" button on the dialog.||false|
||Use the specified label on the "Extra" button.||"Extra"|
||Pass any valid dialog option.
The following dialog widgets are supported:
A buildlist dialog displays two lists, side-by-side. The list on the left shows unselected items. The list on the right shows selected items. As items are selected or unselected, they move between the lists. The SPACE bar is used to select or unselect an item.
Use a carriage return or the "OK" button to accept the current value in the selected-window and exit. The results are written using the order displayed in the selected-window. The caller is responsible to create the items properly. Please look at buildlist.rb for an example.
returns an array of selected tags
result_array = dialog.buildlist(text="Text Goes Here", items, height=0, width=0, listheight=0)
Please look at calendar.rb for an example.
Please look at checklist.rb for an example.
Please look at editbox.rb for an example.
Please look at fselect.rb for an example.
Please look at gauge.rb for an example.
Please look at infobox.rb for an example.
Please look at inputbox.rb for an example.
Please look at menubox.rb for an example.
Please look at msgbox.rb for an example.
Please look at passwordform.rb for an example.
Please look at pause.rb for an example.
Please look at prgbox.rb for an example.
Please look at progressbox.rb for an example.
Please look at programbox.rb for an example.
Please look at radiolist.rb for an example.
Please look at timebox.rb for an example.
Please look at treeview.rb for an example.
Please look at yesno.rb for an example.
Note: Pre-built mrdialog-1.0.3.gem is in the pkg directory
If you need to build the gem yourself:
Install bundler first:
$ gem install bundler $ bundle install
- To build:
$ rake build
Will create the gem inside the pkg directory
To install the built gem:
$ sudo gem install --local pkg/mrdialog-1.0.3.gem
To install using rake:
$ sudo rake install
To install the gem to a specific directory:
$ GEM_HOME=/tmp gem install --local pkg/mrdialog-1.0.3.gem
The gem will be installed in /tmp/gems directory
Lincense is MIT. Please look at the LICENSE.txt file for details.