mrdialog 1.0.1 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/ChangeLog.md +68 -23
- data/Gemfile +3 -2
- data/LICENSE.txt +1 -1
- data/README.md +196 -0
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/lib/mrdialog/mrdialog.rb +261 -178
- data/mrdialog.gemspec +124 -0
- data/pkg/md5.txt +1 -0
- data/samples/buildlist.rb +9 -1
- data/samples/calendar.rb +7 -0
- data/samples/checklist.rb +17 -4
- data/samples/editbox.rb +7 -0
- data/samples/extra_button/buildlist.rb +89 -0
- data/samples/extra_button/calendar.rb +45 -0
- data/samples/extra_button/checklist.rb +84 -0
- data/samples/extra_button/form1.rb +101 -0
- data/samples/extra_button/fselect.rb +36 -0
- data/samples/extra_button/inputbox.rb +48 -0
- data/samples/extra_button/menubox.rb +85 -0
- data/samples/extra_button/password.rb +44 -0
- data/samples/extra_button/radiolist.rb +86 -0
- data/samples/extra_button/timebox.rb +43 -0
- data/samples/extra_button/treeview.rb +112 -0
- data/samples/form1.rb +8 -2
- data/samples/form2.rb +7 -0
- data/samples/form3.rb +7 -1
- data/samples/fselect.rb +7 -0
- data/samples/gauge.rb +7 -0
- data/samples/infobox.rb +7 -0
- data/samples/inputbox.rb +7 -0
- data/samples/menubox.rb +7 -0
- data/samples/mixedform1.rb +7 -2
- data/samples/msgbox.rb +7 -0
- data/samples/password.rb +7 -0
- data/samples/password2.rb +7 -0
- data/samples/passwordform.rb +8 -2
- data/samples/pause.rb +7 -0
- data/samples/prgbox.rb +7 -0
- data/samples/program.rb +7 -0
- data/samples/progress.rb +7 -0
- data/samples/radiolist.rb +8 -0
- data/samples/run_all.rb +52 -0
- data/samples/timebox.rb +7 -0
- data/samples/treeview.rb +7 -0
- data/samples/treeview2.rb +7 -0
- data/samples/yesno.rb +7 -0
- data/screenshots/README.txt +10 -0
- data/screenshots/all.gif +0 -0
- data/screenshots/buildlist.png +0 -0
- data/screenshots/calendar.png +0 -0
- data/screenshots/checklist.png +0 -0
- data/screenshots/editbox.png +0 -0
- data/screenshots/form1.png +0 -0
- data/screenshots/form2.png +0 -0
- data/screenshots/form3.png +0 -0
- data/screenshots/fselect.png +0 -0
- data/screenshots/gauge.png +0 -0
- data/screenshots/infobox.png +0 -0
- data/screenshots/inputbox.png +0 -0
- data/screenshots/menubox.png +0 -0
- data/screenshots/mixedform1.png +0 -0
- data/screenshots/msgbox.png +0 -0
- data/screenshots/password.png +0 -0
- data/screenshots/password2.png +0 -0
- data/screenshots/passwordform.png +0 -0
- data/screenshots/pause.png +0 -0
- data/screenshots/prgbox.png +0 -0
- data/screenshots/program.png +0 -0
- data/screenshots/progress.png +0 -0
- data/screenshots/radiolist.png +0 -0
- data/screenshots/take_shots.rb +111 -0
- data/screenshots/timebox.png +0 -0
- data/screenshots/treeview.png +0 -0
- data/screenshots/treeview2.png +0 -0
- data/screenshots/yesno.png +0 -0
- metadata +83 -29
- data/Gemfile.lock +0 -82
- data/README.rdoc +0 -52
- data/pkg/mrdialog-1.0.1.gem +0 -0
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
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
e6497d81db203c5c49dfff90c7870a09 mrdialog-1.0.3.gem
|
data/samples/buildlist.rb
CHANGED
@@ -5,6 +5,12 @@ require 'pp'
|
|
5
5
|
|
6
6
|
begin
|
7
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
|
8
14
|
text = <<EOF
|
9
15
|
This example is taken from dialog/samples/menulist
|
10
16
|
shell script.
|
@@ -12,7 +18,7 @@ shell script.
|
|
12
18
|
Hi, this is a buildlist dialog. The list on the left
|
13
19
|
shows the unselected items. The list on the right shows
|
14
20
|
the selected items. Use SPACE bar to select/unselect
|
15
|
-
items.
|
21
|
+
items. Shadow is set to false.
|
16
22
|
|
17
23
|
EOF
|
18
24
|
items = []
|
@@ -56,6 +62,8 @@ EOF
|
|
56
62
|
|
57
63
|
dialog = MRDialog.new
|
58
64
|
dialog.clear = true
|
65
|
+
dialog.shadow = false
|
66
|
+
dialog.title = "BUILDLIST"
|
59
67
|
dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
|
60
68
|
|
61
69
|
height = 0
|
data/samples/calendar.rb
CHANGED
data/samples/checklist.rb
CHANGED
@@ -5,6 +5,13 @@ require 'pp'
|
|
5
5
|
|
6
6
|
begin
|
7
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
|
+
|
8
15
|
text = <<EOF
|
9
16
|
This example is taken from dialog/samples/radiolist
|
10
17
|
shell script.
|
@@ -15,7 +22,8 @@ off. If there are more items than can fit on the
|
|
15
22
|
screen, the list will be scrolled. You can use the
|
16
23
|
UP/DOWN arrow keys, the first letter of the choice as a
|
17
24
|
hot key, or the number keys 1-9 to choose an option.
|
18
|
-
Press SPACE to toggle an option on/off.
|
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.
|
19
27
|
|
20
28
|
Which of the following are fruits?
|
21
29
|
|
@@ -48,16 +56,21 @@ EOF
|
|
48
56
|
items.push(data.to_a)
|
49
57
|
|
50
58
|
dialog = MRDialog.new
|
59
|
+
# dialog.notags = false
|
60
|
+
# dialog.dialog_options = "--no-tags"
|
51
61
|
dialog.clear = true
|
62
|
+
dialog.title = "CHECKLIST"
|
52
63
|
dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
|
53
64
|
|
54
65
|
selected_items = dialog.checklist(text, items)
|
55
66
|
exit_code = dialog.exit_code
|
56
67
|
puts selected_items.class
|
57
68
|
puts "Exit code: #{exit_code}"
|
58
|
-
|
59
|
-
|
60
|
-
|
69
|
+
if selected_items
|
70
|
+
puts "Selected Items:"
|
71
|
+
selected_items.each do |item|
|
72
|
+
puts " '#{item}'"
|
73
|
+
end
|
61
74
|
end
|
62
75
|
|
63
76
|
rescue => e
|
data/samples/editbox.rb
CHANGED
@@ -6,6 +6,12 @@ require 'tempfile'
|
|
6
6
|
|
7
7
|
begin
|
8
8
|
ME = File.basename($0)
|
9
|
+
if ENV['CHANGE_TITLE']
|
10
|
+
if ME =~ /(.+)\.rb$/
|
11
|
+
base = $1
|
12
|
+
puts "\033]0;mrdialog - #{base}\007"
|
13
|
+
end
|
14
|
+
end
|
9
15
|
|
10
16
|
tmp = Tempfile.new('editbox')
|
11
17
|
tmp.puts <<-EOF
|
@@ -45,6 +51,7 @@ EOF
|
|
45
51
|
dialog = MRDialog.new
|
46
52
|
dialog.clear = true
|
47
53
|
dialog.shadow = false
|
54
|
+
dialog.title = "EDITBOX"
|
48
55
|
dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
|
49
56
|
|
50
57
|
output = dialog.editbox(tmp.path, height, width)
|
@@ -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
|
@@ -0,0 +1,101 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# muquit@muquit.com Apr-01-2014
|
4
|
+
require [File.expand_path(File.dirname(__FILE__)), '../..', 'lib', 'mrdialog'].join('/')
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
begin
|
8
|
+
ME = File.basename($0)
|
9
|
+
if ENV['CHANGE_TITLE']
|
10
|
+
if ME =~ /(.+)\.rb$/
|
11
|
+
base = $1
|
12
|
+
puts "\033]0;mrdialog - #{base}\007"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
user = ''
|
17
|
+
uid = ''
|
18
|
+
gid = ''
|
19
|
+
home = ENV["HOME"]
|
20
|
+
|
21
|
+
id = `id`.chomp
|
22
|
+
if id =~ /^uid=(\d+)\((.+)\)\sgid=(\d+)\(.*$/
|
23
|
+
uid = $1
|
24
|
+
user = $2
|
25
|
+
gid = $3
|
26
|
+
end
|
27
|
+
|
28
|
+
dialog = MRDialog.new
|
29
|
+
dialog.clear = true
|
30
|
+
dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
|
31
|
+
|
32
|
+
text = <<EOF
|
33
|
+
Here is a possible piece of a configuration program.
|
34
|
+
EOF
|
35
|
+
items = []
|
36
|
+
form_data = Struct.new(:label, :ly, :lx, :item, :iy, :ix, :flen, :ilen)
|
37
|
+
|
38
|
+
data = form_data.new
|
39
|
+
data.label = "Username:"
|
40
|
+
data.ly = 1
|
41
|
+
data.lx = 1
|
42
|
+
data.item = user
|
43
|
+
data.iy = 1
|
44
|
+
data.ix = 10
|
45
|
+
data.flen = user.length + 10
|
46
|
+
data.ilen = 0
|
47
|
+
items.push(data.to_a)
|
48
|
+
|
49
|
+
data = form_data.new
|
50
|
+
data.label = "UID:"
|
51
|
+
data.ly = 2
|
52
|
+
data.lx = 1
|
53
|
+
data.item = uid.to_s
|
54
|
+
data.iy = 2
|
55
|
+
data.ix = 10
|
56
|
+
data.flen = uid.length + 10
|
57
|
+
data.ilen = 0
|
58
|
+
items.push(data.to_a)
|
59
|
+
|
60
|
+
data = form_data.new
|
61
|
+
data.label = "GID:"
|
62
|
+
data.ly = 3
|
63
|
+
data.lx = 1
|
64
|
+
data.item = gid.to_s
|
65
|
+
data.iy =3
|
66
|
+
data.ix = 10
|
67
|
+
data.flen = gid.length + 2
|
68
|
+
data.ilen = 0
|
69
|
+
items.push(data.to_a)
|
70
|
+
|
71
|
+
data = form_data.new
|
72
|
+
data.label = "HOME:"
|
73
|
+
data.ly = 4
|
74
|
+
data.lx = 1
|
75
|
+
data.item = home
|
76
|
+
data.iy = 4
|
77
|
+
data.ix = 10
|
78
|
+
data.flen = home.length + 40
|
79
|
+
data.ilen = 0
|
80
|
+
items.push(data.to_a)
|
81
|
+
|
82
|
+
dialog.title = "FORM"
|
83
|
+
dialog.extra_button = true
|
84
|
+
dialog.ok_label = "Save"
|
85
|
+
dialog.extra_label = "Submit"
|
86
|
+
dialog.cancel_label = "Quit"
|
87
|
+
|
88
|
+
result_hash = dialog.form(text, items, 20, 50, 0)
|
89
|
+
if result_hash
|
90
|
+
puts "Resulting data:"
|
91
|
+
result_hash.each do |key, val|
|
92
|
+
puts " #{key} = #{val}"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
rescue => e
|
98
|
+
puts "#{$!}"
|
99
|
+
t = e.backtrace.join("\n\t")
|
100
|
+
puts "Error: #{t}"
|
101
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# muquit@muquit.com Apr-01-2014
|
4
|
+
require [File.expand_path(File.dirname(__FILE__)), '../..', 'lib', 'mrdialog'].join('/')
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
begin
|
8
|
+
ME = File.basename($0)
|
9
|
+
if ENV['CHANGE_TITLE']
|
10
|
+
if ME =~ /(.+)\.rb$/
|
11
|
+
base = $1
|
12
|
+
puts "\033]0;mrdialog - #{base}\007"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
dialog = MRDialog.new
|
17
|
+
dialog.clear = true
|
18
|
+
dialog.title = "Please choose a file"
|
19
|
+
dialog.extra_button = true
|
20
|
+
dialog.ok_label = "Copy"
|
21
|
+
dialog.extra_label = "Delete"
|
22
|
+
dialog.cancel_label = "Quit"
|
23
|
+
|
24
|
+
h = 14
|
25
|
+
w = 48
|
26
|
+
file_path = ENV["HOME"] + "/"
|
27
|
+
file = dialog.fselect(file_path, h, w)
|
28
|
+
|
29
|
+
puts "Exit code: #{dialog.exit_code}"
|
30
|
+
puts "Result is: #{file}"
|
31
|
+
|
32
|
+
rescue => e
|
33
|
+
puts "#{$!}"
|
34
|
+
t = e.backtrace.join("\n\t")
|
35
|
+
puts "Error: #{t}"
|
36
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# muquit@muquit.com Apr-01-2014
|
4
|
+
require [File.expand_path(File.dirname(__FILE__)), '../..', 'lib', 'mrdialog'].join('/')
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
begin
|
8
|
+
ME = File.basename($0)
|
9
|
+
if ENV['CHANGE_TITLE']
|
10
|
+
if ME =~ /(.+)\.rb$/
|
11
|
+
base = $1
|
12
|
+
puts "\033]0;mrdialog - #{base}\007"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
text = <<EOF
|
17
|
+
Hi, this is an input dialog box. You can use
|
18
|
+
this to ask questions that require the user
|
19
|
+
to input a string as the answer. You can
|
20
|
+
input strings of length longer than the
|
21
|
+
width of the input box, in that case, the
|
22
|
+
input field will be automatically scrolled.
|
23
|
+
You can use BACKSPACE to correct errors.
|
24
|
+
Try entering your name below:
|
25
|
+
|
26
|
+
EOF
|
27
|
+
dialog = MRDialog.new
|
28
|
+
dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
|
29
|
+
dialog.clear = true
|
30
|
+
dialog.title = "INPUT BOX"
|
31
|
+
dialog.extra_button = true
|
32
|
+
dialog.ok_label = "Send"
|
33
|
+
dialog.extra_label = "Save"
|
34
|
+
dialog.cancel_label = "Quit"
|
35
|
+
|
36
|
+
height = 16
|
37
|
+
width = 51
|
38
|
+
init = "blah"
|
39
|
+
result = dialog.inputbox(text, height, width, init)
|
40
|
+
|
41
|
+
puts "Exit Code: #{dialog.exit_code}"
|
42
|
+
puts "Result is: #{result}"
|
43
|
+
|
44
|
+
rescue => e
|
45
|
+
puts "#{$!}"
|
46
|
+
t = e.backtrace.join("\n\t")
|
47
|
+
puts "Error: #{t}"
|
48
|
+
end
|