dialog 0.1.0
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.
- data/README +415 -0
- data/lib/base.rb +346 -0
- data/lib/calendar.rb +31 -0
- data/lib/checklist.rb +33 -0
- data/lib/dialog.rb +17 -0
- data/lib/form.rb +44 -0
- data/lib/fselect.rb +32 -0
- data/lib/gauge.rb +46 -0
- data/lib/infobox.rb +21 -0
- data/lib/inputbox.rb +26 -0
- data/lib/inputmenu.rb +22 -0
- data/lib/menu.rb +46 -0
- data/lib/msgbox.rb +19 -0
- data/lib/passwordbox.rb +20 -0
- data/lib/radiolist.rb +28 -0
- data/lib/tailbox.rb +20 -0
- data/lib/tailboxbg.rb +21 -0
- data/lib/textbox.rb +29 -0
- data/lib/timebox.rb +30 -0
- data/lib/util.rb +74 -0
- data/lib/yesno.rb +19 -0
- metadata +64 -0
data/lib/textbox.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'base'
|
2
|
+
|
3
|
+
module Dialog
|
4
|
+
|
5
|
+
# Displays a textbox.
|
6
|
+
#
|
7
|
+
# Example:
|
8
|
+
#
|
9
|
+
# Textbox.new do |b|
|
10
|
+
# b.text "Please read carefully"
|
11
|
+
# b.file "license.txt"
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# Box option syntax:
|
15
|
+
# --textbox <file> <height> <width>
|
16
|
+
#
|
17
|
+
class Textbox < Base
|
18
|
+
|
19
|
+
# Sets the default file to display
|
20
|
+
def file(f)
|
21
|
+
@options.box_options[0] = case f
|
22
|
+
when File: f.path
|
23
|
+
else f.to_s
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/lib/timebox.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'base'
|
2
|
+
|
3
|
+
module Dialog
|
4
|
+
|
5
|
+
# Displays a time input box.
|
6
|
+
#
|
7
|
+
# Use the time method to set the time being displayed initially.
|
8
|
+
#
|
9
|
+
# Example:
|
10
|
+
#
|
11
|
+
# Timebox.new do |t|
|
12
|
+
# t.text "What time is it?"
|
13
|
+
# m.time Time.now
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# Box option syntax:
|
17
|
+
# --timebox <text> <height> <width> <hour> <minute> <second>
|
18
|
+
class Timebox < Base
|
19
|
+
|
20
|
+
# Sets the default time to display initially
|
21
|
+
def time(t)
|
22
|
+
if !t.kind_of?(Time)
|
23
|
+
t = Time.parse(d)
|
24
|
+
end
|
25
|
+
@options.box_options[3..5] = [t.hour, t.min, t.sec]
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
data/lib/util.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
module Dialog
|
2
|
+
module Util
|
3
|
+
|
4
|
+
# A more flexible variant of the popen3 call
|
5
|
+
#
|
6
|
+
# Other than Open3.popen3, this method allows the parent process
|
7
|
+
# to share individual file descriptors with the child process. By
|
8
|
+
# default, all three file descriptors (stdin, stdout, stderr) of
|
9
|
+
# the child process are connected to pipes, which the parent process
|
10
|
+
# can use to write to/read from the child process. However, if this
|
11
|
+
# is not the desired behaviour, the parent process can pass IO objects
|
12
|
+
# for each stream that should be shared by the child process. This
|
13
|
+
# method does not fork twice (putting the burden to wait/waitpid on
|
14
|
+
# the parent process) and thus gives the parent process a pid. Note,
|
15
|
+
# that this introduces a small chance of receiving yet unitinialized
|
16
|
+
# file descriptors.
|
17
|
+
#
|
18
|
+
# Note, that popen3 behaves like exec concerning its arguments. If popen3
|
19
|
+
# is given a single argument, that argument is taken as a line that is subject
|
20
|
+
# to shell expansion before being executed. If multiple arguments are given,
|
21
|
+
# the second and subsequent arguments are passed as parameters to the command
|
22
|
+
# without shell expansion taking place.
|
23
|
+
#
|
24
|
+
# Examples:
|
25
|
+
#
|
26
|
+
# # Share stdin/stdout, but connect stderr to a pipe
|
27
|
+
# # The * is subject to shell file globbing
|
28
|
+
# pid, stdin, stdout, stderr = popen3("echo *", :stdin => STDIN, :stdout => STDOUT)
|
29
|
+
#
|
30
|
+
# # Share stdin/stdout, but connect stderr to a pipe
|
31
|
+
# # Echoes an asterisk
|
32
|
+
# pid, stdin, stdout, stderr = popen3("echo", "*", :stdin => STDIN, :stdout => STDOUT)
|
33
|
+
#
|
34
|
+
def self.popen3(*command)
|
35
|
+
fds = command.pop if command.last.kind_of?(Hash)
|
36
|
+
command.flatten!
|
37
|
+
stdin = fds[:stdin] if fds
|
38
|
+
stdout = fds[:stdout] if fds
|
39
|
+
stderr = fds[:stderr] if fds
|
40
|
+
|
41
|
+
# pipe[0] for read, pipe[1] for write
|
42
|
+
pi = IO::pipe unless stdin
|
43
|
+
po = IO::pipe unless stdout
|
44
|
+
pe = IO::pipe unless stderr
|
45
|
+
|
46
|
+
pid = fork
|
47
|
+
|
48
|
+
if pid.nil?
|
49
|
+
# child
|
50
|
+
pi[1].close if pi
|
51
|
+
STDIN.reopen(pi[0]) if pi
|
52
|
+
pi[0].close if pi
|
53
|
+
|
54
|
+
po[0].close if po
|
55
|
+
STDOUT.reopen(po[1]) if po
|
56
|
+
pi[1].close if po
|
57
|
+
|
58
|
+
pe[0].close if pe
|
59
|
+
STDERR.reopen(pe[1]) if pe
|
60
|
+
pe[1].close if pe
|
61
|
+
|
62
|
+
exec *command
|
63
|
+
end
|
64
|
+
|
65
|
+
# parent
|
66
|
+
pi[0].close if pi
|
67
|
+
po[1].close if po
|
68
|
+
pe[1].close if pe
|
69
|
+
pi[1].sync = true if pi
|
70
|
+
return [pid, stdin || pi[1], stdout || po[0], stderr || pe[0]]
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
data/lib/yesno.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'base'
|
2
|
+
|
3
|
+
module Dialog
|
4
|
+
|
5
|
+
# Displays a yes/no dialog.
|
6
|
+
#
|
7
|
+
# Example:
|
8
|
+
#
|
9
|
+
# steps = Yesno.new do |b|
|
10
|
+
# b.text "Bla bla"
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# Box option syntax:
|
14
|
+
# --yesno <text> <height> <width>
|
15
|
+
#
|
16
|
+
class Yesno < Base
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.11
|
3
|
+
specification_version: 1
|
4
|
+
name: dialog
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.1.0
|
7
|
+
date: 2006-10-23 00:00:00 +02:00
|
8
|
+
summary: Library for building ncurses-based dialogs by interfacing with dialog(1).
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: martin.landers@jambit.com
|
12
|
+
homepage: http://dialog.rubyforge.org/
|
13
|
+
rubyforge_project: dialog
|
14
|
+
description: "Dialog is a ruby gem for interfacing with the dialog(1) program. It does away
|
15
|
+
with the manual command-line fiddling, allowing ruby programs operating in a
|
16
|
+
commandline-environment to comfortably obtain user input. Ncurses dialogs the
|
17
|
+
easy way!"
|
18
|
+
autorequire:
|
19
|
+
default_executable:
|
20
|
+
bindir: bin
|
21
|
+
has_rdoc: true
|
22
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
23
|
+
requirements:
|
24
|
+
-
|
25
|
+
- ">"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 0.0.0
|
28
|
+
version:
|
29
|
+
platform: ruby
|
30
|
+
signing_key:
|
31
|
+
cert_chain:
|
32
|
+
authors:
|
33
|
+
- Martin Landers <martin.landers@jambit.com>
|
34
|
+
files:
|
35
|
+
- lib/textbox.rb
|
36
|
+
- lib/calendar.rb
|
37
|
+
- lib/msgbox.rb
|
38
|
+
- lib/yesno.rb
|
39
|
+
- lib/menu.rb
|
40
|
+
- lib/dialog.rb
|
41
|
+
- lib/form.rb
|
42
|
+
- lib/timebox.rb
|
43
|
+
- lib/radiolist.rb
|
44
|
+
- lib/tailboxbg.rb
|
45
|
+
- lib/tailbox.rb
|
46
|
+
- lib/inputbox.rb
|
47
|
+
- lib/base.rb
|
48
|
+
- lib/util.rb
|
49
|
+
- lib/passwordbox.rb
|
50
|
+
- lib/inputmenu.rb
|
51
|
+
- lib/infobox.rb
|
52
|
+
- lib/gauge.rb
|
53
|
+
- lib/checklist.rb
|
54
|
+
- lib/fselect.rb
|
55
|
+
- README
|
56
|
+
test_files: []
|
57
|
+
rdoc_options: []
|
58
|
+
extra_rdoc_files:
|
59
|
+
- README
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
requirements:
|
63
|
+
- none
|
64
|
+
dependencies: []
|