Class: Arcadia

Inherits:
TkApplication show all
Includes:
OS, Observable
Defined in:
lib/a-core.rb

Constant Summary

Constants included from Configurable

Configurable::ADD_SYMBOL, Configurable::FONT_TYPE_SYMBOL, Configurable::LC_SYMBOL, Configurable::LINK_SYMBOL

Instance Attribute Summary collapse

Attributes inherited from TkApplication

#tcltk_info

Class Method Summary collapse

Instance Method Summary collapse

Methods included from OS

arm?, freebsd?, linux?, mac?, unix?, windows?

Methods inherited from TkApplication

#run, sys_info

Methods inherited from Application

#[], #[]=, array_conf, conf, #conf, conf_array, #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, #attach_listeners_listener, #broadcast_event, #detach_listener, #detach_listeners_listener, #process_event

Methods included from Persistable

#append_persistent_property, #override_persistent

Methods included from Configurable

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

#initializeArcadia

Returns a new instance of Arcadia.



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
176
177
178
179
# File 'lib/a-core.rb', line 25

def initialize
  @initialized=false
  super(
    ApplicationParams.new(
      'arcadia',
      '1.1.0',
      'conf/arcadia.conf',
      'conf/arcadia.pers'
    )
  )
  load_config
  @localization = ArcadiaLocalization.new
  if self['conf']['encoding']
    Tk.encoding=self['conf']['encoding']
  end
  #    @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
  @wf = TkWidgetFactory.new
  ArcadiaProblemsShower.new(self)
  ArcadiaDialogManager.new(self)
  ArcadiaActionDispatcher.new(self)
  ArcadiaGemsWizard.new(self)
  MonitorLastUsedDir.new
  @focus_event_manager = FocusEventManager.new
  #self.load_local_config(false)
  ObjectSpace.define_finalizer($arcadia, self.class.method(:finalize).to_proc)
  #_title = "Arcadia Ruby ide :: [Platform = #{RUBY_PLATFORM}] [Ruby version = #{RUBY_VERSION}] [TclTk version = #{tcltk_info.level}]"
  _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(A_LOGO_STRIP_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
  ).pack(
    'anchor'=> 'center',
    'fill'=> 'both',
    'expand'=> 1
  )
  #.place('x'=>0,'y'=>0,'relwidth'=>1,'relheight'=>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(62) 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 OS.windows? # on doze don't go below the start gar
      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
    #p "RuntimeError : #{e.message}"
    Arcadia.runtime_error(e)
  end
  begin
    @root.focus(true)
  rescue RuntimeError => e
    #p "RuntimeError : #{e.message}"
    Arcadia.runtime_error(e)
  end
  begin
    @root.geometry(geometry)
  rescue RuntimeError => e
    #p "RuntimeError : #{e.message}"
    Arcadia.runtime_error(e)
  end
  begin
    @root.raise
  rescue RuntimeError => e
    #p "RuntimeError : #{e.message}"
    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? || OS.mac?
      @root.state('zoomed')
    else
      @root.wm_attributes('zoomed',1)
    end
  end
  #sleep(1)
  @splash.last_step if @splash
  @splash.destroy  if @splash
  if @first_run # first ARCADIA ever
    Arcadia.process_event(OpenBufferEvent.new(self,'file'=>'README.md'))
  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
  @initialized=true
 #   @focus_event_manager = FocusEventManager.new
end

Instance Attribute Details

#extsObject (readonly)

Returns the value of attribute exts.



24
25
26
# File 'lib/a-core.rb', line 24

def exts
  @exts
end

#layoutObject (readonly)

Returns the value of attribute layout.



20
21
22
# File 'lib/a-core.rb', line 20

def layout
  @layout
end

#localizationObject (readonly)

Returns the value of attribute localization.



23
24
25
# File 'lib/a-core.rb', line 23

def localization
  @localization
end

#mf_rootObject (readonly)

Returns the value of attribute mf_root.



22
23
24
# File 'lib/a-core.rb', line 22

def mf_root
  @mf_root
end

#wfObject (readonly)

Returns the value of attribute wf.



21
22
23
# File 'lib/a-core.rb', line 21

def wf
  @wf
end

Class Method Details

.[](_name) ⇒ Object



1346
1347
1348
# File 'lib/a-core.rb', line 1346

def Arcadia.[](_name)
  @@instance[_name]
end

.conf_group(_path, _refresh = false) ⇒ Object



1185
1186
1187
# File 'lib/a-core.rb', line 1185

def Arcadia.conf_group(_path, _refresh=false)
  Configurable.properties_group(_path, Arcadia.instance['conf'], 'conf', _refresh)
end

.conf_group_copy(_path_source, _path_target, _suff = 'conf') ⇒ Object



1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
# File 'lib/a-core.rb', line 1193

def Arcadia.conf_group_copy(_path_source, _path_target, _suff = 'conf')
  _target = conf_group(_path_source)
  _postfix = _path_target.sub(_path_source,"")
#      p "====== copy ======="
  _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
#      p "#{k} = #{v}"
  }
#    p "====== copy ======="
end

.conf_group_without_local(_path, _refresh = false) ⇒ Object



1189
1190
1191
# File 'lib/a-core.rb', line 1189

def Arcadia.conf_group_without_local(_path, _refresh=false)
  Configurable.properties_group(_path, Arcadia.instance['conf_without_local'], 'conf_without_local', _refresh)
end

.console(_sender, _args = Hash.new) ⇒ Object



1111
1112
1113
1114
# File 'lib/a-core.rb', line 1111

def Arcadia.console(_sender, _args=Hash.new)
  _event = process_event(MsgEvent.new(_sender, _args))
  _event.mark
end

.console_input(_sender, _pid = nil) ⇒ Object



1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
# File 'lib/a-core.rb', line 1116

def Arcadia.console_input(_sender, _pid=nil)
  @@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, :pid => _pid)
    @@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

.console_input_eventObject



1133
1134
1135
# File 'lib/a-core.rb', line 1133

def Arcadia.console_input_event
  @@last_input_keyboard_query_event
end

.dialog(_sender, _args = Hash.new) ⇒ Object



1163
1164
1165
1166
1167
1168
1169
1170
# File 'lib/a-core.rb', line 1163

def Arcadia.dialog(_sender, _args=Hash.new)
  if @@instance && @@instance.initialized?
    Arcadia.hinner_dialog(_sender, _args)
  else
    _event = process_event(SystemDialogEvent.new(_sender, _args))
    return _event.results[0].value if _event
  end
end

.extension(_name = nil) ⇒ Object



1445
1446
1447
1448
1449
# File 'lib/a-core.rb', line 1445

def Arcadia.extension(_name=nil)
  if _name && @@instance && @@instance['exts_map']
    return @@instance['exts_map'][_name]
  end
end

.extensionsObject



1451
1452
1453
1454
1455
# File 'lib/a-core.rb', line 1451

def Arcadia.extensions
  if @@instance && @@instance.exts
    return @@instance.exts
  end
end

.file_extension(_filename = nil) ⇒ Object



1137
1138
1139
1140
1141
1142
# File 'lib/a-core.rb', line 1137

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



1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
# File 'lib/a-core.rb', line 1394

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)
    #TkPhotoImage.new('dat' => 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))
        #TkPhotoImage.new('dat' => 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



224
225
226
# File 'lib/a-core.rb', line 224

def Arcadia.finalize(id)
  puts "\nArcadia #{id} dying at #{Time.new}"
end

.gem_available?(_gem) ⇒ Boolean

Returns:

  • (Boolean)


289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/a-core.rb', line 289

def Arcadia.gem_available?(_gem)
  #TODO : Gem::Specification::find_by_name(_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

.hinner_dialog(_sender, _args = Hash.new) ⇒ Object



1172
1173
1174
1175
# File 'lib/a-core.rb', line 1172

def Arcadia.hinner_dialog(_sender, _args=Hash.new)
  _event = process_event(HinnerDialogEvent.new(_sender, _args))
  return _event.results[0].value if _event
end

.image_res(_name) ⇒ Object



1375
1376
1377
1378
1379
1380
1381
1382
1383
# File 'lib/a-core.rb', line 1375

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

Returns:

  • (Boolean)


1287
1288
1289
1290
# File 'lib/a-core.rb', line 1287

def Arcadia.is_windows?
  OS.windows?
  #RUBY_PLATFORM =~ /mingw|mswin/
end

.lang_icon(_lang = nil) ⇒ Object



1385
1386
1387
1388
1389
1390
1391
1392
# File 'lib/a-core.rb', line 1385

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

.layoutObject



1237
1238
1239
1240
1241
# File 'lib/a-core.rb', line 1237

def Arcadia.layout
  if @@instance
    return @@instance.layout
  end
end


1365
1366
1367
1368
1369
1370
1371
1372
1373
# File 'lib/a-core.rb', line 1365

def Arcadia.menu_root(_menu_root_name, _menu_root=nil)
  if @@instance['menu_roots'] == nil
    @@instance['menu_roots'] = Hash.new
  end
  if _menu_root != nil
    @@instance['menu_roots'][_menu_root_name]= _menu_root
  end
  @@instance['menu_roots'][_menu_root_name]
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


1432
1433
1434
1435
1436
# File 'lib/a-core.rb', line 1432

def Arcadia.menubar_item(_name=nil)
  if _name && @@instance && @@instance['menubar']
    return @@instance['menubar'].items(_name)
  end
end

.new_statusbar_item(_help = nil) ⇒ Object



1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
# File 'lib/a-core.rb', line 1350

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_string_dialog(_label = nil) ⇒ Object



1283
1284
1285
# File 'lib/a-core.rb', line 1283

def Arcadia.open_string_dialog(_label=nil)
  HinnerStringDialog.new(_label).string
end

.open_system_file_dialogObject



1255
1256
1257
# File 'lib/a-core.rb', line 1255

def Arcadia.open_system_file_dialog
  Tk.getOpenFile 'initialdir' => MonitorLastUsedDir.get_last_dir
end

.pers_group(_path, _refresh = false) ⇒ Object



1181
1182
1183
# File 'lib/a-core.rb', line 1181

def Arcadia.pers_group(_path, _refresh=false)
  Configurable.properties_group(_path, Arcadia.instance['pers'], 'pers', _refresh)
end

.persistent(_property, _value = nil, _immediate = false) ⇒ Object



1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
# File 'lib/a-core.rb', line 1215

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

.rubyObject



1292
1293
1294
1295
# File 'lib/a-core.rb', line 1292

def Arcadia.ruby
  @ruby_interpreter=Gem.ruby if !defined?(@ruby_interpreter)
  @ruby_interpreter
end

.runner(_name = nil) ⇒ Object



1156
1157
1158
1159
1160
# File 'lib/a-core.rb', line 1156

def  Arcadia.runner(_name=nil)
  if @@instance
    return @@instance['runners'][_name]
  end
end

.runner_for_file(_filename = nil) ⇒ Object



1144
1145
1146
1147
1148
# File 'lib/a-core.rb', line 1144

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



1150
1151
1152
1153
1154
# File 'lib/a-core.rb', line 1150

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



1457
1458
1459
# File 'lib/a-core.rb', line 1457

def Arcadia.runtime_error(_e, _title=Arcadia.text("main.e.runtime.title"))
  ArcadiaProblemEvent.new(self, "type"=>ArcadiaProblemEvent::RUNTIME_ERROR_TYPE,"title"=>"#{_title} : [#{_e.class}] #{_e.message} at :", "detail"=>_e.backtrace).go!
end

.runtime_error_msg(_msg, _title = Arcadia.text("main.e.runtime.title")) ⇒ Object



1461
1462
1463
# File 'lib/a-core.rb', line 1461

def Arcadia.runtime_error_msg(_msg, _title=Arcadia.text("main.e.runtime.title"))
  ArcadiaProblemEvent.new(self, "type"=>ArcadiaProblemEvent::RUNTIME_ERROR_TYPE,"title"=>"#{_title} at :", "detail"=>_msg).go!
end

.save_file_dialog(_initial_dir = MonitorLastUsedDir.get_last_dir) ⇒ Object



1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
# File 'lib/a-core.rb', line 1267

def Arcadia.save_file_dialog(_initial_dir=MonitorLastUsedDir.get_last_dir)
  file = HinnerFileDialog.new(HinnerFileDialog::SAVE_FILE_MODE).file(_initial_dir)
  if !file.nil? && File.exists?(file) 
    if (Arcadia.dialog(self, 'type'=>'yes_no',
    'msg'=>Arcadia.text('main.d.confirm_override_file.msg', [file]),
    'title' => Arcadia.text('main.d.confirm_override_file.title'),
    'level' => 'question')=='yes')
        return file
    else
      return nil
    end
  else
    return file
  end
end

.select_dir_dialog(_initial_dir = MonitorLastUsedDir.get_last_dir, must_exist = nil, _label = nil) ⇒ Object



1263
1264
1265
# File 'lib/a-core.rb', line 1263

def Arcadia.select_dir_dialog(_initial_dir=MonitorLastUsedDir.get_last_dir, must_exist = nil, _label=nil)
  HinnerFileDialog.new(HinnerFileDialog::SELECT_DIR_MODE, must_exist, _label).dir(_initial_dir)
end

.select_file_dialog(_initial_dir = MonitorLastUsedDir.get_last_dir, _label = nil) ⇒ Object



1259
1260
1261
# File 'lib/a-core.rb', line 1259

def Arcadia.select_file_dialog(_initial_dir=MonitorLastUsedDir.get_last_dir, _label=nil)
  HinnerFileDialog.new(HinnerFileDialog::SELECT_FILE_MODE, nil, _label).file(_initial_dir)
end

.style(_class) ⇒ Object



1177
1178
1179
# File 'lib/a-core.rb', line 1177

def Arcadia.style(_class)
  Configurable.properties_group(_class, Arcadia.instance['conf'])
end

.text(_key = nil, _params = nil) ⇒ Object



1249
1250
1251
1252
1253
# File 'lib/a-core.rb', line 1249

def Arcadia.text(_key=nil, _params=nil)
  if @@instance
    return @@instance.localization.text(_key, _params)
  end
end

.toolbar_item(_name = nil) ⇒ Object



1438
1439
1440
1441
1442
1443
# File 'lib/a-core.rb', line 1438

def Arcadia.toolbar_item(_name=nil)
  if _name && @@instance && @@instance['toolbar']
    #@@instance['toolbar'].items.each{|k, v | p k}
    return @@instance['toolbar'].items[_name]
  end
end

.unpersistent(_property, _immediate = false) ⇒ Object



1228
1229
1230
1231
1232
1233
1234
1235
# File 'lib/a-core.rb', line 1228

def Arcadia.unpersistent(_property, _immediate=false)
  if @@instance
    @@instance['pers'].delete(_property)
    if _immediate
      # not yet supported
    end
  end
end

.wfObject



1243
1244
1245
1246
1247
# File 'lib/a-core.rb', line 1243

def Arcadia.wf
  if @@instance
    return @@instance.wf
  end
end

.which(_command = nil) ⇒ Object



1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
# File 'lib/a-core.rb', line 1297

def Arcadia.which(_command=nil)
  return nil if _command.nil?
  _ret = nil
  _file = _command
  # command check
  if FileTest.exist?(_file)
    _ret = _file
  end
  # current dir check
  if _ret.nil?
    _file = File.join(Dir.pwd, _command)
    if FileTest.exist?(_file)
      _ret = _file
    end
  end
  # $PATH check
  if _ret.nil?
    begin
      ENV['PATH'].split(File::PATH_SEPARATOR).each{|_path|
        _file = File.join(_path, _command)
        if FileTest.exist?(_file)
          _ret = _file
          break
        end
      }
    rescue RuntimeError => e
      Arcadia.runtime_error(e)
    end
  end
  # gem path check
  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)
  # gem specific bin check
  if _ret.nil?
    begin
      _ret = Gem.bin_path(_command)
    rescue
      _ret = nil
    end
  end
  _ret
end

Instance Method Details

#can_exit?Boolean

Returns:

  • (Boolean)


988
989
990
991
# File 'lib/a-core.rb', line 988

def can_exit?
  _event = Arcadia.process_event(ExitQueryEvent.new(self, 'can_exit'=>true))
  _event.can_exit
end

#check_gems_dependences(_ext) ⇒ Object



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
333
334
335
336
337
338
339
340
341
# File 'lib/a-core.rb', line 304

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|
        # consider gem only if it is not installed
        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
            #EventWatcher.new
            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)
            #              if _event && _event.results
            #                ret = ret && _event.results[0].installed
            #              end
            @splash.deiconify  if @splash
          end
          break if !ret
        end
      }
    end
  end
  ret
end

#do_buildObject



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
# File 'lib/a-core.rb', line 343

def do_build
  # create extensions
  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
        #@splash.next_step('... creating '+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_exitObject



971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
# File 'lib/a-core.rb', line 971

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?
    @root.geometry('1x1-1-1')
    #ArcadiaAboutSplash.new.deiconify
    do_finalize
    @root.destroy
    #      Tk.mainloop_exist?
    #      Tk.destroy
    Tk.exit
  end
end

#do_finalizeObject



1104
1105
1106
1107
1108
1109
# File 'lib/a-core.rb', line 1104

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_initializeObject



382
383
384
# File 'lib/a-core.rb', line 382

def do_initialize
  _build_event = Arcadia.process_event(InitializeEvent.new(self))
end

#do_make_clonesObject



386
387
388
389
390
391
392
393
394
395
# File 'lib/a-core.rb', line 386

def do_make_clones
  Array.new.concat(@exts_i).each{|ext|
    if ext.kind_of?(ArcadiaExtPlus)
      a = ext.conf_array("clones")
      a.each{|clone_name|
        ext.clone(clone_name)
      }
    end
  }
end

#ext_active?(_name) ⇒ Boolean

Returns:

  • (Boolean)


228
229
230
231
# File 'lib/a-core.rb', line 228

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



445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
# File 'lib/a-core.rb', line 445

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')
    #      ans = Tk.messageBox('icon' => 'error', 'type' => 'abortretryignore',
    #      'title' => "(Arcadia) Extensions '#{_extension}'", 'parent' => @root,
    #      'message' => msg)
    if  ans == 'abort'
      raise
      exit
    elsif ans == 'retry'
      retry
    else
      Tk.update
    end
  end
  ret
end

#ext_load(_extension) ⇒ Object



416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
# File 'lib/a-core.rb', line 416

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

Returns:

  • (Boolean)


233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/a-core.rb', line 233

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



1011
1012
1013
1014
# File 'lib/a-core.rb', line 1011

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



993
994
995
996
997
998
999
1000
1001
1002
# File 'lib/a-core.rb', line 993

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



1004
1005
1006
1007
1008
1009
# File 'lib/a-core.rb', line 1004

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_layoutObject

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


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
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
# File 'lib/a-core.rb', line 505

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]
          #next if property.nil?
          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.add_headers
end

#initialized?Boolean

Returns:

  • (Boolean)


185
186
187
# File 'lib/a-core.rb', line 185

def initialized?
  @initialized
end

#insert_runner_item(root_menu = nil, name, run) ⇒ Object



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
725
726
727
728
729
730
731
732
733
734
# File 'lib/a-core.rb', line 693

def insert_runner_item(root_menu=nil, name, run)
  return if root_menu.nil?
  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)
    #self['runners'][name]=run
  end
  if run[:image]
    image = Arcadia.image_res(run[:image])
  else
    image = Arcadia.file_icon(run[:file_exts])
  end
  _run_title = run[:title]
  #run[:title] = nil
  run[:runner_name] = name
  _command = proc{
    _event = Arcadia.process_event(
      RunCmdEvent.new(self, run)
    )
  }
  if run[:pos]
    pos = run[:pos]
  else
    pos = '0'
  end
  args = {
    :image => image,
    :label => _run_title,
    :compound => 'left',
    :command => _command
  }
  args[:font] = Arcadia.conf('menu.font') #if !OS.mac?
  
  root_menu.insert(pos, :command , args)
end

#last_focused_text_widgetObject



207
208
209
# File 'lib/a-core.rb', line 207

def last_focused_text_widget
  @focus_event_manager.last_focus_widget
end

#load_configObject



573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
# File 'lib/a-core.rb', line 573

def load_config
  self.load_local_config(false)
  # local config can contain loading conditions
  self.load_exts_conf
  if @first_run
    myloc = nil
    begin
      myloc = ENV["LANG"].split('.')[0].sub('_','-') if ENV["LANG"]
    rescue Exception => e
    end
    Arcadia.conf('locale', myloc) if myloc != nil
  end
  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_confObject



246
247
248
249
250
251
252
# File 'lib/a-core.rb', line 246

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



254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/a-core.rb', line 254

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



890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
# File 'lib/a-core.rb', line 890

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_maximizedObject



397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
# File 'lib/a-core.rb', line 397

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_runnersObject



737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
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
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
# File 'lib/a-core.rb', line 737

def load_runners
  self['runners'] = Hash.new if self['runners'].nil?
  self['runners_by_ext'] = Hash.new if self['runners_by_ext'].nil?
  self['runners_by_lang'] = Hash.new if self['runners_by_lang'].nil?
  mr = Arcadia.menu_root('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)
#        #self['runners'][name]=run
#      end
#      if run[:image]
#        image = Arcadia.image_res(run[:image])
#      else
#        image = Arcadia.file_icon(run[:file_exts])
#      end
#      _run_title = run[:title]
#      #run[:title] = nil
#      run[:runner_name] = name
#      _command = proc{
#        _event = Arcadia.process_event(
#          RunCmdEvent.new(self, run)
#        )
#      }
#      if run[:pos]
#        pos = run[:pos]
#      else
#        pos = '0'
#      end
#      args = {
#        :image => image,
#        :label => _run_title,
#        :compound => 'left',
#        :command => _command
#      }
#      args[:font] = Arcadia.conf('menu.font') #if !OS.mac?
#      
#      mr.insert(pos, :command , args)
#    }

  insert_runner_instance_item = proc{|name, run|
    if run[:runner] && self['runners'][run[:runner]]
      run = Hash.new.update(self['runners'][run[:runner]]).update(run)
      #self['runners'][name]=run
    end
    _run_title = run[:title]
    run[:title] = nil
    run[:runner_name] = name
    if run[:image]
      image = Arcadia.image_res(run[:image])
    else
      image = Arcadia.file_icon(run[:file_exts])
    end

    _command = proc{
      _event = Arcadia.process_event(
      RunCmdEvent.new(self, run)
      )
    }
    args = {
      :image => image,
      :label => _run_title,
      :compound => 'left',
      :command => _command
    }
    args[:font] = Arcadia.conf('menu.font') #if !OS.mac?
    mr.insert('0', :command , args)
  }

  #conf runner
  runs=Arcadia.conf_group('runners', true)
  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)
    insert_runner_item(mr, name, run)
  }


  #conf exts runner
  @exts.each{|ext|
    if ext_active?(ext)
      ext_runs=Arcadia.conf_group("#{ext}.runners", true)
      mr.insert(self['runners'].count, :separator) if ext_runs && !ext_runs.empty?
      ext_runs.each{|name, hash_string|
        self['runners'][name]=eval hash_string
        self['runners'][name][:pos]=self['runners'].count
        #insert_runner_item.call(name, self['runners'][name])
        insert_runner_item(mr, name, self['runners'][name])
      }
    end
  }



  # pers runner instance
  runs=Arcadia.pers_group('runners', true)
  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
      Arcadia.unpersistent("runners.#{name}")
    end
  }

  pers_runner.each{|name, run|
    insert_runner_instance_item.call(name, run)
  }
end

#load_sysdefaultpropertyObject



592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
# File 'lib/a-core.rb', line 592

def load_sysdefaultproperty
  if !OS.mac?
    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']}"
  end
  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



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
961
962
963
964
965
966
967
968
969
# File 'lib/a-core.rb', line 909

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_runnersObject



862
863
864
865
866
867
868
869
870
871
872
873
# File 'lib/a-core.rb', line 862

def manage_runners
  if !@runm || @runm.nil? 
    @runm = RunnerManager.new(Arcadia.layout.root)
    @runm.on_close=proc{@runm = nil}
    @runm.clear_items
    @runm.load_tips
    @runm.load_items(:runtime)
    @runm.load_items(:config)
  end
  #@runm.show
  #@runm.load_items
end

#on_quit(_event) ⇒ Object



189
190
191
# File 'lib/a-core.rb', line 189

def on_quit(_event)
  self.do_exit
end

#prepareObject



614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
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
# File 'lib/a-core.rb', line 614

def prepare
  super
  @splash.next_step(Arcadia.text('main.splash.initializing_layout'))  if @splash
  #load_config
  initialize_layout
  publish('buffers.code.in_memory',Hash.new)
  #provvisorio
  @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)
  self['menubar'] = ArcadiaMainMenu.new(@root)
  @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
  #Arcadia control
  load_user_control(self['toolbar'])
  load_user_control(self['menubar'])
  #Extension control
  @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")
  # Platform menus
  if OS.mac?
    apple = TkSysMenu_Apple.new(self['menubar'].menubar)
    self['menubar'].menubar.add :cascade, :menu => apple
  elsif OS.windows?
    sysmenu = TkSysMenu_System.new(self['menubar'].menubar)
    self['menubar'].menubar.add :cascade, :menu => sysmenu
  end
  @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
  #@layout.build_invert_menu
end

#refresh_runners_on_menu(root_menu = nil, _file = nil, _dir = nil) ⇒ Object



668
669
670
671
672
673
674
675
676
677
678
679
680
# File 'lib/a-core.rb', line 668

def refresh_runners_on_menu(root_menu=nil, _file=nil, _dir=nil)
  return if root_menu.nil?
  if !root_menu.index('end').nil?
    index_end = root_menu.index('end')-1
    root_menu.delete('0',index_end)
  end
  self['runners'].each{|name, run|
    newrun = {}.update(run)
    newrun[:file] = _file if !_file.nil?
    newrun[:dir] = _dir if !_dir.nil?
    insert_runner_item(root_menu, name, newrun)
  }
end

#register(_ext) ⇒ Object



193
194
195
196
197
198
199
# File 'lib/a-core.rb', line 193

def register(_ext)
  if @@instance['exts_map'] == nil
    @@instance['exts_map'] = Hash.new
  end
  @exts_i << _ext
  @@instance['exts_map'][_ext.name]=_ext 
end

#register_key_binding(_self_target, k, v) ⇒ Object



875
876
877
878
879
880
881
882
883
884
885
886
887
888
# File 'lib/a-core.rb', line 875

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, "%K"){|_keysym|
    if key_sym == _keysym
      Arcadia.process_event(_self_target.instance_eval(value))
    end
  }
end

#reload_runnersObject



682
683
684
685
686
687
688
689
690
691
# File 'lib/a-core.rb', line 682

def reload_runners
  mr = Arcadia.menu_root('runcurr')
  return if mr.nil?
  self['runners'].clear if self['runners']
  self['runners_by_ext'].clear if self['runners_by_ext']
  self['runners_by_lang'].clear if self['runners_by_lang']
  index_end = mr.index('end')-1
  mr.delete('0',index_end)
  load_runners
end

#root_heightObject



181
182
183
# File 'lib/a-core.rb', line 181

def root_height
  @root.winfo_height
end

#save_layoutObject



1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
# File 'lib/a-core.rb', line 1016

def save_layout
  self['conf']['geometry']= geometry_refine(TkWinfo.geometry(@root))
  begin
    if Arcadia.is_windows? || OS.mac?
      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')
  # resizing
  @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
  }
  # layouts
  splits,doms,r,c = @layout.dump_geometry
  header = ""
  splits.each_index{|i|
    header << i.to_s
    header << ',' if i < splits.length-1
  }
  self['conf']['layout.split']= header
  splits.each_with_index{|sp,i|
    self['conf']["layout.split.#{i}"]=sp
  }
  # domains
  @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
      #     p "#{e.conf('name')}.frames=#{str_frames}"
    end
  }
  # toolbar
  if @is_toolbar_show
    self['conf']['user_toolbar_show']='yes'
  else
    self['conf']['user_toolbar_show']='no'
  end
end

#show_hide_toolbarObject



211
212
213
214
215
216
217
218
219
220
221
# File 'lib/a-core.rb', line 211

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



201
202
203
204
205
# File 'lib/a-core.rb', line 201

def unregister(_ext)
  @@instance['exts_map'][_ext.name] = nil
  @@instance['exts_map'].delete(_ext.name)
  @exts_i.delete(_ext)
end