rbcurse 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +1570 -0
- data/History.txt +6 -0
- data/Manifest.txt +54 -0
- data/README.txt +304 -0
- data/Rakefile +28 -0
- data/examples/qdfilechooser.rb +68 -0
- data/examples/rfe.rb +853 -0
- data/examples/rfe_renderer.rb +69 -0
- data/examples/test1.rb +242 -0
- data/examples/test2.rb +498 -0
- data/examples/testcombo.rb +95 -0
- data/examples/testkeypress.rb +61 -0
- data/examples/testmenu.rb +105 -0
- data/examples/testtable.rb +266 -0
- data/examples/testtabp.rb +106 -0
- data/examples/testtodo.rb +532 -0
- data/examples/viewtodo.rb +512 -0
- data/lib/rbcurse/action.rb +31 -0
- data/lib/rbcurse/applicationheader.rb +57 -0
- data/lib/rbcurse/celleditor.rb +120 -0
- data/lib/rbcurse/checkboxcellrenderer.rb +69 -0
- data/lib/rbcurse/colormap.rb +133 -0
- data/lib/rbcurse/comboboxcellrenderer.rb +45 -0
- data/lib/rbcurse/defaultlistselectionmodel.rb +49 -0
- data/lib/rbcurse/keylabelprinter.rb +143 -0
- data/lib/rbcurse/listcellrenderer.rb +99 -0
- data/lib/rbcurse/listkeys.rb +33 -0
- data/lib/rbcurse/listscrollable.rb +216 -0
- data/lib/rbcurse/listselectable.rb +67 -0
- data/lib/rbcurse/mapper.rb +108 -0
- data/lib/rbcurse/orderedhash.rb +77 -0
- data/lib/rbcurse/rcombo.rb +243 -0
- data/lib/rbcurse/rdialogs.rb +183 -0
- data/lib/rbcurse/rform.rb +845 -0
- data/lib/rbcurse/rinputdataevent.rb +36 -0
- data/lib/rbcurse/rlistbox.rb +804 -0
- data/lib/rbcurse/rmenu.rb +666 -0
- data/lib/rbcurse/rmessagebox.rb +325 -0
- data/lib/rbcurse/rpopupmenu.rb +754 -0
- data/lib/rbcurse/rtabbedpane.rb +259 -0
- data/lib/rbcurse/rtable.rb +1296 -0
- data/lib/rbcurse/rtextarea.rb +673 -0
- data/lib/rbcurse/rtextview.rb +335 -0
- data/lib/rbcurse/rwidget.rb +1731 -0
- data/lib/rbcurse/scrollable.rb +301 -0
- data/lib/rbcurse/selectable.rb +94 -0
- data/lib/rbcurse/table/tablecellrenderer.rb +85 -0
- data/lib/rbcurse/table/tabledatecellrenderer.rb +102 -0
- data/lib/rbcurse.rb +7 -0
- data/lib/ver/keyboard.rb +150 -0
- data/lib/ver/keyboard2.rb +170 -0
- data/lib/ver/ncurses.rb +102 -0
- data/lib/ver/window.rb +369 -0
- data/test/test_rbcurse.rb +0 -0
- metadata +118 -0
@@ -0,0 +1,183 @@
|
|
1
|
+
=begin
|
2
|
+
* Name: dialogs so user can do basic stuff in one line.
|
3
|
+
* Description:
|
4
|
+
* Author: rkumar
|
5
|
+
|
6
|
+
--------
|
7
|
+
* Date: 2008-12-30 12:22
|
8
|
+
* License:
|
9
|
+
Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
|
10
|
+
|
11
|
+
TODO:
|
12
|
+
Add one get_string(message, len, regex ...)
|
13
|
+
Add select_one (message, values, default)
|
14
|
+
=end
|
15
|
+
require 'rubygems'
|
16
|
+
require 'ncurses'
|
17
|
+
require 'logger'
|
18
|
+
require 'rbcurse/rwidget'
|
19
|
+
require 'rbcurse/rmessagebox'
|
20
|
+
|
21
|
+
##
|
22
|
+
# pops up a modal box with a message and an OK button.
|
23
|
+
# No return value.
|
24
|
+
# Usage:
|
25
|
+
# alert("You did not enter anything!")
|
26
|
+
# alert("You did not enter anything!", "title"=>"Wake Up")
|
27
|
+
# alert("You did not enter anything!", {"title"=>"Wake Up", "bgcolor"=>"blue", "color"=>"white"})
|
28
|
+
# block currently ignored. don't know what to do, can't pass it to MB since alread sending in a block
|
29
|
+
def alert text, config={}, &block
|
30
|
+
title = config['title'] || "Alert"
|
31
|
+
#instance_eval &block if block_given?
|
32
|
+
mb = RubyCurses::MessageBox.new nil, config do
|
33
|
+
title title
|
34
|
+
message text
|
35
|
+
button_type :ok
|
36
|
+
end
|
37
|
+
end
|
38
|
+
def confirm text, config={}, &block
|
39
|
+
title = config['title'] || "Confirm"
|
40
|
+
#instance_eval &block if block_given?
|
41
|
+
mb = RubyCurses::MessageBox.new nil, config do
|
42
|
+
title title
|
43
|
+
message text
|
44
|
+
button_type :yes_no
|
45
|
+
end
|
46
|
+
return mb.selected_index == 0 ? :YES : :NO
|
47
|
+
end
|
48
|
+
|
49
|
+
##
|
50
|
+
# allows user entry of a string.
|
51
|
+
# In config you may pass Field related properties such as chars_allowed, valid_regex, values, etc.
|
52
|
+
def get_string(message, len=20, default="", config={})
|
53
|
+
config["maxlen"]=len
|
54
|
+
title = config["title"] || "Input required"
|
55
|
+
mb = RubyCurses::MessageBox.new nil, config do
|
56
|
+
title title
|
57
|
+
message message
|
58
|
+
type :input
|
59
|
+
button_type :ok
|
60
|
+
default_value default
|
61
|
+
end
|
62
|
+
return mb.input_value
|
63
|
+
end
|
64
|
+
|
65
|
+
##
|
66
|
+
# Added 2009-02-05 13:16
|
67
|
+
# get a string from user with some additional checkboxes and optionally supply default values
|
68
|
+
# Usage:
|
69
|
+
#sel, inp, hash = get_string_with_options("Enter a filter pattern", 20, "*", {"checkboxes" => ["case sensitive","reverse"], "checkbox_defaults"=>[true, false]})
|
70
|
+
# sel, inp, hash = get_string_with_options("Enter a filter pattern", 20, "*", {"checkboxes" => ["case sensitive","reverse"]})
|
71
|
+
# $log.debug " POPUP: #{sel}: #{inp}, #{hash['case sensitive']}, #{hash['reverse']}"
|
72
|
+
#
|
73
|
+
# @param: message to print,
|
74
|
+
# @param: length of entry field
|
75
|
+
# @param: default value of field
|
76
|
+
# @param: configuration of box or field
|
77
|
+
# checkboxes: array of strings to use as checkboxes
|
78
|
+
# checkbox_defaults : array of true/false default values for each cb
|
79
|
+
# @return: int 0 OK, 1 cancel pressed
|
80
|
+
# @return: string value entered
|
81
|
+
# @return: hash of strings and booleans for checkboxes and values
|
82
|
+
#
|
83
|
+
def get_string_with_options(message, len=20, default="", config={})
|
84
|
+
title = config["title"] || "Input required"
|
85
|
+
input_config = config["input_config"] || {}
|
86
|
+
checks = config["checkboxes"]
|
87
|
+
checkbox_defaults = config["checkbox_defaults"] || []
|
88
|
+
|
89
|
+
height = config["height"] || 1
|
90
|
+
display_length = config["display_length"] || 30
|
91
|
+
|
92
|
+
r = 3
|
93
|
+
c = 4
|
94
|
+
mform = RubyCurses::Form.new nil
|
95
|
+
message_label = RubyCurses::Label.new mform, {'text' => message, "name"=>"message_label","row" => r, "col" => c, "display_length" => display_length, "height" => height, "attr"=>"reverse"}
|
96
|
+
|
97
|
+
r += 1
|
98
|
+
input = RubyCurses::Field.new mform, input_config do
|
99
|
+
name "input"
|
100
|
+
row r
|
101
|
+
col c
|
102
|
+
display_length display_length
|
103
|
+
maxlen len
|
104
|
+
set_buffer default
|
105
|
+
end
|
106
|
+
if !checks.nil?
|
107
|
+
r += 2
|
108
|
+
checks.each_with_index do |cbtext,ix|
|
109
|
+
field = RubyCurses::CheckBox.new mform do
|
110
|
+
text cbtext
|
111
|
+
name cbtext
|
112
|
+
value checkbox_defaults[ix]||false
|
113
|
+
color 'black'
|
114
|
+
bgcolor 'white'
|
115
|
+
row r
|
116
|
+
col c
|
117
|
+
end
|
118
|
+
r += 1
|
119
|
+
end
|
120
|
+
end
|
121
|
+
radios = config["radiobuttons"]
|
122
|
+
if !radios.nil?
|
123
|
+
radio_default = config["radio_default"] || radios[0]
|
124
|
+
radio = RubyCurses::Variable.new radio_default
|
125
|
+
r += 2
|
126
|
+
radios.each_with_index do |cbtext,ix|
|
127
|
+
field = RubyCurses::RadioButton.new mform do
|
128
|
+
variable radio
|
129
|
+
text cbtext
|
130
|
+
value cbtext
|
131
|
+
color 'black'
|
132
|
+
bgcolor 'white'
|
133
|
+
row r
|
134
|
+
col c
|
135
|
+
end
|
136
|
+
r += 1
|
137
|
+
end
|
138
|
+
end
|
139
|
+
mb = RubyCurses::MessageBox.new mform do
|
140
|
+
title title
|
141
|
+
button_type :ok_cancel
|
142
|
+
default_button 0
|
143
|
+
end
|
144
|
+
hash = {}
|
145
|
+
if !checks.nil?
|
146
|
+
checks.each do |c|
|
147
|
+
hash[c] = mform.by_name[c].getvalue
|
148
|
+
end
|
149
|
+
end
|
150
|
+
hash["radio"] = radio.get_value unless radio.nil?
|
151
|
+
# returns button index (0 = OK), value of field, hash containing values of checkboxes
|
152
|
+
return mb.selected_index, mform.by_name['input'].getvalue, hash
|
153
|
+
end
|
154
|
+
|
155
|
+
=begin
|
156
|
+
http://www.kammerl.de/ascii/AsciiSignature.php
|
157
|
+
___
|
158
|
+
|__ \
|
159
|
+
) |
|
160
|
+
/ /
|
161
|
+
|_|
|
162
|
+
(_)
|
163
|
+
|
164
|
+
_
|
165
|
+
| |
|
166
|
+
| |
|
167
|
+
| |
|
168
|
+
|_|
|
169
|
+
(_)
|
170
|
+
|
171
|
+
|
172
|
+
_____ _ _____
|
173
|
+
| __ \ | | / ____|
|
174
|
+
| |__) | _| |__ _ _ | | _ _ _ __ ___ ___ ___
|
175
|
+
| _ / | | | '_ \| | | | | | | | | | '__/ __|/ _ \/ __|
|
176
|
+
| | \ \ |_| | |_) | |_| | | |___| |_| | | \__ \ __/\__ \
|
177
|
+
|_| \_\__,_|_.__/ \__, | \_____\__,_|_| |___/\___||___/
|
178
|
+
__/ |
|
179
|
+
|___/
|
180
|
+
|
181
|
+
=end
|
182
|
+
|
183
|
+
|