forked from muquit/mrdialog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpause.rb
More file actions
executable file
·55 lines (48 loc) · 1.21 KB
/
pause.rb
File metadata and controls
executable file
·55 lines (48 loc) · 1.21 KB
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
#!/usr/bin/env ruby
# muquit@muquit.com Apr-20-2014
require [File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'mrdialog'].join('/')
require 'pp'
class PauseBox
ME = File.basename($0)
if ENV['CHANGE_TITLE']
if ME =~ /(.+)\.rb$/
base = $1
puts "\033]0;mrdialog - #{base}\007"
end
end
def initialize
end
def doit
dialog = MRDialog.new
dialog.shadow = false
dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
dialog.clear = true
dialog.title = "PAUSE BOX"
secs = 20
text = <<EOF
This is an example of pause box.
A pause box displays a meter along the bottom
of the box. The meter indicates how many seconds
remain until the end of the pause. The pause exits
when timeout is reached or the user presses the
OK button (status OK) or the user presses the
Cancel button or Esc key.
EOF
height = 15
width = 0
dialog.pause(text, height, width, secs)
exit_code = dialog.exit_code
puts "Exit code: #{exit_code}"
case exit_code
when 0
puts "OK"
when 1
puts "Cancel button pressed"
when 255
puts "Error or ESC button pressed"
end
end
end
if __FILE__ == $0
PauseBox.new.doit
end