Class: Arcadia
Instance Attribute Summary collapse
#tcltk_info
Class Method Summary
collapse
Instance Method Summary
collapse
#run, #sys_info
Methods inherited from Application
#[], #[]=, conf, conf_group, #create, instance, #load_local_config, #load_theme, #local_dir, #objects, #publish, #run, #sys_info
Methods included from EventBus
#attach_listener, #broadcast_event, #detach_listener, #process_event
#append_persistent_property, #override_persistent
#properties_file2hash, properties_group, #resolve_link, #resolve_properties_link
Constructor Details
Returns a new instance of Arcadia.
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
56
57
58
59
60
61
62
63
64
65
66
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
96
97
|
# File 'lib/a-core.rb', line 22
def initialize
super(
ApplicationParams.new(
'arcadia',
'0.6.0',
'conf/arcadia.conf',
'conf/arcadia.pers'
)
)
load_config
set_sysdefaultproperty
ArcadiaDialogManager.new(self)
ArcadiaActionDispatcher.new(self)
ObjectSpace.define_finalizer($arcadia, self.class.method(:finalize).to_proc)
publish('action.on_exit', proc{do_exit})
_title = "Arcadia Ruby ide :: #{sys_info}"
@root = TkRoot.new(
'background'=> self['conf']['background']
){
title _title
withdraw
protocol( "WM_DELETE_WINDOW", $arcadia['action.on_exit'])
}
@on_event = Hash.new
@main_menu_bar = TkMenubar.new(
'background'=> self['conf']['background']
).pack('fill'=>'x')
@mf_root = Tk::BWidget::MainFrame.new(@root,
'background'=> self['conf']['background']
){
@main_menu_bar
}.pack(
'anchor'=> 'center',
'fill'=> 'both',
'expand'=> 1
)
@mf_root.show_statusbar('none')
@main_toolbar = ArcadiaMainToolbar.new(self, @mf_root.add_toolbar)
@is_toolbar_show=self['conf']['user_toolbar_show']=='yes'
@mf_root.show_toolbar(0,@is_toolbar_show)
@use_splash = self['conf']['splash.show']=='yes'
@splash = ArcadiaAboutSplash.new if @use_splash
@splash.set_progress(50) if @splash
@splash.deiconify if @splash
Tk.update
@splash.next_step('..prepare') if @splash
prepare
@splash.last_step('..load finish') if @splash
geometry = (TkWinfo.screenwidth(@root)-4).to_s+'x'+
(TkWinfo.screenheight(@root)-20).to_s+'+0+0'
@root.deiconify
@root.raise
@root.focus(true)
@root.geometry(geometry)
Tk.update_idletasks
@splash.destroy if @splash
if @first_run
Arcadia.process_event(OpenBufferEvent.new(self,'file'=>'README'))
elsif ARGV.length > 0
ARGV.each{|_f|
if $pwd != File.dirname(__FILE__) && !File.exist?(_f)
_f = "#{$pwd}/#{_f}"
end
Arcadia.process_event(OpenBufferEvent.new(self,'file'=>_f)) if File.exist?(_f)
}
end
Arcadia.attach_listener(self, QuitEvent)
Arcadia.persistent("version", self['applicationParams'].version)
end
|
Instance Attribute Details
#layout ⇒ Object
Returns the value of attribute layout.
21
22
23
|
# File 'lib/a-core.rb', line 21
def layout
@layout
end
|
Class Method Details
.console(_sender, _args = Hash.new) ⇒ Object
430
431
432
|
# File 'lib/a-core.rb', line 430
def Arcadia.console(_sender, _args=Hash.new)
process_event(MsgEvent.new(_sender, _args))
end
|
.dialog(_sender, _args = Hash.new) ⇒ Object
434
435
436
437
|
# File 'lib/a-core.rb', line 434
def Arcadia.dialog(_sender, _args=Hash.new)
_event = process_event(DialogEvent.new(_sender, _args))
return _event.results[0].value if _event
end
|
.finalize(id) ⇒ Object
116
117
118
|
# File 'lib/a-core.rb', line 116
def Arcadia.finalize(id)
puts "\nArcadia #{id} dying at #{Time.new}"
end
|
.layout ⇒ Object
456
457
458
459
460
|
# File 'lib/a-core.rb', line 456
def Arcadia.layout
if @@instance
return @@instance.layout
end
end
|
.persistent(_property, _value = nil, _immediate = false) ⇒ Object
443
444
445
446
447
448
449
450
451
452
453
454
|
# File 'lib/a-core.rb', line 443
def Arcadia.persistent(_property, _value=nil, _immediate=false)
if @@instance
if _value.nil?
return @@instance['pers'][_property]
else
@@instance['pers'][_property] = _value
end
if _immediate
@@instance.append_persistent_property(@@instance['applicationParams'].persistent_file,_property, _value )
end
end
end
|
Instance Method Details
#do_build ⇒ Object
150
151
152
153
154
155
156
157
158
159
160
|
# File 'lib/a-core.rb', line 150
def do_build
@exts.each{|extension|
if extension && ext_active?(extension)
@splash.next_step('... creating '+extension) if @splash
ext_create(extension)
end
}
_build_event = Arcadia.process_event(BuildEvent.new(self))
end
|
#do_exit ⇒ Object
408
409
410
411
412
413
414
415
416
417
418
|
# File 'lib/a-core.rb', line 408
def do_exit
q1 = (Arcadia.dialog(self,
'type'=>'yes_no',
'msg'=>"Do you want exit?",
'title' => '(Arcadia) Exit',
'level' => 'question')=='yes')
if q1 && can_exit?
do_finalize
@root.destroy
end
end
|
#do_finalize ⇒ Object
425
426
427
428
|
# File 'lib/a-core.rb', line 425
def do_finalize
_event = Arcadia.process_event(FinalizeEvent.new(self))
self.override_persistent(self['applicationParams'].persistent_file, self['pers'])
end
|
#ext_active?(_name) ⇒ Boolean
120
121
122
123
|
# File 'lib/a-core.rb', line 120
def ext_active?(_name)
return (self['conf'][_name+'.active'] != nil && self['conf'][_name+'.active']=='yes')||
(self['conf'][_name+'.active'] == nil)
end
|
#ext_create(_extension) ⇒ Object
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
# File 'lib/a-core.rb', line 162
def ext_create(_extension)
begin
source = self['conf'][_extension+'.require']
class_name = self['conf'][_extension+'.class']
if source.strip.length > 0
eval("require '#{source}'")
end
if class_name.strip.length > 0
publish(_extension, eval(class_name).new(self, _extension))
end
rescue Exception
raise
msg = "Loading "+'"'+extension+'"'+" ("+$!.class.to_s+") "+" : "+$! + " at : "+$@.to_s
ans = Tk.messageBox('icon' => 'error', 'type' => 'abortretryignore',
'title' => '(Arcadia) Extensions', 'parent' => @root,
'message' => msg)
if ans == 'abort'
raise
exit
elsif ans == 'retry'
retry
else
Tk.update
end
end
end
|
#ext_method(_extension, _method) ⇒ Object
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
# File 'lib/a-core.rb', line 191
def ext_method(_extension, _method)
begin
self[_extension].send(_method)
rescue Exception
msg = _method.to_s+' "'+_extension.to_s+'"'+" ("+$!.class.to_s+") "+" : "+$! + "\n at : "+$@.to_s
ans = Tk.messageBox('icon' => 'warning', 'type' => 'abortretryignore',
'title' => '(Arcadia) Extensions', 'parent' => @root,
'message' => msg)
if ans == 'abort'
raise
exit
elsif ans == 'retry'
retry
else
Tk.update
end
end
end
|
#init_layout ⇒ Object
210
211
212
213
214
215
216
217
218
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
252
253
254
255
256
257
258
|
# File 'lib/a-core.rb', line 210
def init_layout
@layout = ArcadiaLayout.new(self, @mf_root.get_frame)
suf = "layout.split"
elems = self['conf'][suf]
return if elems.nil?
groups = elems.split(',')
groups.each{|group|
if group
suf1 = suf+'.'+group
begin
property = self['conf'][suf1]
c = property.split('c')
if c && c.length == 2
pt = c[0].split('.')
perc = c[1].include?('%')
w = c[1].sub('%','')
if perc
@layout.add_cols_perc(pt[0].to_i, pt[1].to_i, w.to_i)
else
@layout.add_cols(pt[0].to_i, pt[1].to_i, w.to_i)
end
else
r = property.split('r')
if r && r.length == 2
pt = r[0].split('.')
perc = r[1].include?('%')
w = r[1].sub('%','')
if perc
@layout.add_rows_perc(pt[0].to_i, pt[1].to_i, w.to_i)
else
@layout.add_rows_perc(pt[0].to_i, pt[1].to_i, w.to_i)
end
end
end
rescue Exception
msg = "Loading layout: (#{$!.class.to_s} : #{$!.to_s} at : #{$@.to_s})"
if Arcadia.dialog(self, 'type'=>'ok_cancel', 'level'=>'error','title' => '(Arcadia) Layout', 'msg'=>msg)=='cancel'
raise
exit
else
Tk.update
end
end
end
}
@layout.
end
|
#load_config ⇒ Object
260
261
262
263
264
265
266
267
|
# File 'lib/a-core.rb', line 260
def load_config
self.load_local_config(false)
self.load_exts_conf
self.load_local_config
self.load_theme(self['conf']['theme'])
self.resolve_properties_link(self['conf'],self['conf'])
end
|
#load_exts_conf ⇒ Object
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
# File 'lib/a-core.rb', line 125
def load_exts_conf
@exts = Array.new
dirs = Array.new
files = Dir['ext/*'].concat(Dir[ENV["HOME"]+'/.arcadia/ext/*']).sort
files.each{|f|
dirs << f if File.stat(f).directory? && FileTest.exist?(f+'/'+File.basename(f)+'.conf')
}
dirs.each{|ext_dir|
conf_hash = self.properties_file2hash(ext_dir+'/'+File.basename(ext_dir)+'.conf')
conf_hash2 = Hash.new
name = conf_hash['name']
conf_hash.each{|key, value|
var_plat = key.split(':')
if var_plat.length > 1
new_key = var_plat[0] + ':' + name + '.' + var_plat[1]
else
new_key = name+'.'+key
end
conf_hash2[new_key]= value
}
@exts << name
self['conf'].update(conf_hash2)
}
end
|
#load_user_control(_user_control, _ext = '', _pre = '') ⇒ Object
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
|
# File 'lib/a-core.rb', line 334
def load_user_control(_user_control, _ext='', _pre='')
return unless _ext && ext_active?(_ext)
if _ext.length > 0 && self[_ext]
_self_on_eval = self[_ext]
suf = "#{_ext}.#{_user_control.class::SUF}"
else
_self_on_eval = self
suf = "#{_user_control.class::SUF}"
end
if _pre.length > 0
suf = "#{_pre}.#{suf}"
end
contexts = self['conf']["#{suf}.contexts"]
contexts_caption = self['conf']["#{suf}.contexts.caption"]
return if contexts.nil?
groups = contexts.split(',')
groups_caption = contexts_caption.split(',') if contexts_caption
groups.each_with_index{|group, gi|
if group
suf1 = suf+'.'+group
begin
context_path = self['conf']["#{suf1}.context_path"]
property = proc{|_str, _suf| self['conf']["#{_suf}.#{_str}"]}
property_to_eval = proc{|_str, _suf|
p = self['conf']["#{_suf}.#{_str}"]
_self_on_eval.instance_eval(p) if p
}
items = self['conf'][suf1].split(',')
items.each{|item|
suf2 = suf1+'.'+item
disabled = !self['conf']["#{suf2}.disabled"].nil?
name = property.call('name',suf2)
caption = property.call('caption',suf2)
hint = property.call('hint',suf2)
event_class = property_to_eval.call('event_class',suf2)
event_args = property_to_eval.call('event_args',suf2)
image_data = property_to_eval.call('image_data',suf2)
item_args = {
'name'=>name,
'caption'=>caption,
'hint'=>hint,
'event_class' =>event_class,
'event_args' =>event_args,
'image_data' =>image_data,
'context'=>group,
'context_path'=>context_path
}
item_args['context_caption'] = groups_caption[gi] if groups_caption
i = _user_control.new_item(self, item_args)
i.enable=false if disabled
}
rescue Exception
msg = "Loading #{groups} ->#{items} (#{$!.class.to_s} : #{$!.to_s} at : #{$@.to_s})"
if Arcadia.dialog(self, 'type'=>'ok_cancel', 'title' => '(Arcadia) Toolbar', 'msg'=>msg)=='cancel'
raise
exit
else
Tk.update
end
end
end
}
end
|
#on_quit(_event) ⇒ Object
99
100
101
|
# File 'lib/a-core.rb', line 99
def on_quit(_event)
self.do_exit
end
|
#prepare ⇒ Object
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
|
# File 'lib/a-core.rb', line 277
def prepare
super
@splash.next_step('...initialize') if @splash
@splash.next_step if @splash
@splash.next_step if @splash
@splash.next_step('... load extensions') if @splash
init_layout
publish('buffers.code.in_memory',Hash.new)
publish('action.load_code_from_buffers', proc{TkBuffersChoise.new})
publish('output.action.run_last', proc{$arcadia['output'].run_last})
publish('main.action.open_file', proc{self['editor'].open_file(Tk.getOpenFile)})
@splash.next_step('... load obj controller') if @splash
@splash.next_step('... load editor') if @splash
publish('main.action.new_file',proc{$arcadia['editor'].open_buffer()})
publish('main.action.edit_cut',proc{$arcadia['editor'].raised.text.text_cut()})
publish('main.action.edit_copy',proc{$arcadia['editor'].raised.text.text_copy()})
publish('main.action.edit_paste',proc{$arcadia['editor'].raised.text.text_paste()})
@splash.next_step('... load actions') if @splash
@keytest = KeyTest.new
@keytest.on_close=proc{@keytest.hide}
@keytest.hide
@keytest.title("Keys test")
publish('action.test.keys', proc{@keytest.show})
publish('action.get.font', proc{Tk::BWidget::SelectFont::Dialog.new.create})
@splash.next_step if @splash
publish('action.show_about', proc{ArcadiaAboutSplash.new.deiconify})
@main_menu = ArcadiaMainMenu.new(@main_menu_bar)
self.do_build
@splash.next_step if @splash
publish('objic.action.raise_active_obj',
proc{
InspectorContract.instance.raise_active_toplevel(self)
}
)
@splash.next_step('... toolbar buttons ') if @splash
load_user_control(@main_menu)
load_user_control(@main_toolbar)
@exts.each{|ext|
@splash.next_step("... load #{ext} user controls ") if @splash
load_user_control(@main_menu, ext)
load_user_control(@main_toolbar, ext)
}
load_user_control(@main_menu,"","e")
load_user_control(@main_toolbar,"","e")
end
|
#set_sysdefaultproperty ⇒ Object
269
270
271
272
273
274
275
|
# File 'lib/a-core.rb', line 269
def set_sysdefaultproperty
Tk.tk_call "eval","option add *background #{self['conf']['background']}"
Tk.tk_call "eval","option add *foreground #{self['conf']['foreground']}"
Tk.tk_call "eval","option add *activebackground #{self['conf']['activebackground']}"
Tk.tk_call "eval","option add *activeforeground #{self['conf']['activeforeground']}"
end
|
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/a-core.rb', line 103
def show_hide_toolbar
if @is_toolbar_show
@mf_root.show_toolbar(0,false)
@is_toolbar_show = false
else
@mf_root.show_toolbar(0,true)
Tk.update
@is_toolbar_show = true
end
end
|