Table Of Contents
- Introduction
- Latest Version (1.0.7 - Oct-19-2025)
- To install
- To uninstall
- Screenshots
- Requirements
- Run the sample apps
- How to use the API
- Properties
- Widgets
- buildlist
- calendar
- checklist
- editbox
- form
- fselect
- gauge
- infobox
- textbox
- inputbox
- menu
- msgbox
- passwordbox
- passwordform
- pause
- prgbox
- progressbox
- programbox
- radiolist
- timebox
- treeview
- yesno
- Dependencies
- For Developers
- License
Introduction
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 on terminal. If you compiled linux kernel and typed
make menuconfig, configured Linux from command line with various
configuration managers, you have used 'dialog' like programs. Please
have a lookt at the screenshots on the dialogs look
like.
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. Look at samples/extra_button/ directory for samples on using an extra button on various input dialogs.
MRDialog is based on the rdialog ruby gem http://rdialog.rubyforge.org/ by Aleks Clark (Does not seem to exist anymore).
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.
Latest Version (1.0.7 - Oct-19-2025)
The latest version is 1.0.7
Important fix in 1.0.7: Fixed a parsing bug where dialog commands would fail if any text contained apostrophes (single quotes). All special characters in user input are now properly handled.
Please look at the ChangeLog.md file for details. Please look at the screenshots to see how the widgets look like.
To install
gem install mrdialog
or
sudo gem install mrdialogTo uninstall
gem uninstall mrdialog
or
sudo gem uninstall mrdialogScreenshots
Please look at the screenshots directory. There are individual screenshots for each of the widgets. Also the animated GIF file all.gif contains screenshot of all the widgets.
Requirements
The dialog program must be installed. Note: the dialog program that is available in ubuntu is little old. Check the dialog version by typing dialog --version
I tested with Version: 1.3-20250116
dialog HOME: http://invisible-island.net/dialog/dialog.html.
Run the sample apps
Find out where the mrdialog gem is installed. Example:
gem which mrdialog
/Users/muquit/.rvm/gems/ruby-3.2.2/gems/mrdialog-1.0.7/lib/mrdialog.rbcd to the samples directory and run the apps.
Example:
cd /Users/muquit/.rvm/gems/ruby-3.2.2/gems/mrdialog-1.0.7/samples
./msgbox.rbLook at samples/extra_button/ on how to use an extra button on various input dialogs.
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
Properties
The various properties of the dialog (shadow, title etc.) can be set by calling the appropriate setters. The supported properties are shown below:
| Property | Example | Description | Default |
|---|---|---|---|
| shadow | dialog.shadow = false |
Draw a shadow to the right and bottom of each dialog box. | true |
| title | dialog.title = 'foo' |
Specifies a title string to be displayed at the top of the dialog box | N/A |
| logger | dialog.logger = Logger.new("dialog.log") |
Debug messages will be logged to the specified ruby Logger | N/A |
| clear | dialog.clear = true |
Clears the widget screen, keeping only the screen_color background. | false |
| insecure | dialog.insecure = true |
Makes the password widget friendlier but less secure, by echoing asterisks for each character. | false |
| ascii_lines | dialog.ascii_lines = true |
Rather than draw graphics lines around boxes, draw ASCII "+" and "-" in the same place. See also "--no-lines". | false |
| rc_file | dialog.rc_file = "/path/to/rc/file" |
Use the specified rc file. | "$HOME/.dialogrc" |
| yes_label | dialog.yes_label = "Sure" |
Use the specified label on the "Yes" button. | "Yes" |
| no_label | dialog.no_label = "Nope" |
Use the specified label on the "No" button. | "No" |
| cancel_label | dialog.cancel_label = "Forget" |
Use the specified label on the "Cancel" button. | "Cancel" |
| help_button | dialog.help_button = true |
Include a "Help" button on the dialog. | false |
| help_label | dialog.help_label = "What?" |
Use the specified label on the "Help" button. | "Help" |
| extra_button | dialog.extra_button = true |
Include an "Extra" button on the dialog. | false |
| extra_label | dialog.extra_label = "More" |
Use the specified label on the "Extra" button. | "Extra" |
| dialog_options |
dialog.dialog_options="any valid dialog option" e.g. dialog.dialog_options="--no-tags" for checklist |
Pass any valid dialog option. man dialog and look at the OPTIONS section. It is the caller's responsibility to specify correct options, no validation will be done |
N/A |
Widgets
The following dialog widgets are supported:
- buildlist
- calendar
- checklist
- editbox
- form
- fselect
- gauge
- infobox
- textbox
- inputbox
- menu
- msgbox
- passwordbox
- passwordform
- pause
- prgbox
- progressbox
- programbox
- radiolist
- timebox
- treeview
- yesno
buildlist
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.
returns an array of selected tags
result_array = dialog.buildlist(text="Text Goes Here", items, height=0, width=0, listheight=0)- Please look at buildlist.rb for an example.
calendar
- Please look at calendar.rb for an example.
checklist
- Please look at checklist.rb for an example.
editbox
- Please look at editbox.rb for an example.
form
fselect
- Please look at fselect.rb for an example.
gauge
- Please look at gauge.rb for an example.
infobox
- Please look at infobox.rb for an example.
textbox
- Please look at textbox.rb for an example.
inputbox
- Please look at inputbox.rb for an example.
menu
- Please look at menubox.rb for an example.
msgbox
- Please look at msgbox.rb for an example.
passwordbox
- Please look at password.rb, password2.rb for examples.
passwordform
- Please look at passwordform.rb for an example.
pause
- Please look at pause.rb for an example.
prgbox
- Please look at prgbox.rb for an example.
progressbox
- Please look at progressbox.rb for an example.
programbox
- Please look at programbox.rb for an example.
radiolist
- Please look at radiolist.rb for an example.
timebox
- Please look at timebox.rb for an example.
treeview
- Please look at treeview.rb for an example.
yesno
- Please look at yesno.rb for an example.
Dependencies
Mrdialog does not have dependencies on any other gems. The gems in Gemfile are for development for building the gem.
For Developers
Note: Pre-built mrdialog-1.0.7.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 clean
rake gemspec
rake buildWill create the gem inside the pkg directory
- To install the built gem:
sudo gem install --local pkg/mrdialog-1.0.7.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.7.gem`The gem will be installed in /tmp/gems directory
Please see the Makefile for build and release commands
License
License is MIT. Please look at the LICENSE.txt file for details.
TOC is created by https://github.com/muquit/markdown-toc-go on Oct-19-2025