mrdialog 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f2c5f27d587a51acc7503e1b99fdcfdb97af44d3
4
- data.tar.gz: e1e584a5d7da7a9647630def35388e3fba207f90
2
+ SHA256:
3
+ metadata.gz: 4abf284e5f7c5aa297345dbd4506bce9997aae61093f05cb4dab1190f0c40346
4
+ data.tar.gz: f667bcca5f8556c139a4ee4d38e210df6f6c9163e3dfab588dfecfa8fa4766e2
5
5
  SHA512:
6
- metadata.gz: 35820b6519e3ee6094a4df9299d7879ebea3f140baeb5621221c6d663cf63b7d581a7e113894a7f22b5b4ec24eaef024ad56f52b1f75910322cf913268029739
7
- data.tar.gz: fa921f2ebdfb777fafc614af31ca14cd0b2b90e40059fdfbeb8f1b87f14b7f3dc0bc39c72847b83d31b9cf54fe92ecaf9146cd5c1383d121baf63eeaf3945dc5
6
+ metadata.gz: f79b47813388ebcf37ae95d3cb3373b792cd6e929c3f83a53fa6818a39fb6909e5096c9b493c89de8ae7f4b9233a4442b0844dd2db067bc7a3f885f88f7a3ffc
7
+ data.tar.gz: 89ac7a47299c65fc5fef30fbfd6acaba29e9f80ae20b0fc8d57ce8a65e57cec177f3adfdc6168406882cefe1970a9e776abc04b90ff16fb398b557bfd5decdfe
data/ChangeLog.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## 1.0.4
2
+ * Previously only the OK/Yes button read input from forms, menus and lists.
3
+ If an extra button is used, it was treated the same as the Cancel/No
4
+ button, and no output from the form/menu/list was returned to the caller.
5
+
6
+ This PR changes the various user input dialogs to treat the Extra button
7
+ the same way as the OK/Yes button, and to return the dialog's input to the
8
+ caller.
9
+
10
+ Thanks to https://github.com/OtherJohnGray for pull request.
11
+
12
+ (Jun-22-2022)
13
+
14
+
1
15
  ## 1.0.3
2
16
  * Added accessor `rc_file`. It specifies the DIALOGRC file to use. Default is $HOME/.dialogrc
3
17
  * Added accessor `cancel_label`. It specifies the label to use for the 'Cancel' button.
@@ -29,7 +43,7 @@ This ia exactly same as `dialog.notags = true`
29
43
 
30
44
  ## 1.0.1
31
45
 
32
- * Jeweler support for making the gem.
46
+ * Juwelier support for making the gem.
33
47
 
34
48
  Implemented methods for:
35
49
 
data/Gemfile CHANGED
@@ -8,7 +8,8 @@ source "http://rubygems.org"
8
8
  group :development do
9
9
  gem "shoulda", ">= 0"
10
10
  gem "rdoc", "~> 3.12"
11
- gem "bundler", "~> 1.0"
12
- gem "jeweler", "~> 2.0.1"
11
+ gem "bundler", ">= 2.0"
12
+ gem "juwelier", "~> 2.1.0"
13
13
  gem "simplecov", ">= 0"
14
+ gem "test-unit"
14
15
  end
data/README.md CHANGED
@@ -29,7 +29,7 @@ I did the following:
29
29
  If you have bug reports, questions, requests or suggestions, please enter it in the [Issues](https://github.com/muquit/mrdialog/issues) with an appropriate label.
30
30
 
31
31
  ### Latest Version
32
- The latest version is 1.0.3.
32
+ The latest version is 1.0.4.
33
33
  Please look at the [ChangeLog.md](ChangeLog.md) file for details. Please look at he [screenshots](screenshots/) to see how the widgets look like.
34
34
 
35
35
  ### Screenshots
@@ -171,6 +171,10 @@ Please look at [treeview.rb](samples/treeview.rb) for an example.
171
171
  Please look at [yesno.rb](samples/yesno.rb) for an example.
172
172
 
173
173
  ### For Developers
174
+ Note: Pre-built mrdialog-1.0.4.gem is in the pkg directory
175
+
176
+ If you need to build the gem yourself:
177
+
174
178
  Install bundler first:
175
179
 
176
180
  $ gem install bundler
@@ -180,11 +184,11 @@ Install bundler first:
180
184
 
181
185
  Will create the gem inside the pkg directory
182
186
 
183
- - To install the built gem: ```$ sudo gem install --local pkg/mrdialog-1.0.2.gem```
187
+ - To install the built gem: ```$ sudo gem install --local pkg/mrdialog-1.0.4.gem```
184
188
 
185
189
  - To install using rake: ```$ sudo rake install```
186
190
 
187
- - To install the gem to a specific directory: ```$ GEM_HOME=/tmp gem install --local pkg/mrdialog-1.0.2.gem```
191
+ - To install the gem to a specific directory: ```$ GEM_HOME=/tmp gem install --local pkg/mrdialog-1.0.4.gem```
188
192
 
189
193
  The gem will be installed in /tmp/gems directory
190
194
 
data/Rakefile CHANGED
@@ -11,8 +11,8 @@ rescue Bundler::BundlerError => e
11
11
  end
12
12
  require 'rake'
13
13
 
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
14
+ require 'juwelier'
15
+ Juwelier::Tasks.new do |gem|
16
16
  # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
17
  gem.name = "mrdialog"
18
18
  gem.homepage = "http://github.com/muquit/mrdialog"
@@ -34,7 +34,7 @@ Jeweler::Tasks.new do |gem|
34
34
  gem.files.include 'ChangeLog.md'
35
35
  # dependencies defined in Gemfile
36
36
  end
37
- Jeweler::RubygemsDotOrgTasks.new
37
+ Juwelier::RubygemsDotOrgTasks.new
38
38
 
39
39
  require 'rake/testtask'
40
40
  Rake::TestTask.new(:test) do |test|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.3
1
+ 1.0.4
@@ -442,11 +442,12 @@ class MRDialog
442
442
  @exit_code = $?.exitstatus
443
443
  log_debug "Exit code: #{exit_code}"
444
444
  tag = ''
445
- if @exit_code == 0
445
+ if @exit_code != 1
446
446
  tag = tmp.read
447
447
  end
448
- tmp.close!
449
448
  return tag
449
+ ensure
450
+ tmp.close!
450
451
  end
451
452
 
452
453
  #
@@ -525,7 +526,7 @@ class MRDialog
525
526
  system(cmd)
526
527
  @exit_code = $?.exitstatus
527
528
  log_debug "Exit code: #{exit_code}"
528
- if @exit_code == 0
529
+ if @exit_code != 1
529
530
  lines = tmp.read
530
531
  log_debug "lines: #{lines} #{lines.class}"
531
532
  sep = Shellwords.escape(@separator)
@@ -535,8 +536,9 @@ class MRDialog
535
536
  selected_tags << tag if tag.to_s.length > 0
536
537
  end
537
538
  end
538
- tmp.close!
539
539
  return selected_tags
540
+ ensure
541
+ tmp.close!
540
542
  end
541
543
 
542
544
  # A pause box displays a meter along the bottom of the box. The
@@ -604,8 +606,9 @@ class MRDialog
604
606
  if @exit_code == 0
605
607
  result = tmp.read
606
608
  end
607
- tmp.close!
608
609
  return result
610
+ ensure
611
+ tmp.close!
609
612
  end
610
613
 
611
614
  #
@@ -693,7 +696,7 @@ class MRDialog
693
696
  @exit_code = $?.exitstatus
694
697
  log_debug "Exit code: #{exit_code}"
695
698
 
696
- if @exit_code == 0
699
+ if @exit_code != 1
697
700
  lines = tmp.readlines
698
701
  lines.each_with_index do |val, idx|
699
702
  key = items[idx][0]
@@ -701,8 +704,9 @@ class MRDialog
701
704
  end
702
705
  end
703
706
 
704
- tmp.close!
705
707
  return res_hash
708
+ ensure
709
+ tmp.close!
706
710
  end
707
711
 
708
712
  #
@@ -754,15 +758,14 @@ class MRDialog
754
758
  " 2> " + tmp.path
755
759
  success = system(command)
756
760
  @exit_code = $?.exitstatus
757
- if success
761
+ if @exit_code != 1
758
762
  date = Date::civil(*tmp.readline.split('/').collect {|i| i.to_i}.reverse)
759
- tmp.close!
760
763
  return date
761
764
  else
762
- tmp.close!
763
765
  return success
764
766
  end
765
-
767
+ ensure
768
+ tmp.close!
766
769
  end
767
770
 
768
771
  # A checklist box is similar to a menu box; there are multiple
@@ -800,9 +803,8 @@ class MRDialog
800
803
  success = system(command)
801
804
  @exit_code = $?.exitstatus
802
805
  selected_array = []
803
- if success
806
+ if @exit_code != 1
804
807
  selected_string = tmp.readline
805
- tmp.close!
806
808
  log_debug "Separator: #{@separator}"
807
809
 
808
810
  sep = Shellwords.escape(@separator)
@@ -813,10 +815,10 @@ class MRDialog
813
815
  end
814
816
  return selected_array
815
817
  else
816
- tmp.close!
817
818
  return success
818
819
  end
819
-
820
+ ensure
821
+ tmp.close!
820
822
  end
821
823
 
822
824
  # The file-selection dialog displays a text-entry window in which
@@ -850,18 +852,18 @@ class MRDialog
850
852
  success = system(command)
851
853
  @exit_code = $?.exitstatus
852
854
 
853
- if success
855
+ if @exit_code != 1
854
856
  begin
855
857
  selected_string = tmp.readline
856
858
  rescue EOFError
857
859
  selected_string = ""
858
860
  end
859
- tmp.close!
860
861
  return selected_string
861
862
  else
862
- tmp.close!
863
863
  return success
864
864
  end
865
+ ensure
866
+ tmp.close!
865
867
  end
866
868
 
867
869
 
@@ -914,15 +916,14 @@ class MRDialog
914
916
  success = system(command)
915
917
  @exit_code = $?.exitstatus
916
918
 
917
- if success
919
+ if @exit_code != 1
918
920
  selected_string = tmp.readline
919
- tmp.close!
920
921
  return selected_string
921
922
  else
922
- tmp.close!
923
923
  return success
924
924
  end
925
-
925
+ ensure
926
+ tmp.close!
926
927
  end
927
928
 
928
929
  # As its name suggests, a menu box is a dialog box that can be
@@ -961,15 +962,14 @@ class MRDialog
961
962
  success = system(command)
962
963
  @exit_code = $?.exitstatus
963
964
 
964
- if success
965
+ if @exit_code != 1
965
966
  selected_string = tmp.readline
966
- tmp.close!
967
967
  return selected_string
968
968
  else
969
- tmp.close!
970
969
  return success
971
970
  end
972
-
971
+ ensure
972
+ tmp.close!
973
973
  end
974
974
 
975
975
  # A message box is very similar to a yes/no box. The only dif-
@@ -1012,18 +1012,18 @@ class MRDialog
1012
1012
  success = system(command)
1013
1013
  @exit_code = $?.exitstatus
1014
1014
 
1015
- if success
1015
+ if @exit_code != 1
1016
1016
  begin
1017
1017
  selected_string = tmp.readline
1018
1018
  rescue EOFError
1019
1019
  selected_string = ""
1020
1020
  end
1021
- tmp.close!
1022
1021
  return selected_string
1023
1022
  else
1024
- tmp.close!
1025
1023
  return success
1026
1024
  end
1025
+ ensure
1026
+ tmp.close!
1027
1027
  end
1028
1028
 
1029
1029
  # The textbox method handles three similar dialog functions, textbox,
@@ -1093,15 +1093,14 @@ class MRDialog
1093
1093
  log_debug("Command:\n#{command}")
1094
1094
  success = system(command)
1095
1095
  @exit_code = $?.exitstatus
1096
- if success
1096
+ if @exit_code != 1
1097
1097
  time = Time.parse(tmp.readline)
1098
- tmp.close!
1099
1098
  return time
1100
1099
  else
1101
- tmp.close!
1102
1100
  return success
1103
1101
  end
1104
-
1102
+ ensure
1103
+ tmp.close!
1105
1104
  end
1106
1105
 
1107
1106
  # An input box is useful when you want to ask questions that
@@ -1129,18 +1128,18 @@ class MRDialog
1129
1128
  success = system(command)
1130
1129
  @exit_code = $?.exitstatus
1131
1130
 
1132
- if success
1131
+ if @exit_code != 1
1133
1132
  begin
1134
1133
  selected_string = tmp.readline
1135
1134
  rescue EOFError
1136
1135
  selected_string = ""
1137
1136
  end
1138
- tmp.close!
1139
1137
  return selected_string
1140
1138
  else
1141
- tmp.close!
1142
1139
  return success
1143
1140
  end
1141
+ ensure
1142
+ tmp.close!
1144
1143
  end
1145
1144
 
1146
1145
  # A yes/no dialog box of size height rows by width columns will
data/mrdialog.gemspec ADDED
@@ -0,0 +1,124 @@
1
+ # Generated by juwelier
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: mrdialog 1.0.4 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "mrdialog"
9
+ s.version = "1.0.4"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Aleks Clark", "Muhammad Muquit"]
14
+ s.date = "2018-04-12"
15
+ s.description = "A ruby gem for ncurses dialog program.\n This gem is based on rdialog (http://rdialog.rubyforge.org/) by\n Aleks Clark. I added support for missing widgets, fixed \n bugs and wrote the sample apps. I am \n also renaming the class to MRDialog to avoid conflicts.\n Please look at ChangeLog.md for details. "
16
+ s.email = "muquit@gmail.com"
17
+ s.extra_rdoc_files = [
18
+ "ChangeLog.md",
19
+ "LICENSE.txt",
20
+ "README.md"
21
+ ]
22
+ s.files = [
23
+ ".document",
24
+ "ChangeLog.md",
25
+ "Gemfile",
26
+ "Gemfile.lock",
27
+ "LICENSE.txt",
28
+ "README.md",
29
+ "Rakefile",
30
+ "VERSION",
31
+ "lib/mrdialog.rb",
32
+ "lib/mrdialog/mrdialog.rb",
33
+ "pkg/md5.txt",
34
+ "pkg/mrdialog-1.0.4.gem",
35
+ "samples/buildlist.rb",
36
+ "samples/calendar.rb",
37
+ "samples/checklist.rb",
38
+ "samples/editbox.rb",
39
+ "samples/form1.rb",
40
+ "samples/form2.rb",
41
+ "samples/form3.rb",
42
+ "samples/fselect.rb",
43
+ "samples/gauge.rb",
44
+ "samples/infobox.rb",
45
+ "samples/inputbox.rb",
46
+ "samples/menubox.rb",
47
+ "samples/mixedform1.rb",
48
+ "samples/msgbox.rb",
49
+ "samples/password.rb",
50
+ "samples/password2.rb",
51
+ "samples/passwordform.rb",
52
+ "samples/pause.rb",
53
+ "samples/prgbox.rb",
54
+ "samples/program.rb",
55
+ "samples/progress.rb",
56
+ "samples/radiolist.rb",
57
+ "samples/run_all.rb",
58
+ "samples/shortlist",
59
+ "samples/timebox.rb",
60
+ "samples/treeview.rb",
61
+ "samples/treeview2.rb",
62
+ "samples/yesno.rb",
63
+ "screenshots/README.txt",
64
+ "screenshots/all.gif",
65
+ "screenshots/buildlist.png",
66
+ "screenshots/calendar.png",
67
+ "screenshots/checklist.png",
68
+ "screenshots/editbox.png",
69
+ "screenshots/form1.png",
70
+ "screenshots/form2.png",
71
+ "screenshots/form3.png",
72
+ "screenshots/fselect.png",
73
+ "screenshots/gauge.png",
74
+ "screenshots/infobox.png",
75
+ "screenshots/inputbox.png",
76
+ "screenshots/menubox.png",
77
+ "screenshots/mixedform1.png",
78
+ "screenshots/msgbox.png",
79
+ "screenshots/password.png",
80
+ "screenshots/password2.png",
81
+ "screenshots/passwordform.png",
82
+ "screenshots/pause.png",
83
+ "screenshots/prgbox.png",
84
+ "screenshots/program.png",
85
+ "screenshots/progress.png",
86
+ "screenshots/radiolist.png",
87
+ "screenshots/take_shots.rb",
88
+ "screenshots/timebox.png",
89
+ "screenshots/treeview.png",
90
+ "screenshots/treeview2.png",
91
+ "screenshots/yesno.png",
92
+ "test/helper.rb",
93
+ "test/test_mrdialog.rb"
94
+ ]
95
+ s.homepage = "http://github.com/muquit/mrdialog"
96
+ s.licenses = ["MIT"]
97
+ s.rubygems_version = "2.5.2.1"
98
+ s.summary = "A ruby gem for ncurses dialog program, based on the gem rdialog"
99
+
100
+ if s.respond_to? :specification_version then
101
+ s.specification_version = 4
102
+
103
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
104
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
105
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
106
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
107
+ s.add_development_dependency(%q<juwelier>, ["~> 2.0.1"])
108
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
109
+ else
110
+ s.add_dependency(%q<shoulda>, [">= 0"])
111
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
112
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
113
+ s.add_dependency(%q<juwelier>, ["~> 2.0.1"])
114
+ s.add_dependency(%q<simplecov>, [">= 0"])
115
+ end
116
+ else
117
+ s.add_dependency(%q<shoulda>, [">= 0"])
118
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
119
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
120
+ s.add_dependency(%q<juwelier>, ["~> 2.0.1"])
121
+ s.add_dependency(%q<simplecov>, [">= 0"])
122
+ end
123
+ end
124
+
data/pkg/md5.txt CHANGED
@@ -1 +1 @@
1
- 2e4238d8e121adb4b646a299e63d333f mrdialog-1.0.3.gem
1
+ e6497d81db203c5c49dfff90c7870a09 mrdialog-1.0.3.gem
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require [File.expand_path(File.dirname(__FILE__)), '../..', 'lib', 'mrdialog'].join('/')
4
+ require 'pp'
5
+
6
+ begin
7
+ ME = File.basename($0)
8
+ if ENV['CHANGE_TITLE']
9
+ if ME =~ /(.+)\.rb$/
10
+ base = $1
11
+ puts "\033]0;mrdialog - #{base}\007"
12
+ end
13
+ end
14
+ text = <<EOF
15
+ This example is taken from dialog/samples/menulist
16
+ shell script.
17
+
18
+ Hi, this is a buildlist dialog. The list on the left
19
+ shows the unselected items. The list on the right shows
20
+ the selected items. Use SPACE bar to select/unselect
21
+ items. Shadow is set to false.
22
+
23
+ EOF
24
+ items = []
25
+ Struct.new("BuildListData", :tag, :item, :status)
26
+ data = Struct::BuildListData.new
27
+
28
+ data.tag = "1"
29
+ data.item = "Item number 1"
30
+ data.status = true
31
+ items.push(data.to_a)
32
+
33
+ data = Struct::BuildListData.new
34
+ data.tag = "2"
35
+ data.item = "Item number 2"
36
+ data.status = false
37
+ items.push(data.to_a)
38
+
39
+ data = Struct::BuildListData.new
40
+ data.tag = "3"
41
+ data.item = "Item number 3"
42
+ data.status = false
43
+ items.push(data.to_a)
44
+
45
+ data = Struct::BuildListData.new
46
+ data.tag = "4"
47
+ data.item = "Item number 4"
48
+ data.status = true
49
+ items.push(data.to_a)
50
+
51
+ data = Struct::BuildListData.new
52
+ data.tag = "5"
53
+ data.item = "Item number 5"
54
+ data.status = false
55
+ items.push(data.to_a)
56
+
57
+ data = Struct::BuildListData.new
58
+ data.tag = "6"
59
+ data.item = "Item number 6"
60
+ data.status = true
61
+ items.push(data.to_a)
62
+
63
+ dialog = MRDialog.new
64
+ dialog.clear = true
65
+ dialog.shadow = false
66
+ dialog.title = "BUILDLIST"
67
+ dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
68
+ dialog.extra_button = true
69
+ dialog.ok_label = "Send"
70
+ dialog.extra_label = "Archive"
71
+ dialog.cancel_label = "Quit"
72
+
73
+ height = 0
74
+ width = 0
75
+ listheight = 0
76
+
77
+ selected_items = dialog.buildlist(text, items, height, width, listheight)
78
+ exit_code = dialog.exit_code
79
+ puts "Exit code: #{exit_code}"
80
+ puts "Selecetd tags:"
81
+ selected_items.each do |item|
82
+ puts " '#{item}'"
83
+ end
84
+
85
+ rescue => e
86
+ puts "#{$!}"
87
+ t = e.backtrace.join("\n\t")
88
+ puts "Error: #{t}"
89
+ end
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ########################################################################
4
+ # Example for calendar widget.
5
+ # muquit@muquit.com Apr-02-2014
6
+ ########################################################################
7
+ #
8
+ require [File.expand_path(File.dirname(__FILE__)), '../..', 'lib', 'mrdialog'].join('/')
9
+ require 'date'
10
+
11
+ begin
12
+ ME = File.basename($0)
13
+ if ENV['CHANGE_TITLE']
14
+ if ME =~ /(.+)\.rb$/
15
+ base = $1
16
+ puts "\033]0;mrdialog - #{base}\007"
17
+ end
18
+ end
19
+
20
+ text = "Please choose a date..."
21
+
22
+ height = 0
23
+ width = 0
24
+ day = Date.today.mday
25
+ month =Date.today.mon
26
+ year =Date.today.year
27
+
28
+ dialog = MRDialog.new
29
+ dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
30
+ dialog.clear = true
31
+ dialog.title = "CALENDAR"
32
+ dialog.extra_button = true
33
+ dialog.ok_label = "Save"
34
+ dialog.extra_label = "Send"
35
+ dialog.cancel_label = "Quit"
36
+
37
+ date = dialog.calendar(text, height, width, day, month, year)
38
+ puts "Exit code: #{dialog.exit_code}"
39
+ puts "Result is: #{date.to_s}"
40
+
41
+ rescue => e
42
+ puts "#{$!}"
43
+ t = e.backtrace.join("\n\t")
44
+ puts "Error: #{t}"
45
+ end
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require [File.expand_path(File.dirname(__FILE__)), '../..', 'lib', 'mrdialog'].join('/')
4
+ require 'pp'
5
+
6
+ begin
7
+ ME = File.basename($0)
8
+ if ENV['CHANGE_TITLE']
9
+ if ME =~ /(.+)\.rb$/
10
+ base = $1
11
+ puts "\033]0;mrdialog - #{base}\007"
12
+ end
13
+ end
14
+
15
+ text = <<EOF
16
+ This example is taken from dialog/samples/radiolist
17
+ shell script.
18
+
19
+ Hi, this is a radiolist box. You can use this to
20
+ present a list of choices which can be turned on or
21
+ off. If there are more items than can fit on the
22
+ screen, the list will be scrolled. You can use the
23
+ UP/DOWN arrow keys, the first letter of the choice as a
24
+ hot key, or the number keys 1-9 to choose an option.
25
+ Press SPACE to toggle an option on/off. Set the option
26
+ notags to true if you don't want to diaplay the tags.
27
+
28
+ Which of the following are fruits?
29
+
30
+ EOF
31
+ items = []
32
+ checklist_data = Struct.new(:tag, :item, :select)
33
+
34
+ data = checklist_data.new
35
+ data.tag = "Apple"
36
+ data.item = "It's an applie"
37
+ data.select = false
38
+ items.push(data.to_a)
39
+
40
+ data = checklist_data.new
41
+ data.tag = "Dog"
42
+ data.item = "No it's not my dog"
43
+ data.select = true
44
+ items.push(data.to_a)
45
+
46
+ data = checklist_data.new
47
+ data.tag = "Orange"
48
+ data.item = "Yeah! it is juicy"
49
+ data.select = false
50
+ items.push(data.to_a)
51
+
52
+ data = checklist_data.new
53
+ data.tag = "Chicken"
54
+ data.item = "Normally not a pet"
55
+ data.select = true
56
+ items.push(data.to_a)
57
+
58
+ dialog = MRDialog.new
59
+ # dialog.notags = false
60
+ # dialog.dialog_options = "--no-tags"
61
+ dialog.clear = true
62
+ dialog.title = "CHECKLIST"
63
+ dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
64
+ dialog.extra_button = true
65
+ dialog.ok_label = "Send"
66
+ dialog.extra_label = "Save"
67
+ dialog.cancel_label = "Quit"
68
+
69
+ selected_items = dialog.checklist(text, items)
70
+ exit_code = dialog.exit_code
71
+ puts selected_items.class
72
+ puts "Exit code: #{exit_code}"
73
+ if selected_items
74
+ puts "Selected Items:"
75
+ selected_items.each do |item|
76
+ puts " '#{item}'"
77
+ end
78
+ end
79
+
80
+ rescue => e
81
+ puts "#{$!}"
82
+ t = e.backtrace.join("\n\t")
83
+ puts "Error: #{t}"
84
+ end