class Arcadia
Attributes
exts[R]
layout[R]
localization[R]
mf_root[R]
wf[R]
Public Class Methods
[](_name)
click to toggle source
# File lib/a-core.rb, line 1346 def Arcadia.[](_name) @@instance[_name] end
conf_group(_path, _refresh=false)
click to toggle source
# 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')
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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_event()
click to toggle source
# File lib/a-core.rb, line 1133 def Arcadia.console_input_event @@last_input_keyboard_query_event end
dialog(_sender, _args=Hash.new)
click to toggle source
# 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)
click to toggle source
# 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
extensions()
click to toggle source
# File lib/a-core.rb, line 1451 def Arcadia.extensions if @@instance && @@instance.exts return @@instance.exts end end
file_extension(_filename=nil)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# File lib/a-core.rb, line 224 def Arcadia.finalize(id) puts "\nArcadia #{id} dying at #{Time.new}" end
gem_available?(_gem)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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?()
click to toggle source
# File lib/a-core.rb, line 1287 def Arcadia.is_windows? OS.windows? #RUBY_PLATFORM =~ /mingw|mswin/ end
lang_icon(_lang=nil)
click to toggle source
# 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
layout()
click to toggle source
# File lib/a-core.rb, line 1237 def Arcadia.layout if @@instance return @@instance.layout end end
new()
click to toggle source
Calls superclass method
TkApplication::new
# File lib/a-core.rb, line 25 def initialize @initialized=false super( ApplicationParams.new( 'arcadia', '1.1.1', '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
new_statusbar_item(_help=nil)
click to toggle source
# 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)
click to toggle source
# File lib/a-core.rb, line 1283 def Arcadia.open_string_dialog(_label=nil) HinnerStringDialog.new(_label).string end
open_system_file_dialog()
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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
ruby()
click to toggle source
# File lib/a-core.rb, line 1292 def Arcadia.ruby @ruby_interpreter=Gem.ruby if !defined?(@ruby_interpreter) @ruby_interpreter end
runner(_name=nil)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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"))
click to toggle source
# 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"))
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# File lib/a-core.rb, line 1177 def Arcadia.style(_class) Configurable.properties_group(_class, Arcadia.instance['conf']) end
text(_key=nil, _params=nil)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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
wf()
click to toggle source
# File lib/a-core.rb, line 1243 def Arcadia.wf if @@instance return @@instance.wf end end
which(_command=nil)
click to toggle source
# 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
Public Instance Methods
can_exit?()
click to toggle source
# 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)
click to toggle source
# 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_build()
click to toggle source
# 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_exit()
click to toggle source
# 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_finalize()
click to toggle source
# 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_initialize()
click to toggle source
# File lib/a-core.rb, line 382 def do_initialize _build_event = Arcadia.process_event(InitializeEvent.new(self)) end
do_make_clones()
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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_layout()
click to toggle source
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 : "+$@.to_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
# 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?()
click to toggle source
# File lib/a-core.rb, line 185 def initialized? @initialized end
insert_runner_item(root_menu=nil, name, run)
click to toggle source
# 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 if run[:default]=='yes' || self['runners_by_ext'][ext.strip.sub('.','')].nil? } end if run[:lang] self['runners_by_lang'][run[:lang]]=run if run[:default]=='yes' || self['runners_by_lang'][run[:lang]].nil? 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_widget()
click to toggle source
# File lib/a-core.rb, line 207 def last_focused_text_widget @focus_event_manager.last_focus_widget end
load_config()
click to toggle source
# 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_conf()
click to toggle source
# 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)
click to toggle source
# 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='')
click to toggle source
# 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_maximized()
click to toggle source
# 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_runners()
click to toggle source
# 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_sysdefaultproperty()
click to toggle source
# 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='')
click to toggle source
# 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_runners()
click to toggle source
# 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)
click to toggle source
# File lib/a-core.rb, line 189 def on_quit(_event) self.do_exit end
prepare()
click to toggle source
Calls superclass method
Application#prepare
# 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
register(_ext)
click to toggle source
# 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)
click to toggle source
# 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_runners()
click to toggle source
# 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_height()
click to toggle source
# File lib/a-core.rb, line 181 def root_height @root.winfo_height end
save_layout()
click to toggle source
# 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_toolbar()
click to toggle source
# 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)
click to toggle source
# 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