Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mrdialog

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mrdialog

  • 1.0.6
  • Rubygems
  • Socket score

Version published
Maintainers
2
Created
Source

MRDialog

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

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

The latest version is 1.0.4. Please look at the ChangeLog.md file for details. Please look at he screenshots to see how the widgets look like.

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 dialog Version: 1.2-20130928

dialog HOME: http://invisible-island.net/dialog/dialog.html.

To install

# gem install mrdialog or $ sudo gem install mrdialog

To uninstall

# gem uninstall mrdialog or $ sudo gem uninstall mrdialog

Run the sample apps

Find out where the mrdialog gem is installed. Example:

$ gem which mrdialog
/Users/muquit/.rvm/gems/ruby-3.0.0/gems/mrdialog-1.0.4/lib/mrdialog.rb

cd to the samples directory and run the apps. Example:

$ cd /Users/muquit/.rvm/gems/ruby-3.0.0/gems/mrdialog-1.0.4/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:

PropertyExampleDescriptionDefault
shadowdialog.shadow = falseDraw a shadow to the right and bottom of each dialog box.true
titledialog.title = 'foo'Specifies a title string to be displayed at the top of the dialog boxN/A
loggerdialog.logger = Logger.new("dialog.log")Debug messages will be logged to the specified ruby LoggerN/A
cleardialog.clear = trueClears the widget screen, keeping only the screen_color background.false
insecuredialog.insecure = trueMakes the password widget friendlier but less secure, by echoing asterisks for each character.false
ascii_linesdialog.ascii_lines = trueRather than draw graphics lines around boxes, draw ASCII "+" and "-" in the same place. See also "--no-lines".false
rc_filedialog.rc_file = "/path/to/rc/file"Use the specified rc file."$HOME/.dialogrc"
yes_labeldialog.yes_label = "Sure"Use the specified label on the "Yes" button."Yes"
no_labeldialog.no_label = "Nope"Use the specified label on the "No" button."No"
cancel_labeldialog.cancel_label = "Forget"Use the specified label on the "Cancel" button."Cancel"
help_buttondialog.help_button = trueInclude a "Help" button on the dialog.false
help_labeldialog.help_label = "What?"Use the specified label on the "Help" button."Help"
extra_buttondialog.extra_button = trueInclude an "Extra" button on the dialog.false
extra_labeldialog.extra_label = "More"Use the specified label on the "Extra" button."Extra"
dialog_optionsdialog.dialog_options="any valid dialog option" e.g. dialog.dialog_options="--no-tags" for checklistPass 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 doneN/A
Widgets

The following dialog widgets are supported:

  • buildlist
  • calendar
  • checklist
  • editbox
  • form
  • fselect
  • gauge
  • infobox
  • 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. 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)
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

Please look at form1.rb, form2.rb, form3.rb for examples.

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.

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.5.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.5.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.5.gem

The gem will be installed in /tmp/gems directory

License is MIT. Please look at the LICENSE.txt file for details.

FAQs

Package last updated on 16 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc