-
Notifications
You must be signed in to change notification settings - Fork 8
/
buildlist.rb
executable file
·89 lines (75 loc) · 2.11 KB
/
buildlist.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env ruby
require [File.expand_path(File.dirname(__FILE__)), '../..', 'lib', 'mrdialog'].join('/')
require 'pp'
begin
ME = File.basename($0)
if ENV['CHANGE_TITLE']
if ME =~ /(.+)\.rb$/
base = $1
puts "\033]0;mrdialog - #{base}\007"
end
end
text = <<EOF
This example is taken from dialog/samples/menulist
shell script.
Hi, this is a buildlist dialog. The list on the left
shows the unselected items. The list on the right shows
the selected items. Use SPACE bar to select/unselect
items. Shadow is set to false.
EOF
items = []
Struct.new("BuildListData", :tag, :item, :status)
data = Struct::BuildListData.new
data.tag = "1"
data.item = "Item number 1"
data.status = true
items.push(data.to_a)
data = Struct::BuildListData.new
data.tag = "2"
data.item = "Item number 2"
data.status = false
items.push(data.to_a)
data = Struct::BuildListData.new
data.tag = "3"
data.item = "Item number 3"
data.status = false
items.push(data.to_a)
data = Struct::BuildListData.new
data.tag = "4"
data.item = "Item number 4"
data.status = true
items.push(data.to_a)
data = Struct::BuildListData.new
data.tag = "5"
data.item = "Item number 5"
data.status = false
items.push(data.to_a)
data = Struct::BuildListData.new
data.tag = "6"
data.item = "Item number 6"
data.status = true
items.push(data.to_a)
dialog = MRDialog.new
dialog.clear = true
dialog.shadow = false
dialog.title = "BUILDLIST"
dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
dialog.extra_button = true
dialog.ok_label = "Send"
dialog.extra_label = "Archive"
dialog.cancel_label = "Quit"
height = 0
width = 0
listheight = 0
selected_items = dialog.buildlist(text, items, height, width, listheight)
exit_code = dialog.exit_code
puts "Exit code: #{exit_code}"
puts "Selecetd tags:"
selected_items.each do |item|
puts " '#{item}'"
end
rescue => e
puts "#{$!}"
t = e.backtrace.join("\n\t")
puts "Error: #{t}"
end