Class: Editor
Constant Summary
collapse
- @@name =
"Edit menu"
Instance Attribute Summary
Attributes inherited from Menu
#path, #style
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Menu
#encode_with, #filter_entries, #get_font_string, #init_with, #items, #remove_item, #set_item
Methods included from Item
#name=
Constructor Details
#initialize(parent) ⇒ Editor
Returns a new instance of Editor.
19
20
21
22
|
# File 'lib/editor.rb', line 19
def initialize parent
@parent = parent
self.style = parent.style
end
|
Class Method Details
.name ⇒ Object
11
12
13
|
# File 'lib/editor.rb', line 11
def self.name
@@name
end
|
Instance Method Details
#execute ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/editor.rb', line 28
def execute
entries = []
selection = nil
while selection != "" && (entries.index selection) != entries.length - 1
entries = ["Name (#{@parent.name})"]
entries << "Style"
entries << "Entries"
entries << "Run menu"
entries << "Done"
selection = entries, @@name
case entries.index selection
when 0 then @parent.name = ([@parent.name], "Edit Name")
when 1 then @parent.style =
when 2 then
when 3 then
end
end
false
end
|
#name ⇒ Object
15
16
17
|
# File 'lib/editor.rb', line 15
def name
"> #{Editor.name}"
end
|
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
# File 'lib/editor.rb', line 165
def
entries = []
entries = ["Command"]
entries << "Menu"
entries << "Done"
selection = nil
while selection != "" && (entries.index selection) != entries.length - 1
selection = entries, "Add items"
case entries.index selection
when 0 then
when 1 then
end
end
end
|
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
# File 'lib/editor.rb', line 180
def command = Command.new("New command", "")
new = false
if (@parent.remove_item command).nil?
new = true
end
entries = []
selection = nil
delete = false
while selection != "" && (entries.index selection) != entries.length - 1
entries = ["Name (#{command.name})"]
entries << "Command (#{command.command})"
if new
string = "Add command"
else
string = "Edit command"
if delete
entries << "Undo"
else
entries << "Delete"
end
end
entries << "Done"
selection = entries, "Add Command"
case entries.index selection
when 0
new_name = ([command.name], "Enter a name")
command.name = new_name unless new_name.empty?
when 1
history = History.new 1, 1
history.update command.command unless command.command.nil? or command.command.empty?
new_command = .new(self, history, "Enter a command").
command.command = new_command unless new_command.empty?
when 2 then delete = !delete unless new
end
end
delete = true if selection == "" && new
@parent.set_item command unless delete
end
|
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
# File 'lib/editor.rb', line 150
def
selection = nil
while selection != "" && @parent.items[selection].nil?
selection = @parent.items.keys.sort, "Select item to edit"
item = @parent.items[selection]
unless item.nil?
if item.is_a? Command
item
else
item
end
end
end
end
|
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
# File 'lib/editor.rb', line 219
def = nil
new = .nil?
if new
= .new "New menu"
.style = @parent.style
end
@parent.remove_item
entries = []
selection = nil
delete = false
while selection != "" && (entries.index selection) != entries.length - 1
entries = ["Name (#{menu.name})"]
if new
string = "Add menu"
else
string = "Edit menu"
if delete
entries << "Undo"
else
entries << "Remove"
end
end
entries << "Done"
selection = entries, string
if (entries.index selection) == 0
new_name = [], "Enter a name"
.name = new_name unless new_name.empty?
end
delete = !delete if (entries.index selection) == 1 && !new
end
delete = true if selection == "" && new
@parent.set_item unless delete
end
|
136
137
138
139
140
141
142
143
144
145
146
147
148
|
# File 'lib/editor.rb', line 136
def
entries = ["Edit/Remove entries"]
entries << "Add entries"
entries << "Done"
selection = nil
while selection != "" && (entries.index selection) != 2
selection = entries, "Edit entries"
case entries.index selection
when 0 then
when 1 then
end
end
end
|
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/editor.rb', line 67
def
entries = []
selection = nil
clear = false
while selection != "" && (entries.index selection) != entries.length - 1
entries = ["History length (#{@parent.history.length})"]
entries << "Items shown in run menu (#{@parent.history.show_num_items})"
if clear
entries << "Undo"
else
entries << "Clear history"
end
entries << "Done"
selection = entries, "History"
case entries.index selection
when 0
selection = ( [], "Enter a number")
number = selection.to_i
@parent.history.length = number unless number < 1 || number.to_s != selection
when 1
selection = ( [], "Enter a number")
number = ( [], "Enter a number").to_i
@parent.history.show_num_items = number unless number.to_s != selection
when 2 then clear = !clear
when (entries.length - 1) then @parent.history.clear if clear
end
end
end
|
132
133
134
|
# File 'lib/editor.rb', line 132
def entries, name, = false
super
end
|
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/editor.rb', line 48
def
entries = []
selection = nil
while selection != "" && (entries.index selection) != entries.length - 1
if @parent.
entries = ["Disable run menu"]
else
entries = ["Enable run menu"]
end
entries << "History"
entries << "Done"
selection = entries, "Run menu"
case entries.index selection
when 0 then @parent. = !@parent.
when 1 then
end
end
end
|
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/editor.rb', line 97
def
style = @parent.style
entries = []
selection = nil
while selection != "" && (entries.index selection) != entries.length - 1
entries = ["Background: (#{style.color :bg})"]
entries << "Foreground: (#{style.color :fg})"
entries << "Selected Background: (#{style.color :bg_hi})"
entries << "Selected Foreground: (#{style.color :fg_hi})"
if style.font.nil?
entries << "Font: (default)"
else
entries << "Font: (#{style.font})"
end
entries << "Done"
selection = entries, "Edit style"
colors = [:bg, :fg, :bg_hi, :fg_hi]
unless (entries.index selection).nil?
if (entries.index selection) < 4
style.set_color colors[entries.index selection], ([style.color(colors[entries.index selection])], "Enter a color")
elsif (entries.index selection) < 5
if style.font.nil?
selection = (["default"], "Set font")
else
selection = ([style.font], "Set font")
end
unless selection.nil? || selection == "default"
style.font = selection
end
end
end
end
style
end
|
#to_s ⇒ Object
24
25
26
|
# File 'lib/editor.rb', line 24
def to_s
"Edit menu"
end
|