Class: Arcadia
Constant Summary
Configurable::ADD_SYMBOL, Configurable::FONT_TYPE_SYMBOL, Configurable::LC_SYMBOL, Configurable::LINK_SYMBOL
Instance Attribute Summary collapse
#tcltk_info
Class Method Summary
collapse
-
.[](_name) ⇒ Object
-
.conf_group(_path, _refresh = false) ⇒ Object
-
.conf_group_copy(_path_source, _path_target, _suff = 'conf') ⇒ Object
-
.console(_sender, _args = Hash.new) ⇒ Object
-
.console_input(_sender) ⇒ Object
-
.console_input_event ⇒ Object
-
.dialog(_sender, _args = Hash.new) ⇒ Object
-
.file_extension(_filename = nil) ⇒ Object
-
.file_icon(_file_name) ⇒ Object
-
.finalize(id) ⇒ Object
-
.gem_available?(_gem) ⇒ Boolean
-
.image_res(_name) ⇒ Object
-
.is_windows? ⇒ Boolean
-
.lang_icon(_lang = nil) ⇒ Object
-
.layout ⇒ Object
-
.menu_root(_menu_root_name, _menu_root = nil) ⇒ Object
-
.menubar_item(_name = nil) ⇒ Object
def Arcadia.res(_res) theme = Arcadia.instance[‘theme’] if theme ret = eval(“#theme::#_res”) end ret=Res::_res if ret.nil? return ret end.
-
.new_statusbar_item(_help = nil) ⇒ Object
-
.open_file_dialog ⇒ Object
-
.pers_group(_path, _refresh = false) ⇒ Object
-
.persistent(_property, _value = nil, _immediate = false) ⇒ Object
-
.ruby ⇒ Object
-
.runner(_name = nil) ⇒ Object
-
.runner_for_file(_filename = nil) ⇒ Object
-
.runner_for_lang(_lang = nil) ⇒ Object
-
.runtime_error(_e, _title = Arcadia.text("main.e.runtime.title")) ⇒ Object
-
.runtime_error_msg(_msg, _title = Arcadia.text("main.e.runtime.title")) ⇒ Object
-
.style(_class) ⇒ Object
-
.text(_key = nil, _params = nil) ⇒ Object
-
.toolbar_item(_name = nil) ⇒ Object
-
.unpersistent(_property, _immediate = false) ⇒ Object
-
.wf ⇒ Object
-
.which(_command = nil) ⇒ Object
Instance Method Summary
collapse
-
#can_exit? ⇒ Boolean
-
#check_gems_dependences(_ext) ⇒ Object
-
#do_build ⇒ Object
-
#do_exit ⇒ Object
-
#do_finalize ⇒ Object
-
#do_initialize ⇒ Object
-
#do_make_clones ⇒ Object
-
#ext_active?(_name) ⇒ Boolean
-
#ext_create(_extension) ⇒ Object
-
#ext_load(_extension) ⇒ Object
-
#ext_source_must_be_loaded?(_name) ⇒ Boolean
-
#geometry_from_a(_a = nil) ⇒ Object
-
#geometry_refine(_geometry) ⇒ Object
-
#geometry_to_a(_geometry = nil) ⇒ Object
-
#initialize ⇒ Arcadia
constructor
A new instance of Arcadia.
-
#initialize_layout ⇒ Object
def ext_method(_extension, _method) begin self.send(_method) rescue Exception => e msg = _method.to_s+‘ “’_extension.to_s
‘”’+“ (”+$!.class.to_s+“) ”+“ : ”+$! + “n at : ”[email protected]_s ans = Arcadia.dialog(self, ‘type’=>‘abort_retry_ignore’, ‘title’ => “(Arcadia) Extensions”, ‘msg’=>msg, ‘exception’=>e, ‘level’=>‘error’) if ans == ‘abort’ raise exit elsif ans == ‘retry’ retry else Tk.update end end end.
-
#last_focused_text_widget ⇒ Object
-
#load_config ⇒ Object
-
#load_exts_conf ⇒ Object
-
#load_exts_conf_from(_dir = '', _ext_root = nil) ⇒ Object
-
#load_key_binding(_ext = '') ⇒ Object
-
#load_maximized ⇒ Object
-
#load_runners ⇒ Object
-
#load_sysdefaultproperty ⇒ Object
-
#load_user_control(_user_control, _ext = '', _pre = '') ⇒ Object
-
#manage_runners ⇒ Object
-
#on_quit(_event) ⇒ Object
-
#prepare ⇒ Object
-
#register(_ext) ⇒ Object
-
#register_key_binding(_self_target, k, v) ⇒ Object
-
#save_layout ⇒ Object
-
#show_hide_toolbar ⇒ Object
-
#unregister(_ext) ⇒ Object
#run, sys_info
Methods inherited from Application
#[], #[]=, conf, #conf, #create, del_conf, del_conf_group, instance, #load_local_config, #load_theme, local_dir, #local_dir, #local_file_config, #objects, #publish, #run, sys_info, #update_local_config, version
Methods included from EventBus
#attach_listener, #broadcast_event, #detach_listener, #process_event
#append_persistent_property, #override_persistent
clear_properties_group_cache, #hash2properties_file, #make_locale_value, #make_value, #properties_file2hash, properties_group, #resolve_locale_value, #resolve_properties_link, #resolve_value
Constructor Details
Returns a new instance of Arcadia.
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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
# File 'lib/a-core.rb', line 23
def initialize
super(
ApplicationParams.new(
'arcadia',
'0.12.0',
'conf/arcadia.conf',
'conf/arcadia.pers'
)
)
load_config
@localization = ArcadiaLocalization.new
if self['conf']['encoding']
Tk.encoding=self['conf']['encoding']
end
@wf = TkWidgetFactory.new
ArcadiaProblemsShower.new(self)
ArcadiaDialogManager.new(self)
ArcadiaActionDispatcher.new(self)
ArcadiaGemsWizard.new(self)
MonitorLastUsedDir.new
@focus_event_manager = FocusEventManager.new
ObjectSpace.define_finalizer($arcadia, self.class.method(:finalize).to_proc)
_title = "Arcadia"
@root = TkRoot.new(
'background'=> self['conf']['background']
){
title _title
withdraw
protocol( "WM_DELETE_WINDOW", proc{Arcadia.process_event(QuitEvent.new(self))})
iconphoto(Arcadia.image_res(ARCADIA_RING_GIF)) if Arcadia.instance.tcltk_info.level >= '8.4.9'
}
@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'],
'height'=> 0
){
@main_menu_bar
}.pack(
'anchor'=> 'center',
'fill'=> 'both',
'expand'=> 1
)
@mf_root.show_statusbar('status')
Arcadia.new_statusbar_item("Platform").text=RUBY_PLATFORM
self['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(31) if @splash
@splash.deiconify if @splash
Tk.update
@screenwidth=TkWinfo.screenwidth(@root)
@screenheight=TkWinfo.screenheight(@root)
@need_resize=false
@x_scale=1
@y_scale=1
if self['conf']['geometry']
w0,h0,x0,y0= geometry_to_a(self['conf']['geometry'])
g_array = []
if @screenwidth > 0 && w0.to_i > @screenwidth
g_array << (@screenwidth - x0.to_i).to_s
@need_resize = true
@x_scale = @screenwidth.to_f/w0.to_f
else
g_array << w0
end
if @screenheight > 0 && h0.to_i > @screenheight
g_array << (@screenheight - y0.to_i).to_s
@need_resize = true
@y_scale = @screenheight.to_f/h0.to_f
else
g_array << h0
end
g_array << x0
g_array << y0
geometry = geometry_from_a(g_array)
else
start_width = (@screenwidth-4)
start_height = (@screenheight-20)
if RUBY_PLATFORM =~ /mswin|mingw/ start_height -= 50
start_width -= 20
end
geometry = start_width.to_s+'x'+start_height.to_s+'+0+0'
end
prepare
begin
@root.deiconify
rescue RuntimeError => e
Arcadia.runtime_error(e)
end
begin
@root.focus(true)
rescue RuntimeError => e
Arcadia.runtime_error(e)
end
begin
@root.geometry(geometry)
rescue RuntimeError => e
Arcadia.runtime_error(e)
end
begin
@root.raise
rescue RuntimeError => e
Arcadia.runtime_error(e)
end
begin
Tk.update_idletasks
rescue RuntimeError => e
Arcadia.runtime_error(e)
end
if self['conf']['geometry.state'] == 'zoomed'
if Arcadia.is_windows?
@root.state('zoomed')
else
@root.wm_attributes('zoomed',1)
end
end
@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)
@@last_input_keyboard_query_event=nil
end
|
Instance Attribute Details
#layout ⇒ Object
Returns the value of attribute layout.
19
20
21
|
# File 'lib/a-core.rb', line 19
def layout
@layout
end
|
#localization ⇒ Object
Returns the value of attribute localization.
22
23
24
|
# File 'lib/a-core.rb', line 22
def localization
@localization
end
|
#mf_root ⇒ Object
Returns the value of attribute mf_root.
21
22
23
|
# File 'lib/a-core.rb', line 21
def mf_root
@mf_root
end
|
#wf ⇒ Object
Returns the value of attribute wf.
20
21
22
|
# File 'lib/a-core.rb', line 20
def wf
@wf
end
|
Class Method Details
.[](_name) ⇒ Object
1158
1159
1160
|
# File 'lib/a-core.rb', line 1158
def Arcadia.[](_name)
@@instance[_name]
end
|
.conf_group(_path, _refresh = false) ⇒ Object
.conf_group_copy(_path_source, _path_target, _suff = 'conf') ⇒ Object
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
|
# File 'lib/a-core.rb', line 1038
def Arcadia.conf_group_copy(_path_source, _path_target, _suff = 'conf')
_target = conf_group(_path_source)
_postfix = _path_target.sub(_path_source,"")
_target.each{|k,v|
if ["frames.labels","frames.names","name"].include?(k)
v_a = v.split(',')
new_val = ''
v_a.each{|value|
if new_val.length > 0
new_val = "#{new_val},"
end
new_val = "#{new_val}#{value}#{_postfix}"
}
v = new_val
end
@@instance['conf']["#{_path_target}.#{k}"]=v
}
end
|
.console(_sender, _args = Hash.new) ⇒ Object
969
970
971
972
|
# File 'lib/a-core.rb', line 969
def Arcadia.console(_sender, _args=Hash.new)
_event = process_event(MsgEvent.new(_sender, _args))
_event.mark
end
|
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
|
# File 'lib/a-core.rb', line 974
def Arcadia.console_input(_sender)
@@input_ready = true if !defined?(@@input_ready)
while !@@input_ready && !@@input_ready.nil?
sleep(0.1)
end
begin
@@input_ready=false
@@last_input_keyboard_query_event = InputKeyboardQueryEvent.new(_sender)
@@last_input_keyboard_query_event.go!
ret = @@last_input_keyboard_query_event.results.length > 0 ? @@last_input_keyboard_query_event.results[0].input : nil
ensure
@@input_ready=true
@@last_input_keyboard_query_event=nil
end
ret
end
|
991
992
993
|
# File 'lib/a-core.rb', line 991
def Arcadia.console_input_event
@@last_input_keyboard_query_event
end
|
.dialog(_sender, _args = Hash.new) ⇒ Object
1021
1022
1023
1024
|
# File 'lib/a-core.rb', line 1021
def Arcadia.dialog(_sender, _args=Hash.new)
_event = process_event(DialogEvent.new(_sender, _args))
return _event.results[0].value if _event
end
|
.file_extension(_filename = nil) ⇒ Object
995
996
997
998
999
1000
|
# File 'lib/a-core.rb', line 995
def Arcadia.file_extension(_filename=nil)
if _filename
_m = /(.*\.)(.*$)/.match(File.basename(_filename))
end
_ret = (_m && _m.length > 1)?_m[2]: nil
end
|
.file_icon(_file_name) ⇒ Object
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
|
# File 'lib/a-core.rb', line 1206
def Arcadia.file_icon(_file_name)
_file_name = '' if _file_name.nil?
if @@instance['file_icons'] == nil
@@instance['file_icons'] = Hash.new
@@instance['file_icons']['default']= image_res(FILE_ICON_DEFAULT)
end
_base_name= File.basename(_file_name)
if _base_name.include?('.')
file_dn = _base_name.split('.')[-1]
else
file_dn = "no_ext"
end
if @@instance['file_icons'][file_dn].nil?
file_icon_name="FILE_ICON_#{file_dn.upcase}"
begin
if eval("defined?(#{file_icon_name})")
@@instance['file_icons'][file_dn]=image_res(eval(file_icon_name))
else
@@instance['file_icons'][file_dn]= @@instance['file_icons']['default']
end
rescue Exception
@@instance['file_icons'][file_dn]= @@instance['file_icons']['default']
end
end
@@instance['file_icons'][file_dn]
end
|
.finalize(id) ⇒ Object
206
207
208
|
# File 'lib/a-core.rb', line 206
def Arcadia.finalize(id)
puts "\nArcadia #{id} dying at #{Time.new}"
end
|
.gem_available?(_gem) ⇒ Boolean
271
272
273
274
275
276
277
278
279
280
281
282
283
284
|
# File 'lib/a-core.rb', line 271
def Arcadia.gem_available?(_gem)
if Gem::Specification.respond_to?(:find_by_name)
begin
!Gem::Specification::find_by_name(_gem).nil?
rescue Exception => e
false
end
elsif Gem.respond_to?(:available?)
return Gem.available?(_gem)
else
return !Gem.source_index.find_name(_gem).empty?
end
end
|
.image_res(_name) ⇒ Object
1187
1188
1189
1190
1191
1192
1193
1194
1195
|
# File 'lib/a-core.rb', line 1187
def Arcadia.image_res(_name)
if @@instance['image_res'] == nil
@@instance['image_res'] = Hash.new
end
if @@instance['image_res'][_name].nil?
@@instance['image_res'][_name] = TkPhotoImage.new('data' => _name)
end
@@instance['image_res'][_name]
end
|
.is_windows? ⇒ Boolean
1104
1105
1106
|
# File 'lib/a-core.rb', line 1104
def Arcadia.is_windows?
RUBY_PLATFORM =~ /mingw|mswin/
end
|
.lang_icon(_lang = nil) ⇒ Object
1197
1198
1199
1200
1201
1202
1203
1204
|
# File 'lib/a-core.rb', line 1197
def Arcadia.lang_icon(_lang=nil)
icon = "FILE_ICON_#{_lang.upcase if _lang}"
if _lang && eval("defined?(#{icon})")
image_res(eval(icon))
else
image_res(FILE_ICON_DEFAULT)
end
end
|
.layout ⇒ Object
1082
1083
1084
1085
1086
|
# File 'lib/a-core.rb', line 1082
def Arcadia.layout
if @@instance
return @@instance.layout
end
end
|
1177
1178
1179
1180
1181
1182
1183
1184
1185
|
# File 'lib/a-core.rb', line 1177
def Arcadia.(, =nil)
if @@instance['menu_roots'] == nil
@@instance['menu_roots'] = Hash.new
end
if != nil
@@instance['menu_roots'][]=
end
@@instance['menu_roots'][]
end
|
def Arcadia.res(_res)
theme = Arcadia.instance['conf']['theme']
if theme
ret = eval("#{theme}::#{_res}")
end
ret=Res::_res if ret.nil?
return ret
end
1244
1245
1246
1247
1248
|
# File 'lib/a-core.rb', line 1244
def Arcadia.(_name=nil)
if _name && @@instance && @@instance['menubar']
return @@instance['menubar'].items(_name)
end
end
|
.new_statusbar_item(_help = nil) ⇒ Object
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
|
# File 'lib/a-core.rb', line 1162
def Arcadia.new_statusbar_item(_help=nil)
_other = @@last_status_item if defined?(@@last_status_item)
@@last_status_item=@@instance.mf_root.add_indicator()
@@last_status_item.configure(:background=>Arcadia.conf("background"))
@@last_status_item.configure(:foreground=>Arcadia.conf("foreground"))
@@last_status_item.configure(:font=>Arcadia.conf("font"))
if _other
@@last_status_item.pack('before'=>_other)
end
if _help
Tk::BWidget::DynamicHelp::add(@@last_status_item, 'text'=>_help)
end
@@last_status_item
end
|
.open_file_dialog ⇒ Object
.pers_group(_path, _refresh = false) ⇒ Object
.persistent(_property, _value = nil, _immediate = false) ⇒ Object
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
|
# File 'lib/a-core.rb', line 1060
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
|
.ruby ⇒ Object
1108
1109
1110
1111
|
# File 'lib/a-core.rb', line 1108
def Arcadia.ruby
@ruby_interpreter=Gem.ruby if !defined?(@ruby_interpreter)
@ruby_interpreter
end
|
.runner(_name = nil) ⇒ Object
1014
1015
1016
1017
1018
|
# File 'lib/a-core.rb', line 1014
def Arcadia.runner(_name=nil)
if @@instance
return @@instance['runners'][_name]
end
end
|
.runner_for_file(_filename = nil) ⇒ Object
1002
1003
1004
1005
1006
|
# File 'lib/a-core.rb', line 1002
def Arcadia.runner_for_file(_filename=nil)
if @@instance
return @@instance['runners_by_ext'][Arcadia.file_extension(_filename)]
end
end
|
.runner_for_lang(_lang = nil) ⇒ Object
1008
1009
1010
1011
1012
|
# File 'lib/a-core.rb', line 1008
def Arcadia.runner_for_lang(_lang=nil)
if @@instance
return @@instance['runners_by_lang'][_lang]
end
end
|
.runtime_error(_e, _title = Arcadia.text("main.e.runtime.title")) ⇒ Object
.runtime_error_msg(_msg, _title = Arcadia.text("main.e.runtime.title")) ⇒ Object
.text(_key = nil, _params = nil) ⇒ Object
1094
1095
1096
1097
1098
|
# File 'lib/a-core.rb', line 1094
def Arcadia.text(_key=nil, _params=nil)
if @@instance
return @@instance.localization.text(_key, _params)
end
end
|
1250
1251
1252
1253
1254
1255
|
# File 'lib/a-core.rb', line 1250
def Arcadia.toolbar_item(_name=nil)
if _name && @@instance && @@instance['toolbar']
return @@instance['toolbar'].items[_name]
end
end
|
.unpersistent(_property, _immediate = false) ⇒ Object
1073
1074
1075
1076
1077
1078
1079
1080
|
# File 'lib/a-core.rb', line 1073
def Arcadia.unpersistent(_property, _immediate=false)
if @@instance
@@instance['pers'].delete(_property)
if _immediate
end
end
end
|
.wf ⇒ Object
1088
1089
1090
1091
1092
|
# File 'lib/a-core.rb', line 1088
def Arcadia.wf
if @@instance
return @@instance.wf
end
end
|
.which(_command = nil) ⇒ Object
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
|
# File 'lib/a-core.rb', line 1113
def Arcadia.which(_command=nil)
return nil if _command.nil?
_ret = nil
_file = _command
if FileTest.exist?(_file)
_ret = _file
end
if _ret.nil?
_file = File.join(Dir.pwd, _command)
if FileTest.exist?(_file)
_ret = _file
end
end
if _ret.nil?
ENV['PATH'].split(File::PATH_SEPARATOR).each{|_path|
_file = File.join(_path, _command)
if FileTest.exist?(_file)
_ret = _file
break
end
}
end
gem_path = Gem.path
gem_path.each{|_path|
_file = File.join(_path,'bin',_command)
if FileTest.exist?(_file)
_ret = _file
break
end
} if gem_path && gem_path.kind_of?(Array)
if _ret.nil?
begin
_ret = Gem.bin_path(_command)
rescue
_ret = nil
end
end
_ret
end
|
Instance Method Details
#check_gems_dependences(_ext) ⇒ Object
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
|
# File 'lib/a-core.rb', line 286
def check_gems_dependences(_ext)
ret = true
gems_property = self['conf']["#{_ext}.gems"]
if gems_property
gems = gems_property.split(',').collect{| g | g.strip }
if gems && gems.length > 0
gems.each{|gem|
if !Arcadia.gem_available?(gem)
repository_property = self['conf']["#{_ext}.gems.#{gem}.repository"]
events_property = self['conf']["#{_ext}.gems.#{gem}.events"]
args = Hash.new
args['extension_name']=_ext
args['gem_name']=gem
args['gem_repository']=repository_property if repository_property
args['gem_events']=events_property if events_property
if events_property
events_str = events_property.split(',')
events_str.each{|event_str|
EventWatcherForGem.new(eval(event_str),args)
}
else
@splash.withdraw if @splash
_event = Arcadia.process_event(NeedRubyGemWizardEvent.new(self, args))
ret = ret && Arcadia.gem_available?(gem)
@splash.deiconify if @splash
end
break if !ret
end
}
end
end
ret
end
|
#do_build ⇒ Object
325
326
327
328
329
330
331
332
333
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
|
# File 'lib/a-core.rb', line 325
def do_build
Array.new.concat(@exts).each{|extension|
if extension && ext_source_must_be_loaded?(extension)
gems_installed = check_gems_dependences(extension)
if !gems_installed || !ext_load(extension)
@exts.delete(extension)
elsif !ext_active?(extension)
@exts.delete(extension)
elsif ext_active?(extension)
@splash.next_step(Arcadia.text("main.splash.creating_extension", [extension])) if @splash
@exts.delete(extension) unless
(((@exts_dip[extension] != nil && @exts_loaded.include?(@exts_dip[extension]))||@exts_dip[extension] == nil) && ext_create(extension))
end
end
}
begin
_build_event = Arcadia.process_event(BuildEvent.new(self))
rescue Exception => e
ret = false
msg = Arcadia.text("main.e.during_build_event.msg", [ $!.class.to_s , $!.to_s , $@.to_s ] )
ans = Arcadia.dialog(self,
'type'=>'abort_retry_ignore',
'title' => Arcadia.text("main.e.during_build_event.title"),
'msg'=>msg,
'exception'=>e,
'level'=>'error')
if ans == 'abort'
raise
exit
elsif ans == 'retry'
retry
else
Tk.update
end
end
end
|
#do_exit ⇒ Object
831
832
833
834
835
836
837
838
839
840
841
842
843
844
|
# File 'lib/a-core.rb', line 831
def do_exit
q1 = conf('confirm-on-exit')!='yes' || (Arcadia.dialog(self,
'type'=>'yes_no',
'msg'=> Arcadia.text("main.d.confirm_exit.msg"),
'title' => Arcadia.text("main.d.confirm_exit.title"),
'level' => 'question')=='yes')
if q1 && can_exit?
do_finalize
@root.destroy
Tk.exit
end
end
|
#do_finalize ⇒ Object
962
963
964
965
966
967
|
# File 'lib/a-core.rb', line 962
def do_finalize
self.save_layout
_event = Arcadia.process_event(FinalizeEvent.new(self))
update_local_config
self.override_persistent(self['applicationParams'].persistent_file, self['pers'])
end
|
#do_make_clones ⇒ Object
368
369
370
371
372
373
374
375
376
377
|
# File 'lib/a-core.rb', line 368
def do_make_clones
Array.new.concat(@exts_i).each{|ext|
if ext.kind_of?(ArcadiaExtPlus)
a = ext.conf_array("#{ext.name}.clones")
a.each{|clone_name|
ext.clone(clone_name)
}
end
}
end
|
#ext_active?(_name) ⇒ Boolean
210
211
212
213
|
# File 'lib/a-core.rb', line 210
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
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
|
# File 'lib/a-core.rb', line 427
def ext_create(_extension)
ret = true
begin
class_name = self['conf'][_extension+'.class']
if class_name.strip.length > 0
klass = nil
begin
klass = eval(class_name)
rescue => e
puts 'does an extension class have the wrong name associated with it, in its conf file?, or is not listing the right .rb file?'
raise e
end
publish(_extension, klass.new(self, _extension))
end
rescue Exception,LoadError => e
ret = false
msg = Arcadia.text("main.e.creating_ext.msg", [_extension, $!.class.to_s, $!, $@.to_s])
ans = Arcadia.dialog(self,
'type'=>'abort_retry_ignore',
'title' => Arcadia.text("main.e.creating_ext.title", [_extension]),
'msg'=>msg,
'exception'=>e,
'level'=>'error')
if ans == 'abort'
raise
exit
elsif ans == 'retry'
retry
else
Tk.update
end
end
ret
end
|
#ext_load(_extension) ⇒ Object
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
|
# File 'lib/a-core.rb', line 398
def ext_load(_extension)
ret = true
begin
source = self['conf'][_extension+'.require']
if source.strip.length > 0
require "#{Dir.pwd}/#{source}"
end
@exts_loaded << _extension
rescue Exception,LoadError => e
ret = false
msg = Arcadia.text("main.e.loading_ext.msg", [_extension, $!.class.to_s, $!.to_s, $@.to_s ] )
ans = Arcadia.dialog(self,
'type'=>'abort_retry_ignore',
'title' => Arcadia.text("main.e.loading_ext.title", [_extension]),
'msg'=>msg,
'exception'=>e,
'level'=>'error')
if ans == 'abort'
raise
exit
elsif ans == 'retry'
retry
else
Tk.update
end
end
ret
end
|
#ext_source_must_be_loaded?(_name) ⇒ Boolean
215
216
217
218
219
220
221
222
223
224
225
226
|
# File 'lib/a-core.rb', line 215
def ext_source_must_be_loaded?(_name)
ret = ext_active?(_name)
if !ret
@exts_dip.each{|key,val|
if val == _name
ret = ret || ext_active?(key)
end
break if ret
}
end
ret
end
|
#geometry_from_a(_a = nil) ⇒ Object
869
870
871
872
|
# File 'lib/a-core.rb', line 869
def geometry_from_a(_a=nil)
return "0x0+0+0" if _a.nil? || _a.length < 4
"#{_a[0]}x#{_a[1]}+#{_a[2]}+#{_a[3]}"
end
|
#geometry_refine(_geometry) ⇒ Object
851
852
853
854
855
856
857
858
859
860
|
# File 'lib/a-core.rb', line 851
def geometry_refine(_geometry)
begin
a = geometry_to_a(_geometry)
toolbar_height = @root.winfo_height-@root.winfo_screenheight
a[3] = (a[3].to_i - toolbar_height.abs).abs.to_s
geometry_from_a(a)
rescue
return _geometry
end
end
|
#geometry_to_a(_geometry = nil) ⇒ Object
862
863
864
865
866
867
|
# File 'lib/a-core.rb', line 862
def geometry_to_a(_geometry=nil)
return if _geometry.nil?
wh,x,y=_geometry.split('+')
w,h=wh.split('x')
[w,h,x,y]
end
|
#initialize_layout ⇒ Object
def ext_method(_extension, _method)
begin
self[_extension].send(_method)
rescue Exception => e
msg = _method.to_s+' "'+_extension.to_s+'"'+" ("+$!.class.to_s+") "+" : "+$! + "\n at : "[email protected]_s
ans = Arcadia.dialog(self,
'type'=>'abort_retry_ignore',
'title' => "(Arcadia) Extensions",
'msg'=>msg,
'exception'=>e,
'level'=>'error')
if ans == 'abort'
raise
exit
elsif ans == 'retry'
retry
else
Tk.update
end
end
end
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
|
# File 'lib/a-core.rb', line 487
def initialize_layout
@layout = ArcadiaLayout.new(self, @mf_root.get_frame)
suf = "layout.split"
elems = self['conf'][suf]
return if elems.nil?
if elems.strip.length > 0
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
if @need_resize
w_c = (w.to_i*@x_scale).to_i
else
w_c = w.to_i
end
@layout.add_cols(pt[0].to_i, pt[1].to_i, w_c)
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
if @need_resize
w_c = (w.to_i*@y_scale).to_i
else
w_c = w.to_i
end
@layout.add_rows(pt[0].to_i, pt[1].to_i, w_c)
end
end
end
rescue Exception
msg = Arcadia.text('main.e.loading_layout.msg', [$!.class.to_s, $!.to_s, $@.to_s])
if Arcadia.dialog(self,
'type'=>'ok_cancel',
'level'=>'error',
'title' => Arcadia.text('main.e.loading_layout.title'),
'exception' => $!,
'msg'=>msg)=='cancel'
raise
exit
else
Tk.update
end
end
end
}
else
@layout.add_mono_panel
end
@layout.
end
|
#last_focused_text_widget ⇒ Object
189
190
191
|
# File 'lib/a-core.rb', line 189
def last_focused_text_widget
@focus_event_manager.last_focus_widget
end
|
#load_config ⇒ Object
555
556
557
558
559
560
561
562
563
564
|
# File 'lib/a-core.rb', line 555
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'])
self.resolve_properties_link(self['conf_without_local'],self['conf_without_local'])
self.load_sysdefaultproperty
end
|
#load_exts_conf ⇒ Object
228
229
230
231
232
233
234
|
# File 'lib/a-core.rb', line 228
def load_exts_conf
@exts = Array.new
@exts_i = Array.new
@exts_dip = Hash.new
@exts_loaded = Array.new
load_exts_conf_from('ext')
end
|
#load_exts_conf_from(_dir = '', _ext_root = nil) ⇒ Object
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
# File 'lib/a-core.rb', line 236
def load_exts_conf_from(_dir='',_ext_root=nil)
dirs = Array.new
files = Dir["#{_dir}/*"].concat(Dir[ENV["HOME"]+"/.arcadia/#{_dir}/*"]).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
begin
new_key = name+'.'+key
rescue => e
puts 'is an extension missing a name?'
raise e
end
end
conf_hash2[new_key]= value
}
@exts << name
if _ext_root
@exts_dip[name] = _ext_root
end
self['conf'].update(conf_hash2)
self['origin_conf'].update(conf_hash2)
self['conf_without_local'].update(conf_hash2)
load_exts_conf_from("#{ext_dir}/ext",name)
}
end
|
#load_key_binding(_ext = '') ⇒ Object
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
|
# File 'lib/a-core.rb', line 750
def load_key_binding(_ext='')
return unless _ext && ext_active?(_ext)
if _ext.length > 0
if self[_ext]
_self_on_eval = self[_ext]
else
_self_on_eval = self
end
suf = "#{_ext}.keybinding"
else
_self_on_eval = self
suf = "keybinding"
end
keybs=Arcadia.conf_group(suf)
keybs.each{|k,v|
register_key_binding(_self_on_eval, k, v)
}
end
|
#load_maximized ⇒ Object
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
|
# File 'lib/a-core.rb', line 379
def load_maximized
lm = self['conf']['layout.maximized']
if lm
ext,index=lm.split(',')
maxed = false
if ext && index
ext = ext.strip
i=index.strip.to_i
@exts_i.each{|e|
if e.conf('name')==ext && !maxed
e.maximize(i)
maxed=true
break
end
}
end
end
end
|
#load_runners ⇒ Object
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
|
# File 'lib/a-core.rb', line 632
def load_runners
self['runners'] = Hash.new
self['runners_by_ext'] = Hash.new
self['runners_by_lang'] = Hash.new
mr = Arcadia.('runcurr')
return if mr.nil?
insert_runner_item = proc{|name, run|
if run[:file_exts]
run[:file_exts].split(',').each{|ext|
self['runners_by_ext'][ext.strip.sub('.','')]=run
}
end
if run[:lang]
self['runners_by_lang'][run[:lang]]=run
end
if run[:runner] && self['runners'][run[:runner]]
run = Hash.new.update(self['runners'][run[:runner]]).update(run)
end
_run_title = run[:title]
run[:title] = nil
run[:runner_name] = name
_command = proc{
_event = Arcadia.process_event(
RunCmdEvent.new(self, run)
)
}
mr.insert('0',
:command ,{
:image => Arcadia.file_icon(run[:file_exts]),
:label => _run_title,
:font => Arcadia.conf('menu.font'),
:compound => 'left',
:command => _command
}
)
}
insert_runner_instance_item = proc{|name, run|
if run[:runner] && self['runners'][run[:runner]]
run = Hash.new.update(self['runners'][run[:runner]]).update(run)
end
_run_title = run[:title]
run[:title] = nil
run[:runner_name] = name
_command = proc{
_event = Arcadia.process_event(
RunCmdEvent.new(self, run)
)
}
mr.insert('0',
:command ,{
:image => Arcadia.file_icon(run[:file_exts]),
:label => _run_title,
:font => Arcadia.conf('menu.font'),
:compound => 'left',
:command => _command
}
)
}
runs=Arcadia.conf_group('runners')
mr.insert('0', :separator) if runs && !runs.empty?
runs.each{|name, hash_string|
self['runners'][name]=eval hash_string
}
self['runners'].each{|name, run|
insert_runner_item.call(name, run)
}
runs=Arcadia.pers_group('runners')
mr.insert('0', :separator) if runs && !runs.empty?
pers_runner = Hash.new
runs.each{|name, hash_string|
begin
pers_runner[name]=eval hash_string
rescue Exception => e
p Arcadia("main.e.loading_runner.title", [name])
p Arcadia("main.e.loading_runner.msg", [hash_string, e.message])
Arcadia.unpersistent("runners.#{name}")
end
}
pers_runner.each{|name, run|
insert_runner_instance_item.call(name, run)
}
end
|
#load_sysdefaultproperty ⇒ Object
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
|
# File 'lib/a-core.rb', line 566
def load_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']}"
Tk.tk_call "eval","option add *highlightcolor #{self['conf']['background']}"
Tk.tk_call "eval","option add *relief #{self['conf']['relief']}"
if !Arcadia.is_windows? && File.basename(Arcadia.ruby) != 'ruby'
begin
if !FileTest.exist?("#{local_dir}/bin")
Dir.mkdir("#{local_dir}/bin")
end
system("ln -s #{Arcadia.ruby} #{local_dir}/bin/ruby") if !File.exist?("#{local_dir}/bin/ruby")
rescue Exception => e
Arcadia.runtime_error(e)
end
end
end
|
#load_user_control(_user_control, _ext = '', _pre = '') ⇒ Object
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
|
# File 'lib/a-core.rb', line 769
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 = make_value(_self_on_eval, 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"]
rif = self['conf']["#{suf1}.rif"] == nil ? 'main': self['conf']["#{suf1}.rif"]
context_underline = self['conf']["#{suf1}.context_underline"]
items = self['conf'][suf1].split(',')
items.each{|item|
suf2 = suf1+'.'+item
disabled = !self['conf']["#{suf2}.disabled"].nil?
iprops=Arcadia.conf_group(suf2)
item_args = Hash.new
iprops.each{|k,v|
item_args[k]=make_value(_self_on_eval, v)
}
item_args['name'] = item if item_args['name'].nil?
item_args['rif'] = rif
item_args['context'] = group
item_args['context_path'] = context_path
item_args['context_caption'] = groups_caption[gi] if groups_caption
item_args['context_underline'] = context_underline.strip.to_i if context_underline
i = _user_control.new_item(_self_on_eval, item_args)
i.enable=false if disabled
}
rescue Exception
msg = Arcadia.text("main.e.loading_user_control.msg", [groups, items, $!.class.to_s, $!.to_s, $@.to_s])
if Arcadia.dialog(self,
'type'=>'ok_cancel',
'title' => Arcadia.text("main.e.loading_user_control.title", [_user_control.class::SUF]),
'msg'=>msg,
'exception'=>$!,
'level'=>'error')=='cancel'
raise
exit
else
Tk.update
end
end
end
}
end
|
#manage_runners ⇒ Object
726
727
728
729
730
731
732
733
|
# File 'lib/a-core.rb', line 726
def manage_runners
if !@runm
@runm = RunnerManager.new(Arcadia.layout.root)
@runm.on_close=proc{@runm.hide}
end
@runm.show
@runm.load_items
end
|
#on_quit(_event) ⇒ Object
177
178
179
|
# File 'lib/a-core.rb', line 177
def on_quit(_event)
self.do_exit
end
|
#prepare ⇒ Object
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
|
# File 'lib/a-core.rb', line 587
def prepare
super
@splash.next_step(Arcadia.text('main.splash.initializing_layout')) if @splash
initialize_layout
publish('buffers.code.in_memory',Hash.new)
@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})
publish('action.show_about', proc{ArcadiaAboutSplash.new.deiconify})
self['menubar'] = ArcadiaMainMenu.new(@main_menu_bar)
@splash.next_step(Arcadia.text('main.splash.building_extensions')) if @splash
self.do_build
publish('objic.action.raise_active_obj',
proc{
InspectorContract.instance.raise_active_toplevel(self)
}
)
@splash.next_step(Arcadia.text('main.splash.loading_common_user_controls')) if @splash
load_user_control(self['toolbar'])
load_user_control(self['menubar'])
@splash.next_step(Arcadia.text('main.splash.loading_keys_binding')) if @splash
load_key_binding
@exts.each{|ext|
@splash.next_step(Arcadia.text("main.splash.loading_ext_user_controls",[ext])) if @splash
load_user_control(self['toolbar'], ext)
load_user_control(self['menubar'], ext)
load_key_binding(ext)
}
load_user_control(self['toolbar'],"","e")
load_user_control(self['menubar'],"","e")
@splash.next_step(Arcadia.text('main.splash.loading_runners')) if @splash
load_runners
do_make_clones
@splash.next_step(Arcadia.text('main.splash.initializing_extensions')) if @splash
do_initialize
end
|
#register(_ext) ⇒ Object
181
182
183
|
# File 'lib/a-core.rb', line 181
def register(_ext)
@exts_i << _ext
end
|
#register_key_binding(_self_target, k, v) ⇒ Object
735
736
737
738
739
740
741
742
743
744
745
746
747
748
|
# File 'lib/a-core.rb', line 735
def register_key_binding(_self_target, k, v)
value = v.strip
key_dits = k.split('[')
return if k.length == 0
key_event=key_dits[0]
if key_dits[1]
key_sym=key_dits[1][0..-2]
end
@root.bind_append(key_event){|e|
if key_sym == e.keysym
Arcadia.process_event(_self_target.instance_eval(value))
end
}
end
|
#save_layout ⇒ Object
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
|
# File 'lib/a-core.rb', line 874
def save_layout
self['conf']['geometry']= geometry_refine(TkWinfo.geometry(@root))
begin
if Arcadia.is_windows?
self['conf']['geometry.state'] = @root.state.to_s
else
if @root.wm_attributes('zoomed') == '1'
self['conf']['geometry.state']='zoomed'
else
self['conf']['geometry.state']='normal'
end
end
rescue
self['conf']['geometry.state']='not_supported'
end
Arcadia.del_conf_group(self['conf'],'layout')
@exts_i.each{|e|
found = false
if e.conf('frames')
frs = e.conf('frames').split(',')
else
frs = Array.new
end
frs.each_index{|i|
if e.maximized?(i)
self['conf']['layout.maximized']="#{e.conf('name')},#{i}"
e.resize(i)
found=true
break
end
}
break if found
}
splits,doms,r,c = @layout.dump_geometry
= ""
splits.each_index{|i|
<< i.to_s
<< ',' if i < splits.length-1
}
self['conf']['layout.split']=
splits.each_with_index{|sp,i|
self['conf']["layout.split.#{i}"]=sp
}
@exts_i.each{|e|
if e.conf('frames')
frs = e.conf('frames').split(',')
else
frs = Array.new
end
str_frames=''
frs.each_index{|i|
f = e.frame(i,false)
if f
ff = f.hinner_frame
frame = ff.frame if ff
if frame && TkWinfo.parent(frame).instance_of?(Tk::BWidget::NoteBook)
frame=TkWinfo.parent(TkWinfo.parent(frame))
elsif frame.nil?
if str_frames.length > 0
str_frames << ','
end
str_frames << ArcadiaLayout::HIDDEN_DOMAIN
end
if doms[frame]
if str_frames.length > 0
str_frames << ','
end
str_frames << doms[frame]
end
else
end
}
if str_frames.length > 0
self['conf']["#{e.conf('name')}.frames"]=str_frames
end
}
if @is_toolbar_show
self['conf']['user_toolbar_show']='yes'
else
self['conf']['user_toolbar_show']='no'
end
end
|
193
194
195
196
197
198
199
200
201
202
203
|
# File 'lib/a-core.rb', line 193
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
|
#unregister(_ext) ⇒ Object
185
186
187
|
# File 'lib/a-core.rb', line 185
def unregister(_ext)
@exts_i.delete(_ext)
end
|