mrdialog 1.0.1 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- 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/lib/mrdialog/mrdialog.rb
CHANGED
@@ -39,6 +39,9 @@ class MRDialog
|
|
39
39
|
# All accessors are boolean unless otherwise noted.
|
40
40
|
#
|
41
41
|
|
42
|
+
# Specify the rc file to use for dialog. Default is $HOME/.dialogrc
|
43
|
+
attr_accessor :rc_file
|
44
|
+
|
42
45
|
#
|
43
46
|
# This gives you some control over the box dimensions when
|
44
47
|
# using auto sizing (specifying 0 for height and width).
|
@@ -94,6 +97,9 @@ class MRDialog
|
|
94
97
|
#
|
95
98
|
attr_accessor :shadow
|
96
99
|
|
100
|
+
# MMM
|
101
|
+
attr_accessor :notags
|
102
|
+
|
97
103
|
#
|
98
104
|
# Sleep (delay) for the given integer of seconds after processing
|
99
105
|
# a dialog box.
|
@@ -129,9 +135,12 @@ class MRDialog
|
|
129
135
|
attr_accessor :dialog_ok
|
130
136
|
attr_accessor :dialog_cancel
|
131
137
|
attr_accessor :dialog_help
|
132
|
-
attr_accessor :dialog_extra
|
133
138
|
attr_accessor :dialog_item_help
|
134
139
|
attr_accessor :dialog_esc
|
140
|
+
attr_accessor :dialog_extra
|
141
|
+
|
142
|
+
# pass dialog's option exactly
|
143
|
+
attr_accessor :dialog_options
|
135
144
|
|
136
145
|
#
|
137
146
|
# ruby logger
|
@@ -140,6 +149,27 @@ class MRDialog
|
|
140
149
|
# Override the label used for "OK" buttons
|
141
150
|
attr_accessor :ok_label
|
142
151
|
|
152
|
+
# Override the label used for "Cancel" buttons
|
153
|
+
attr_accessor :cancel_label
|
154
|
+
|
155
|
+
# Override the label used for "Yes" buttons
|
156
|
+
attr_accessor :yes_label
|
157
|
+
|
158
|
+
# Override the label used for "No" buttons
|
159
|
+
attr_accessor :no_label
|
160
|
+
|
161
|
+
# Add a "Help" button
|
162
|
+
attr_accessor :help_button
|
163
|
+
|
164
|
+
# Override the label used for the "Help" button
|
165
|
+
attr_accessor :help_label
|
166
|
+
|
167
|
+
# Add an "Extra" button
|
168
|
+
attr_accessor :extra_button
|
169
|
+
|
170
|
+
# Override the label used for the "Extra" button
|
171
|
+
attr_accessor :extra_label
|
172
|
+
|
143
173
|
# clear screen
|
144
174
|
attr_accessor :clear
|
145
175
|
|
@@ -166,6 +196,7 @@ class MRDialog
|
|
166
196
|
# muquit@muquit.com mod starts--
|
167
197
|
$stdout.sync = true
|
168
198
|
$stderr.sync = true
|
199
|
+
# @tags = true
|
169
200
|
@dialog_ok = DIALOG_OK
|
170
201
|
@dialog_cancel = DIALOG_CANCEL
|
171
202
|
@dialog_help = DIALOG_HELP
|
@@ -411,11 +442,12 @@ class MRDialog
|
|
411
442
|
@exit_code = $?.exitstatus
|
412
443
|
log_debug "Exit code: #{exit_code}"
|
413
444
|
tag = ''
|
414
|
-
if @exit_code
|
445
|
+
if @exit_code != 1
|
415
446
|
tag = tmp.read
|
416
447
|
end
|
417
|
-
tmp.close!
|
418
448
|
return tag
|
449
|
+
ensure
|
450
|
+
tmp.close!
|
419
451
|
end
|
420
452
|
|
421
453
|
#
|
@@ -494,7 +526,7 @@ class MRDialog
|
|
494
526
|
system(cmd)
|
495
527
|
@exit_code = $?.exitstatus
|
496
528
|
log_debug "Exit code: #{exit_code}"
|
497
|
-
if @exit_code
|
529
|
+
if @exit_code != 1
|
498
530
|
lines = tmp.read
|
499
531
|
log_debug "lines: #{lines} #{lines.class}"
|
500
532
|
sep = Shellwords.escape(@separator)
|
@@ -504,8 +536,9 @@ class MRDialog
|
|
504
536
|
selected_tags << tag if tag.to_s.length > 0
|
505
537
|
end
|
506
538
|
end
|
507
|
-
tmp.close!
|
508
539
|
return selected_tags
|
540
|
+
ensure
|
541
|
+
tmp.close!
|
509
542
|
end
|
510
543
|
|
511
544
|
# A pause box displays a meter along the bottom of the box. The
|
@@ -573,8 +606,9 @@ class MRDialog
|
|
573
606
|
if @exit_code == 0
|
574
607
|
result = tmp.read
|
575
608
|
end
|
576
|
-
tmp.close!
|
577
609
|
return result
|
610
|
+
ensure
|
611
|
+
tmp.close!
|
578
612
|
end
|
579
613
|
|
580
614
|
#
|
@@ -662,7 +696,7 @@ class MRDialog
|
|
662
696
|
@exit_code = $?.exitstatus
|
663
697
|
log_debug "Exit code: #{exit_code}"
|
664
698
|
|
665
|
-
if @exit_code
|
699
|
+
if @exit_code != 1
|
666
700
|
lines = tmp.readlines
|
667
701
|
lines.each_with_index do |val, idx|
|
668
702
|
key = items[idx][0]
|
@@ -670,8 +704,9 @@ class MRDialog
|
|
670
704
|
end
|
671
705
|
end
|
672
706
|
|
673
|
-
tmp.close!
|
674
707
|
return res_hash
|
708
|
+
ensure
|
709
|
+
tmp.close!
|
675
710
|
end
|
676
711
|
|
677
712
|
#
|
@@ -722,15 +757,15 @@ class MRDialog
|
|
722
757
|
day.to_i.to_s + " " + month.to_i.to_s + " " + year.to_i.to_s +
|
723
758
|
" 2> " + tmp.path
|
724
759
|
success = system(command)
|
725
|
-
|
760
|
+
@exit_code = $?.exitstatus
|
761
|
+
if @exit_code != 1
|
726
762
|
date = Date::civil(*tmp.readline.split('/').collect {|i| i.to_i}.reverse)
|
727
|
-
tmp.close!
|
728
763
|
return date
|
729
764
|
else
|
730
|
-
tmp.close!
|
731
765
|
return success
|
732
766
|
end
|
733
|
-
|
767
|
+
ensure
|
768
|
+
tmp.close!
|
734
769
|
end
|
735
770
|
|
736
771
|
# A checklist box is similar to a menu box; there are multiple
|
@@ -766,10 +801,10 @@ class MRDialog
|
|
766
801
|
tmp.path
|
767
802
|
log_debug "Command:\n#{command}"
|
768
803
|
success = system(command)
|
769
|
-
|
770
|
-
|
804
|
+
@exit_code = $?.exitstatus
|
805
|
+
selected_array = []
|
806
|
+
if @exit_code != 1
|
771
807
|
selected_string = tmp.readline
|
772
|
-
tmp.close!
|
773
808
|
log_debug "Separator: #{@separator}"
|
774
809
|
|
775
810
|
sep = Shellwords.escape(@separator)
|
@@ -780,10 +815,10 @@ class MRDialog
|
|
780
815
|
end
|
781
816
|
return selected_array
|
782
817
|
else
|
783
|
-
tmp.close!
|
784
818
|
return success
|
785
819
|
end
|
786
|
-
|
820
|
+
ensure
|
821
|
+
tmp.close!
|
787
822
|
end
|
788
823
|
|
789
824
|
# The file-selection dialog displays a text-entry window in which
|
@@ -807,27 +842,28 @@ class MRDialog
|
|
807
842
|
# value in the text-entry window and exit.
|
808
843
|
|
809
844
|
def fselect(path, height=0, width=0)
|
810
|
-
|
845
|
+
tmp = Tempfile.new('tmp')
|
811
846
|
|
812
|
-
|
813
|
-
|
847
|
+
command = option_string() + "--fselect \"" + path.to_s +
|
848
|
+
"\" " + height.to_i.to_s + " " + width.to_i.to_s + " "
|
849
|
+
|
850
|
+
command += "2> " + tmp.path
|
814
851
|
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
end
|
852
|
+
success = system(command)
|
853
|
+
@exit_code = $?.exitstatus
|
854
|
+
|
855
|
+
if @exit_code != 1
|
856
|
+
begin
|
857
|
+
selected_string = tmp.readline
|
858
|
+
rescue EOFError
|
859
|
+
selected_string = ""
|
860
|
+
end
|
861
|
+
return selected_string
|
862
|
+
else
|
863
|
+
return success
|
864
|
+
end
|
865
|
+
ensure
|
866
|
+
tmp.close!
|
831
867
|
end
|
832
868
|
|
833
869
|
|
@@ -845,49 +881,49 @@ class MRDialog
|
|
845
881
|
command = option_string() + "--infobox \"" + text.to_s +
|
846
882
|
"\" " + height.to_i.to_s + " " + width.to_i.to_s + " "
|
847
883
|
success = system(command)
|
884
|
+
@exit_code = $?.exitstatus
|
848
885
|
return success
|
849
886
|
end
|
850
887
|
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
def radiolist(text, items, height=0, width=0, listheight=0)
|
888
|
+
# A radiolist box is similar to a menu box. The only difference
|
889
|
+
# is that you can indicate which entry is currently selected, by
|
890
|
+
# setting its status to true.
|
891
|
+
def radiolist(text, items, height=0, width=0, listheight=0)
|
856
892
|
|
857
|
-
|
893
|
+
tmp = Tempfile.new('tmp')
|
858
894
|
|
859
|
-
|
895
|
+
itemlist = String.new
|
860
896
|
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
897
|
+
for item in items
|
898
|
+
if item[2]
|
899
|
+
item[2] = "on"
|
900
|
+
else
|
901
|
+
item[2] = "off"
|
902
|
+
end
|
903
|
+
itemlist += "\"" + item[0].to_s + "\" \"" + item[1].to_s +
|
904
|
+
"\" " + item[2] + " "
|
869
905
|
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
906
|
+
if @itemhelp
|
907
|
+
itemlist += "\"" + item[3].to_s + "\" "
|
908
|
+
end
|
909
|
+
end
|
874
910
|
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
if success
|
883
|
-
selected_string = tmp.readline
|
884
|
-
tmp.close!
|
885
|
-
return selected_string
|
886
|
-
else
|
887
|
-
tmp.close!
|
888
|
-
return success
|
889
|
-
end
|
911
|
+
command = option_string() + "--radiolist \"" + text.to_s +
|
912
|
+
"\" " + height.to_i.to_s + " " + width.to_i.to_s +
|
913
|
+
" " + listheight.to_i.to_s + " " + itemlist + "2> " +
|
914
|
+
tmp.path
|
915
|
+
log_debug("Command:\n#{command}")
|
916
|
+
success = system(command)
|
917
|
+
@exit_code = $?.exitstatus
|
890
918
|
|
919
|
+
if @exit_code != 1
|
920
|
+
selected_string = tmp.readline
|
921
|
+
return selected_string
|
922
|
+
else
|
923
|
+
return success
|
924
|
+
end
|
925
|
+
ensure
|
926
|
+
tmp.close!
|
891
927
|
end
|
892
928
|
|
893
929
|
# As its name suggests, a menu box is a dialog box that can be
|
@@ -905,43 +941,43 @@ class MRDialog
|
|
905
941
|
# Returns a string containing the tag of the chosen menu entry.
|
906
942
|
|
907
943
|
def menu(text="Text Goes Here", items=nil, height=0, width=0, listheight=0)
|
908
|
-
|
944
|
+
tmp = Tempfile.new('tmp')
|
909
945
|
|
910
|
-
|
946
|
+
itemlist = String.new
|
947
|
+
|
948
|
+
for item in items
|
949
|
+
itemlist += "\"" + item[0].to_s + "\" \"" + item[1].to_s + "\" "
|
950
|
+
|
951
|
+
if @itemhelp
|
952
|
+
itemlist += "\"" + item[2].to_s + "\" "
|
953
|
+
end
|
954
|
+
end
|
911
955
|
|
912
|
-
|
913
|
-
|
956
|
+
command = option_string() + "--menu \"" + text.to_s +
|
957
|
+
"\" " + height.to_i.to_s + " " + width.to_i.to_s +
|
958
|
+
" " + listheight.to_i.to_s + " " + itemlist + "2> " +
|
959
|
+
tmp.path
|
914
960
|
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
end
|
961
|
+
log_debug("Command:\n#{command}")
|
962
|
+
success = system(command)
|
963
|
+
@exit_code = $?.exitstatus
|
919
964
|
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
if success
|
929
|
-
selected_string = tmp.readline
|
930
|
-
tmp.close!
|
931
|
-
return selected_string
|
932
|
-
else
|
933
|
-
tmp.close!
|
934
|
-
return success
|
935
|
-
end
|
936
|
-
|
965
|
+
if @exit_code != 1
|
966
|
+
selected_string = tmp.readline
|
967
|
+
return selected_string
|
968
|
+
else
|
969
|
+
return success
|
970
|
+
end
|
971
|
+
ensure
|
972
|
+
tmp.close!
|
937
973
|
end
|
938
974
|
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
975
|
+
# A message box is very similar to a yes/no box. The only dif-
|
976
|
+
# ference between a message box and a yes/no box is that a mes-
|
977
|
+
# sage box has only a single OK button. You can use this dialog
|
978
|
+
# box to display any message you like. After reading the mes-
|
979
|
+
# sage, the user can press the ENTER key so that dialog will exit
|
980
|
+
# and the calling shell script can continue its operation.
|
945
981
|
|
946
982
|
def msgbox(text="Text Goes Here", height=0, width=0)
|
947
983
|
command = option_string() + "--msgbox \"" + text.to_s +
|
@@ -949,44 +985,46 @@ class MRDialog
|
|
949
985
|
|
950
986
|
log_debug "Command\n#{command}"
|
951
987
|
success = system(command)
|
988
|
+
@exit_code = $?.exitstatus
|
952
989
|
return success
|
953
990
|
end
|
954
991
|
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
992
|
+
# A password box is similar to an input box, except that the text
|
993
|
+
# the user enters is not displayed. This is useful when prompt-
|
994
|
+
# ing for passwords or other sensitive information. Be aware
|
995
|
+
# that if anything is passed in "init", it will be visible in the
|
996
|
+
# system's process table to casual snoopers. Also, it is very
|
997
|
+
# confusing to the user to provide them with a default password
|
998
|
+
# they cannot see. For these reasons, using "init" is highly
|
999
|
+
# discouraged.
|
963
1000
|
|
964
1001
|
def passwordbox(text="Please enter some text", height=0, width=0, init="")
|
965
|
-
|
966
|
-
|
967
|
-
|
1002
|
+
tmp = Tempfile.new('tmp')
|
1003
|
+
command = option_string() + "--passwordbox \"" + text.to_s +
|
1004
|
+
"\" " + height.to_i.to_s + " " + width.to_i.to_s + " "
|
968
1005
|
|
969
|
-
|
970
|
-
|
971
|
-
|
1006
|
+
unless init.empty?
|
1007
|
+
command += init.to_s + " "
|
1008
|
+
end
|
972
1009
|
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
tmp.close!
|
984
|
-
return selected_string
|
985
|
-
else
|
986
|
-
tmp.close!
|
987
|
-
return success
|
1010
|
+
command += "2> " + tmp.path
|
1011
|
+
log_debug(command)
|
1012
|
+
success = system(command)
|
1013
|
+
@exit_code = $?.exitstatus
|
1014
|
+
|
1015
|
+
if @exit_code != 1
|
1016
|
+
begin
|
1017
|
+
selected_string = tmp.readline
|
1018
|
+
rescue EOFError
|
1019
|
+
selected_string = ""
|
988
1020
|
end
|
989
|
-
|
1021
|
+
return selected_string
|
1022
|
+
else
|
1023
|
+
return success
|
1024
|
+
end
|
1025
|
+
ensure
|
1026
|
+
tmp.close!
|
1027
|
+
end
|
990
1028
|
|
991
1029
|
# The textbox method handles three similar dialog functions, textbox,
|
992
1030
|
# tailbox, and tailboxbg. They are activated by setting type to
|
@@ -1030,38 +1068,39 @@ class MRDialog
|
|
1030
1068
|
"\" " + height.to_i.to_s + " " + width.to_i.to_s + " "
|
1031
1069
|
|
1032
1070
|
success = system(command)
|
1071
|
+
@exit_code = $?.exitstatus
|
1033
1072
|
|
1034
1073
|
return success
|
1035
1074
|
end
|
1036
1075
|
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1076
|
+
# A dialog is displayed which allows you to select hour, minute
|
1077
|
+
# and second. If the values for hour, minute or second are miss-
|
1078
|
+
# ing or negative, the current date's corresponding values are
|
1079
|
+
# used. You can increment or decrement any of those using the
|
1080
|
+
# left-, up-, right- and down-arrows. Use tab or backtab to move
|
1081
|
+
# between windows.
|
1082
|
+
#
|
1083
|
+
# On exit, a Time object is returned.
|
1045
1084
|
|
1046
1085
|
##- def timebox(file, type="text", height=0, width=0, time=Time.now)
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1086
|
+
def timebox(text, height=0, width=0, time=Time.now)
|
1087
|
+
tmp = Tempfile.new('tmp')
|
1088
|
+
|
1089
|
+
command = option_string() + "--timebox \"" + text.to_s +
|
1090
|
+
"\" " + height.to_i.to_s + " " + width.to_i.to_s + " " +
|
1091
|
+
time.hour.to_s + " " + time.min.to_s + " " +
|
1092
|
+
time.sec.to_s + " 2> " + tmp.path
|
1093
|
+
log_debug("Command:\n#{command}")
|
1094
|
+
success = system(command)
|
1095
|
+
@exit_code = $?.exitstatus
|
1096
|
+
if @exit_code != 1
|
1097
|
+
time = Time.parse(tmp.readline)
|
1098
|
+
return time
|
1099
|
+
else
|
1100
|
+
return success
|
1101
|
+
end
|
1102
|
+
ensure
|
1103
|
+
tmp.close!
|
1065
1104
|
end
|
1066
1105
|
|
1067
1106
|
# An input box is useful when you want to ask questions that
|
@@ -1077,7 +1116,7 @@ class MRDialog
|
|
1077
1116
|
tmp = Tempfile.new('tmp')
|
1078
1117
|
|
1079
1118
|
command = option_string() + "--inputbox \"" + text.to_s +
|
1080
|
-
|
1119
|
+
"\" " + height.to_i.to_s + " " + width.to_i.to_s + " "
|
1081
1120
|
|
1082
1121
|
unless init.empty?
|
1083
1122
|
command += init.to_s + " "
|
@@ -1086,32 +1125,33 @@ class MRDialog
|
|
1086
1125
|
command += "2> " + tmp.path
|
1087
1126
|
|
1088
1127
|
log_debug(command)
|
1089
|
-
|
1128
|
+
success = system(command)
|
1129
|
+
@exit_code = $?.exitstatus
|
1090
1130
|
|
1091
|
-
|
1131
|
+
if @exit_code != 1
|
1092
1132
|
begin
|
1093
|
-
|
1133
|
+
selected_string = tmp.readline
|
1094
1134
|
rescue EOFError
|
1095
1135
|
selected_string = ""
|
1096
1136
|
end
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1137
|
+
return selected_string
|
1138
|
+
else
|
1139
|
+
return success
|
1140
|
+
end
|
1141
|
+
ensure
|
1142
|
+
tmp.close!
|
1103
1143
|
end
|
1104
1144
|
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1145
|
+
# A yes/no dialog box of size height rows by width columns will
|
1146
|
+
# be displayed. The string specified by text is displayed inside
|
1147
|
+
# the dialog box. If this string is too long to fit in one line,
|
1148
|
+
# it will be automatically divided into multiple lines at appro-
|
1149
|
+
# priate places. The text string can also contain the sub-string
|
1150
|
+
# "\n" or newline characters '\n' to control line breaking
|
1151
|
+
# explicitly. This dialog box is useful for asking questions
|
1152
|
+
# that require the user to answer either yes or no. The dialog
|
1153
|
+
# box has a Yes button and a No button, in which the user can
|
1154
|
+
# switch between by pressing the TAB key.
|
1115
1155
|
|
1116
1156
|
# changing --inputbox to --yesno
|
1117
1157
|
# muquit@muquit.com Apr-01-2014
|
@@ -1137,6 +1177,7 @@ class MRDialog
|
|
1137
1177
|
|
1138
1178
|
log_debug("Command:\n#{command}")
|
1139
1179
|
success = system(command)
|
1180
|
+
@exit_code = $?.exitstatus
|
1140
1181
|
return success
|
1141
1182
|
end
|
1142
1183
|
|
@@ -1159,10 +1200,14 @@ class MRDialog
|
|
1159
1200
|
end
|
1160
1201
|
end
|
1161
1202
|
raise "'dialog' executable not found in path" unless exe_loc
|
1203
|
+
|
1204
|
+
# if an rc file was specified, set DIALOGRC to that file
|
1205
|
+
ENV["DIALOGRC"] = @rc_file if @rc_file
|
1206
|
+
|
1162
1207
|
ostring = exe_loc + " "
|
1163
1208
|
|
1164
1209
|
if @aspect
|
1165
|
-
ostring += "--aspect " + aspect + " "
|
1210
|
+
ostring += "--aspect " + @aspect + " "
|
1166
1211
|
end
|
1167
1212
|
|
1168
1213
|
if @beep
|
@@ -1189,6 +1234,16 @@ class MRDialog
|
|
1189
1234
|
end
|
1190
1235
|
end
|
1191
1236
|
|
1237
|
+
unless @notags == nil
|
1238
|
+
if @notags == true
|
1239
|
+
ostring += "--no-tags "
|
1240
|
+
end
|
1241
|
+
end
|
1242
|
+
|
1243
|
+
if @dialog_options
|
1244
|
+
ostring += " #{@dialog_options} "
|
1245
|
+
end
|
1246
|
+
|
1192
1247
|
if @sleep
|
1193
1248
|
ostring += "--sleep " + @sleep.to_s + " "
|
1194
1249
|
end
|
@@ -1224,6 +1279,34 @@ class MRDialog
|
|
1224
1279
|
ostring += "--ok-label #{@ok_label} "
|
1225
1280
|
end
|
1226
1281
|
|
1282
|
+
if @cancel_label
|
1283
|
+
ostring += "--cancel-label #{@cancel_label} "
|
1284
|
+
end
|
1285
|
+
|
1286
|
+
if @yes_label
|
1287
|
+
ostring += "--yes-label #{@yes_label} "
|
1288
|
+
end
|
1289
|
+
|
1290
|
+
if @no_label
|
1291
|
+
ostring += "--no-label #{@no_label} "
|
1292
|
+
end
|
1293
|
+
|
1294
|
+
if @extra_button
|
1295
|
+
ostring += "--extra-button "
|
1296
|
+
end
|
1297
|
+
|
1298
|
+
if @extra_label
|
1299
|
+
ostring += "--extra-label #{@extra_label} "
|
1300
|
+
end
|
1301
|
+
|
1302
|
+
if @help_button
|
1303
|
+
ostring += "--help-button "
|
1304
|
+
end
|
1305
|
+
|
1306
|
+
if @help_label
|
1307
|
+
ostring += "--help-label #{@help_label} "
|
1308
|
+
end
|
1309
|
+
|
1227
1310
|
if @separator
|
1228
1311
|
ostring += "--separator \"#{@separator}\" "
|
1229
1312
|
end
|