Project

mrdialog

0.01
Low commit activity in last 3 years
A long-lived project that still receives updates
A ruby gem for ncurses dialog program. This gem is based on rdialog (http://rdialog.rubyforge.org/) by Aleks Clark. I added support for missing widgets, fixed bugs and wrote the sample apps. I am also renaming the class to MRDialog to avoid conflicts. Please look at ChangeLog.md for details.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 6.1.2.1
~> 2.1.0
>= 2.4.9
 Project Readme

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 mrdialog

To uninstall

gem uninstall mrdialog
or
sudo gem uninstall mrdialog

Screenshots

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

cd 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.rb

Look 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)

calendar

checklist

editbox

form

fselect

gauge

  • Please look at gauge.rb for an example.

infobox

textbox

inputbox

menu

msgbox

passwordbox

passwordform

pause

  • Please look at pause.rb for an example.

prgbox

progressbox

programbox

radiolist

timebox

treeview

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 build

Will 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