<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>ext/ae-editor/langs/coderay.tokens</filename>
    </added>
    <added>
      <filename>ext/ae-editor/langs/erb.lang.bind</filename>
    </added>
    <added>
      <filename>ext/ae-editor/langs/java.lang</filename>
    </added>
    <added>
      <filename>ext/ae-editor/langs/rhtml.lang</filename>
    </added>
    <added>
      <filename>ext/ae-editor/langs/tokens.lang.bind</filename>
    </added>
    <added>
      <filename>ext/ae-editor/langs/xml.lang</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -192,6 +192,7 @@ hightlight.1.background=#abc9fc
 hightlight.1.borderwidth=1
 hightlight.1.relief=raised
 #hightlight.selected
+hightlight.2.foreground=red
 hightlight.2.background=yellow
 #hightlight.tabs
 hightlight.3.foreground=black
@@ -205,7 +206,6 @@ hightlight.4.borderwidth=1
 hightlight.4.relief=raised
 #+--------------------------------------------------
 
-
 #keyword
 hightlight.5.foreground=#00007F
 #method_name
@@ -229,11 +229,29 @@ hightlight.14.foreground=#000000
 #symbol
 hightlight.15.foreground=#bdc175
 #debug
-#hightlight.16.foreground=black
+hightlight.16.foreground=#d95ed9
 hightlight.16.background=#b3c1d9
 hightlight.16.borderwidth=2
 hightlight.16.relief=groove
 
+hightlight.17.foreground=#682821
+hightlight.18.foreground=#3866d9
+
+#:::::::::::::::::::::::::::::::::::::::::::::::::
+
+hightlight.reserved.foreground=#00007F
+hightlight.comment.foreground=#007F00
+hightlight.string.foreground=#7F007F
+hightlight.symbol.foreground=#bdc175
+hightlight.operator.foreground=#000000
+hightlight.class.foreground=#0000FF
+hightlight.method.foreground=#007F7F
+hightlight.number.foreground=#007F7F
+hightlight.instance_variable.foreground=#7F7F7F
+hightlight.global_variable.foreground=#db66ca
+hightlight.constant.foreground=#bdc175
+hightlight.tag.foreground=#69a8d9
+
 #:::::::::::::::::::::::::::::::::::::::::::::::::&lt;end&gt;
 #:::::::::::::::::::: menu  ::::::::::::::::::::::&lt;begin&gt;
 #user_menu.contexts=File2
@@ -402,5 +420,4 @@ win::all.frame.title.font.italic=courier 9 italic
 
 #theme=default
 #theme=dark
-#theme=harlock
-
+#theme=harlock
\ No newline at end of file</diff>
      <filename>conf/arcadia.conf</filename>
    </modified>
    <modified>
      <diff>@@ -1580,3 +1580,55 @@ xxQPoTQwncWsRHdKKhGFX3Ys2XapysMBIB4Xy1zSNF2oL4nb4zYu5x3qgGwa
 EXkiZmd/BQMDdh1DRh4XRSoKBgKLbEJLHoR8JxoEjEtNm1krGgCZTUCDk6eC
 q0udLSdvrrS4ubghADs=
 EOS
+
+FILE_ICON_DEFAULT=DOCUMENT_GIF
+FILE_ICON_RB=RUBY_DOCUMENT_GIF
+FILE_ICON_RBW=FILE_ICON_RB
+
+
+FILE_ICON_JAVA=&lt;&lt;EOS
+R0lGODlhEAAQAOMKAAAAAAAAQAAAVQAAgAAAqn8AAKoAAL8AAL9AAKpVAP//
+/////////////////////yH+EUNyZWF0ZWQgd2l0aCBHSU1QACH5BAEAAA8A
+LAAAAAAQABAAAARM8Mn5Er244C215ZN2gGFlkI9XfKSGgIQwIatEPEMgBTdG
+BDKBLkcMEAGDSfIh8+mYPaO0mBw0d5fY4zfpCYreLrBH+QnIMaqUsHxEAAA7
+EOS
+
+FILE_ICON_RHTML=&lt;&lt;EOS
+R0lGODlhDwAOAMZOALQzPK0qMbVqepwfM68xN7U7PrhKR/r076UcJsh0Wffq
+55QiOOS2sakkK9uqrLxUScNqVezNytyhmchyZ5EhNsJdTsp/Xr10gMNiUL5U
+Vc2BfO7XvdGMbYwjNblMVKIiNKYpPvDbyZgbMvXn2OrLtY4eMfn3975lUKkk
+NcVrZ7djb5EqP9GHhcudqu/U0t6umdmndp4mN+/S1Ojb3v77+q0tOqAvRbqD
+j4kcLZwQGf7+/KQyPPj49d+3hZ5YY9WPkMx4eqUmPNm4walHVdXX271caM2L
+ldiWiqcrMJlFUcNWYJQYK7dwfrQoOP////r6+v//////////////////////
+////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////ywAAAAADwAO
+AAAHs4BPQkwCTIaGhYhPTygDAA8THBIJJAkVBgCLH44PFRMyCgcHERMEiwNN
+TRMZGiQbJCQSLxqLKKmsIRsvDSkSEA+LqQQBPCMjCAUIBBwWwU0eGQcKCgEI
+1jDNTyU1QAdOOi4AAQ0NHAmLODspTuwRBMMBJ+dPCwMu7E4KHgDDFtkeDhTg
+oxGgAL8EEBZRWDIDnxMXPwpgarKoAw4iDdkZmNgExaIVKygMECFiRxAQKG3c
+eBIIADs=
+EOS
+
+
+FILE_ICON_ERB=FILE_ICON_RHTML
+
+FILE_ICON_XML=&lt;&lt;EOS
+R0lGODlhDwAQALMAAAAAADGcAAAAhACEhAAAzTFjnDFj/zGc/zHO/zH//1r/
+KYSEhKXO98bGxvf39////yH5BAEAAAoALAAAAAAPABAAAARXcMlJpbrr6c3b
+wtzmPE7zfBmpjiPgApnDjMNgkPMDP4zwDI/EwSeYwXqkQQIREIyKO6ThECAQ
+jbGcYItrpVir1c5RKJvNXg14TRqf3+kw2zGWh1/4PD4CADs=
+EOS
+
+FILE_ICON_BAT=&lt;&lt;EOS
+R0lGODlhDwAPAMIGAAAAAICAAP//AAAAgICAgMDAwP///////ywAAAAADwAP
+AAADP0i63DUwykjejKWAUrP/X2WMZEmKJmEa6BhUQFC2hmwAAnAWZBDkuICO
+xRvhYrrNiCbwIXer4ay4SjWujKo2AQA7
+EOS
+
+FILE_ICON_NO_EXT=&lt;&lt;EOS
+R0lGODlhDQANALMAAP////f39+/v7+fn59/f38bGxr6+vra2tmVlZQAAAAAA
+AAAAAAAAAAAAAAAAAAAAACH5BAAHAP8ALAAAAAANAA0AAAREEJhZpp2SgM13
+IFgnSkZgBkh6AhVgqmpAuieKmGQg7ELKzzzf73AIDI5IJEmATCVZhgFhmppO
+SQOOTCswSCqGAtgCiAAAOw==
+EOS</diff>
      <filename>conf/arcadia.res.rb</filename>
    </modified>
    <modified>
      <diff>@@ -172,8 +172,8 @@ class DirProjects &lt; ArcadiaExt
     self.pop_up_menu_tree
     @image_kdir = TkPhotoImage.new('dat' =&gt; BOOK_GIF)
     @image_kdir_closed = TkPhotoImage.new('dat' =&gt; FOLDER_GIF)
-    @image_kfile_rb = TkPhotoImage.new('dat' =&gt; RUBY_DOCUMENT_GIF)
-    @image_kfile = TkPhotoImage.new('dat' =&gt; DOCUMENT_GIF)
+#    @image_kfile_rb = TkPhotoImage.new('dat' =&gt; RUBY_DOCUMENT_GIF)
+#    @image_kfile = TkPhotoImage.new('dat' =&gt; DOCUMENT_GIF)
 	  self.load_projects
     @htree.areabind_append('KeyPress'){|e| key_press(e[1])}
 	end
@@ -418,7 +418,7 @@ class DirProjects &lt; ArcadiaExt
         if String.method_defined?(:lines)
       	   selection_lines = @htree.selection_get[0].lines
         else
-      	   selection_lines = @htree.selection_get[0].lines
+      	   selection_lines = @htree.selection_get[0]
         end
         selection_lines.each{|_block|
           _selected = _selected + _block.to_s + &quot;\s&quot; 
@@ -880,11 +880,15 @@ class DirProjects &lt; ArcadiaExt
         return @image_kdir
       elsif _kind == 'project'
         return @image_kdir_closed
-      elsif _kind == 'file' &amp;&amp; _label.include?('.rb')
-        return @image_kfile_rb
-      else
-        return @image_kfile
+      elsif _kind == 'file'
+        return Arcadia.file_icon(_label)
       end
+
+#      elsif _kind == 'file' &amp;&amp; _label.include?('.rb')
+#        return @image_kfile_rb
+#      else
+#        return @image_kfile
+#      end
   end
 
 </diff>
      <filename>ext/ae-dir-projects/ae-dir-projects.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,6 +5,7 @@ frames.names=editor,editor_outline
 active=yes
 require=ext/ae-editor/ae-editor
 class=AgMultiEditor
+gems=coderay
 
 tabs=0.5c left
 # to use tab key set tab-replace-width-space=0
@@ -131,4 +132,4 @@ explorer_panel.tabs.side=top
 
 #:::::::::::::::: Editor group    ::::::::::::::::::::::&lt;end&gt;
 popup.bind.shortcut=Button-3
-arm::popup.bind.shortcut=F4
+arm::popup.bind.shortcut=F4
\ No newline at end of file</diff>
      <filename>ext/ae-editor/ae-editor.conf</filename>
    </modified>
    <modified>
      <diff>@@ -347,7 +347,7 @@ class SafeCompleteCode
     @modified_source = &quot;#{@modified_source}Dir.chdir('#{File.dirname(@file)}')\n&quot; if @file
     @modified_row = @modified_row+1
     source_array.each_with_index{|line,j|
-      # 0) se &#195;&#402;&#194;&#168; un commento non lo prendo in considerazione
+      # 0) if a comment I do not consider it
       if line.strip.length &gt; 0 &amp;&amp; line.strip[0..0]=='#'
         @modified_row = @modified_row-1
         m = /&amp;require_dir_ref=[\s]*(.)*/.match(line)
@@ -879,7 +879,6 @@ class AgEditorOutline
 end
 
 class AgEditor
-  include Configurable
   attr_accessor :file
   attr_reader :read_only 
   attr_reader :page_frame
@@ -932,6 +931,14 @@ class AgEditor
       tabs $arcadia['conf']['editor.tabs']
     }
 
+    class &lt;&lt; @text
+      def tag_adds(tag, *args)
+        tk_send_without_enc('tag', 'add', _get_eval_enc_str(tag), 
+                            *args.flatten)
+        self
+      end
+    end
+
     #do_tag_configure_global('debug')
     @text.tag_configure('eval','foreground' =&gt; 'yellow', 'background' =&gt;'red','borderwidth'=&gt;1, 'relief'=&gt;'raised')
     @text.tag_configure('errline','borderwidth'=&gt;1, 'relief'=&gt;'groove')
@@ -1345,9 +1352,10 @@ class AgEditor
         end
         _e = @text.index('insert').split('.')[0].to_i
         if @highlighting
-          for j in _b..._e
-            rehighlightline(j)
-          end
+          rehighlightlines(_b,_e)
+#          for j in _b..._e
+#            rehighlightline(j)
+#          end
         end
         break
       when 'o'  
@@ -1369,9 +1377,10 @@ class AgEditor
         @text.text_paste
         _e = @text.index('insert').split('.')[0].to_i
         if @highlighting
-          for j in _b..._e
-            rehighlightline(j)
-          end
+          rehighlightlines(_b,_e)
+#          for j in _b..._e
+#            rehighlightline(j)
+#          end
         end
         break
       end
@@ -1430,7 +1439,8 @@ class AgEditor
           else
             @text.insert(_row.to_s+'.0',&quot;#&quot;)
           end
-          rehighlightline(_row) if @highlighting
+          #rehighlightline(_row) if @highlighting
+          rehighlightlines(_row, _row) if @highlighting
         end
 
       end
@@ -1443,11 +1453,13 @@ class AgEditor
       when 'BackSpace'
         _index = @text.index('insert')
         _row, _col = _index.split('.')
-        rehighlightline(_row.to_i) if @highlighting
+        rehighlightlines(_row.to_i,_row.to_i) if @highlighting
+  #      rehighlightline(_row.to_i) if @highlighting
       when 'Delete'
         _index = @text.index('insert')
         _row, _col = _index.split('.')
-        rehighlightline(_row.to_i) if @highlighting
+        rehighlightlines(_row.to_i, _row.to_i) if @highlighting
+  #      rehighlightline(_row.to_i) if @highlighting
       when 'F5'
         run_buffer
       when 'F3'
@@ -1491,13 +1503,13 @@ class AgEditor
 #          #Thread.new do
 #            complete_code.call
 #          #end
-        when 'Control_L','Return', 'Control_V', 'BackSpace', 'Delete'
-          do_line_update
+#        when 'Control_L','Return', 'Control_V', 'BackSpace', 'Delete'
+#          do_line_update
         when 'Up','Down'
           refresh_outline
-      end
-      case e.keysym
-      when 'Return'
+#      end
+#      case e.keysym
+      when 'Return' #,'Control_L', 'Control_V', 'BackSpace', 'Delete'
         _index = @text.index('insert')
         _row, _col = _index.split('.')
         _txt = @text.get((_row.to_i-1).to_s+'.0',_index)
@@ -1515,8 +1527,13 @@ class AgEditor
           do_line_update
         end
       else 
+        if ['Control_L', 'Control_V', 'BackSpace', 'Delete'].include?(e.keysym)
+          do_line_update
+        end
         if @highlighting &amp;&amp; /\w/.match(e.keysym)
-          rehighlightline(@text.index('insert').split('.')[0].to_i)
+    #      rehighlightline(@text.index('insert').split('.')[0].to_i)
+          row = @text.index('insert').split('.')[0].to_i
+          rehighlightlines(row, row)
         end
       end
       check_modify
@@ -1770,19 +1787,35 @@ class AgEditor
 
   def reset_highlight
     @is_line_bold.clear
-    @is_tag_bold.clear
     @highlight_zone.clear if @highlighting
     @last_line_begin=0
     @last_line_end=0
     @last_zone_begin=0
     @last_zone_end=0
   end
+  
+  def change_highlight(_ext)
+    new_highlight_scanner = @controller.highlight_scanner(_ext)
+    if new_highlight_scanner != @highlight_scanner
+      @highlight_scanner.classes.each{|c|
+        @text.tag_remove(c,'1.0', 'end')
+        @text.tag_delete(c)
+        @is_tag_bold.delete(c)
+      }
+      @highlight_scanner = new_highlight_scanner
+      reset_highlight
+      @highlight_scanner.classes.each{|c|
+        do_tag_configure(c)
+      }
+    end
+  end
 
-  def initialize_highlight
+  def initialize_highlight(_ext)
+    @highlight_scanner = @controller.highlight_scanner(_ext)
     @is_line_bold = Hash.new
     @is_tag_bold = Hash.new
     do_tag_configure_global('debug')
-    if @lang_hash.nil?
+    if @lang_hash.nil? || @highlight_scanner.nil?
       @highlighting = false
       return
     end
@@ -1794,19 +1827,8 @@ class AgEditor
     @last_line_end = 0
     @last_zone_begin=0;
     @last_zone_end=0;
-    #@is_line_bold = Hash.new
-    #@is_tag_bold = Hash.new
-    @h_classes = @lang_hash['classes'].split(',')
-    @h_re = Hash.new
-    @op_to_end_line = Array.new
-    @op_to_end_line.concat(@lang_hash['re_op.to_line_end'].split(',')) if @lang_hash['re_op.to_line_end']
-
-    @op_only_first = Array.new
-    @op_only_first.concat(@lang_hash['re_op.only_first'].split(',')) if @lang_hash['re_op.only_first']
-    
-    @h_classes.each{|c|
+    @highlight_scanner.classes.each{|c|
       do_tag_configure(c)
-      @h_re[c]=Regexp::new(@lang_hash[&quot;re.#{c}&quot;].strip) if @lang_hash[&quot;re.#{c}&quot;]
     }
 
     ['sel','selected','tabs','spaces'].each{|_name|
@@ -1820,23 +1842,23 @@ class AgEditor
 
   def do_tag_configure(_name)
     h = Hash.new
-    if @lang_hash['hightlight.'+_name+'.foreground']
-      h['foreground']=@lang_hash['hightlight.'+_name+'.foreground']
+    if @lang_hash[&quot;#{@lang_hash['scanner']}.hightlight.&quot;+_name+'.foreground']
+      h['foreground']=@lang_hash[&quot;#{@lang_hash['scanner']}.hightlight.&quot;+_name+'.foreground']
     end
-    if @lang_hash['hightlight.'+_name+'.background']
-      h['background']=@lang_hash['hightlight.'+_name+'.background']
+    if @lang_hash[&quot;#{@lang_hash['scanner']}.hightlight.&quot;+_name+'.background']
+      h['background']=@lang_hash[&quot;#{@lang_hash['scanner']}.hightlight.&quot;+_name+'.background']
     end
-    if @lang_hash['hightlight.'+_name+'.style']== 'bold'
+    if @lang_hash[&quot;#{@lang_hash['scanner']}.hightlight.&quot;+_name+'.style']== 'bold'
       h['font']=@font_bold
       @is_tag_bold[_name]= true
     else
       @is_tag_bold[_name]= false
     end
-    if @lang_hash['hightlight.'+_name+'.relief']
-      h['relief']=@lang_hash['hightlight.'+_name+'.relief']
+    if @lang_hash[&quot;#{@lang_hash['scanner']}.hightlight.&quot;+_name+'.relief']
+      h['relief']=@lang_hash[&quot;#{@lang_hash['scanner']}.hightlight.&quot;+_name+'.relief']
     end
-    if @lang_hash['hightlight.'+_name+'.borderwidth']
-      h['borderwidth']=@lang_hash['hightlight.'+_name+'.borderwidth']
+    if @lang_hash[&quot;#{@lang_hash['scanner']}.hightlight.&quot;+_name+'.borderwidth']
+      h['borderwidth']=@lang_hash[&quot;#{@lang_hash['scanner']}.hightlight.&quot;+_name+'.borderwidth']
     end
     @text.tag_configure(_name, h)
   end
@@ -2259,85 +2281,94 @@ class AgEditor
     return (_riga.to_i + _gap_row).to_s + '.'+ (_colonna.to_i + _gap_col).to_s
   end
 
-  def find_and_set_tag_ml(_re, _row, _txt, _tag, _tag_rem = nil)
-    m = _re.match(_txt)
-    _offset = 0
-    _s_txt = _txt
-    #_old_txt = ''
-    while m &amp;&amp; (_txt=m.post_match)
-      if !defined?(_old_txt) || _txt != _old_txt
+#  def find_and_set_tag_ml(_re, _row, _txt, _tag, _tag_rem = nil)
+#    m = _re.match(_txt)
+#    _offset = 0
+#    _s_txt = _txt
+#    #_old_txt = ''
+#    while m &amp;&amp; (_txt=m.post_match)
+#      if !defined?(_old_txt) || _txt != _old_txt
+#
+#        apos =  pos_to_index(_s_txt, _offset+m.begin(0))
+#        _offset = _offset + m.end(0)
+#        
+#        
+#        _old_txt = _txt
+#        _r = _row + apos[0]
+#        _ibegin = _r.to_s+'.'+apos[1].to_s
+#        _iend = _r.to_s+'.'+(apos[1]+m.end(0)-m.begin(0)).to_s
+#        if _tag_rem
+#          _tag_rem.each {|value|
+#            @text.tag_remove(value,_ibegin, _iend)
+#          }
+#        end
+#        @text.tag_add(_tag,_ibegin, _iend)
+#        if @is_tag_bold[_tag]
+#          @is_line_bold[_r]=true
+#        end
+#
+#        if @op_only_first.include?(_tag) &amp;&amp; _txt
+#          #eliminino la prima riga a partire dal risultato
+#          _p = _txt.index(&quot;\n&quot;)+1
+#          if _p
+#              _txt = _txt[_p..-1]
+#              _offset = _offset + _p
+#          else
+#            m = nil
+#          end
+#        end
+#        m = _re.match(_txt)
+#        
+#      else
+#        m = nil
+#      end
+#    end
+#  end
 
-        apos =  pos_to_index(_s_txt, _offset+m.begin(0))
-        _offset = _offset + m.end(0)
-        
-        
-        _old_txt = _txt
-        _r = _row + apos[0]
-        _ibegin = _r.to_s+'.'+apos[1].to_s
-        _iend = _r.to_s+'.'+(apos[1]+m.end(0)-m.begin(0)).to_s
-        if _tag_rem
-          _tag_rem.each {|value|
-            @text.tag_remove(value,_ibegin, _iend)
-          }
-        end
-        @text.tag_add(_tag,_ibegin, _iend)
-        if @is_tag_bold[_tag]
-          @is_line_bold[_r]=true
-        end
 
-        if @op_only_first.include?(_tag) &amp;&amp; _txt
-          #eliminino la prima riga a partire dal risultato
-          _p = _txt.index(&quot;\n&quot;)+1
-          if _p
-              _txt = _txt[_p..-1]
-              _offset = _offset + _p
-          else
-            m = nil
-          end
-        end
-        m = _re.match(_txt)
-        
-      else
-        m = nil
-      end
-    end
-  end
+#  def find_and_set_tag(_re, _row, _txt, _tag, _tag_rem = nil)
+#    m = _re.match(_txt)
+#    _end = 0
+#    if m &amp;&amp; @is_tag_bold[_tag]
+#      @is_line_bold[_row]=true
+#    end
+#    #_old_txt = ''
+#    while m &amp;&amp; (_txt=m.post_match)
+#      if !defined?(_old_txt) || _txt != _old_txt
+#        _old_txt = _txt 
+#        _ibegin = _row.to_s+'.'+(m.begin(0)+_end).to_s
+#        _end = m.end(0) + _end
+#        _iend = _row.to_s+'.'+(_end.to_s)
+#        if _tag_rem
+#          _tag_rem.each {|value|
+#            @text.tag_remove(value,_ibegin, _iend)
+#          }
+#        end
+#        @text.tag_add(_tag,_ibegin, _iend)
+#        if @op_only_first.include?(_tag)
+#          m = nil
+#        else
+#          m = _re.match(_txt)
+#        end
+#      else
+#        m = nil
+#      end
+#    end
+#  end
 
 
-  def find_and_set_tag(_re, _row, _txt, _tag, _tag_rem = nil)
-    m = _re.match(_txt)
-    _end = 0
-    if m &amp;&amp; @is_tag_bold[_tag]
-      @is_line_bold[_row]=true
-    end
-    #_old_txt = ''
-    while m &amp;&amp; (_txt=m.post_match)
-      if !defined?(_old_txt) || _txt != _old_txt
-        _old_txt = _txt 
-        _ibegin = _row.to_s+'.'+(m.begin(0)+_end).to_s
-        _end = m.end(0) + _end
-        _iend = _row.to_s+'.'+(_end.to_s)
-        if _tag_rem
-          _tag_rem.each {|value|
-            @text.tag_remove(value,_ibegin, _iend)
-          }
-        end
-        @text.tag_add(_tag,_ibegin, _iend)
-        if @op_only_first.include?(_tag)
-          m = nil
-        else
-          m = _re.match(_txt)
-        end
-      else
-        m = nil
-      end
+  def text_value_lines
+    if String.method_defined?(:lines)
+      return @text.value.lines
+    else
+      return @text.value
     end
   end
 
   def show_spaces
     @spaces_show = true
     _row = 1
-    @text.value.each{|_line|
+    text_value_lines.each{|_line|
       show_chars_line(_row, _line, /[ ^\t]\s*/, 'spaces')
       _row = _row+1
     }
@@ -2347,7 +2378,7 @@ class AgEditor
   def show_tabs
     @tabs_show = true
     _row = 1
-    @text.value.each{|_line|
+    text_value_lines.each{|_line|
       show_chars_line(_row, _line, /\t/, 'tabs')
       _row = _row+1
     }
@@ -2369,7 +2400,7 @@ class AgEditor
 
   def indentation_space_2_tabs(_n_space=2)
     _row = 1
-    @text.value.each{|_line|
+    text_value_lines.each{|_line|
       m = /\s*/.match(_line)
       _end = 0
       if m &amp;&amp; m.begin(0)==0
@@ -2389,7 +2420,7 @@ class AgEditor
 
   def indentation_tabs_2_space(_n_space=2)
     _row = 1
-    @text.value.each{|_line|
+    text_value_lines.each{|_line|
       m = /\t*/.match(_line)
       _end = 0
       if m &amp;&amp; m.begin(0)==0
@@ -2451,95 +2482,18 @@ class AgEditor
     end
   end
 
-  def highlightlines(_row, _lines, _check_mod = false)
-    if _check_mod 
-      check_modify
-    end
-    _txt = _lines
-    _end = 0
-    
-#    @op_to_end_line.each{|c|
-#      if @h_re[c]
-#        m_c = @h_re[c].match(_txt)
-#        if m_c then
-#          _ibegin = _row.to_s+'.'+(m_c.begin(0)).to_s
-#          _iend = _row.to_s+'.'+(_line.length - 1).to_s
-#          @text.tag_add(c,_ibegin, _iend)
-#          _txt = m_c.pre_match
-#        end
-#      end
-#    } if @lang_hash['re_op.to_line_end']
 
-    arem = Array.new
-    
-      
-    @h_classes.each{|c|
-      if !@op_to_end_line.include?(c) &amp;&amp; @h_re[c]
-        find_and_set_tag_ml(@h_re[c], _row, _txt, c, arem)
-        arem &lt;&lt; c
-      end
-    } if _txt.strip.length &gt; 0  
 
-    find_and_set_tag_ml(/\t/, _row, _txt, 'tabs', arem) if @tabs_show 
-    find_and_set_tag_ml(/[ ^\t]\s*/, _row, _txt, 'spaces', arem) if @spaces_show 
-  end
 
 
-  def highlightline(_row, _line, _check_mod = false)
-    #p &quot;highlightline #{_row} _line=#{_line}&quot;
-    if _check_mod 
-      check_modify
-    end
-    _txt = _line
-    _end = 0
-    
-    @op_to_end_line.each{|c|
-      if @h_re[c]
-        m_c = @h_re[c].match(_txt)
-        if m_c then
-          _ibegin = _row.to_s+'.'+(m_c.begin(0)).to_s
-          _iend = _row.to_s+'.'+(_line.length - 1).to_s
-          @text.tag_add(c,_ibegin, _iend)
-          #p &quot;tag_add  found #{c}&quot;
-          _txt = m_c.pre_match
-        end
-      end
-    } if @lang_hash['re_op.to_line_end']
-
-    arem = Array.new
-    
-      
-    @h_classes.each{|c|
-      if !@op_to_end_line.include?(c) &amp;&amp; @h_re[c]
-        find_and_set_tag(@h_re[c], _row, _txt, c, arem)
-        arem &lt;&lt; c
-      end
-    } if _txt.strip.length &gt; 0  
-
-    find_and_set_tag(/\t/, _row, _txt, 'tabs', arem) if @tabs_show 
-    find_and_set_tag(/[ ^\t]\s*/, _row, _txt, 'spaces', arem) if @spaces_show 
-  end
-
-  def rehighlightline(_row)
-    _ibegin = _row.to_s+'.0'
-    _iend = (_row+1).to_s+'.0'
-    #p &quot;rehighlightline _ibegin=#{_ibegin}&quot;
-    #p &quot;rehighlightline _iend=#{_iend}&quot;
-    #p &quot;_line = #{@text.get(_ibegin, _iend)}&quot;
-    @h_classes.each{|c| @text.tag_remove(c,_ibegin, _iend)}
-    _line = @text.get(_ibegin, _iend)
-    highlightline(_row, _line)
-  end
 
   def rehighlightlines(_row_begin, _row_end)
     _ibegin = _row_begin.to_s+'.0'
     _iend = (_row_end+1).to_s+'.0'
-    @h_classes.each{|c| @text.tag_remove(c,_ibegin, _iend)}
-    _lines = @text.get(_ibegin, _iend)
-    highlightlines(_row_begin, _lines)
+    @highlight_scanner.classes.each{|c| @text.tag_remove(c,_ibegin, _iend)}
+    highlightlines(_row_begin, _row_end)
   end
 
-
   def row(_index='insert')
     _row = @text.index(_index).split('.')[0].to_i
     return _row
@@ -2563,7 +2517,7 @@ class AgEditor
           _zone_begin = ((line_begin) / @highlight_zone_length).to_i + 1
           _zone_end = ((line_end) / @highlight_zone_length).to_i + 1
           #Arcadia.new_msg(self, &quot;for lines #{line_begin}..#{line_end} \n
-          _zone_begin=#{_zone_begin} ; _zone_end=#{_zone_end}&quot;)
+          #_zone_begin=#{_zone_begin} ; _zone_end=#{_zone_end}&quot;)
           (_zone_begin &gt;=@last_zone_begin)?_zone_begin.upto(_zone_end+1){|_zone| 
             highlight_zone(_zone)
           }:_zone_end.downto(_zone_begin-1){|_zone| 
@@ -2574,7 +2528,6 @@ class AgEditor
           @last_zone_begin = _zone_begin
           @last_zone_end = _zone_end
         end
-        
         @text_line_num.delete('1.0','end')
 
         _rx, _ry, _widht, _heigth = @text.bbox(line_begin_index);
@@ -2621,23 +2574,55 @@ class AgEditor
       refresh_outline if Tk.focus==@text
   end
 
-  def highlight_zone_new(_zone)
-    if !@highlight_zone[_zone]
-      _b = @highlight_zone_length*(_zone - 1) 
-      _e = @highlight_zone_length*(_zone) #+ 1
-      rehighlightlines(_b,_e)
-      @highlight_zone[_zone] = true
+  def highlightlines(_row_begin, _row_end, _check_mod = false)
+    if _check_mod 
+      check_modify
+    end
+    #_row_begin = _row_begin+1
+    _ibegin = _row_begin.to_s+'.0'
+    _iend = (_row_end+1).to_s+'.0'
+    @highlight_scanner.classes.each{|c| @text.tag_remove(c,_ibegin, _iend)}
+    _lines = @text.get(_ibegin, _iend)
+    tags_map = @highlight_scanner.highlight_tags(_row_begin,_lines)
+    tags_map.each do |key,value|      
+      to_tag = Array.new
+      value.each{|ite|
+        to_tag.concat(ite)
+        if @is_tag_bold[key]
+          if ite.length==2
+            row_begin = ite[0].split('.')[0].to_i
+            row_end = ite[1].split('.')[0].to_i
+            for row in row_begin...row_end 
+              @is_line_bold[row]=true
+            end
+          end
+#          ite.each{|p|
+#            row_begin = p[0].split('.')[0].to_i
+#            row_end = p[1].split('.')[0].to_i
+#            for row in row_begin...row_end 
+#              @is_line_bold[row]=true
+#            end
+#          }
+        end
+      }
+      @text.tag_adds(key.to_s,to_tag)
+    end
+    if @tabs_show || @spaces_show
+      if @lang_hash['scanner']!='re' &amp;&amp; !defined?(@rescanner)
+        @rescanner = ReHighlightScanner.new(@lang_hash) if !defined?(@rescanner)
+      else
+        @rescanner = @highlight_scanner
+      end
+      @rescanner.highlight_tags(_row_begin,_lines,['tabs']) if @tabs_show
+      @rescanner.highlight_tags(_row_begin,_lines,['spaces']) if @spaces_show
     end
   end
 
-
   def highlight_zone(_zone, _force_highlight=false)
     if !@highlight_zone[_zone] || _force_highlight
-      _b = @highlight_zone_length*(_zone - 1) 
+      _b = @highlight_zone_length*(_zone - 1) +1
       _e = @highlight_zone_length*(_zone) #+ 1
-      for j in _b..._e
-        rehighlightline(j)
-      end
+      rehighlightlines(_b,_e)
       @highlight_zone[_zone] = true
     end
   end
@@ -2670,7 +2655,8 @@ class AgEditor
           _iend = _row+'.'+(line.length - 1).to_s
           @text.tag_add('comment',_ibegin, _iend)
         else
-          highlightline(_row.to_i, line, false)
+          #highlightline(_row.to_i, line, false)
+          highlightlines(_row.to_i, _row.to_i, false)
         end
       end
       _row = (_row.to_i + 1).to_s
@@ -2714,15 +2700,24 @@ class AgEditor
   end
 
   def save_as
-    @file = Tk.getSaveFile(&quot;filetypes&quot;=&gt;[[&quot;Ruby Files&quot;, [&quot;.rb&quot;, &quot;.rbw&quot;]],[&quot;All Files&quot;, [&quot;.*&quot;]]])
-    @file = nil if @file == &quot;&quot;  # cancelled
-    if @file
+    file = Tk.getSaveFile(&quot;filetypes&quot;=&gt;[[&quot;Ruby Files&quot;, [&quot;.rb&quot;, &quot;.rbw&quot;]],[&quot;All Files&quot;, [&quot;.*&quot;]]])
+    file = nil if file == &quot;&quot;  # cancelled
+    if file
+      new_file_name(file)
       save
-      @controller.change_file_name(@page_frame, @file)
+      @controller.change_file_name(@page_frame, file)
       #EditorContract.instance.file_created(self, 'file'=&gt;@file)
     end
   end
 
+  def new_file_name(_new_file)
+    @file =_new_file
+    base_name= File.basename(_new_file)
+    if base_name.include?('.')
+      self.change_highlight(base_name.split('.')[-1])
+    end
+  end
+
   def check_modify
     return  if @loading
     if modified? 
@@ -2764,37 +2759,12 @@ class AgEditor
     end
   end
   
-  def languages_hash(_ext=nil)
-    @@langs_hash = Hash.new if !defined?(@@langs_hash)
-    return nil if _ext.nil?
-    if @@langs_hash[_ext].nil?
-      #_ext='' if _ext.nil?
-      lang_file = File.dirname(__FILE__)+'/langs/'+_ext+'.lang'
-      if File.exist?(lang_file)
-        @@langs_hash[_ext] = properties_file2hash(lang_file)
-      elsif File.exist?(lang_file+'.bind')
-        b= properties_file2hash(lang_file+'.bind')
-        if b 
-          if @@langs_hash[b['bind']].nil?
-            lang_file_bind = File.dirname(__FILE__)+'/langs/'+b['bind']+&quot;.lang&quot;
-            if File.exist?(lang_file_bind)
-              @@langs_hash[b['bind']]=properties_file2hash(lang_file_bind)
-              @@langs_hash[_ext]=@@langs_hash[b['bind']]
-            end
-          else
-            @@langs_hash[_ext]=@@langs_hash[b['bind']]
-          end
-        end
-      end
-      self.resolve_properties_link(@@langs_hash[_ext], Arcadia.instance['conf']) if @@langs_hash[_ext]
-    end
-    @@langs_hash[_ext]
-  end
 
   def init_editing(_ext='rb', _w1=150, _w2=60)
     @is_ruby = _ext=='rb'|| _ext=='rbw'
     @classbrowsing = @is_ruby
-    @lang_hash = languages_hash(_ext)
+    @lang_hash = @controller.languages_hash(_ext)
+#    @highlight_scanner = @controller.highlight_scanner(_ext)
 #    if !_ext.nil? &amp;&amp; @is_ruby
 #      @fm = AGTkVSplittedFrames.new(@page_frame,_w1)
 #      @fm1 = AGTkVSplittedFrames.new(@fm.right_frame,_w2)
@@ -2806,7 +2776,7 @@ class AgEditor
     @fm1 = AGTkVSplittedFrames.new(@page_frame,@page_frame,_w2)
     @fm1.splitter_frame.configure('relief'=&gt;'flat')
     initialize_text(@fm1.right_frame)
-    initialize_highlight
+    initialize_highlight(_ext)
     initialize_line_number(@fm1.left_frame)
     initialize_text_binding
   end
@@ -2907,9 +2877,162 @@ class AgMultiEditorView
   
 end
 
+class HighlightScanner
+  
+  def initialize(_langs_conf)
+    @langs_conf = _langs_conf
+    @lang=@langs_conf['language'].to_sym if @langs_conf['language']
+  end
+  
+  def highlight_tags(_row_begin,_code)
+  end
+  
+  def classes
+    if !defined?(@h_classes)
+      @h_classes = @langs_conf[&quot;#{@langs_conf['scanner']}.classes&quot;].split(',')
+    end
+    @h_classes
+  end
+end
+
+class ReHighlightScanner &lt; HighlightScanner
+  def initialize(_langs_conf)
+    super(_langs_conf)
+    @h_re = Hash.new
+    @op_to_end_line = Array.new
+    @op_to_end_line.concat(@langs_conf['re_op.to_line_end'].split(',')) if @langs_conf['re_op.to_line_end']
+
+    @op_only_first = Array.new
+    @op_only_first.concat(@langs_conf['re_op.only_first'].split(',')) if @langs_conf['re_op.only_first']
+    
+    self.classes.each{|c|
+      @h_re[c]=Regexp::new(@langs_conf[&quot;re.#{c}&quot;].strip) if @langs_conf[&quot;re.#{c}&quot;]
+    }
+  end
+
+
+  def find_tag(_tag, _row, _txt)
+    to_ret = []
+    _re = @h_re[_tag]
+    m = _re.match(_txt)
+    _end = 0
+    while m &amp;&amp; (_txt=m.post_match)
+      if !defined?(_old_txt) || _txt != _old_txt
+        _old_txt = _txt 
+        _ibegin = _row.to_s+'.'+(m.begin(0)+_end).to_s
+        _end = m.end(0) + _end
+        _iend = _row.to_s+'.'+(_end.to_s)
+        to_ret &lt;&lt; [_ibegin, _iend]
+        if @op_only_first.include?(_tag)
+          m = nil
+        else
+          m = _re.match(_txt)
+        end
+      else
+        m = nil
+      end
+    end
+    to_ret
+  end
+  
+  def highlight_tags(_row_begin,_code,_classes=self.classes)
+    super(_row_begin,_code)
+    tags_map = Hash.new 
+    lines = _code.split(&quot;\n&quot;)
+    lines.each_with_index{|_line,_i|
+      _line+=&quot;\n&quot;
+      _row = _row_begin+_i
+      #p &quot;_row=#{_row}-_line=#{_line}&quot;
+      _txt = _line
+      _end = 0
+      @op_to_end_line.each{|c|
+        if _classes.include?(c) &amp;&amp; @h_re[c]
+          m_c = @h_re[c].match(_txt)
+          if m_c then
+            _ibegin = _row.to_s+'.'+(m_c.begin(0)).to_s
+            _iend = _row.to_s+'.'+(_line.length - 1).to_s
+            tags_map[c] = [] if tags_map[c].nil?
+            tags_map[c] &lt;&lt; [_ibegin, _iend]
+            _txt = m_c.pre_match
+          end
+        end
+      } if @langs_conf['re_op.to_line_end']
+  
+      _classes.each{|c|
+        if !@op_to_end_line.include?(c) &amp;&amp; @h_re[c]
+          _tags = find_tag(c, _row, _txt)
+          if _tags.length &gt;0
+            tags_map[c] = [] if tags_map[c].nil?
+            tags_map[c].concat(_tags)
+          end
+        end
+      } if _txt.strip.length &gt; 0  
+    }
+    tags_map
+  end
+end
+  
+class CoderayHighlightScanner &lt; HighlightScanner
+  def initialize(_langs_conf)
+    super(_langs_conf)
+    require 'coderay'
+  end
+#  def highlight_tags(_row_begin,_code)
+#    super(_row_begin,_code)
+#    case @lang
+#      when :ruby
+#        _highlight_tags_ruby(_row_begin,_code)
+#    end
+#  end
+  def highlight_tags(_row_begin,_code)
+    super(_row_begin,_code)
+    c_scanner = CodeRay::Scanners[@lang].new _code
+    row=_row_begin
+    col=0
+    tags_map = Hash.new 
+    c_scanner.tokens.each{|tok|
+      #p tok
+      if tok[1]==:space &amp;&amp; tok[0].include?(&quot;\n&quot;)
+        row+=tok[0].count(&quot;\n&quot;)
+        begin_gap = tok[0].split(&quot;\n&quot;)[-1]
+        if begin_gap &amp;&amp; tok[0][-1..-1]!=&quot;\n&quot;
+          col = begin_gap.length
+        else
+          col = 0
+        end
+      elsif !([:open,:close].include?(tok[0])&amp;&amp; tok[1].class==Symbol)
+        toklength = tok[0].length
+        t_begin=&quot;#{row}.#{col}&quot;
+        if tok[0].include?(&quot;\n&quot;)
+          ar = tok[0].split
+          row+=tok[0].count(&quot;\n&quot;)
+
+          begin_gap = ar[-1]
+          if begin_gap &amp;&amp; tok[0][-1..-1]!=&quot;\n&quot;
+            col = begin_gap.length
+          else
+            col = 0
+          end
+        else
+          col+=toklength
+        end
+        t_end=&quot;#{row}.#{col}&quot;
+        if tok[1]!=:space
+          tags_map[tok[1]] = [] if tags_map[tok[1]].nil?
+          tags_map[tok[1]] &lt;&lt; [t_begin,t_end]
+          #Arcadia.console(self, 'msg'=&gt;&quot;#{tok[1]}=#{[t_begin,t_end]}&quot;, 'level'=&gt;'error')          
+          #p [t_begin,t_end]
+        end
+      end  
+    }
+    tags_map
+  end
+end
+
 
 class AgMultiEditor &lt; ArcadiaExt
   include Autils
+  include Configurable
   attr_reader :breakpoints
   attr_reader :splitted_frame
   attr_reader :outline_bar
@@ -2970,6 +3093,60 @@ class AgMultiEditor &lt; ArcadiaExt
     }
   end
 
+  def highlight_scanner(_ext=nil)
+    return nil if _ext.nil?
+    scanner = nil
+    @highlight_scanner_hash = Hash.new if !defined?(@highlight_scanner_hash)
+    lh = languages_hash(_ext)
+    if lh &amp;&amp; lh['language'] &amp;&amp; lh['scanner']  
+      if @highlight_scanner_hash[lh['language']].nil?
+        case lh['scanner']
+          when 'coderay'
+            @highlight_scanner_hash[lh['language']]=CoderayHighlightScanner.new(lh)
+          when 're'
+            @highlight_scanner_hash[lh['language']]=ReHighlightScanner.new(lh)
+        end
+      end
+      scanner = @highlight_scanner_hash[lh['language']]
+    end
+    scanner
+  end
+
+  def languages_hash(_ext=nil)
+    @@langs_hash = Hash.new if !defined?(@@langs_hash)
+    return nil if _ext.nil?
+    if @@langs_hash[_ext].nil?
+      #_ext='' if _ext.nil?
+      lang_file = File.dirname(__FILE__)+'/langs/'+_ext+'.lang'
+      if File.exist?(lang_file)
+        @@langs_hash[_ext] = properties_file2hash(lang_file)
+      elsif File.exist?(lang_file+'.bind')
+        b= properties_file2hash(lang_file+'.bind')
+        if b 
+          if @@langs_hash[b['bind']].nil?
+            lang_file_bind = File.dirname(__FILE__)+'/langs/'+b['bind']+&quot;.lang&quot;
+            if File.exist?(lang_file_bind)
+              @@langs_hash[b['bind']]=properties_file2hash(lang_file_bind)
+              @@langs_hash[_ext]=@@langs_hash[b['bind']]
+            end
+          else
+            @@langs_hash[_ext]=@@langs_hash[b['bind']]
+          end
+        end
+      end
+      if @@langs_hash[_ext] &amp;&amp; @@langs_hash[_ext]['@include'] != nil
+        include_file = &quot;#{File.dirname(__FILE__)}/langs/#{@@langs_hash[_ext]['@include']}&quot;
+        if File.exist?(include_file)
+          include_hash = properties_file2hash(include_file)
+          @@langs_hash[_ext] = include_hash.merge(@@langs_hash[_ext])
+        end
+      end 
+      self.resolve_properties_link(@@langs_hash[_ext], Arcadia.instance['conf']) if @@langs_hash[_ext]
+    end
+    @@langs_hash[_ext]
+  end
+
+
   def pop_up_menu
     @pop_up = TkMenu.new(
       :parent=&gt;@main_frame.enb,
@@ -3402,17 +3579,22 @@ class AgMultiEditor &lt; ArcadiaExt
     @main_frame.enb.itemconfigure(page_name(_tab), 'text'=&gt; _new_text)
   end
 
+  def change_tab_icon(_tab, _new_text)
+    @main_frame.enb.itemconfigure(page_name(_tab), 'image'=&gt; Arcadia.file_icon(_new_text))
+  end
+
   def change_file(_old_file, _new_file)
     _tab_name=tab_file_name(_old_file)
     _tab = @main_frame.enb.get_frame(_tab_name)
     e =  @tabs_editor[_tab_name]
-    e.file =_new_file if e
+    e.new_file_name(_new_file) if e
     change_file_name(_tab, _new_file)
   end
 
   def change_file_name(_tab, _new_file)
     _new_label = File.basename(_new_file)
     change_tab_title(_tab, _new_label)
+    change_tab_icon(_tab, _new_label)
     @tabs_file[page_name(_tab)] = _new_file
   end
 
@@ -3564,6 +3746,7 @@ class AgMultiEditor &lt; ArcadiaExt
       end
       _tab = @main_frame.enb.insert('end', _buffer_name ,
         'text'=&gt; _title,
+        'image'=&gt; Arcadia.file_icon(_title),
         'background'=&gt; Arcadia.style(&quot;tabpanel.background&quot;),
         'foreground'=&gt; Arcadia.style(&quot;tabpanel.foreground&quot;),
         'raisecmd'=&gt;proc{do_buffer_raise(_buffer_name, _title)}</diff>
      <filename>ext/ae-editor/ae-editor.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,6 @@
-classes=key,value,operator,comment,link
+scanner=re
+language=conf
+re.classes=key,value,operator,comment,link
 re.key=(.*)\=
 re.value=\=(.*)
 re.operator=\=
@@ -15,12 +17,12 @@ re_op.only_first=operator
 #hightlight.operator.foreground=red
 #hightlight.operator.style=bold
 
-hightlight.comment.foreground=&gt;&gt;&gt;hightlight.11.foreground
-hightlight.key.foreground=&gt;&gt;&gt;hightlight.5.foreground
-hightlight.key.style=bold
-hightlight.value.foreground=&gt;&gt;&gt;hightlight.6.foreground
-hightlight.value.style=bold
-hightlight.operator.foreground=&gt;&gt;&gt;hightlight.14.foreground
-hightlight.operator.style=bold
-hightlight.link.foreground=&gt;&gt;&gt;hightlight.12.foreground
-hightlight.link.style=bold
\ No newline at end of file
+re.hightlight.comment.foreground=&gt;&gt;&gt;hightlight.11.foreground
+re.hightlight.key.foreground=&gt;&gt;&gt;hightlight.5.foreground
+re.hightlight.key.style=bold
+re.hightlight.value.foreground=&gt;&gt;&gt;hightlight.6.foreground
+re.hightlight.value.style=bold
+re.hightlight.operator.foreground=&gt;&gt;&gt;hightlight.14.foreground
+re.hightlight.operator.style=bold
+re.hightlight.link.foreground=&gt;&gt;&gt;hightlight.12.foreground
+re.hightlight.link.style=bold
\ No newline at end of file</diff>
      <filename>ext/ae-editor/langs/conf.lang</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,8 @@
-classes=number,method_name,class_name,module_name,keyword,instance_variable,global_variable,symbol,operator,string,comment
+language=ruby
+
+scanner=coderay
+#scanner=re
+re.classes=number,method_name,class_name,module_name,keyword,instance_variable,global_variable,symbol,operator,string,comment
 re.keyword=\b(and|or|unless|end|in|begin|defined?|ensure|redo|super|until|BEGIN|break|do|false|next|rescue|then|when|END|case|else|for|nil|retry|true|while|alias|elsif|if|not|return|undef|yield|require|include)([\(\s\n])|\b(self)([.,+\(\s])|__LINE__|__FILE__|[\s]*def[\s]|[\s]*module[\s]|[\s]*class[\s]
 re.method_name=(def[\s][\s]*)[A-Za-z0-9_]*
 re.instance_variable=([\s]*@)[A-Za-z0-9_]*
@@ -46,58 +50,24 @@ hightlight.spaces.relief=&gt;&gt;&gt;hightlight.4.relief
 #+--------------------------------------------------
 
 # custom classes
-hightlight.keyword.foreground=&gt;&gt;&gt;hightlight.5.foreground
-hightlight.keyword.style=bold
-hightlight.method_name.foreground=&gt;&gt;&gt;hightlight.6.foreground
-hightlight.method_name.style=bold
-hightlight.class_name.foreground=&gt;&gt;&gt;hightlight.7.foreground
-hightlight.class_name.style=bold
-hightlight.module_name.foreground=&gt;&gt;&gt;hightlight.8.foreground
-hightlight.module_name.style=bold
-hightlight.instance_variable.foreground=&gt;&gt;&gt;hightlight.9.foreground
-hightlight.instance_variable.style=bold
-hightlight.global_variable.foreground=&gt;&gt;&gt;hightlight.10.foreground
-hightlight.global_variable.style=bold
-hightlight.comment.foreground=&gt;&gt;&gt;hightlight.11.foreground
-hightlight.string.foreground=&gt;&gt;&gt;hightlight.12.foreground
-hightlight.number.foreground=&gt;&gt;&gt;hightlight.13.foreground
-hightlight.operator.foreground=&gt;&gt;&gt;hightlight.14.foreground
-hightlight.operator.style=bold
-hightlight.symbol.foreground=&gt;&gt;&gt;hightlight.15.foreground
-hightlight.symbol.style=bold
-
+re.hightlight.keyword.foreground=&gt;&gt;&gt;hightlight.5.foreground
+re.hightlight.keyword.style=bold
+re.hightlight.method_name.foreground=&gt;&gt;&gt;hightlight.6.foreground
+re.hightlight.method_name.style=bold
+re.hightlight.class_name.foreground=&gt;&gt;&gt;hightlight.7.foreground
+re.hightlight.class_name.style=bold
+re.hightlight.module_name.foreground=&gt;&gt;&gt;hightlight.8.foreground
+re.hightlight.module_name.style=bold
+re.hightlight.instance_variable.foreground=&gt;&gt;&gt;hightlight.9.foreground
+re.hightlight.instance_variable.style=bold
+re.hightlight.global_variable.foreground=&gt;&gt;&gt;hightlight.10.foreground
+re.hightlight.global_variable.style=bold
+re.hightlight.comment.foreground=&gt;&gt;&gt;hightlight.11.foreground
+re.hightlight.string.foreground=&gt;&gt;&gt;hightlight.12.foreground
+re.hightlight.number.foreground=&gt;&gt;&gt;hightlight.13.foreground
+re.hightlight.operator.foreground=&gt;&gt;&gt;hightlight.14.foreground
+re.hightlight.operator.style=bold
+re.hightlight.symbol.foreground=&gt;&gt;&gt;hightlight.15.foreground
+re.hightlight.symbol.style=bold
 
-#hightlight.keyword.color.foreground=#00007F
-#hightlight.keyword.style=bold
-#hightlight.method_name.color.foreground=#007F7F
-#hightlight.method_name.style=bold
-#hightlight.class_name.color.foreground=#0000FF
-#hightlight.class_name.style=bold
-#hightlight.module_name.color.foreground=#0000FF
-#hightlight.module_name.style=bold
-#hightlight.instance_variable.color.foreground=#7F7F7F
-#hightlight.instance_variable.style=bold
-#hightlight.global_variable.style=bold
-#hightlight.global_variable.color.foreground=#db66ca
-#hightlight.comment.color.foreground=#007F00
-#hightlight.string.color.foreground=#7F007F
-#hightlight.number.color.foreground=#007F7F
-#hightlight.capitalize.color.foreground=#0000FF
-#hightlight.operator.color.foreground=#000000
-#hightlight.operator.style=bold
-#hightlight.symbol.color.foreground=#bdc175
-#hightlight.symbol.style=bold
-#hightlight.sel.color.foreground=black
-#hightlight.sel.color.background=#68f914
-#hightlight.sel.borderwidth=1
-#hightlight.sel.relief=raised
-#hightlight.goto.color.foreground=blue
-#hightlight.selected.color.background=yellow
-#hightlight.tabs.color.foreground=black
-#hightlight.tabs.color.background=#b1cfba
-#hightlight.tabs.borderwidth=1
-#hightlight.tabs.relief=raised
-#hightlight.spaces.color.foreground=black
-#hightlight.spaces.color.background=#d9f42b
-#hightlight.spaces.borderwidth=1
-#hightlight.spaces.relief=raised
+@include=coderay.tokens</diff>
      <filename>ext/ae-editor/langs/rb.lang</filename>
    </modified>
    <modified>
      <diff>@@ -121,7 +121,7 @@ class FilesHistrory &lt; ArcadiaExt
         if String.method_defined?(:lines)
       	   selection_lines = _self.selection_get[0].lines
         else
-      	   selection_lines = _self.selection_get[0].lines
+      	   selection_lines = _self.selection_get[0]
         end
        	selection_lines.each{|_block|
         	 _selected = _selected + _block.to_s + &quot;\s&quot; 
@@ -291,8 +291,8 @@ class FilesHistrory &lt; ArcadiaExt
 
     #@image_kdir = TkPhotoImage.new('dat' =&gt; BOOK_GIF)
     @image_kdir = TkPhotoImage.new('dat' =&gt; ICON_FOLDER_OPEN_GIF)
-    @image_kfile_rb = TkPhotoImage.new('dat' =&gt; RUBY_DOCUMENT_GIF)
-    @image_kfile = TkPhotoImage.new('dat' =&gt; DOCUMENT_GIF)
+#    @image_kfile_rb = TkPhotoImage.new('dat' =&gt; RUBY_DOCUMENT_GIF)
+#    @image_kfile = TkPhotoImage.new('dat' =&gt; DOCUMENT_GIF)
 
 	  build_tree_from_node(root)
   end
@@ -357,10 +357,12 @@ class FilesHistrory &lt; ArcadiaExt
   def image(_kind, _label='.rb')
       if _kind == 'KDir'
         return @image_kdir
-      elsif _kind == 'KFile' &amp;&amp; _label.include?('.rb')
-        return @image_kfile_rb
-      else
-        return @image_kfile
+      elsif _kind == 'KFile'
+        return Arcadia.file_icon(_label)
+#      elsif _kind == 'KFile' &amp;&amp; _label.include?('.rb')
+#        return @image_kfile_rb
+#      else
+#        return @image_kfile
       end
   end
 </diff>
      <filename>ext/ae-file-history/ae-file-history.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,6 +3,7 @@ active=yes
 require=ext/ae-shell/ae-shell
 class=Shell
 
+win32::gems=win32-process,ruby-wmi
 
 #:::::::::::::::: output  ::::::::::::::::::::::&lt;begin&gt;
 ruby=ruby
@@ -10,4 +11,4 @@ freebsd::ruby=ruby
 win32::ruby=ruby
 win32::rubyw=rubyw
 rubyw=rubyw
-#:::::::::::::::: output  ::::::::::::::::::::::&lt;end&gt;
+#:::::::::::::::: output  ::::::::::::::::::::::&lt;end&gt;
\ No newline at end of file</diff>
      <filename>ext/ae-shell/ae-shell.conf</filename>
    </modified>
    <modified>
      <diff>@@ -174,4 +174,4 @@ class Shell &lt; ArcadiaExt
     end
   end
 
-end
+end
\ No newline at end of file</diff>
      <filename>ext/ae-shell/ae-shell.rb</filename>
    </modified>
    <modified>
      <diff>@@ -811,17 +811,19 @@ class Application
     if @objs[_name]
       return @objs[_name]
     else
-      raise RuntimeError, &quot;resurce '&quot;+_name+&quot;' unavabled &quot;, caller
+      return nil
+      #raise RuntimeError, &quot;resurce '&quot;+_name+&quot;' unavabled &quot;, caller
     end
   end
 
   def []=(_name, _value)
-    if @objs[_name]
-      @objs[_name] = _value
-    end
+    @objs[_name] = _value
+#    if @objs[_name]
+#      @objs[_name] = _value
+#    end
   end
 
 
   def run
   end
-end
+end
\ No newline at end of file</diff>
      <filename>lib/a-commons.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,2617 +1,2651 @@
-#
-#   a-core.rb - Arcadia Ruby ide
-#   by Antonio Galeone &lt;antonio-galeone@rubyforge.org&gt;
-#
-#   &amp;require_dir_ref=..
-#   &amp;require_omissis=conf/arcadia.init
-#   &amp;require_omissis=tk
-#   &amp;require_omissis=tk/label
-#   &amp;require_omissis=tk/toplevel
-
-
-
-require &quot;conf/arcadia.res&quot;
-require 'tkextlib/bwidget'
-require &quot;lib/a-tkcommons&quot;
-require &quot;lib/a-contracts&quot;
-require &quot;observer&quot;
-
-class Arcadia &lt; TkApplication
-  include Observable
-  attr_reader :layout
-  def initialize
-    super(
-      ApplicationParams.new(
-        'arcadia',
-        '0.8.0',
-        'conf/arcadia.conf',
-        'conf/arcadia.pers'
-      )
-    )
-    load_config
-    set_sysdefaultproperty
-    ArcadiaDialogManager.new(self)
-    ArcadiaActionDispatcher.new(self)
-    ArcadiaGemsWizard.new(self)
-    #self.load_local_config(false)
-    ObjectSpace.define_finalizer($arcadia, self.class.method(:finalize).to_proc)
-    publish('action.on_exit', proc{do_exit})
-    #_title = &quot;Arcadia Ruby ide :: [Platform = #{RUBY_PLATFORM}] [Ruby version = #{RUBY_VERSION}] [TclTk version = #{tcltk_info.level}]&quot;
-    _title = &quot;Arcadia ide &quot;
-    @root = TkRoot.new(
-      'background'=&gt; self['conf']['background']
-      ){
-      title _title
-      withdraw
-      protocol( &quot;WM_DELETE_WINDOW&quot;, $arcadia['action.on_exit'])
-      iconphoto(TkPhotoImage.new('dat'=&gt;ARCADIA_RING_GIF))
-    }
-    
-    @on_event = Hash.new
-
-    @main_menu_bar = TkMenubar.new(
-      'background'=&gt; self['conf']['background']
-    ).pack('fill'=&gt;'x')
-    @mf_root = Tk::BWidget::MainFrame.new(@root,
-     'background'=&gt; self['conf']['background']
-      ){
-      menu @main_menu_bar
-    }.pack(
-      'anchor'=&gt; 'center',
-      'fill'=&gt; 'both',
-      'expand'=&gt; 1
-    )
-    #.place('x'=&gt;0,'y'=&gt;0,'relwidth'=&gt;1,'relheight'=&gt;1)
-    @mf_root.show_statusbar('none')
-    #@toolbar = @mf_root.add_toolbar
-    @main_toolbar = ArcadiaMainToolbar.new(self, @mf_root.add_toolbar)
-    @is_toolbar_show=self['conf']['user_toolbar_show']=='yes'
-    @mf_root.show_toolbar(0,@is_toolbar_show)
-    @use_splash = self['conf']['splash.show']=='yes'
-    @splash = ArcadiaAboutSplash.new if @use_splash
-    @splash.set_progress(50) if @splash
-    @splash.deiconify if @splash
-    Tk.update
-    @splash.next_step('..prepare')  if @splash
-    prepare
-    @splash.last_step('..load finish')  if @splash
-    start_width = (TkWinfo.screenwidth(@root)-4)
-    start_height = (TkWinfo.screenheight(@root)-20)
-    if RUBY_PLATFORM =~ /mswin|mingw/ # 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'
-    @root.deiconify
-    @root.raise
-    @root.focus(true)
-    @root.geometry(geometry)
-    Tk.update_idletasks
-    #sleep(1)
-    @splash.destroy  if @splash
-    if @first_run
-      Arcadia.process_event(OpenBufferEvent.new(self,'file'=&gt;'README'))
-    elsif ARGV.length &gt; 0
-      ARGV.each{|_f|
-        if  $pwd != File.dirname(__FILE__) &amp;&amp; !File.exist?(_f)
-          _f = &quot;#{$pwd}/#{_f}&quot;
-        end
-        Arcadia.process_event(OpenBufferEvent.new(self,'file'=&gt;_f)) if File.exist?(_f)
-      }
-    end
-    Arcadia.attach_listener(self, QuitEvent)
-    Arcadia.persistent(&quot;version&quot;, self['applicationParams'].version)
-  end
-
-  def on_quit(_event)
-    self.do_exit
-  end
-  
-  def register(_ext)
-    @exts_i &lt;&lt; _ext
-  end
-  
-  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
-  
-  
-  def Arcadia.finalize(id)
-    puts &quot;\nArcadia #{id} dying at #{Time.new}&quot;
-  end
-	
-  def ext_active?(_name)
-	 return (self['conf'][_name+'.active'] != nil &amp;&amp; self['conf'][_name+'.active']=='yes')||
-       	  (self['conf'][_name+'.active'] == nil)
-  end
-	
-  def load_exts_conf
-  		@exts = Array.new
-  		@exts_i = Array.new
-  		dirs = Array.new
-  		files = Dir['ext/*'].concat(Dir[ENV[&quot;HOME&quot;]+'/.arcadia/ext/*']).sort
-  		files.each{|f|
-  			 dirs &lt;&lt; f if File.stat(f).directory? &amp;&amp; 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 &gt; 1
-             new_key = var_plat[0] + ':' + name + '.' + var_plat[1]
-           else
-             new_key = name+'.'+key
-           end	
-       	   conf_hash2[new_key]= value
-       	 }
-       @exts &lt;&lt; name	 	
-    		 self['conf'].update(conf_hash2)	
-    		 self['origin_conf'].update(conf_hash2)	
-  		}
-  end
-
-  def check_gems_dependences(_ext)
-    ret = true
-    gems_property = self['conf'][&quot;#{_ext}.gems&quot;]
-    if gems_property
-      gems = gems_property.split(',').collect{| g | g.strip }
-      if gems &amp;&amp; gems.length &gt; 0
-        gems.each{|gem|
-          # consider gem only if it is not installed
-          if !Gem.available?(gem)
-            repository_property =  self['conf'][&quot;#{_ext}.gems.#{gem}.repository&quot;]
-            args = Hash.new
-            args['extension_name']=_ext
-            args['gem_name']=gem
-            args['gem_repository']=repository_property if repository_property
-            _event = Arcadia.process_event(NeedRubyGemWizardEvent.new(self, args))
-            if _event &amp;&amp; _event.results
-              ret = ret &amp;&amp; _event.results[0].installed
-            end
-            break if !ret
-          end
-        } 
-      end 
-    end 
-    ret
-  end
-
-  def do_build
-    # create extensions
-    Array.new.concat(@exts).each{|extension|
-      if extension &amp;&amp; ext_active?(extension)
-        @splash.next_step('... creating '+extension)  if @splash
-        # before creating extension check gems dependences
-        gems_installed = check_gems_dependences(extension)
-        if !gems_installed || !ext_create(extension)
-          @exts.delete(extension)
-        end
-      end
-    }
-    begin
-      _build_event = Arcadia.process_event(BuildEvent.new(self))
-    rescue Exception
-      ret = false
-      msg = &quot;During build event processing(#{$!.class.to_s}) : #{$!} at : #{$@.to_s}&quot;
-      ans = Tk.messageBox('icon' =&gt; 'error', 'type' =&gt; 'abortretryignore',
-      'title' =&gt; &quot;(Arcadia) Build face&quot;, 'parent' =&gt; @root,
-      'message' =&gt; msg)
-      if  ans == 'abort'
-        raise
-        exit
-      elsif ans == 'retry'
-        retry
-      else
-        Tk.update
-      end
-    end
-  end
-  
-  def load_maximised
-    lm = self['conf']['layout.maximized']
-    if lm    
-      ext,index=lm.split(',')
-      maxed = false
-      if ext &amp;&amp; index
-        ext = ext.strip
-        i=index.strip.to_i
-        @exts_i.each{|e|
-          if e.conf('name')==ext &amp;&amp; !maxed
-            p &quot;maximizzo #{ext}&quot;
-            e.maximize(i)
-            maxed=true
-            break
-          end
-        }    
-      end
-    end
-  end
-
-  def ext_create(_extension)
-    ret = true
-    begin
-      source = self['conf'][_extension+'.require']
-      class_name = self['conf'][_extension+'.class']
-      if source.strip.length &gt; 0
-	      require source 
-      end
-      if class_name.strip.length &gt; 0
-        publish(_extension, eval(class_name).new(self, _extension))
-      end
-    rescue Exception,LoadError
-      ret = false
-      msg = &quot;Loading \&quot;#{_extension}\&quot; (#{$!.class.to_s}) : #{$!} at : #{$@.to_s}&quot;
-      ans = Tk.messageBox('icon' =&gt; 'error', 'type' =&gt; 'abortretryignore',
-      'title' =&gt; &quot;(Arcadia) Extensions '#{_extension}'&quot;, 'parent' =&gt; @root,
-      'message' =&gt; msg)
-      if  ans == 'abort'
-        raise
-        exit
-      elsif ans == 'retry'
-        retry
-      else
-        Tk.update
-      end
-    end
-    ret
-  end
-
-  def ext_method(_extension, _method)
-    begin
-      self[_extension].send(_method)
-    rescue Exception
-      msg = _method.to_s+' &quot;'+_extension.to_s+'&quot;'+&quot; (&quot;+$!.class.to_s+&quot;) &quot;+&quot; : &quot;+$! + &quot;\n at : &quot;+$@.to_s
-      ans = Tk.messageBox('icon' =&gt; 'warning', 'type' =&gt; 'abortretryignore',
-      'title' =&gt; '(Arcadia) Extensions', 'parent' =&gt; @root,
-      'message' =&gt; msg)
-      if ans == 'abort'
-        raise
-        exit
-      elsif ans == 'retry'
-        retry
-      else
-        Tk.update
-      end
-    end
-  end
-
-  def init_layout
-    @layout = ArcadiaLayout.new(self, @mf_root.get_frame)
-    suf = &quot;layout.split&quot;
-    elems = self['conf'][suf]
-    return if elems.nil?
-    if elems.strip.length &gt; 0
-      groups = elems.split(',')
-      groups.each{|group|
-        if group
-          suf1 = suf+'.'+group
-          begin
-            property = self['conf'][suf1]
-            c = property.split('c')
-            if c &amp;&amp; c.length == 2
-              pt = c[0].split('.')
-              perc = c[1].include?('%')
-              w = c[1].sub('%','')
-              if perc 
-                @layout.add_cols_perc(pt[0].to_i, pt[1].to_i, w.to_i)
-              else
-                @layout.add_cols(pt[0].to_i, pt[1].to_i, w.to_i)
-              end
-            else
-              r = property.split('r')
-              if r &amp;&amp; r.length == 2
-                pt = r[0].split('.')
-                perc = r[1].include?('%')
-                w = r[1].sub('%','')
-                if perc 
-                  @layout.add_rows_perc(pt[0].to_i, pt[1].to_i, w.to_i)
-                else
-                  @layout.add_rows(pt[0].to_i, pt[1].to_i, w.to_i)
-                end
-              end
-            end
-            
-          rescue Exception
-            msg = &quot;Loading layout: (#{$!.class.to_s} : #{$!.to_s} at : #{$@.to_s})&quot;
-            if Arcadia.dialog(self, 'type'=&gt;'ok_cancel', 'level'=&gt;'error','title' =&gt; '(Arcadia) Layout', 'msg'=&gt;msg)=='cancel'
-              raise
-              exit
-            else
-              Tk.update
-            end
-          end
-        end
-      }
-    else
-      @layout.add_mono_panel
-    end
-    @layout.add_headers
-  end
-
-  def load_config
-    self.load_local_config(false)
-    # local config can contain loading conditions
-    self.load_exts_conf
-    self.load_local_config
-    self.load_theme(self['conf']['theme'])
-    self.resolve_properties_link(self['conf'],self['conf'])
-    self.resolve_properties_link(self['origin_conf'],self['origin_conf'])
-  end
-
-  def set_sysdefaultproperty
-    Tk.tk_call &quot;eval&quot;,&quot;option add *background #{self['conf']['background']}&quot;
-    Tk.tk_call &quot;eval&quot;,&quot;option add *foreground #{self['conf']['foreground']}&quot;
-    #Tk.tk_call &quot;eval&quot;,&quot;option add *font #{self['conf']['font']}&quot;
-    Tk.tk_call &quot;eval&quot;,&quot;option add *activebackground #{self['conf']['activebackground']}&quot;
-    Tk.tk_call &quot;eval&quot;,&quot;option add *activeforeground #{self['conf']['activeforeground']}&quot;
-  end
-
-  def prepare
-    super
-    @splash.next_step('...initialize')  if @splash
-    @splash.next_step  if @splash
-    #self.load_libs
-    @splash.next_step  if @splash
-    @splash.next_step('... load extensions')  if @splash
-    #load_config
-    init_layout
-    publish('buffers.code.in_memory',Hash.new)
-    publish('action.load_code_from_buffers', proc{TkBuffersChoise.new})
-    publish('output.action.run_last', proc{$arcadia['output'].run_last})
-    publish('main.action.open_file', proc{self['editor'].open_file(Tk.getOpenFile)})
-    @splash.next_step('... load obj controller')  if @splash
-    @splash.next_step('... load editor')  if @splash
-    publish('main.action.new_file',proc{$arcadia['editor'].open_buffer()})
-    publish('main.action.edit_cut',proc{$arcadia['editor'].raised.text.text_cut()})
-    publish('main.action.edit_copy',proc{$arcadia['editor'].raised.text.text_copy()})
-    publish('main.action.edit_paste',proc{$arcadia['editor'].raised.text.text_paste()})
-    @splash.next_step('... load actions')  if @splash
-    #provvisorio 
-    @keytest = KeyTest.new
-    @keytest.on_close=proc{@keytest.hide}
-    @keytest.hide
-    @keytest.title(&quot;Keys test&quot;)
-    publish('action.test.keys', proc{@keytest.show})
-    publish('action.get.font', proc{Tk::BWidget::SelectFont::Dialog.new.create})
-    @splash.next_step  if @splash
-    publish('action.show_about', proc{ArcadiaAboutSplash.new.deiconify})
-#    publish('main.menu', @main_menu)
-    @main_menu = ArcadiaMainMenu.new(@main_menu_bar)
-    self.do_build
-    #publish('main.menu', ArcadiaMainMenu.new(@main_menu))
-    @splash.next_step  if @splash
-    publish('objic.action.raise_active_obj',
-    proc{
-    		InspectorContract.instance.raise_active_toplevel(self)
-    }
-    )
-    @splash.next_step('... toolbar buttons ')  if @splash
-    #@main_toolbar.load_toolbar_buttons
-    
-    #load user controls
-    #Arcadia control
-    load_user_control(@main_menu)
-    load_user_control(@main_toolbar)
-    #Extension control
-    @exts.each{|ext|
-      @splash.next_step(&quot;... load #{ext} user controls &quot;)  if @splash
-      load_user_control(@main_menu, ext)
-      load_user_control(@main_toolbar, ext)
-    }
-    load_user_control(@main_menu,&quot;&quot;,&quot;e&quot;)
-    load_user_control(@main_toolbar,&quot;&quot;,&quot;e&quot;)
-    #@layout.build_invert_menu
-  end
-
-  def load_user_control(_user_control, _ext='', _pre='')
-    return unless _ext &amp;&amp; ext_active?(_ext)
-    
-    if _ext.length &gt; 0 &amp;&amp; self[_ext]
-      _self_on_eval = self[_ext]
-      suf = &quot;#{_ext}.#{_user_control.class::SUF}&quot;
-    else
-      _self_on_eval = self
-      suf = &quot;#{_user_control.class::SUF}&quot;
-    end
-    if _pre.length &gt; 0
-      suf = &quot;#{_pre}.#{suf}&quot;
-    end
-    contexts = self['conf'][&quot;#{suf}.contexts&quot;]
-    contexts_caption = self['conf'][&quot;#{suf}.contexts.caption&quot;]
-    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'][&quot;#{suf1}.context_path&quot;]
-          property = proc{|_str, _suf| self['conf'][&quot;#{_suf}.#{_str}&quot;]} 
-          property_to_eval = proc{|_str, _suf| 
-            p = self['conf'][&quot;#{_suf}.#{_str}&quot;]
-            _self_on_eval.instance_eval(p) if p 
-          } 
-          items = self['conf'][suf1].split(',')
-          items.each{|item|
-            suf2 = suf1+'.'+item
-            disabled = !self['conf'][&quot;#{suf2}.disabled&quot;].nil?
-#            property = proc{|_str| self['conf'][&quot;#{suf2}.#{_str}&quot;]} 
-#            property_to_eval = proc{|_str| 
-#              p = self['conf'][&quot;#{suf2}.#{_str}&quot;]
-#              _self_on_eval.instance_eval(p) if p 
-#            } 
-            name = property.call('name',suf2)
-            caption = property.call('caption',suf2)
-            hint = property.call('hint',suf2)
-            event_class = property_to_eval.call('event_class',suf2)
-            
-            event_args = property_to_eval.call('event_args',suf2)
-            image_data = property_to_eval.call('image_data',suf2)
-            item_args = {
-              'name'=&gt;name,
-              'caption'=&gt;caption,
-              'hint'=&gt;hint,
-              'event_class' =&gt;event_class,
-              'event_args' =&gt;event_args,
-              'image_data' =&gt;image_data,
-              'context'=&gt;group,
-              'context_path'=&gt;context_path
-            }
-            item_args['context_caption'] = groups_caption[gi] if groups_caption
-            i = _user_control.new_item(self, item_args)
-            i.enable=false if disabled
-
-          }
-        rescue Exception
-          msg = &quot;Loading #{groups} -&gt;#{items} (#{$!.class.to_s} : #{$!.to_s} at : #{$@.to_s})&quot;
-          if Arcadia.dialog(self, 'type'=&gt;'ok_cancel', 'title' =&gt; '(Arcadia) Toolbar', 'msg'=&gt;msg)=='cancel'
-            raise
-            exit
-          else
-            Tk.update
-          end
-        end
-      end
-    }
-    
-  end
-
-
-  def do_exit
-    q1 = conf('confirm-on-exit')!='yes' || (Arcadia.dialog(self,
-                        'type'=&gt;'yes_no',
-                        'msg'=&gt;&quot;Do you want exit?&quot;,
-                        'title' =&gt; '(Arcadia) Exit',
-                        'level' =&gt; 'question')=='yes')
-    if q1 &amp;&amp; can_exit?
-      do_finalize
-      @root.destroy
-    end
-  end
-
-  def can_exit?
-    _event = Arcadia.process_event(ExitQueryEvent.new(self, 'can_exit'=&gt;true))
-   return _event.can_exit
-  end
-
-  def save_layout
-    Arcadia.del_conf_group('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']=&quot;#{e.conf('name')},#{i}&quot;
-          e.resize(i)
-          found=true
-          break
-        end
-      } 
-      break if found
-    }
-    # layouts
-    splits,doms,r,c = @layout.dump_geometry
-    header = &quot;&quot;
-    splits.each_index{|i|
-      header &lt;&lt; i.to_s
-      header &lt;&lt; ',' if i &lt; splits.length-1
-    }
-    self['conf']['layout.split']= header
-    splits.each_with_index{|sp,i|
-      self['conf'][&quot;layout.split.#{i}&quot;]=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 &amp;&amp; TkWinfo.parent(frame).instance_of?(Tk::BWidget::NoteBook)
-            frame=TkWinfo.parent(TkWinfo.parent(frame))
-          elsif frame.nil?
-            if str_frames.length &gt; 0
-              str_frames &lt;&lt; ','
-            end
-            str_frames &lt;&lt; '-1.-1'
-          end
-          if doms[frame]
-            if str_frames.length &gt; 0
-              str_frames &lt;&lt; ','
-            end
-            str_frames &lt;&lt; doms[frame]
-          end
-        else
-        end
-      }
-      if str_frames.length &gt; 0
-        self['conf'][&quot;#{e.conf('name')}.frames&quot;]=str_frames
- #     p &quot;#{e.conf('name')}.frames=#{str_frames}&quot;
-      end
-    }
-  end
-  
-  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
-
-  def Arcadia.console(_sender, _args=Hash.new)
-    process_event(MsgEvent.new(_sender, _args))
-  end
-  
-  def Arcadia.dialog(_sender, _args=Hash.new)
-    _event = process_event(DialogEvent.new(_sender, _args))  
-    return _event.results[0].value if _event
-  end
-
-  def Arcadia.style(_class)
-    Configurable.properties_group(_class, Arcadia.instance['conf'])
-  end
-  
-  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
-
-  def Arcadia.layout
-    if @@instance
-        return @@instance.layout
-	  end
-  end
-
-#  def Arcadia.res(_res)
-#    theme = Arcadia.instance['conf']['theme']
-#    if theme
-#      ret = eval(&quot;#{theme}::#{_res}&quot;)
-#    end
-#    ret=Res::_res if ret.nil?
-#    return ret
-#  end
-
-
-end
-
-class ArcadiaUserControl
-  SUF='user_control'
-  class UserItem
-    attr_accessor :name
-    attr_accessor :context
-    attr_accessor :context_caption
-    attr_accessor :caption
-    attr_accessor :hint
-    attr_accessor :event_class
-    attr_accessor :event_args
-    attr_accessor :image_data
-    def initialize(_sender, _args)
-      @sender = _sender
-      if _args 
-        _args.each do |key, value|
-          self.send(key+'=', value)
-        end
-      end
-      #@item_obj = ?
-    end
-
-    def method_missing(m, *args)  
-      if @item_obj &amp;&amp; m.respond_to?(m)
-        @item_obj.send(m, *args)
-      end
-    end  
-
-        
-    def enable=(_value)
-    end
-    
-    def background
-    end
-    
-    def foreground
-    end
-    
-  end
-#  def initialize
-#    @items = Hash.new
-#  end
-  def items
-    @items = Hash.new if @items.nil?
-    @items
-  end
-  
-  def new_item(_sender, _args)
-    item = self.class::UserItem.new(_sender, _args)
-    items[_args['name']]= item if _args['name']
-  end
-  
-end
-
-
-class ArcadiaMainToolbar &lt; ArcadiaUserControl
-  SUF='user_toolbar'
-  class UserItem &lt; UserItem
-    attr_accessor :frame
-    def initialize(_sender, _args)
-      super(_sender, _args)
-      _image = TkPhotoImage.new('data' =&gt; @image_data) if @image_data
-      _command = proc{Arcadia.process_event(@event_class.new(_sender, @event_args))} if @event_class
-      _hint = @hint
-      _font = @font
-      _caption = @caption
-      @item_obj = Tk::BWidget::Button.new(_args['frame'], Arcadia.style('toolbarbutton')){
-        image  _image if _image
-        #borderwidth 1
-        #font _font if _font
-        #activebackground Arcadia.conf('button.activebackground')
-        #activeforeground Arcadia.conf('button.activeforeground')
-        #background Arcadia.conf('button.background')
-        #foreground Arcadia.conf('button.foreground')
-        #highlightbackground Arcadia.conf('button.highlightbackground')
-        #relief Arcadia.conf('button.relief')
-        command _command if _command
-        #relief 'groove'
-        width 20
-        height 20
-        helptext  _hint if _hint
-        text _caption if _caption
-        pack('side' =&gt;'left', :padx=&gt;2, :pady=&gt;0)
-      }
-      #Tk::BWidget::Separator.new(@frame, :orient=&gt;'vertical').pack('side' =&gt;'left', :padx=&gt;2, :pady=&gt;2, :fill=&gt;'y',:anchor=&gt; 'w')
-    end
-
-    def enabled=(_value)
-      if _value
-        @item_obj.state='enable'
-      else
-        @item_obj.state='disable'
-      end
-    end
-  end
-  
-  
-  def initialize(_arcadia, _frame)
-    @arcadia = _arcadia
-    @frame = _frame
-    @frame.borderwidth(Arcadia.conf('panel.borderwidth'))
-    #@frame.highlightbackground(Arcadia.conf('panel.highlightbackground'))
-    @frame.relief(Arcadia.conf('panel.relief'))
- 
-     @context_frames = Hash.new  
-    @last_context = nil
-  end
-
-  def new_item(_sender, _args= nil)
-     _context = _args['context']
-#    if _context
-#      if @context_frames[_context]
-#      else
-#        @context_frames[_context] = TkLabelFrame.new(@frame){
-#          text  &quot;&quot;
-#          relief 'groove'
-#          pack('side' =&gt;'left', :padx=&gt;0, :pady=&gt;0)
-#        } 
-#      end
-#      _args['frame']=@context_frames[_context]
-#    else
-#      _args['frame']=@frame
-#    end
-    if @last_context &amp;&amp; _context != @last_context 
-      new_separator
-    end
-    @last_context = _context
-    _args['frame']=@frame
-    super(_sender, _args)
-  end
-
-  def new_separator
-    Tk::BWidget::Separator.new(@frame, 
-    :orient=&gt;'vertical',
-    :background=&gt;Arcadia.conf('button.highlightbackground')
-    ).pack('side' =&gt;'left', :padx=&gt;2, :pady=&gt;2, :fill=&gt;'y',:anchor=&gt; 'w')
-  end  
-
-#  def load_toolbar_buttons
-#    suf = 'toolbar_buttons'
-#    return if @arcadia['conf'][suf].nil?
-#    @buttons = Hash.new
-#    toolbar_buttons = @arcadia['conf'][suf].split(',')
-#    toolbar_buttons.each{|groups|
-#      if groups
-#        suf1 = suf+'.'+groups
-#        begin
-#          buttons = @arcadia['conf'][suf1].split(',')
-#          buttons.each{|button|
-#            suf2 = suf1+'.'+button
-#            name = @arcadia['conf'][suf2+'.name']
-#            text = @arcadia['conf'][suf2+'.text']
-#            image = @arcadia['conf'][suf2+'.image']
-#            font = @arcadia['conf'][suf2+'.font']
-#            background = @arcadia['conf'][suf2+'.background']
-#            foreground = @arcadia['conf'][suf2+'.foreground']
-#            hint = @arcadia['conf'][suf2+'.hint']
-#            action = @arcadia['conf'][suf2+'.action']
-#            actions = action.split('-&gt;')  if action
-#            if actions &amp;&amp; actions.length&gt;1
-#              _command = proc{
-#                action_obj = $arcadia[actions[0]]
-#                1.upto(actions.length-2) do |x|
-#                  action_obj = action_obj.send(actions[x])
-#                end
-#                action_obj.send(actions[actions.length-1])
-#              }
-#            elsif action
-#              _command = proc{$arcadia[action].call}
-#            end
-#            @buttons[name] = Tk::BWidget::Button.new(@frame){
-#              image  TkPhotoImage.new('data' =&gt; eval(image)) if image
-#              borderwidth 1
-#              font font if font
-#              background background if background
-#              foreground foreground if foreground
-#              command _command if action
-#              relief 'flat'
-#              helptext  hint if hint
-#              text text if text
-#              pack('side' =&gt;'left', :padx=&gt;2, :pady=&gt;0)
-#            }
-#          }
-#        rescue Exception
-#          msg = 'Loading '+groups+'&quot; -&gt; '+buttons.to_s+ '&quot; (' + $!.class.to_s + &quot;) : &quot; + $!.to_s + &quot; at : &quot;+$@.to_s
-#          if Tk.messageBox('icon' =&gt; 'error', 'type' =&gt; 'okcancel',
-#            'title' =&gt; '(Arcadia) Toolbar', 'parent' =&gt; @frame,
-#            'message' =&gt; msg) == 'cancel'
-#            raise
-#            exit
-#          else
-#            Tk.update
-#          end
-#        end
-#      end
-#      Tk::BWidget::Separator.new(@frame, :orient=&gt;'vertical').pack('side' =&gt;'left', :padx=&gt;2, :pady=&gt;2, :fill=&gt;'y',:anchor=&gt; 'w')
-#    }
-#  end
-
-  
-end
-
-class ArcadiaMainMenu &lt; ArcadiaUserControl
-  SUF='user_menu'
-  class UserItem &lt; UserItem
-    attr_accessor :menu
-    def initialize(_sender, _args)
-      super(_sender, _args)
-      _image = TkPhotoImage.new('data' =&gt; @image_data) if @image_data
-      _command = proc{
-        Arcadia.process_event(@event_class.new(_sender, @event_args))
-      } if @event_class
-      #_menu = @menu[@parent]
-      @item_obj = @menu.insert('end', :command, 
-        'image'=&gt;_image,
-        'label'=&gt;@caption, 
-        'compound'=&gt;'left',
-        'command'=&gt;_command )
-      @index = @menu.index('last')
-    end
-
-    def enabled=(_value)
-      if _value
-        @item_obj.entryconfigure(@index, 'state'=&gt;'enable')
-      else
-        @item_obj.entryconfigure(@index,'state'=&gt;'disable')
-      end
-    end
-  end
-  
-  def initialize(menu)
-    # create main menu
-    @menu = menu
-    build
-    @menu.configure(Arcadia.style('menu'))
-#    menu.foreground('black')
-#    menu.activeforeground('#6679f1')
-#    menu.relief('flat')
-#    menu.borderwidth(0)
-#    menu.font(Arcadia.conf('main.mainmenu.font'))
-  end
-
-  def get_menu_context(_menubar, _context)
-    menubuttons =  _menubar[0..-1]
-    # cerchiamo il context
-    m_i = -1
-    menubuttons.each_with_index{|mb, i|
-      _t = mb[0].cget('text')
-      if _t==_context
-        m_i = i 
-        break
-      end
-    }
-    if m_i &gt; -1
-      _menubar[m_i][1]
-    else
-      _menubar.add_menu([[_context],[]])[1].delete(0)
-    end
-  end
-  
-  def get_sub_menu(menu_context, folder=nil)
-    if folder
-      s_i = -1 
-      i_end = menu_context.index('end')
-      if i_end
-        0.upto(i_end){|j|
-          l = menu_context.entrycget(j,'label')
-          if l == folder
-           s_i = j
-           break
-          end
-        }
-      end
-    end
-    if s_i &gt; -1 &amp;&amp; menu_context.menutype(s_i) == 'cascade'
-      sub = menu_context.entrycget(s_i, 'menu')
-    else
-      sub = TkMenu.new(
-        :parent=&gt;@pop_up,
-        :tearoff=&gt;0
-      )
-      sub.configure(Arcadia.style('menu'))
-      #update_style(sub)
-      menu_context.insert('end',
-        :cascade,
-        :label=&gt;folder,
-        :menu=&gt;sub,
-        :hidemargin =&gt; false
-      )
-    end
-    sub
-  end
-  
-  def get_menu(_menubar, _context, context_path)
-    context_menu = get_menu_context(_menubar, _context)
-    folders = context_path.split('/')
-    sub = context_menu
-    folders.each{|folder|
-      sub = get_sub_menu(sub, folder)
-    }
-    sub
-  end
-
-
-  def new_item(_sender, _args= nil)
-    return if _args.nil?
-    if _args['context_caption']
-      conte = _args['context_caption']
-    else
-      conte = _args['context']
-    end
-    _args['menu']=get_menu(@menu, conte, _args['context_path'])
-    super(_sender, _args)
-  end
-
-
-  def build
-    menu_spec_file = [
-      ['File', 0],
-      ['Open', proc{Arcadia.process_event(OpenBufferEvent.new(self,'file'=&gt;Tk.getOpenFile))}, 0],
-      ['New', $arcadia['main.action.new_file'], 0],
-      #['Save', proc{EditorContract.instance.save_file_raised(self)},0],
-      ['Save', proc{Arcadia.process_event(SaveBufferEvent.new(self))},0],
-      ['Save as ...', proc{Arcadia.process_event(SaveAsBufferEvent.new(self))},0],
-      '---',
-      ['Quit', $arcadia['action.on_exit'], 0]]
-      menu_spec_edit = [['Edit', 0],
-      ['Cut', $arcadia['main.action.edit_cut'], 2],
-      ['Copy', $arcadia['main.action.edit_copy'], 0],
-      ['Paste', $arcadia['main.action.edit_paste'], 0]]
-      menu_spec_search = [['Search', 0],
-      ['Find ...', proc{Arcadia.process_event(SearchBufferEvent.new(self))}, 2],
-      ['Find in files...', proc{Arcadia.process_event(SearchInFilesEvent.new(self))}, 2],
-      ['Ack in files...', proc{Arcadia.process_event(AckInFilesEvent.new(self))}, 2],
-      ['Go to line ...', proc{Arcadia.process_event(GoToLineBufferEvent.new(self))}, 2]]
-      menu_spec_view = [['View', 0],['Show/Hide Toolbar', proc{$arcadia.show_hide_toolbar}, 2]]
-      menu_spec_tools = [['Tools', 0],
-      ['Keys-test', $arcadia['action.test.keys'], 2]
-    ]
-    menu_spec_help = [['Help', 0],
-    ['About', $arcadia['action.show_about'], 2],]
-    @menu.add_menu(menu_spec_file)
-    @menu.add_menu(menu_spec_edit)
-    @menu.add_menu(menu_spec_search)
-    @menu.add_menu(menu_spec_view)
-    @menu.add_menu(menu_spec_tools)
-    @menu.add_menu(menu_spec_help)
-  
-    #@menu.bind_append(&quot;1&quot;, proc{
-#      chs = TkWinfo.children(@menu)
-#      hh = 25
-#      @last_post = nil
-#      chs.each{|ch|
-#        ch.bind_append(&quot;Enter&quot;, proc{|x,y,rx,ry| 
-#          @last_post.unpost if @last_post
-#          ch.menu.post(x-rx,y-ry+hh)
-#          @last_post=ch.menu}, &quot;%X %Y %x %y&quot;)
-#        ch.bind_append(&quot;Leave&quot;, proc{
-#          @last_post.unpost if @last_post
-#        })
-#      }
-    #})
-  end
-  
-end
-
-class ArcadiaAboutSplash &lt; TkToplevel
-  attr :progress
-  def initialize
-    #_bgcolor = '#B83333'
-    _bgcolor = '#000000'
-    super()
-    relief 'groove'
-    #relief 'flat'
-    background  _bgcolor
-    highlightbackground  _bgcolor
-    highlightthickness  1
-    borderwidth 2
-    withdraw 
-    overrideredirect(true)
-    
-    @tkLabel3 = TkLabel.new(self){
-      image  TkPhotoImage.new('format'=&gt;'GIF','data' =&gt;A_LOGO_GIF)
-      background  _bgcolor
-      place('x'=&gt; 20,'y' =&gt; 20)
-    }
-    @tkLabel1 = TkLabel.new(self){
-      text  'Arcadia'
-      background  _bgcolor
-      foreground  '#ffffff'
-      font Arcadia.conf('splash.title.font')
-      justify  'left'
-      place('width' =&gt; '190','x' =&gt; 110,'y' =&gt; 10,'height' =&gt; 25)
-    }
-    @tkLabelRuby = TkLabel.new(self){
-      image TkPhotoImage.new('data' =&gt;RUBY_DOCUMENT_GIF)
-      background  _bgcolor
-      place('x'=&gt; 150,'y' =&gt; 40)
-    }
-    @tkLabel2 = TkLabel.new(self){
-      text  'Ruby ide'
-      background  _bgcolor
-      foreground  '#ffffff'
-      font Arcadia.instance['conf']['splash.subtitle.font']
-      justify  'left'
-      place('width' =&gt; '90','x' =&gt; 170,'y' =&gt; 40,'height' =&gt; 19)
-    }
-    @tkLabelVersion = TkLabel.new(self){
-      text  'version: '+$arcadia['applicationParams'].version
-      background  _bgcolor
-      foreground  '#ffffff'
-      font Arcadia.instance['conf']['splash.version.font']
-      justify  'left'
-      place('width' =&gt; '120','x' =&gt; 150,'y' =&gt; 65,'height' =&gt; 19)
-    }
-    @tkLabel21 = TkLabel.new(self){
-      text  'by Antonio Galeone - 2004/2009'
-      background  _bgcolor
-      foreground  '#ffffff'
-      font Arcadia.instance['conf']['splash.credits.font']
-      justify  'left'
-      place('width' =&gt; '210','x' =&gt; 100,'y' =&gt; 95,'height' =&gt; 25)
-    }
-    @tkLabelStep = TkLabel.new(self){
-      text  ''
-      background  _bgcolor
-      foreground  'yellow'
-      font Arcadia.instance['conf']['splash.banner.font']
-      justify  'left'
-      anchor  'w'
-      place('width'=&gt;-5,'relwidth' =&gt; 1,'x' =&gt; 5,'y' =&gt; 160,'height' =&gt; 45)
-    }
-    @progress  = TkVariable.new
-    reset
-    _width = 380
-    _height = 240
-    #_width = 0;_height = 0
-    _x = TkWinfo.screenwidth(self)/2 -  _width / 2
-    _y = TkWinfo.screenheight(self)/2 -  _height / 2
-    geometry = _width.to_s+'x'+_height.to_s+'+'+_x.to_s+'+'+_y.to_s
-    Tk.tk_call('wm', 'geometry', self, geometry )
-    bind(&quot;Double-Button-1&quot;, proc{self.destroy})
-    info = TkApplication.sys_info
-    set_sysinfo(info)
-  end
-
-  def set_sysinfo(_info)
-    @tkLabelStep.text(_info)
-  end
-
-  def set_progress(_max=10)
-    @max = _max
-    Tk::BWidget::ProgressBar.new(self, :width=&gt;150, :height=&gt;10,
-    :background=&gt;'black',
-    :troughcolor=&gt;'black',
-    :foreground=&gt;'#a11934',
-    :variable=&gt;@progress,
-    :borderwidth=&gt;0,
-    :relief=&gt;'flat',
-    :maximum=&gt;_max).place('relwidth' =&gt; '1','y' =&gt; 146,'height' =&gt; 2)
-  end
-
-  def reset
-    @progress.value = -1
-  end
-
-  def next_step(_txt = nil)
-    @progress.numeric += 1
-    labelStep(_txt) if _txt
-  end
-
-  def labelStep(_txt)
-    @tkLabelStep.text = _txt
-    Tk.update
-  end
-
-  def last_step(_txt = nil)
-    @progress.numeric = @max
-    labelStep(_txt) if _txt
-  end
-  
-end
-
-class ArcadiaActionDispatcher
-
-  def initialize(_arcadia)
-    @arcadia = _arcadia
-    Arcadia.attach_listener(self, ActionEvent)
-  end
-  
-  def on_action(_event)
-    if _event.receiver != nil &amp;&amp; _event.receiver.respond_to?(_event.action)
-      if _event.action_args.nil?
-        _event.receiver.send(_event.action)
-      else
-        _event.receiver.send(_event.action, _event.action_args)
-      end
-    end
-  end
-
-end
-
-class ArcadiaGemsWizard
-  def initialize(_arcadia)
-    @arcadia = _arcadia
-    Arcadia.attach_listener(self, NeedRubyGemWizardEvent)
-  end
-  
-  def on_need_ruby_gem_wizard(_event)
-    # ... todo implamentation
-    msg = &quot;Appears that gem : '#{_event.gem_name}' required by : '#{_event.extension_name}' is not installed!\n Do you want to try install it now?&quot; 
-    ans = Tk.messageBox('icon' =&gt; 'error', 'type' =&gt; 'yesno',
-      'title' =&gt; &quot;(Arcadia) Extensions '#{_event.extension_name}'&quot;,
-      'message' =&gt; msg)
-      if  ans == 'yes'
-        _event.add_result(self, 'installed'=&gt;try_to_install_gem(_event.gem_name,_event.gem_repository))
-      else
-        _event.add_result(self, 'installed'=&gt;false)
-      end
-  end
-  
-  def try_to_install_gem(name, repository=nil, version = '&gt;0')
-    ret = false
-    # TODO WIZARD
-    
-#    # rubygems version must be &gt;= 1.2 Gem::RubyGemsVersion
-#    if Gem::RubyGemsVersion &gt;= '1.2'
-#      begin
-#        gem name, version
-#      rescue LoadError, Gem::LoadError =&gt; e
-#        require 'rubygems/gem_runner'
-#        begin
-#          gr = Gem::GemRunner.new
-#          com = %W[install #{name}]
-#          com.concat(%W[--source= #{repository}]) if repository
-#          p com
-#          gr.run(com)
-#        rescue Gem::SystemExitException=&gt;e
-#          if e.exit_code == 0
-#            ret = true
-#            p &quot;Successfully installed. #{e.message}&quot;
-#          else
-#            msg = &quot;Install of '#{name}' (#{version}) failed. #{e.message}&quot;
-#            Tk.messageBox('icon' =&gt; 'error', 
-#              'type' =&gt; 'ok',
-#              'title' =&gt; &quot;(Arcadia) gem&quot;,
-#              'message' =&gt; msg)
-#          end
-#        end
-#      end
-#    end
-    ret
-  end
-  
-end
-
-class ArcadiaDialogManager
-  def initialize(_arcadia)
-    @arcadia = _arcadia
-    Arcadia.attach_listener(self, DialogEvent)
-  end
-
-  def on_dialog(_event)
-    type = _event.type
-    if !DialogEvent::TYPE_PATTERNS.include?(_event.type)
-      type = 'ok'
-    end
-    res_array = type.split('_')
-    icon = _event.level
-    tktype = type.gsub('_','').downcase
-    
-    tkdialog =  Tk::BWidget::MessageDlg.new(
-            'icon' =&gt; icon,
-            'bg' =&gt; Arcadia.conf('background'),
-            'fg' =&gt; Arcadia.conf('foreground'),
-            'type' =&gt; tktype,
-            'title' =&gt; _event.title, 
-            'message' =&gt; _event.msg)
-            
-    tkdialog.configure('font'=&gt;'courier 6')        
-    res = tkdialog.create
-    _event.add_result(self, 'value'=&gt;res_array[res.to_i])
-  end
-
-
-  def on_dialog_old(_event)
-    type = _event.type
-    if !DialogEvent::TYPE_PATTERNS.include?(_event.type)
-      type = 'ok'
-    end
-    icon = _event.level
-    tktype = type.gsub('_','').downcase
-    
-    res =  Tk.messageBox(
-            'icon' =&gt; icon,
-            'type' =&gt; tktype,
-            'title' =&gt; _event.title, 
-            'message' =&gt; _event.msg)
-    _event.add_result(self, 'value'=&gt;res)
-  end
-end
-
-
-class ArcadiaLayout
-#  include Observable
-#  ArcadiaPanelInfo = Struct.new( &quot;ArcadiaPanelInfo&quot;,
-#    :name,
-#    :title,
-#    :frame,
-#    :ffw
-#  )
-
-  def initialize(_arcadia, _frame, _autotab=true)
-    @arcadia = _arcadia
-    @frames = Array.new
-    @frames[0] = Array.new
-    @frames[0][0] = _frame
-   # @domains = Array.new
-   # @domains[0] = Array.new
-   # @domains[0][0] = '_domain_root_'
-    @panels = Hash.new
-    @panels['_domain_root_']= Hash.new
-    @panels['_domain_root_']['root']= _frame
-    @panels['_domain_root_']['sons'] = 	Hash.new
-    @autotab = _autotab
-    @headed = false
-    @wrappers=Hash.new
-    @splitters=Array.new
-    #ArcadiaContractListener.new(self, MainContract, :do_main_event)
-  end
-	
-	def root
-		@panels['_domain_root_']['root']
-	end
-	
-	def raise_panel(_domain, _extension)
-    p = @panels[_domain]
-    if p &amp;&amp; p['notebook'] != nil
-      p['notebook'].raise(_extension)
-      p['notebook'].see(_extension)
-    end
-	end
-
-#  def raise_panel(_domain_name, _name)
-#    @panels[_domain_name]['notebook'].raise(_name) if @panels[_domain_name] &amp;&amp; @panels[_domain_name]['notebook']
-#  end
-
-	def raised?(_domain, _name)
-    ret = true
-    p = @panels[_domain]
-    if p &amp;&amp; p['notebook'] != nil
-      ret=p['notebook'].raise == _name
-    end
-    ret
-	end
-	
-	def raised_fixed_frame(_domain)
-	  ret = nil
-	  p = @panels[_domain]
-    if p &amp;&amp; p['notebook'] != nil
-      raised_name=p['notebook'].raise
-   	  @panels[_domain]['sons'].each{|k,v|
-   	    if raised_name == k 
-   	      ret = v 
-   	      break
-   	    end
-   	  }
-    elsif @panels[_domain]['sons'].length == 1
-      ret = @panels[_domain]['sons'].values[0]
-    end
-    ret
-  end
-  
-  def _prepare_rows(_row,_col, _height, _perc=false, _top_name=nil, _bottom_name=nil)
-    if (@frames[_row][_col] !=  nil)
-      #source_domains = all_domains(@frames[_row][_col])
-      #source_domains = others_domains(@frames[_row][_col], false)
-      _h = AGTkOSplittedFrames.new(self.root,@frames[_row][_col],_height, @arcadia['conf']['layout.splitter.length'].to_i,_perc)
-      @splitters &lt;&lt; _h
-      if @frames[_row + 1] == nil
-      		@frames[_row + 1] = Array.new
-      	#	@domains[_row + 1] = Array.new
-      end
-      @frames[_row][_col] = _h.top_frame
-      
-      _top_name = _row.to_s+'.'+_col.to_s if _top_name == nil
-      @panels[_top_name] = Hash.new
-      @panels[_top_name]['root'] = @frames[_row][_col]
-      @panels[_top_name]['sons'] = 	Hash.new
-      if @panels[_top_name]['root_splitted_frames'].nil?
-        @panels[_top_name]['root_splitted_frames'] = _h 
-      end
-      @panels[_top_name]['splitted_frames'] = _h
-     # @domains[_row][_col] = _top_name
-
-      _bottom_name = (_row+1).to_s+'.'+_col.to_s if _bottom_name == nil
-      
-      if !@panels[_bottom_name].nil?
-        shift_bottom(_row+1, _col)
-      end
-      
-      @panels[_bottom_name] = Hash.new
-      @frames[_row + 1][_col] = _h.bottom_frame
-      @panels[_bottom_name]['root'] = @frames[_row + 1][_col]
-      @panels[_bottom_name]['sons'] = Hash.new
-      if @panels[_bottom_name]['root_splitted_frames'].nil?
-        @panels[_bottom_name]['root_splitted_frames'] = _h 
-      end
-      @panels[_bottom_name]['splitted_frames'] = _h
-    	#	@domains[_row + 1][_col] = _bottom_name
-    end
-  end
-  private :_prepare_rows
-
-  def add_mono_panel(_name=nil)
-    if (@frames[0][0] !=  nil)
-      _name = '0.0' if _name.nil?
-      @panels[_name] = Hash.new
-      @panels[_name]['root'] = @frames[0][0]
-      @panels[_name]['sons'] = 	Hash.new
-    end
-  end
-
-
-  def add_rows(_row,_col, _height, _top_name=nil, _bottom_name=nil)
-  		_prepare_rows(_row,_col, _height, false, _top_name, _bottom_name)
-  end
-
-  def add_rows_perc(_row,_col, _height, _top_name=nil, _bottom_name=nil)
-  		_prepare_rows(_row,_col, _height, true, _top_name, _bottom_name)
-  end
-
-#  def others_domains(_frame, _vertical=true)
-#      if _vertical
-#        splitter_adapter_class = AGTkVSplittedFrames
-#      else
-#        splitter_adapter_class = AGTkOSplittedFrames
-#      end
-#      splitted_adapter = find_splitted_frame(_frame)
-#      consider_it = splitted_adapter.instance_of?(splitter_adapter_class) &amp;&amp; splitted_adapter.frame1 == _frame
-#      if splitted_adapter &amp;&amp; !consider_it &amp;&amp; splitted_adapter != _frame
-#         rif_frame = splitted_adapter.frame
-#         ret = others_domains(rif_frame)
-#      elsif splitted_adapter &amp;&amp; consider_it
-#        ret = domains_on_frame(splitted_adapter.frame2)
-#      else
-#        ret = Array.new
-#      end
-#      ret    
-#  end
-
-  def all_domains(_frame)
-      splitted_adapter = find_splitted_frame(_frame)
-      consider_it = splitted_adapter.kind_of?(AGTkSplittedFrames)
-      if consider_it
-        ret = domains_on_frame(splitted_adapter.frame2).concat(domains_on_frame(splitted_adapter.frame1))
-      else
-        ret = Array.new
-      end
-      ret    
-  end
-
-  def all_domains_cols(_frame)
-    ret = Array.new
-    all_domains(_frame).each{|d|
-      v = d.split('.')[1]
-      ret &lt;&lt; v if !ret.include?(v)
-    }
-    ret
-  end
-
-  def all_domains_rows(_frame)
-    ret = Array.new
-    all_domains(_frame).each{|d|
-      v = d.split('.')[0]
-      ret &lt;&lt; v if !ret.include?(v)
-    }
-    ret
-  end
-
-
-  def _prepare_cols(_row,_col, _width, _perc=false, _left_name=nil, _right_name=nil)
-    if (@frames[_row][_col] !=  nil)
-      #source_domains = all_domains(@frames[_row][_col])
-      #source_domains = others_domains(@frames[_row][_col])
-      _w = AGTkVSplittedFrames.new(self.root,@frames[_row][_col],_width,@arcadia['conf']['layout.splitter.length'].to_i,_perc)
-      @splitters &lt;&lt; _w
-      @frames[_row][_col] = _w.left_frame
-      #@frames[_row][_col + 1] = _w.right_frame
-
-      _left_name = _row.to_s+'.'+_col.to_s if _left_name == nil
-      @panels[_left_name] = Hash.new
-      @panels[_left_name]['root'] = @frames[_row][_col]
-      @panels[_left_name]['sons'] = Hash.new
-      if @panels[_left_name]['root_splitted_frames'].nil?
-        @panels[_left_name]['root_splitted_frames'] = _w 
-      end
-      @panels[_left_name]['splitted_frames'] = _w
-     # @domains[_row][_col] = _left_name
-        
-      _right_name = _row.to_s+'.'+(_col+1).to_s if _right_name == nil
-      if !@panels[_right_name].nil?
-        shift_right(_row, _col+1)
-      end
-
-      @frames[_row][_col + 1] = _w.right_frame
-      @panels[_right_name] = Hash.new
-      @panels[_right_name]['root'] = @frames[_row][_col + 1]
-      @panels[_right_name]['sons'] = Hash.new
-      if @panels[_right_name]['root_splitted_frames'].nil?
-        @panels[_right_name]['root_splitted_frames'] = _w 
-      end
-      @panels[_right_name]['splitted_frames'] = _w
-     # @domains[_row][_col + 1] = _right_name
-    end
-  end
- 	private :_prepare_cols
-  
-  
-  def domain_name(_row,_col)
-    _row.to_s+'.'+_col.to_s
-  end
-  
-  def shift_right(_row,_col)
-    d = domain_name(_row, _col+1)
-    dj = domain_name(_row, _col)
-    if @panels[d] !=nil
-      shift_right(_row,_col+1)
-    end
-    @panels[d] = @panels[dj]
-    #-------------------------------
-    #@panels[d]['root'].set_domain(d)
-    #-------------------------------
-    @panels[d]['sons'].each{|name,ffw| ffw.domain=d}
-    @frames[_row][_col+1] = @frames[_row][_col]
-   # @domains[_row][_col+1] = @domains[_row][_col]
-    
-    @panels.delete(dj)
-    #@panels[dj] = nil
-    @frames[_row][_col] = nil
-   # @domains[_row][_col] = nil
-  end
-
-  def shift_left(_row,_col)
-    d = domain_name(_row, _col)
-    dj = domain_name(_row, _col+1)
-    if @panels[dj] !=nil
-      @panels[d] = @panels[dj]
-      #-------------------------------
-      #@panels[d]['root'].set_domain(d)
-      #-------------------------------
-      @panels[d]['sons'].each{|name,ffw| ffw.domain=d}
-      @frames[_row][_col] = @frames[_row][_col+1]
-     # @domains[_row][_col] = @domains[_row][_col+1]
-      
-      @panels.delete(dj) # = nil
-      @frames[_row][_col+1] = nil
-     # @domains[_row][_col+1] = nil
-      shift_left(_row,_col+1)
-    end
-  
-  end
-
-  def shift_top(_row,_col)
-    d = domain_name(_row, _col)
-    dj = domain_name(_row+1, _col)
-    if @panels[dj] !=nil
-      @panels[d] = @panels[dj]
-      #-------------------------------
-      #@panels[d]['root'].set_domain(d)
-      #-------------------------------
-      @panels[d]['sons'].each{|name,ffw| ffw.domain=d}
-      @frames[_row][_col] = @frames[_row+1][_col]
-     # @domains[_row][_col] = @domains[_row+1][_col]
-      
-      @panels.delete(dj) # = nil
-      @frames[_row+1][_col] = nil
-     # @domains[_row+1][_col] = nil
-
-      shift_top(_row+1,_col)
-    end
-  
-  end
-
-
-  def shift_bottom(_row, _col)
-    d = domain_name(_row+1, _col)
-    dj = domain_name(_row, _col)
-    if @panels[d] !=nil
-      shift_bottom(_row+1,_col)
-    end
-    @panels[d] = @panels[dj]
-    #-------------------------------
-    #@panels[d]['root'].set_domain(d)
-    #-------------------------------
-    @panels[d]['sons'].each{|name,ffw| ffw.domain=d}
-    if @frames[_row + 1] == nil
-    		@frames[_row + 1] = Array.new
-    	#	@domains[_row + 1] = Array.new
-    end
-    @frames[_row+1][_col] = @frames[_row][_col]
-   # @domains[_row+1][_col] = @domains[_row][_col]
-    
-    @panels.delete(dj)
-    #@panels[dj] = nil
-    @frames[_row][_col] = nil
-   # @domains[_row][_col] = nil
-  end
-  
-  def add_cols(_row,_col, _width, _left_name=nil, _right_name=nil)
-    _prepare_cols(_row,_col, _width, false, _left_name, _right_name)
-  end
-
-  def add_cols_perc(_row,_col, _width, _left_name=nil, _right_name=nil)
-    _prepare_cols(_row,_col, _width, true, _left_name, _right_name)
-  end
-
-  def add_cols_runtime(_domain)
-    saved_root_splitted_frames = @panels[_domain]['root_splitted_frames']
-    _saved = Hash.new
-    _saved.update(@panels[_domain]['sons'])
-    geometry = TkWinfo.geometry(@panels[_domain]['root'])
-    width = geometry.split('x')[0].to_i/2
-    _saved.each{|name,ffw|
-      unregister_panel(ffw, false, false)
-    }
-    unbuild_titled_frame(_domain)
-    _row,_col = _domain.split('.')
-    add_cols(_row.to_i,_col.to_i, width)
-    build_titled_frame(_domain)
-    build_titled_frame(domain_name(_row.to_i,_col.to_i+1))
-    _saved.each{|name,ffw|
-      ffw.domain = _domain
-      register_panel(ffw, ffw.hinner_frame)    
-    }
-    if saved_root_splitted_frames
-      @panels[_domain]['root_splitted_frames']=saved_root_splitted_frames
-    end
-    build_invert_menu(true)
-  end
-
-  def add_rows_runtime(_domain)
-    saved_root_splitted_frames = @panels[_domain]['root_splitted_frames']
-    _saved = Hash.new
-    _saved.update(@panels[_domain]['sons'])
-    geometry = TkWinfo.geometry(@panels[_domain]['root'])
-    height = geometry.split('+')[0].split('x')[1].to_i/2
-    _saved.each{|name,ffw|
-      unregister_panel(ffw, false, false)
-    }
-    unbuild_titled_frame(_domain)
-    _row,_col = _domain.split('.')
-    add_rows(_row.to_i,_col.to_i, height)
-    build_titled_frame(_domain)
-    build_titled_frame(domain_name(_row.to_i+1,_col.to_i))
-    _saved.each{|name,ffw|
-      ffw.domain = _domain
-      register_panel(ffw, ffw.hinner_frame)    
-    }
-    if saved_root_splitted_frames
-      @panels[_domain]['root_splitted_frames']=saved_root_splitted_frames
-    end
-
-    build_invert_menu(true)
-  end
-
-  def domains_on_frame_rows(_frame)
-    ret = Array.new
-    domains_on_frame(_frame).each{|d|
-      v = d.split('.')[0]
-      ret &lt;&lt; v if !ret.include?(v)
-    }
-    ret
-  end
-  
-  def domains_rows(_domains)
-    ret = Array.new
-    if _domains
-      _domains.each{|d|
-        v = d.split('.')[0]
-        ret &lt;&lt; v if !ret.include?(v)
-      }
-    end
-    ret
-  end
-
-  def max_col(_domains, _row)
-    ret = 0
-    if _domains
-      _domains.each{|d|
-        r,c = d.split('.')
-        if r.to_i == _row &amp;&amp; c.to_i &gt; ret
-          ret = c.to_i
-        end
-      }
-    end
-    ret
-  end
-
-  def max_row(_domains, _col)
-    ret = 0
-    if _domains
-      _domains.each{|d|
-        r,c = d.split('.')
-        if c.to_i == _col &amp;&amp; r.to_i &gt; ret
-          ret = r.to_i
-        end
-      }
-    end
-    ret
-  end
-
-  def domains_cols(_domains)
-    ret = Array.new
-    _domains.each{|d|
-      v = d.split('.')[1]
-      ret &lt;&lt; v if !ret.include?(v)
-    }
-    ret
-  end
-
-  
-  def domains_on_frame_cols(_frame)
-    ret = Array.new
-    domains_on_frame(_frame).each{|d|
-      v = d.split('.')[1]
-      ret &lt;&lt; v if !ret.include?(v)
-    }
-    ret
-  end
-
-  def domains_on_splitter(_splitter)
-    domains_on_frame(_splitter.frame1).concat(domains_on_frame(_splitter.frame2))  
-  end
-
-  def domains_on_splitter_cols(_splitter)
-    ret = Array.new
-    domains_on_splitter(_splitter).each{|d|
-      v = d.split('.')[1]
-      ret &lt;&lt; v if !ret.include?(v)
-    }
-    ret
-  end
-
-  def domains_on_splitter_rows(_splitter)
-    ret = Array.new
-    domains_on_splitter(_splitter).each{|d|
-      v = d.split('.')[0]
-      ret &lt;&lt; v if !ret.include?(v)
-    }
-    ret
-  end
-
-
-  def domains_on_frame(_frame)
-    ret_doms = Array.new
-    frame_found = false
-    @panels.keys.each{|dom|
-      if dom != '_domain_root_'
-         if (@panels[dom]['splitted_frames'] != nil &amp;&amp; @panels[dom]['splitted_frames'].frame == _frame) || (@panels[dom]['root_splitted_frames'] != nil &amp;&amp; @panels[dom]['root_splitted_frames'].frame  == _frame)
-           ret_doms.concat(domains_on_frame(@panels[dom]['splitted_frames'].frame1))
-           ret_doms.concat(domains_on_frame(@panels[dom]['splitted_frames'].frame2))
-           frame_found = true
-           break
-         elsif @panels[dom]['notebook'] != nil 
-           cfrs = TkWinfo.children(_frame)
-           if cfrs &amp;&amp; cfrs.length == 1 &amp;&amp; cfrs[0].instance_of?(TkTitledFrame) &amp;&amp; TkWinfo.parent(@panels[dom]['notebook'])== cfrs[0].frame
-             ret_doms &lt;&lt; dom
-             frame_found = true
-           end       
-         elsif @panels[dom]['root'].instance_of?(TkTitledFrame) &amp;&amp; @panels[dom]['root'].parent == _frame 
-             ret_doms &lt;&lt; dom
-             frame_found = true
-         end
-      end
-    }    
-    
-    if !frame_found
-      cfrs = TkWinfo.children(_frame)
-      if cfrs &amp;&amp; cfrs.length == 1 &amp;&amp; cfrs[0].instance_of?(TkTitledFrame)
-        @wrappers.each{|name, ffw|
-          if ffw.hinner_frame.frame == cfrs[0].frame
-            ret_doms &lt;&lt; ffw.domain 
-          end
-        }
-      end
-    end
-    return ret_doms
-  end
-
-  def close_runtime_old(_domain)
-    splitted_adapter = find_splitted_frame(@panels[_domain]['root'])
-    splitted_adapter_frame = splitted_adapter.frame
-    vertical = splitted_adapter.instance_of?(AGTkVSplittedFrames)
-    
-    _row, _col = _domain.split('.')
-    
-    if @frames[_row.to_i][_col.to_i] == splitted_adapter.frame1
-      close_first = true
-    elsif @frames[_row.to_i][_col.to_i] == splitted_adapter.frame2
-      close_first = false
-    end
-    
-    return if close_first.nil?    
-    
-    #source_domains = domains_on_frame(splitted_adapter.frame1).concat(domains_on_frame(splitted_adapter.frame2))
-    #Arcadia.console(self,'msg'=&gt;&quot;domini coinvolti = #{source_domains.to_s}&quot;)
-    
-    @panels[_domain]['sons'].each{|name,ffw|
-      unregister_panel(ffw, false, false)
-    }
-    unbuild_titled_frame(_domain)
-    if close_first
-      #left_frame
-      other_ds = domains_on_frame(@panels[_domain]['splitted_frames'].frame2)
-      if other_ds.length == 1
-        source_domain = other_ds[0]
-      elsif other_ds.length &gt; 1
-        max = other_ds.length-1
-        j = 0
-        while j &lt;= max
-          if source_domain.nil?
-            source_domain = other_ds[j]
-          else
-            r,c = source_domain.split('.')
-            new_r,new_c = other_ds[j].split('.')
-            if new_r.to_i &lt; r.to_i || new_r.to_i == r.to_i &amp;&amp; new_c.to_i &lt; c.to_i
-              source_domain = other_ds[j]
-            end
-          end
-          j = j+1
-        end
-      else
-        if vertical
-          source_domain = domain_name(_row.to_i, _col.to_i+1)
-        else
-          source_domain = domain_name(_row.to_i+1, _col.to_i)
-        end
-      end
-      if vertical
-        ref_source_domain = domain_name(_row.to_i, _col.to_i+1)
-      else
-        ref_source_domain = domain_name(_row.to_i+1, _col.to_i)
-      end
-
-      destination_domain = _domain
-            
-      if @panels[source_domain]['splitted_frames'] != @panels[destination_domain]['splitted_frames']
-        if @panels[source_domain]['root_splitted_frames'] &amp;&amp; @panels[source_domain]['root_splitted_frames'] != @panels[destination_domain]['splitted_frames']
-          other_root_splitted_adapter = @panels[source_domain]['root_splitted_frames']
-        elsif @panels[source_domain]['splitted_frames']
-          other_root_splitted_adapter = @panels[source_domain]['splitted_frames']
-        end
-      end
-
-      if other_root_splitted_adapter
-        p &quot;primo quadrante&quot;
-        other_root_splitted_adapter.detach_frame
-        splitted_adapter.detach_frame
-        splitted_adapter.destroy
-        other_root_splitted_adapter.attach_frame(splitted_adapter_frame)
-        if source_domain == ref_source_domain
-          if vertical
-            rows = domains_on_splitter_rows(other_root_splitted_adapter)
-            rows.each{|r|
-              shift_left(r.to_i,_col.to_i)
-            }
-          else
-            cols = domains_on_splitter_cols(other_root_splitted_adapter)
-            cols.each{|c|
-              shift_top(_row.to_i,c.to_i)
-            }
-          end
-        else
-          @panels.delete(_domain)
-          @frames[_row.to_i][_col.to_i] = nil
-         # @domains[_row.to_i][_col.to_i] = nil
-#          ref_r,ref_c = ref_source_domain.split('.')
-#          real_r,real_c=source_domain.split('.')
-#          gap_r = ref_r.to_i - real_r.to_i
-#          gap_c = ref_c.to_i - real_c.to_i
-#          if gap_r != 0 &amp;&amp; gap_c == 0 # vertical
-#            doms = domains_on_splitter(other_root_splitted_adapter)
-#            doms.each{|d|
-#              r,c=d.split('.')
-#              cur_r = r.to_i+gap_r
-#              cur_domain = &quot;#{cur_r}.#{_col}&quot;
-#              if @panels[cur_domain] != nil
-#                shift_bottom(cur_r,_col.to_i)
-#              end
-#              @panels[cur_domain] = @panels[d]
-#              @panels[cur_domain]['root'].set_domain(cur_domain)
-#              @panels[cur_domain]['sons'].each{|name,ffw| ffw.domain=cur_domain}
-#              @frames[cur_r.to_i][_col.to_i] = @frames[r.to_i][c.to_i]
-#              @domains[cur_r.to_i][_col.to_i] = @domains[r.to_i][c.to_i]
-#              
-#              @panels.delete(d)
-#              @frames[r.to_i][c.to_i] = nil
-#              @domains[r.to_i][c.to_i] = nil
-#            }
-#          elsif gap_c != 0
-#          end
-        end
-        @panels.delete(source_domain)
-        if vertical
-          @frames[_row.to_i][_col.to_i+1] = nil
-         # @domains[_row.to_i][_col.to_i+1] = nil
-        else
-          @frames[_row.to_i+1][_col.to_i] = nil
-         # @domains[_row.to_i+1][_col.to_i] = nil
-        end
-      else
-        p &quot;secondo quadrante&quot;
-        source_save = Hash.new
-        source_save.update(@panels[source_domain]['sons']) if @panels[source_domain]
-        source_save.each{|name,ffw|
-          unregister_panel(ffw, false, false)
-        }
-        splitted_adapter.detach_frame
-        splitted_adapter.destroy
-        @panels[destination_domain]['root']=splitted_adapter_frame
-        @frames[_row.to_i][_col.to_i] = splitted_adapter_frame
-       # @domains[_row.to_i][_col.to_i] = destination_domain
-        build_titled_frame(destination_domain)
-        @panels.delete(source_domain)
-        if vertical
-          @frames[_row.to_i][_col.to_i+1] = nil
-         # @domains[_row.to_i][_col.to_i+1] = nil
-        else
-          @frames[_row.to_i+1][_col.to_i] = nil
-         # @domains[_row.to_i+1][_col.to_i] = nil
-        end
-        source_save.each{|name,ffw|
-          ffw.domain = destination_domain
-          register_panel(ffw, ffw.hinner_frame)
-        }
-        #-----
-        parent_splitted_adapter = find_splitted_frame(@panels[destination_domain]['root'])
-        if  parent_splitted_adapter
-          @panels[destination_domain]['splitted_frames']=parent_splitted_adapter
-        else
-          @panels[destination_domain]['splitted_frames']= nil
-        end
-        #-----
-        source_row,source_col = source_domain.split('.')
-#        shift_left(source_row.to_i,source_col.to_i)
-        if vertical
-          shift_left(source_row.to_i,source_col.to_i-1)
-        else
-          shift_top(source_row.to_i-1,source_col.to_i)
-        end
-      end
-    else  # CLOSE OTHER
-      # verifichiamo se la contro parte &#195;&#402;&#194;&#168; uno splitter_adapter
-      other_ds = domains_on_frame(@panels[_domain]['splitted_frames'].frame1)
-      if other_ds.length == 1
-        other_dom = other_ds[0]
-      else
-        if vertical
-          other_dom = domain_name(_row.to_i, _col.to_i-1)
-        else
-          other_dom = domain_name(_row.to_i-1, _col.to_i)
-        end
-      end
-      if @panels[_domain]['splitted_frames'] != @panels[other_dom]['splitted_frames']
-        if @panels[other_dom]['root_splitted_frames'] &amp;&amp; @panels[other_dom]['root_splitted_frames'] != @panels[_domain]['splitted_frames']
-          other_root_splitted_adapter = @panels[other_dom]['root_splitted_frames']
-        elsif @panels[other_dom]['splitted_frames']
-          other_root_splitted_adapter = @panels[other_dom]['splitted_frames']
-        end
-      end
-
-      if other_root_splitted_adapter
-        p &quot;terzo quadrante&quot;
-        other_root_splitted_adapter.detach_frame
-        splitted_adapter.detach_frame
-        splitted_adapter.destroy
-        other_root_splitted_adapter.attach_frame(splitted_adapter_frame)
-
-        @frames[_row.to_i][_col.to_i] = nil
-       # @domains[_row.to_i][_col.to_i] = nil
-        @panels.delete(_domain)
-      else
-        p &quot;quarto quadrante&quot;
-        source_save = Hash.new
-        source_save.update(@panels[other_dom]['sons'])
-        source_save.each{|name,ffw|
-          unregister_panel(ffw, false, false)
-        }
-        splitted_adapter.detach_frame
-        splitted_adapter.destroy
-        @panels[other_dom]['root']=splitted_adapter_frame 
-
-        @frames[_row.to_i][_col.to_i] = nil
-       # @domains[_row.to_i][_col.to_i] = nil
-        build_titled_frame(other_dom)
-        @panels.delete(_domain)
-  
-        source_save.each{|name,ffw|
-          ffw.domain = other_dom
-          register_panel(ffw, ffw.hinner_frame)
-        }
-        #-----
-        parent_splitted_adapter = find_splitted_frame(@panels[other_dom]['root'])
-        if  parent_splitted_adapter
-          @panels[other_dom]['splitted_frames']=parent_splitted_adapter
-        else
-          @panels[other_dom]['splitted_frames']= nil
-        end
-        other_row,other_col = other_dom.split('.')
-        @frames[other_row.to_i][other_col.to_i] = splitted_adapter_frame
-       # @domains[other_row.to_i][other_col.to_i] = other_dom
-#        if vertical
-#          @frames[_row.to_i][_col.to_i-1] = splitted_adapter_frame
-#         # @domains[_row.to_i][_col.to_i-1] = other_dom
-#        else
-#          @frames[_row.to_i-1][_col.to_i] = splitted_adapter_frame
-#         # @domains[_row.to_i-1][_col.to_i] = other_dom
-#        end
-      end
-
-      if vertical
-        shift_left(_row.to_i,_col.to_i)
-      else
-        shift_top(_row.to_i,_col.to_i)
-      end
-    end 
-    build_invert_menu(true)
-  end
-
-  def find_splitted_frame(_start_frame)
-    splitted_frame = _start_frame
-    while splitted_frame != nil &amp;&amp; !splitted_frame.kind_of?(AGTkSplittedFrames)
-      splitted_frame = TkWinfo.parent(splitted_frame)
-    end
-    splitted_frame
-  end
-#--
-  def close_runtime(_domain)
-    splitted_adapter = find_splitted_frame(@panels[_domain]['root'])
-    splitted_adapter_frame = splitted_adapter.frame
-    vertical = splitted_adapter.instance_of?(AGTkVSplittedFrames)
-    _row, _col = _domain.split('.')
-    if @frames[_row.to_i][_col.to_i] == splitted_adapter.frame1
-      other_ds = domains_on_frame(@panels[_domain]['splitted_frames'].frame2)
-    elsif @frames[_row.to_i][_col.to_i] == splitted_adapter.frame2
-      other_ds = domains_on_frame(@panels[_domain]['splitted_frames'].frame1)
-    end
-
-    return if other_ds.nil?    
-
-
-    if other_ds.length == 1
-      other_domain = other_ds[0]
-    elsif other_ds.length &gt; 1
-      max = other_ds.length-1
-      j = 0
-      while j &lt;= max
-        if other_domain.nil?
-          other_domain = other_ds[j]
-        else
-          r,c = other_domain.split('.')
-          new_r,new_c = other_ds[j].split('.')
-          if new_r.to_i &lt; r.to_i || new_r.to_i == r.to_i &amp;&amp; new_c.to_i &lt; c.to_i
-            other_domain = other_ds[j]
-          end
-        end
-        j = j+1
-      end
-    end
-    _other_row, _other_col = other_domain.split('.')
-    @panels[_domain]['sons'].each{|name,ffw|
-      unregister_panel(ffw, false, false)
-    }
-    unbuild_titled_frame(_domain)
-
-    if @panels[other_domain]['splitted_frames'] != @panels[_domain]['splitted_frames']
-      if @panels[other_domain]['root_splitted_frames'].frame == @panels[_domain]['splitted_frames'].frame1 || @panels[other_domain]['root_splitted_frames'].frame == @panels[_domain]['splitted_frames'].frame2
-        other_root_splitted_adapter = @panels[other_domain]['root_splitted_frames']
-      elsif @panels[other_domain]['splitted_frames']
-        other_root_splitted_adapter = @panels[other_domain]['splitted_frames']
-      end
-    end
-
-    @panels.delete(_domain)
-    @frames[_row.to_i][_col.to_i] = nil
-   # @domains[_row.to_i][_col.to_i] = nil
-
-    if other_root_splitted_adapter
-      if other_root_splitted_adapter != @panels[other_domain]['splitted_frames']
-        other_ds.each{|d|
-          if @panels[d]['root_splitted_frames'] == splitted_adapter
-            @panels[d]['root_splitted_frames']=other_root_splitted_adapter
-          end
-        }
-      end
-      other_root_splitted_adapter.detach_frame
-      splitted_adapter.detach_frame
-      @splitters.delete(splitted_adapter)
-      splitted_adapter.destroy
-      other_root_splitted_adapter.attach_frame(splitted_adapter_frame)
-    else
-      other_source_save = Hash.new
-      other_source_save.update(@panels[other_domain]['sons']) if @panels[other_domain]
-      other_source_save.each{|name,ffw|
-        unregister_panel(ffw, false, false)
-      }
-      splitted_adapter.detach_frame
-      splitted_adapter.destroy
-      @panels[other_domain]['root']=splitted_adapter_frame
-      @frames[_other_row.to_i][_other_col.to_i] = splitted_adapter_frame
-      build_titled_frame(other_domain)
-      other_source_save.each{|name,ffw|
-        ffw.domain = other_domain
-        register_panel(ffw, ffw.hinner_frame)
-      }
-      parent_splitted_adapter = find_splitted_frame(@panels[other_domain]['root'])
-      if  parent_splitted_adapter
-        @panels[other_domain]['splitted_frames']=parent_splitted_adapter
-      else
-        @panels[other_domain]['splitted_frames']= nil
-      end
-    end
-    build_invert_menu(true)
-  end
-
-#--
-  
-  def unbuild_titled_frame(domain)
-    if @panels[domain]
-      parent = @panels[domain]['root'].parent
-      @panels[domain]['root'].destroy
-      @panels[domain]['root']=parent
-    end
-  end
-  
-  def add_commons_menu_items(_domain, _menu)
-      _menu.insert('end', :separator)
-      _menu.insert('end',:command,
-          :label=&gt;&quot;add column&quot;,
-          :image=&gt;TkPhotoImage.new('dat'=&gt;ADD_GIF),
-          :compound=&gt;'left',
-          :command=&gt;proc{add_cols_runtime(_domain)},
-          :hidemargin =&gt; true
-      )
-      _menu.insert('end',:command,
-          :label=&gt;&quot;add row&quot;,
-          :image=&gt;TkPhotoImage.new('dat'=&gt;ADD_GIF),
-          :compound=&gt;'left',
-          :command=&gt;proc{add_rows_runtime(_domain)},
-          :hidemargin =&gt; true
-      )
-      if @panels.keys.length &gt; 2
-        _menu.insert('end',:command,
-            :label=&gt;&quot;close&quot;,
-            :image=&gt;TkPhotoImage.new('dat'=&gt;CLOSE_FRAME_GIF),
-            :compound=&gt;'left',
-            :command=&gt;proc{close_runtime(_domain)},
-            :hidemargin =&gt; true
-        )
-      end
-  end
-  
-  def build_titled_frame(domain)
-    if @panels[domain]
-      tframe = TkTitledFrame.new(@panels[domain]['root']).place('x'=&gt;0, 'y'=&gt;0,'relheight'=&gt;1, 'relwidth'=&gt;1)
-      mb = tframe.add_menu_button('ext')
-      # add commons item
-      menu = mb.cget('menu')
-      add_commons_menu_items(domain, menu)
-      @panels[domain]['root']= tframe
-      #-----------------------------------
-#      class &lt;&lt; tframe
-#        def set_domain(_domain)
-#          if @label_domain.nil?
-#            @label_domail = TkLabel.new(self.frame, 'text'=&gt;_domain).pack
-#          else
-#            @label_domain.configure('text'=&gt;_domain)
-#          end
-#        end
-#      end
-#      tframe.set_domain(domain)
-      #-----------------------------------
-    end
-  end
-  
-  def domains
-    ret = Array.new
-    @panels.keys.each{|dom|
-        if dom != '_domain_root_' &amp;&amp; @panels[dom] &amp;&amp; @panels[dom]['root']
-          ret &lt;&lt; dom
-        end
-    }
-    ret
-  end
-  
-  def add_headers
-    @panels.keys.each{|dom|
-        if dom != '_domain_root_' &amp;&amp; @panels[dom] &amp;&amp; @panels[dom]['root']
-          build_titled_frame(dom)
-        end
-    }
-
-#    @domains.each{|row|
-#      row.each{|domain|
-#        build_titled_frame(domain)
-#      }
-#    }
-    @headed = true
-  end
-
-  def headed?
-    @headed
-  end
-
-  def autotab?
-    @autotab
-  end
-
-  def registed?(_domain_name, _name)
-    @panels[_domain_name]['sons'][_name] != nil
-  end
-
-  def change_domain(_target_domain, _source_name)
-    tt1= @panels[_target_domain]['root'].top_text
-    source_domain = @wrappers[_source_name].domain
-    source_has_domain = !source_domain.nil?
-    tt2= @panels[source_domain]['root'].top_text if source_has_domain
-    if @arcadia.conf('layout.exchange_panel_if_no_tabbed')=='true' &amp;&amp; source_has_domain &amp;&amp; @panels[source_domain]['sons'].length ==1 &amp;&amp; @panels[_target_domain]['sons'].length &gt; 0
-      # change ------
-      ffw1 = raised_fixed_frame(_target_domain)
-      ffw2 = @panels[source_domain]['sons'].values[0]
-      unregister_panel(ffw1,false,false) if ffw1
-      unregister_panel(ffw2,false,false)
-      ffw1.domain = source_domain if ffw1
-      ffw2.domain = _target_domain
-      register_panel(ffw1, ffw1.hinner_frame) if ffw1
-      register_panel(ffw2, ffw2.hinner_frame)
-      @panels[_target_domain]['root'].top_text(tt2)
-      @panels[source_domain]['root'].top_text(tt1)
-    elsif source_has_domain &amp;&amp; @panels[source_domain]['sons'].length &gt;= 1
-      ffw2 = @panels[source_domain]['sons'][_source_name]
-      unregister_panel(ffw2, false, false)
-      ffw2.domain = _target_domain
-      register_panel(ffw2, ffw2.hinner_frame)
-      @panels[_target_domain]['root'].top_text(tt2)
-      @panels[source_domain]['root'].top_text('')
-    elsif !source_has_domain
-      ffw2 = @wrappers[_source_name]
-      ffw2.domain = _target_domain
-      register_panel(ffw2, ffw2.hinner_frame)
-      @panels[_target_domain]['root'].top_text('')
-    end
-    # refresh -----
-    build_invert_menu
-  end
-
-
-#  def change_domain_old(_dom1, _dom2, _name2)
-#    tt1= @panels[_dom1]['root'].top_text
-#    tt2= @panels[_dom2]['root'].top_text
-#    if  @panels[_dom2]['sons'].length ==1 &amp;&amp; @panels[_dom1]['sons'].length &gt; 0
-#      # change ------
-#      ffw1 = raised_fixed_frame(_dom1)
-#      ffw2 = @panels[_dom2]['sons'].values[0]
-#      unregister_panel(ffw1,false,false) if ffw1
-#      unregister_panel(ffw2,false,false)
-#      ffw1.domain = _dom2 if ffw1
-#      ffw2.domain = _dom1
-#      register_panel(ffw1, ffw1.hinner_frame) if ffw1
-#      register_panel(ffw2, ffw2.hinner_frame)
-#      @panels[_dom1]['root'].top_text(tt2)
-#      @panels[_dom2]['root'].top_text(tt1)
-#    elsif @panels[_dom2]['sons'].length &gt; 1
-#      ffw2 = @panels[_dom2]['sons'][_name2]
-#      unregister_panel(ffw2, false, false)
-#      ffw2.domain = _dom1
-#      register_panel(ffw2, ffw2.hinner_frame)
-#      @panels[_dom1]['root'].top_text(tt2)
-#      @panels[_dom2]['root'].top_text('')
-#    end
-#    # refresh -----
-#    build_invert_menu
-#  end
-
-  def process_frame(_ffw)
-  #def process_frame(_domain_name, _frame_name)
-    #domain_root = @panels[_domain_name]['sons'][_frame_name]
-    @panels.keys.each{|dom|
-      if  dom != '_domain_root_' &amp;&amp; dom != _ffw.domain &amp;&amp; @panels[dom] &amp;&amp; @panels[dom]['root']
-        titledFrame = @panels[dom]['root']
-        if titledFrame.instance_of?(TkTitledFrame)
-          menu = @panels[dom]['root'].menu_button('ext').cget('menu')
-          menu.insert('0',:command,
-                :label=&gt;_ffw.title,
-                :image=&gt;TkPhotoImage.new('dat'=&gt;ARROW_LEFT_GIF),
-                :compound=&gt;'left',
-                :command=&gt;proc{change_domain(dom, _ffw.name)},
-                :hidemargin =&gt; true
-          )
-        end
-      end
-    }
-  end
-
-  
-  def build_invert_menu(refresh_commons_items=false)
-    @panels.keys.each{|dom|
-      if dom != '_domain_root_' &amp;&amp; @panels[dom] &amp;&amp; @panels[dom]['root']
-        titledFrame = @panels[dom]['root']
-        if titledFrame.instance_of?(TkTitledFrame)
-          menu = titledFrame.menu_button('ext').cget('menu')
-          if refresh_commons_items
-             @panels[dom]['root'].menu_button('ext').cget('menu').delete('0','end')
-             add_commons_menu_items(dom, menu)
-          else
-            if @panels.keys.length &gt; 2
-              i=menu.index('end').to_i-4
-            else
-              i=menu.index('end').to_i-3
-            end
-            if i &gt;= 0
-              end_index = i.to_s
-              @panels[dom]['root'].menu_button('ext').cget('menu').delete('0',end_index)
-            end
-          end
-        end
-      end
-    }
-    
-    @wrappers.each{|name,ffw|
-      process_frame(ffw) #if ffw.domain
-    }
-  end
-  
-#  def register_panel_old(_domain_name, _name, _title)
-#    p = @panels[_domain_name]
-#    if p!=nil
-#      num = p['sons'].length
-#      if @headed
-#        p['root'].title(_title)
-#        if !p['root'].frame.instance_of?(TkFrameAdapter)
-#          wrapper = TkFrameAdapter.new(self.root, Arcadia.style('frame'))
-#          wrapper.attach_frame(p['root'].frame)
-#          p['root'].frame=wrapper
-#        end
-#        root_frame = p['root'].frame
-#        process_register_panel(_domain_name)
-#      else
-#        root_frame = p['root']
-#      end
-#      if (num == 0 &amp;&amp; @autotab)
-#        api = ArcadiaPanelInfo.new(_name,_title,nil)
-#        api.frame = TkFrame.new(root_frame, Arcadia.style('panel')).place('x'=&gt;0, 'y'=&gt;0, 'relwidth'=&gt;1, 'relheight'=&gt;1)
-#        p['sons'][_name] = api
-#        return api.frame
-#      else
-#        if num == 1 &amp;&amp; @autotab &amp;&amp;  p['notebook'] == nil
-#          p['notebook'] = Tk::BWidget::NoteBook.new(root_frame, Arcadia.style('tabpanel')){
-#            tabbevelsize 0
-#            internalborderwidth 0
-#            pack('fill'=&gt;'both', :padx=&gt;0, :pady=&gt;0, :expand =&gt; 'yes')
-#          }
-#          api = p['sons'].values[0]
-#          api_tab_frame = p['notebook'].insert('end',
-#            api.name,
-#            'text'=&gt;api.title,
-#            'raisecmd'=&gt;proc{
-#  					    p['root'].title(api.title)
-#  					    p['root'].top_text('')            
-#               changed
-#              notify_observers('RAISE', api.name)
-#            }
-#          )
-#          api.frame.place('in'=&gt;api_tab_frame, 'x'=&gt;0, 'y'=&gt;0, 'relwidth'=&gt;1, 'relheight'=&gt;1)
-#          api.frame.raise
-#        elsif (num==0 &amp;&amp; !@autotab)
-#          p['notebook'] = Tk::BWidget::NoteBook.new(root_frame){
-#            tabbevelsize 0
-#            internalborderwidth 0
-#            pack('fill'=&gt;'both', :padx=&gt;0, :pady=&gt;0, :expand =&gt; 'yes')
-#          }
-#        end
-#        _panel = p['notebook'].insert('end',_name , 
-#        		'text'=&gt;_title, 
-#          'raisecmd'=&gt;proc{
-#					  p['root'].title(_title)            
-#            changed
-#            notify_observers('RAISE', _name)
-#          }
-#        		)
-#        p['sons'][_name] = ArcadiaPanelInfo.new(_name,_title,_panel)
-#        p['notebook'].raise(_name)
-#        return _panel
-#      end
-#    else
-#      Arcadia.dialog(self, 
-#        'type'=&gt;'ok',
-#        'msg'=&gt;&quot;domain #{_domain_name} do not exist\nfor '#{_title}'!&quot;,
-#        'level'=&gt;'warning' 
-#      )
-#      float_frame = new_float_frame
-#      float_frame.title(_title)
-#      return float_frame.frame
-#    end
-#  end
-
-  def register_panel(_ffw, _adapter=nil)
-    _domain_name = _ffw.domain
-    _name = _ffw.name
-    _title = _ffw.title
-    pan = @panels[_domain_name]
-    @wrappers[_name]=_ffw
-    if pan!=nil
-      num = pan['sons'].length
-      if @headed
-        pan['root'].title(_title)
-        if !pan['root'].frame.instance_of?(TkFrameAdapter) &amp;&amp; num==0
-          if _adapter
-            adapter = _adapter
-          else
-            adapter = TkFrameAdapter.new(self.root, Arcadia.style('frame'))
-          end
-          adapter.attach_frame(pan['root'].frame)
-          adapter.raise
-          #@wrappers[_name]=wrapper
-        end
-        root_frame = pan['root'].frame
-      else
-        root_frame = pan['root']
-      end
-      if (num == 0 &amp;&amp; @autotab)
-        #api = ArcadiaPanelInfo.new(_name,_title,wrapper,_ffw)
-        pan['sons'][_name] = _ffw
-        process_frame(_ffw)
-        return adapter
-      else
-        if num == 1 &amp;&amp; @autotab &amp;&amp;  pan['notebook'] == nil
-          pan['notebook'] = Tk::BWidget::NoteBook.new(root_frame, Arcadia.style('titletabpanel')){
-            tabbevelsize 0
-            internalborderwidth 0
-            pack('fill'=&gt;'both', :padx=&gt;0, :pady=&gt;0, :expand =&gt; 'yes')
-          }
-          api = pan['sons'].values[0]
-          api_tab_frame = pan['notebook'].insert('end',
-            api.name,
-            'text'=&gt;api.title,
-            'raisecmd'=&gt;proc{
-  					    pan['root'].title(api.title)
-  					    pan['root'].top_text('') 
-         	     Arcadia.process_event(LayoutRaisingFrameEvent.new(self,'extension_name'=&gt;_ffw.extension, 'frame_name'=&gt;_ffw.name))
-
-#               changed
-#               notify_observers('RAISE', api.name)
-            }
-          )
-          adapter = api.hinner_frame
-          adapter.detach_frame
-          adapter.attach_frame(api_tab_frame)
-          api.hinner_frame.raise
-        elsif (num==0 &amp;&amp; !@autotab)
-          pan['notebook'] = Tk::BWidget::NoteBook.new(root_frame, Arcadia.style('titletabpanel')){
-            tabbevelsize 0
-            internalborderwidth 0
-            pack('fill'=&gt;'both', :padx=&gt;0, :pady=&gt;0, :expand =&gt; 'yes')
-          }
-        end
-        _panel = pan['notebook'].insert('end',_name , 
-        		'text'=&gt;_title, 
-          'raisecmd'=&gt;proc{
-					  pan['root'].title(_title)            
-      	     Arcadia.process_event(LayoutRaisingFrameEvent.new(self,'extension_name'=&gt;_ffw.extension, 'frame_name'=&gt;_ffw.name))
-#            changed
-#            notify_observers('RAISE', _name)
-          }
-        		)
-        if _adapter
-          adapter = _adapter
-        else
-          adapter = TkFrameAdapter.new(self.root, Arcadia.style('frame'))
-        end
-        adapter.attach_frame(_panel)
-        adapter.raise
-        _panel=adapter
-        #@wrappers[_name]=wrapper
-        #p['sons'][_name] = ArcadiaPanelInfo.new(_name,_title,_panel,_ffw)
-        pan['sons'][_name] = _ffw
-        pan['notebook'].raise(_name)
-        process_frame(_ffw)
-        return _panel
-      end
-    else
-      _ffw.domain = nil
-      process_frame(_ffw)
-      return TkFrameAdapter.new(self.root, Arcadia.style('frame'))
-      
-#
-#      Arcadia.dialog(self, 
-#        'type'=&gt;'ok',
-#        'msg'=&gt;&quot;domain #{_domain_name} do not exist\nfor '#{_title}'!&quot;,
-#        'level'=&gt;'warning' 
-#      )
-#      float_frame = new_float_frame
-#      float_frame.title(_title)
-#      return float_frame.frame
-    end
-  end
-
-
-  def unregister_panel(_ffw, delete_wrapper=true, refresh_menu=true)
-    #p &quot;unregister #{_name} ------&gt; 1&quot;
-    _domain_name = _ffw.domain
-    _name = _ffw.name
-    @panels[_domain_name]['sons'][_name].hinner_frame.detach_frame
-    if delete_wrapper
-      @wrappers.delete(_name).hinner_frame.destroy 
-    else
-      @wrappers[_name].domain=nil
-    end
-    @panels[_domain_name]['sons'].delete(_name)
-    #p &quot;unregister #{_name} ------&gt; 2&quot;
-    if @panels[_domain_name]['sons'].length == 1
-      w = @panels[_domain_name]['sons'].values[0].hinner_frame
-      t = @panels[_domain_name]['sons'].values[0].title
-      w.detach_frame
-      w.attach_frame(@panels[_domain_name]['root'].frame)
-      @panels[_domain_name]['root'].title(t)
-      @panels[_domain_name]['notebook'].destroy
-      @panels[_domain_name]['notebook']=nil
-    elsif @panels[_domain_name]['sons'].length &gt; 1
-      @panels[_domain_name]['notebook'].delete(_name) if @panels[_domain_name]['notebook'].index(_name) &gt; 0
-      #p &quot;unregister #{_name} ------&gt; 3&quot;
-      new_raise_key = @panels[_domain_name]['sons'].keys[@panels[_domain_name]['sons'].length-1]
-      #p &quot;unregister #{_name} ------&gt; 4&quot;
-      @panels[_domain_name]['notebook'].raise(new_raise_key)
-      #p &quot;unregister #{_name} ------&gt; 5&quot;
-    elsif @panels[_domain_name]['sons'].length == 0
-      @panels[_domain_name]['root'].title('')
-    end
-    build_invert_menu if refresh_menu
-  end
-
-  def view_panel
-  end
-
-  def hide_panel
-  end
-
-  def [](_row, _col)
-    @frames[_row][_col]
-  end
-  
-  def frame(_domain_name, _name)
-    @panels[_domain_name]['sons'][_name].frame
-  end
-
-#  def domain_for_frame(_domain_name, _name)
-#    domain(@panels[_domain_name]['sons'][_name].domain)
-#  end
-
-  def domain(_domain_name)
-    @panels[_domain_name]
-  end
-  
-  def domain_root_frame(_domain_name)
-    @panels[_domain_name]['root'].frame
-  end
-  
-  def new_float_frame(_args=nil)
-    if _args.nil?
-     _args = {'x'=&gt;10, 'y'=&gt;10, 'width'=&gt;100, 'height'=&gt;100}
-    end
-    _frame =  TkFloatTitledFrame.new(root)
-    _frame.on_close=proc{_frame.hide}
-    _frame.place(_args)
-    return _frame
-  end
-  
-  def dump_splitter(_splitter)
-    ret = ''
-    if  _splitter.instance_of?(AGTkVSplittedFrames)
-      w = TkWinfo.width(_splitter.frame1) 
-      ret = &quot;c#{w}&quot;
-    elsif _splitter.instance_of?(AGTkOSplittedFrames)
-      h = TkWinfo.height(_splitter.frame1) 
-      ret = &quot;r#{h}&quot;
-    end
-    ret
-  end
-  
-  def splitter_frame_on_frame(_frame)
-    ret=nil
-    @splitters.each{|sp|
-       if sp.frame == _frame
-         ret = sp
-         break 
-       end
-    }
-    ret
-  end
-  
-  def get_hinner_frame(_frame)
-    ret = _frame
-#    child = TkWinfo.children(_frame)[0]
-    TkWinfo.children(_frame).each{|child|
-      if child.instance_of?(TkTitledFrame)
-        ret = child.frame
-        break
-      end
-    }
-#    if child.instance_of?(TkTitledFrame)
-#      ret = child.frame
-#    end
-    ret
-  end
-  
-  def shift_domain_column(_r,_c,_dom)
-    Hash.new.update(_dom).each{|k,d|
-      dr,dc=d.split('.')
-      if dc.to_i &gt;= _c &amp;&amp; dr.to_i == _r 
-        #shift_domain_column(_r,dc.to_i+1,_dom)
-        p &quot;== #{d} --&gt; #{domain_name(_r,dc.to_i+1)}&quot;
-        _dom[k]= domain_name(_r,dc.to_i+1)
-      end
-    }
-  end
-
-  def shift_domain_row(_r,_c,_dom)
-    Hash.new.update(_dom).each{|k,d|
-      dr,dc=d.split('.')
-      if dr.to_i &gt;= _r &amp;&amp; dc.to_i == _c 
-         #shift_domain_row(dr.to_i+1,_c,_dom)
-        p &quot;shift_domain_row == #{d} --&gt; #{domain_name(dr.to_i+1,_c)}&quot;
-        _dom[k]=domain_name(dr.to_i+1,_c)
-      end
-    }
-  end
-
-  def gap_domain_column(_r,_c,_dom)
-    ret = _c
-    Hash.new.update(_dom).each{|k,d|
-      dr,dc=d.split('.')
-      if dc.to_i == _c &amp;&amp; dr.to_i == _r 
-        ret = gap_domain_column(_r,dc.to_i+1,_dom)
-      end
-    }
-    ret
-  end
-
-  def gap_domain_row(_r,_c,_dom)
-    ret = _r
-    Hash.new.update(_dom).each{|k,d|
-      dr,dc=d.split('.')
-      if dr.to_i == _r &amp;&amp; dc.to_i == _c 
-         ret = gap_domain_row(dr.to_i+1,_c,_dom)
-      end
-    }
-    ret
-  end
-
-  
-  def dump_geometry(_r=0,_c=0,_frame=root)
-    spl = Array.new
-    dom = Hash.new
-    ret = [nil,nil,nil,nil]
-    sp = splitter_frame_on_frame(_frame)
-    if sp
-      spl &lt;&lt; &quot;#{domain_name(_r,_c)}#{dump_splitter(sp)}&quot;
-      dom[get_hinner_frame(sp.frame1)]=domain_name(_r,_c)
-      sspl,ddom,rr,cc = dump_geometry(_r, _c, sp.frame1)
-      spl.concat(sspl)
-      dom.update(ddom)
-      if sp.instance_of?(AGTkVSplittedFrames)
-        _c=cc+1
-        _c=gap_domain_column(_r,_c,dom)
-      else
-        _r=rr+1
-        _r=gap_domain_row(_r,_c,dom)
-      end
-      dom[get_hinner_frame(sp.frame2)]=domain_name(_r,_c)
-      sspl,ddom,rr,cc = dump_geometry(_r, _c, sp.frame2)
-      spl.concat(sspl)
-      dom.update(ddom)
-    elsif _frame==root
-      dom[get_hinner_frame(root)]=domain_name(_r,_c) 
-    end
-    ret[0]=spl
-    ret[1]=dom
-    ret[2]=_r
-    ret[3]=_c
-    ret
-  end
+#
+#   a-core.rb - Arcadia Ruby ide
+#   by Antonio Galeone &lt;antonio-galeone@rubyforge.org&gt;
+#
+#   &amp;require_dir_ref=..
+#   &amp;require_omissis=conf/arcadia.init
+#   &amp;require_omissis=tk
+#   &amp;require_omissis=tk/label
+#   &amp;require_omissis=tk/toplevel
+
+
+
+require &quot;conf/arcadia.res&quot;
+require 'tkextlib/bwidget'
+require &quot;lib/a-tkcommons&quot;
+require &quot;lib/a-contracts&quot;
+require &quot;observer&quot;
+
+class Arcadia &lt; TkApplication
+  include Observable
+  attr_reader :layout
+  def initialize
+    super(
+      ApplicationParams.new(
+        'arcadia',
+        '0.8.0',
+        'conf/arcadia.conf',
+        'conf/arcadia.pers'
+      )
+    )
+    load_config
+    set_sysdefaultproperty
+    ArcadiaDialogManager.new(self)
+    ArcadiaActionDispatcher.new(self)
+    ArcadiaGemsWizard.new(self)
+    #self.load_local_config(false)
+    ObjectSpace.define_finalizer($arcadia, self.class.method(:finalize).to_proc)
+    publish('action.on_exit', proc{do_exit})
+    #_title = &quot;Arcadia Ruby ide :: [Platform = #{RUBY_PLATFORM}] [Ruby version = #{RUBY_VERSION}] [TclTk version = #{tcltk_info.level}]&quot;
+    _title = &quot;Arcadia ide &quot;
+    @root = TkRoot.new(
+      'background'=&gt; self['conf']['background']
+      ){
+      title _title
+      withdraw
+      protocol( &quot;WM_DELETE_WINDOW&quot;, $arcadia['action.on_exit'])
+      iconphoto(TkPhotoImage.new('dat'=&gt;ARCADIA_RING_GIF))
+    }
+    
+    @on_event = Hash.new
+
+    @main_menu_bar = TkMenubar.new(
+      'background'=&gt; self['conf']['background']
+    ).pack('fill'=&gt;'x')
+    @mf_root = Tk::BWidget::MainFrame.new(@root,
+     'background'=&gt; self['conf']['background']
+      ){
+      menu @main_menu_bar
+    }.pack(
+      'anchor'=&gt; 'center',
+      'fill'=&gt; 'both',
+      'expand'=&gt; 1
+    )
+    #.place('x'=&gt;0,'y'=&gt;0,'relwidth'=&gt;1,'relheight'=&gt;1)
+    @mf_root.show_statusbar('none')
+    #@toolbar = @mf_root.add_toolbar
+    @main_toolbar = ArcadiaMainToolbar.new(self, @mf_root.add_toolbar)
+    @is_toolbar_show=self['conf']['user_toolbar_show']=='yes'
+    @mf_root.show_toolbar(0,@is_toolbar_show)
+    @use_splash = self['conf']['splash.show']=='yes'
+    @splash = ArcadiaAboutSplash.new if @use_splash
+    @splash.set_progress(50) if @splash
+    @splash.deiconify if @splash
+    Tk.update
+    @splash.next_step('..prepare')  if @splash
+    prepare
+    @splash.last_step('..load finish')  if @splash
+    start_width = (TkWinfo.screenwidth(@root)-4)
+    start_height = (TkWinfo.screenheight(@root)-20)
+    if RUBY_PLATFORM =~ /mswin|mingw/ # 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'
+    @root.deiconify
+    @root.raise
+    @root.focus(true)
+    @root.geometry(geometry)
+    Tk.update_idletasks
+    #sleep(1)
+    @splash.destroy  if @splash
+    if @first_run
+      Arcadia.process_event(OpenBufferEvent.new(self,'file'=&gt;'README'))
+    elsif ARGV.length &gt; 0
+      ARGV.each{|_f|
+        if  $pwd != File.dirname(__FILE__) &amp;&amp; !File.exist?(_f)
+          _f = &quot;#{$pwd}/#{_f}&quot;
+        end
+        Arcadia.process_event(OpenBufferEvent.new(self,'file'=&gt;_f)) if File.exist?(_f)
+      }
+    end
+    Arcadia.attach_listener(self, QuitEvent)
+    Arcadia.persistent(&quot;version&quot;, self['applicationParams'].version)
+  end
+
+  def on_quit(_event)
+    self.do_exit
+  end
+  
+  def register(_ext)
+    @exts_i &lt;&lt; _ext
+  end
+  
+  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
+  
+  
+  def Arcadia.finalize(id)
+    puts &quot;\nArcadia #{id} dying at #{Time.new}&quot;
+  end
+	
+  def ext_active?(_name)
+	 return (self['conf'][_name+'.active'] != nil &amp;&amp; self['conf'][_name+'.active']=='yes')||
+       	  (self['conf'][_name+'.active'] == nil)
+  end
+	
+  def load_exts_conf
+  		@exts = Array.new
+  		@exts_i = Array.new
+  		dirs = Array.new
+  		files = Dir['ext/*'].concat(Dir[ENV[&quot;HOME&quot;]+'/.arcadia/ext/*']).sort
+  		files.each{|f|
+  			 dirs &lt;&lt; f if File.stat(f).directory? &amp;&amp; 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 &gt; 1
+             new_key = var_plat[0] + ':' + name + '.' + var_plat[1]
+           else
+             new_key = name+'.'+key
+           end	
+       	   conf_hash2[new_key]= value
+       	 }
+       @exts &lt;&lt; name	 	
+    		 self['conf'].update(conf_hash2)	
+    		 self['origin_conf'].update(conf_hash2)	
+  		}
+  end
+
+  def gem_available?(_gem)
+      if Gem.respond_to?(:available?)
+          return Gem.available?(_gem)
+      else
+          return !Gem.source_index.find_name(_gem).empty?
+      end
+  end
+
+  def check_gems_dependences(_ext)
+    ret = true
+    gems_property = self['conf'][&quot;#{_ext}.gems&quot;]
+    if gems_property
+      gems = gems_property.split(',').collect{| g | g.strip }
+      if gems &amp;&amp; gems.length &gt; 0
+        gems.each{|gem|
+          # consider gem only if it is not installed
+          if !gem_available?(gem)
+            repository_property =  self['conf'][&quot;#{_ext}.gems.#{gem}.repository&quot;]
+            args = Hash.new
+            args['extension_name']=_ext
+            args['gem_name']=gem
+            args['gem_repository']=repository_property if repository_property
+            _event = Arcadia.process_event(NeedRubyGemWizardEvent.new(self, args))
+            if _event &amp;&amp; _event.results
+              ret = ret &amp;&amp; _event.results[0].installed
+            end
+            break if !ret
+          end
+        } 
+      end 
+    end 
+    ret
+  end
+
+  def do_build
+    # create extensions
+    Array.new.concat(@exts).each{|extension|
+      if extension &amp;&amp; ext_active?(extension)
+        @splash.next_step('... creating '+extension)  if @splash
+        # before creating extension check gems dependences
+        gems_installed = check_gems_dependences(extension)
+        if !gems_installed || !ext_create(extension)
+          @exts.delete(extension)
+        end
+      end
+    }
+    begin
+      _build_event = Arcadia.process_event(BuildEvent.new(self))
+    rescue Exception
+      ret = false
+      msg = &quot;During build event processing(#{$!.class.to_s}) : #{$!} at : #{$@.to_s}&quot;
+      ans = Tk.messageBox('icon' =&gt; 'error', 'type' =&gt; 'abortretryignore',
+      'title' =&gt; &quot;(Arcadia) Build face&quot;, 'parent' =&gt; @root,
+      'message' =&gt; msg)
+      if  ans == 'abort'
+        raise
+        exit
+      elsif ans == 'retry'
+        retry
+      else
+        Tk.update
+      end
+    end
+  end
+  
+  def load_maximised
+    lm = self['conf']['layout.maximized']
+    if lm    
+      ext,index=lm.split(',')
+      maxed = false
+      if ext &amp;&amp; index
+        ext = ext.strip
+        i=index.strip.to_i
+        @exts_i.each{|e|
+          if e.conf('name')==ext &amp;&amp; !maxed
+            p &quot;maximizzo #{ext}&quot;
+            e.maximize(i)
+            maxed=true
+            break
+          end
+        }    
+      end
+    end
+  end
+
+  def ext_create(_extension)
+    ret = true
+    begin
+      source = self['conf'][_extension+'.require']
+      class_name = self['conf'][_extension+'.class']
+      if source.strip.length &gt; 0
+	      require source 
+      end
+      if class_name.strip.length &gt; 0
+        publish(_extension, eval(class_name).new(self, _extension))
+      end
+    rescue Exception,LoadError
+      ret = false
+      msg = &quot;Loading \&quot;#{_extension}\&quot; (#{$!.class.to_s}) : #{$!} at : #{$@.to_s}&quot;
+      ans = Tk.messageBox('icon' =&gt; 'error', 'type' =&gt; 'abortretryignore',
+      'title' =&gt; &quot;(Arcadia) Extensions '#{_extension}'&quot;, 'parent' =&gt; @root,
+      'message' =&gt; msg)
+      if  ans == 'abort'
+        raise
+        exit
+      elsif ans == 'retry'
+        retry
+      else
+        Tk.update
+      end
+    end
+    ret
+  end
+
+  def ext_method(_extension, _method)
+    begin
+      self[_extension].send(_method)
+    rescue Exception
+      msg = _method.to_s+' &quot;'+_extension.to_s+'&quot;'+&quot; (&quot;+$!.class.to_s+&quot;) &quot;+&quot; : &quot;+$! + &quot;\n at : &quot;+$@.to_s
+      ans = Tk.messageBox('icon' =&gt; 'warning', 'type' =&gt; 'abortretryignore',
+      'title' =&gt; '(Arcadia) Extensions', 'parent' =&gt; @root,
+      'message' =&gt; msg)
+      if ans == 'abort'
+        raise
+        exit
+      elsif ans == 'retry'
+        retry
+      else
+        Tk.update
+      end
+    end
+  end
+
+  def init_layout
+    @layout = ArcadiaLayout.new(self, @mf_root.get_frame)
+    suf = &quot;layout.split&quot;
+    elems = self['conf'][suf]
+    return if elems.nil?
+    if elems.strip.length &gt; 0
+      groups = elems.split(',')
+      groups.each{|group|
+        if group
+          suf1 = suf+'.'+group
+          begin
+            property = self['conf'][suf1]
+            c = property.split('c')
+            if c &amp;&amp; c.length == 2
+              pt = c[0].split('.')
+              perc = c[1].include?('%')
+              w = c[1].sub('%','')
+              if perc 
+                @layout.add_cols_perc(pt[0].to_i, pt[1].to_i, w.to_i)
+              else
+                @layout.add_cols(pt[0].to_i, pt[1].to_i, w.to_i)
+              end
+            else
+              r = property.split('r')
+              if r &amp;&amp; r.length == 2
+                pt = r[0].split('.')
+                perc = r[1].include?('%')
+                w = r[1].sub('%','')
+                if perc 
+                  @layout.add_rows_perc(pt[0].to_i, pt[1].to_i, w.to_i)
+                else
+                  @layout.add_rows(pt[0].to_i, pt[1].to_i, w.to_i)
+                end
+              end
+            end
+            
+          rescue Exception
+            msg = &quot;Loading layout: (#{$!.class.to_s} : #{$!.to_s} at : #{$@.to_s})&quot;
+            if Arcadia.dialog(self, 'type'=&gt;'ok_cancel', 'level'=&gt;'error','title' =&gt; '(Arcadia) Layout', 'msg'=&gt;msg)=='cancel'
+              raise
+              exit
+            else
+              Tk.update
+            end
+          end
+        end
+      }
+    else
+      @layout.add_mono_panel
+    end
+    @layout.add_headers
+  end
+
+  def load_config
+    self.load_local_config(false)
+    # local config can contain loading conditions
+    self.load_exts_conf
+    self.load_local_config
+    self.load_theme(self['conf']['theme'])
+    self.resolve_properties_link(self['conf'],self['conf'])
+    self.resolve_properties_link(self['origin_conf'],self['origin_conf'])
+  end
+
+  def set_sysdefaultproperty
+    Tk.tk_call &quot;eval&quot;,&quot;option add *background #{self['conf']['background']}&quot;
+    Tk.tk_call &quot;eval&quot;,&quot;option add *foreground #{self['conf']['foreground']}&quot;
+    #Tk.tk_call &quot;eval&quot;,&quot;option add *font #{self['conf']['font']}&quot;
+    Tk.tk_call &quot;eval&quot;,&quot;option add *activebackground #{self['conf']['activebackground']}&quot;
+    Tk.tk_call &quot;eval&quot;,&quot;option add *activeforeground #{self['conf']['activeforeground']}&quot;
+  end
+
+  def prepare
+    super
+    @splash.next_step('...initialize')  if @splash
+    @splash.next_step  if @splash
+    #self.load_libs
+    @splash.next_step  if @splash
+    @splash.next_step('... load extensions')  if @splash
+    #load_config
+    init_layout
+    publish('buffers.code.in_memory',Hash.new)
+    publish('action.load_code_from_buffers', proc{TkBuffersChoise.new})
+    publish('output.action.run_last', proc{$arcadia['output'].run_last})
+    publish('main.action.open_file', proc{self['editor'].open_file(Tk.getOpenFile)})
+    @splash.next_step('... load obj controller')  if @splash
+    @splash.next_step('... load editor')  if @splash
+    publish('main.action.new_file',proc{$arcadia['editor'].open_buffer()})
+    publish('main.action.edit_cut',proc{$arcadia['editor'].raised.text.text_cut()})
+    publish('main.action.edit_copy',proc{$arcadia['editor'].raised.text.text_copy()})
+    publish('main.action.edit_paste',proc{$arcadia['editor'].raised.text.text_paste()})
+    @splash.next_step('... load actions')  if @splash
+    #provvisorio 
+    @keytest = KeyTest.new
+    @keytest.on_close=proc{@keytest.hide}
+    @keytest.hide
+    @keytest.title(&quot;Keys test&quot;)
+    publish('action.test.keys', proc{@keytest.show})
+    publish('action.get.font', proc{Tk::BWidget::SelectFont::Dialog.new.create})
+    @splash.next_step  if @splash
+    publish('action.show_about', proc{ArcadiaAboutSplash.new.deiconify})
+#    publish('main.menu', @main_menu)
+    @main_menu = ArcadiaMainMenu.new(@main_menu_bar)
+    self.do_build
+    #publish('main.menu', ArcadiaMainMenu.new(@main_menu))
+    @splash.next_step  if @splash
+    publish('objic.action.raise_active_obj',
+    proc{
+    		InspectorContract.instance.raise_active_toplevel(self)
+    }
+    )
+    @splash.next_step('... toolbar buttons ')  if @splash
+    #@main_toolbar.load_toolbar_buttons
+    
+    #load user controls
+    #Arcadia control
+    load_user_control(@main_menu)
+    load_user_control(@main_toolbar)
+    #Extension control
+    @exts.each{|ext|
+      @splash.next_step(&quot;... load #{ext} user controls &quot;)  if @splash
+      load_user_control(@main_menu, ext)
+      load_user_control(@main_toolbar, ext)
+    }
+    load_user_control(@main_menu,&quot;&quot;,&quot;e&quot;)
+    load_user_control(@main_toolbar,&quot;&quot;,&quot;e&quot;)
+    #@layout.build_invert_menu
+  end
+
+  def load_user_control(_user_control, _ext='', _pre='')
+    return unless _ext &amp;&amp; ext_active?(_ext)
+    
+    if _ext.length &gt; 0 &amp;&amp; self[_ext]
+      _self_on_eval = self[_ext]
+      suf = &quot;#{_ext}.#{_user_control.class::SUF}&quot;
+    else
+      _self_on_eval = self
+      suf = &quot;#{_user_control.class::SUF}&quot;
+    end
+    if _pre.length &gt; 0
+      suf = &quot;#{_pre}.#{suf}&quot;
+    end
+    contexts = self['conf'][&quot;#{suf}.contexts&quot;]
+    contexts_caption = self['conf'][&quot;#{suf}.contexts.caption&quot;]
+    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'][&quot;#{suf1}.context_path&quot;]
+          property = proc{|_str, _suf| self['conf'][&quot;#{_suf}.#{_str}&quot;]} 
+          property_to_eval = proc{|_str, _suf| 
+            p = self['conf'][&quot;#{_suf}.#{_str}&quot;]
+            _self_on_eval.instance_eval(p) if p 
+          } 
+          items = self['conf'][suf1].split(',')
+          items.each{|item|
+            suf2 = suf1+'.'+item
+            disabled = !self['conf'][&quot;#{suf2}.disabled&quot;].nil?
+#            property = proc{|_str| self['conf'][&quot;#{suf2}.#{_str}&quot;]} 
+#            property_to_eval = proc{|_str| 
+#              p = self['conf'][&quot;#{suf2}.#{_str}&quot;]
+#              _self_on_eval.instance_eval(p) if p 
+#            } 
+            name = property.call('name',suf2)
+            caption = property.call('caption',suf2)
+            hint = property.call('hint',suf2)
+            event_class = property_to_eval.call('event_class',suf2)
+            
+            event_args = property_to_eval.call('event_args',suf2)
+            image_data = property_to_eval.call('image_data',suf2)
+            item_args = {
+              'name'=&gt;name,
+              'caption'=&gt;caption,
+              'hint'=&gt;hint,
+              'event_class' =&gt;event_class,
+              'event_args' =&gt;event_args,
+              'image_data' =&gt;image_data,
+              'context'=&gt;group,
+              'context_path'=&gt;context_path
+            }
+            item_args['context_caption'] = groups_caption[gi] if groups_caption
+            i = _user_control.new_item(self, item_args)
+            i.enable=false if disabled
+
+          }
+        rescue Exception
+          msg = &quot;Loading #{groups} -&gt;#{items} (#{$!.class.to_s} : #{$!.to_s} at : #{$@.to_s})&quot;
+          if Arcadia.dialog(self, 'type'=&gt;'ok_cancel', 'title' =&gt; '(Arcadia) Toolbar', 'msg'=&gt;msg)=='cancel'
+            raise
+            exit
+          else
+            Tk.update
+          end
+        end
+      end
+    }
+    
+  end
+
+
+  def do_exit
+    q1 = conf('confirm-on-exit')!='yes' || (Arcadia.dialog(self,
+                        'type'=&gt;'yes_no',
+                        'msg'=&gt;&quot;Do you want exit?&quot;,
+                        'title' =&gt; '(Arcadia) Exit',
+                        'level' =&gt; 'question')=='yes')
+    if q1 &amp;&amp; can_exit?
+      do_finalize
+      @root.destroy
+    end
+  end
+
+  def can_exit?
+    _event = Arcadia.process_event(ExitQueryEvent.new(self, 'can_exit'=&gt;true))
+   return _event.can_exit
+  end
+
+  def save_layout
+    Arcadia.del_conf_group('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']=&quot;#{e.conf('name')},#{i}&quot;
+          e.resize(i)
+          found=true
+          break
+        end
+      } 
+      break if found
+    }
+    # layouts
+    splits,doms,r,c = @layout.dump_geometry
+    header = &quot;&quot;
+    splits.each_index{|i|
+      header &lt;&lt; i.to_s
+      header &lt;&lt; ',' if i &lt; splits.length-1
+    }
+    self['conf']['layout.split']= header
+    splits.each_with_index{|sp,i|
+      self['conf'][&quot;layout.split.#{i}&quot;]=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 &amp;&amp; TkWinfo.parent(frame).instance_of?(Tk::BWidget::NoteBook)
+            frame=TkWinfo.parent(TkWinfo.parent(frame))
+          elsif frame.nil?
+            if str_frames.length &gt; 0
+              str_frames &lt;&lt; ','
+            end
+            str_frames &lt;&lt; '-1.-1'
+          end
+          if doms[frame]
+            if str_frames.length &gt; 0
+              str_frames &lt;&lt; ','
+            end
+            str_frames &lt;&lt; doms[frame]
+          end
+        else
+        end
+      }
+      if str_frames.length &gt; 0
+        self['conf'][&quot;#{e.conf('name')}.frames&quot;]=str_frames
+ #     p &quot;#{e.conf('name')}.frames=#{str_frames}&quot;
+      end
+    }
+  end
+  
+  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
+
+  def Arcadia.console(_sender, _args=Hash.new)
+    process_event(MsgEvent.new(_sender, _args))
+  end
+  
+  def Arcadia.dialog(_sender, _args=Hash.new)
+    _event = process_event(DialogEvent.new(_sender, _args))  
+    return _event.results[0].value if _event
+  end
+
+  def Arcadia.style(_class)
+    Configurable.properties_group(_class, Arcadia.instance['conf'])
+  end
+  
+  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
+
+  def Arcadia.layout
+    if @@instance
+        return @@instance.layout
+	  end
+  end
+  
+  def Arcadia.file_icon(_file_name)
+    if @@instance['file_icons'] == nil
+      @@instance['file_icons'] = Hash.new 
+      @@instance['file_icons']['default']= TkPhotoImage.new('dat' =&gt; FILE_ICON_DEFAULT)
+    end
+    _base_name= File.basename(_file_name)
+    if _base_name.include?('.')
+      file_dn = _base_name.split('.')[-1]
+    else
+      file_dn = &quot;no_ext&quot;
+    end
+    if @@instance['file_icons'][file_dn].nil?
+      file_icon_name=&quot;FILE_ICON_#{file_dn.upcase}&quot;
+      begin
+        if eval(&quot;defined?(#{file_icon_name})&quot;)
+          @@instance['file_icons'][file_dn]= TkPhotoImage.new('dat' =&gt; 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
+
+#  def Arcadia.res(_res)
+#    theme = Arcadia.instance['conf']['theme']
+#    if theme
+#      ret = eval(&quot;#{theme}::#{_res}&quot;)
+#    end
+#    ret=Res::_res if ret.nil?
+#    return ret
+#  end
+
+
+end
+
+class ArcadiaUserControl
+  SUF='user_control'
+  class UserItem
+    attr_accessor :name
+    attr_accessor :context
+    attr_accessor :context_caption
+    attr_accessor :caption
+    attr_accessor :hint
+    attr_accessor :event_class
+    attr_accessor :event_args
+    attr_accessor :image_data
+    def initialize(_sender, _args)
+      @sender = _sender
+      if _args 
+        _args.each do |key, value|
+          self.send(key+'=', value)
+        end
+      end
+      #@item_obj = ?
+    end
+
+    def method_missing(m, *args)  
+      if @item_obj &amp;&amp; m.respond_to?(m)
+        @item_obj.send(m, *args)
+      end
+    end  
+
+        
+    def enable=(_value)
+    end
+    
+    def background
+    end
+    
+    def foreground
+    end
+    
+  end
+#  def initialize
+#    @items = Hash.new
+#  end
+  def items
+    @items = Hash.new if @items.nil?
+    @items
+  end
+  
+  def new_item(_sender, _args)
+    item = self.class::UserItem.new(_sender, _args)
+    items[_args['name']]= item if _args['name']
+  end
+  
+end
+
+
+class ArcadiaMainToolbar &lt; ArcadiaUserControl
+  SUF='user_toolbar'
+  class UserItem &lt; UserItem
+    attr_accessor :frame
+    def initialize(_sender, _args)
+      super(_sender, _args)
+      _image = TkPhotoImage.new('data' =&gt; @image_data) if @image_data
+      _command = proc{Arcadia.process_event(@event_class.new(_sender, @event_args))} if @event_class
+      _hint = @hint
+      _font = @font
+      _caption = @caption
+      @item_obj = Tk::BWidget::Button.new(_args['frame'], Arcadia.style('toolbarbutton')){
+        image  _image if _image
+        #borderwidth 1
+        #font _font if _font
+        #activebackground Arcadia.conf('button.activebackground')
+        #activeforeground Arcadia.conf('button.activeforeground')
+        #background Arcadia.conf('button.background')
+        #foreground Arcadia.conf('button.foreground')
+        #highlightbackground Arcadia.conf('button.highlightbackground')
+        #relief Arcadia.conf('button.relief')
+        command _command if _command
+        #relief 'groove'
+        width 20
+        height 20
+        helptext  _hint if _hint
+        text _caption if _caption
+        pack('side' =&gt;'left', :padx=&gt;2, :pady=&gt;0)
+      }
+      #Tk::BWidget::Separator.new(@frame, :orient=&gt;'vertical').pack('side' =&gt;'left', :padx=&gt;2, :pady=&gt;2, :fill=&gt;'y',:anchor=&gt; 'w')
+    end
+
+    def enabled=(_value)
+      if _value
+        @item_obj.state='enable'
+      else
+        @item_obj.state='disable'
+      end
+    end
+  end
+  
+  
+  def initialize(_arcadia, _frame)
+    @arcadia = _arcadia
+    @frame = _frame
+    @frame.borderwidth(Arcadia.conf('panel.borderwidth'))
+    #@frame.highlightbackground(Arcadia.conf('panel.highlightbackground'))
+    @frame.relief(Arcadia.conf('panel.relief'))
+ 
+     @context_frames = Hash.new  
+    @last_context = nil
+  end
+
+  def new_item(_sender, _args= nil)
+     _context = _args['context']
+#    if _context
+#      if @context_frames[_context]
+#      else
+#        @context_frames[_context] = TkLabelFrame.new(@frame){
+#          text  &quot;&quot;
+#          relief 'groove'
+#          pack('side' =&gt;'left', :padx=&gt;0, :pady=&gt;0)
+#        } 
+#      end
+#      _args['frame']=@context_frames[_context]
+#    else
+#      _args['frame']=@frame
+#    end
+    if @last_context &amp;&amp; _context != @last_context 
+      new_separator
+    end
+    @last_context = _context
+    _args['frame']=@frame
+    super(_sender, _args)
+  end
+
+  def new_separator
+    Tk::BWidget::Separator.new(@frame, 
+    :orient=&gt;'vertical',
+    :background=&gt;Arcadia.conf('button.highlightbackground')
+    ).pack('side' =&gt;'left', :padx=&gt;2, :pady=&gt;2, :fill=&gt;'y',:anchor=&gt; 'w')
+  end  
+
+#  def load_toolbar_buttons
+#    suf = 'toolbar_buttons'
+#    return if @arcadia['conf'][suf].nil?
+#    @buttons = Hash.new
+#    toolbar_buttons = @arcadia['conf'][suf].split(',')
+#    toolbar_buttons.each{|groups|
+#      if groups
+#        suf1 = suf+'.'+groups
+#        begin
+#          buttons = @arcadia['conf'][suf1].split(',')
+#          buttons.each{|button|
+#            suf2 = suf1+'.'+button
+#            name = @arcadia['conf'][suf2+'.name']
+#            text = @arcadia['conf'][suf2+'.text']
+#            image = @arcadia['conf'][suf2+'.image']
+#            font = @arcadia['conf'][suf2+'.font']
+#            background = @arcadia['conf'][suf2+'.background']
+#            foreground = @arcadia['conf'][suf2+'.foreground']
+#            hint = @arcadia['conf'][suf2+'.hint']
+#            action = @arcadia['conf'][suf2+'.action']
+#            actions = action.split('-&gt;')  if action
+#            if actions &amp;&amp; actions.length&gt;1
+#              _command = proc{
+#                action_obj = $arcadia[actions[0]]
+#                1.upto(actions.length-2) do |x|
+#                  action_obj = action_obj.send(actions[x])
+#                end
+#                action_obj.send(actions[actions.length-1])
+#              }
+#            elsif action
+#              _command = proc{$arcadia[action].call}
+#            end
+#            @buttons[name] = Tk::BWidget::Button.new(@frame){
+#              image  TkPhotoImage.new('data' =&gt; eval(image)) if image
+#              borderwidth 1
+#              font font if font
+#              background background if background
+#              foreground foreground if foreground
+#              command _command if action
+#              relief 'flat'
+#              helptext  hint if hint
+#              text text if text
+#              pack('side' =&gt;'left', :padx=&gt;2, :pady=&gt;0)
+#            }
+#          }
+#        rescue Exception
+#          msg = 'Loading '+groups+'&quot; -&gt; '+buttons.to_s+ '&quot; (' + $!.class.to_s + &quot;) : &quot; + $!.to_s + &quot; at : &quot;+$@.to_s
+#          if Tk.messageBox('icon' =&gt; 'error', 'type' =&gt; 'okcancel',
+#            'title' =&gt; '(Arcadia) Toolbar', 'parent' =&gt; @frame,
+#            'message' =&gt; msg) == 'cancel'
+#            raise
+#            exit
+#          else
+#            Tk.update
+#          end
+#        end
+#      end
+#      Tk::BWidget::Separator.new(@frame, :orient=&gt;'vertical').pack('side' =&gt;'left', :padx=&gt;2, :pady=&gt;2, :fill=&gt;'y',:anchor=&gt; 'w')
+#    }
+#  end
+
+  
+end
+
+class ArcadiaMainMenu &lt; ArcadiaUserControl
+  SUF='user_menu'
+  class UserItem &lt; UserItem
+    attr_accessor :menu
+    def initialize(_sender, _args)
+      super(_sender, _args)
+      _image = TkPhotoImage.new('data' =&gt; @image_data) if @image_data
+      _command = proc{
+        Arcadia.process_event(@event_class.new(_sender, @event_args))
+      } if @event_class
+      #_menu = @menu[@parent]
+      @item_obj = @menu.insert('end', :command, 
+        'image'=&gt;_image,
+        'label'=&gt;@caption, 
+        'compound'=&gt;'left',
+        'command'=&gt;_command )
+      @index = @menu.index('last')
+    end
+
+    def enabled=(_value)
+      if _value
+        @item_obj.entryconfigure(@index, 'state'=&gt;'enable')
+      else
+        @item_obj.entryconfigure(@index,'state'=&gt;'disable')
+      end
+    end
+  end
+  
+  def initialize(menu)
+    # create main menu
+    @menu = menu
+    build
+    @menu.configure(Arcadia.style('menu'))
+#    menu.foreground('black')
+#    menu.activeforeground('#6679f1')
+#    menu.relief('flat')
+#    menu.borderwidth(0)
+#    menu.font(Arcadia.conf('main.mainmenu.font'))
+  end
+
+  def get_menu_context(_menubar, _context)
+    menubuttons =  _menubar[0..-1]
+    # cerchiamo il context
+    m_i = -1
+    menubuttons.each_with_index{|mb, i|
+      _t = mb[0].cget('text')
+      if _t==_context
+        m_i = i 
+        break
+      end
+    }
+    if m_i &gt; -1
+      _menubar[m_i][1]
+    else
+      _menubar.add_menu([[_context],[]])[1].delete(0)
+    end
+  end
+  
+  def get_sub_menu(menu_context, folder=nil)
+    if folder
+      s_i = -1 
+      i_end = menu_context.index('end')
+      if i_end
+        0.upto(i_end){|j|
+          l = menu_context.entrycget(j,'label')
+          if l == folder
+           s_i = j
+           break
+          end
+        }
+      end
+    end
+    if s_i &gt; -1 &amp;&amp; menu_context.menutype(s_i) == 'cascade'
+      sub = menu_context.entrycget(s_i, 'menu')
+    else
+      sub = TkMenu.new(
+        :parent=&gt;@pop_up,
+        :tearoff=&gt;0
+      )
+      sub.configure(Arcadia.style('menu'))
+      #update_style(sub)
+      menu_context.insert('end',
+        :cascade,
+        :label=&gt;folder,
+        :menu=&gt;sub,
+        :hidemargin =&gt; false
+      )
+    end
+    sub
+  end
+  
+  def get_menu(_menubar, _context, context_path)
+    context_menu = get_menu_context(_menubar, _context)
+    folders = context_path.split('/')
+    sub = context_menu
+    folders.each{|folder|
+      sub = get_sub_menu(sub, folder)
+    }
+    sub
+  end
+
+
+  def new_item(_sender, _args= nil)
+    return if _args.nil?
+    if _args['context_caption']
+      conte = _args['context_caption']
+    else
+      conte = _args['context']
+    end
+    _args['menu']=get_menu(@menu, conte, _args['context_path'])
+    super(_sender, _args)
+  end
+
+
+  def build
+    menu_spec_file = [
+      ['File', 0],
+      ['Open', proc{Arcadia.process_event(OpenBufferEvent.new(self,'file'=&gt;Tk.getOpenFile))}, 0],
+      ['New', $arcadia['main.action.new_file'], 0],
+      #['Save', proc{EditorContract.instance.save_file_raised(self)},0],
+      ['Save', proc{Arcadia.process_event(SaveBufferEvent.new(self))},0],
+      ['Save as ...', proc{Arcadia.process_event(SaveAsBufferEvent.new(self))},0],
+      '---',
+      ['Quit', $arcadia['action.on_exit'], 0]]
+      menu_spec_edit = [['Edit', 0],
+      ['Cut', $arcadia['main.action.edit_cut'], 2],
+      ['Copy', $arcadia['main.action.edit_copy'], 0],
+      ['Paste', $arcadia['main.action.edit_paste'], 0]]
+      menu_spec_search = [['Search', 0],
+      ['Find ...', proc{Arcadia.process_event(SearchBufferEvent.new(self))}, 2],
+      ['Find in files...', proc{Arcadia.process_event(SearchInFilesEvent.new(self))}, 2],
+      ['Ack in files...', proc{Arcadia.process_event(AckInFilesEvent.new(self))}, 2],
+      ['Go to line ...', proc{Arcadia.process_event(GoToLineBufferEvent.new(self))}, 2]]
+      menu_spec_view = [['View', 0],['Show/Hide Toolbar', proc{$arcadia.show_hide_toolbar}, 2]]
+      menu_spec_tools = [['Tools', 0],
+      ['Keys-test', $arcadia['action.test.keys'], 2]
+    ]
+    menu_spec_help = [['Help', 0],
+    ['About', $arcadia['action.show_about'], 2],]
+    @menu.add_menu(menu_spec_file)
+    @menu.add_menu(menu_spec_edit)
+    @menu.add_menu(menu_spec_search)
+    @menu.add_menu(menu_spec_view)
+    @menu.add_menu(menu_spec_tools)
+    @menu.add_menu(menu_spec_help)
+  
+    #@menu.bind_append(&quot;1&quot;, proc{
+#      chs = TkWinfo.children(@menu)
+#      hh = 25
+#      @last_post = nil
+#      chs.each{|ch|
+#        ch.bind_append(&quot;Enter&quot;, proc{|x,y,rx,ry| 
+#          @last_post.unpost if @last_post
+#          ch.menu.post(x-rx,y-ry+hh)
+#          @last_post=ch.menu}, &quot;%X %Y %x %y&quot;)
+#        ch.bind_append(&quot;Leave&quot;, proc{
+#          @last_post.unpost if @last_post
+#        })
+#      }
+    #})
+  end
+  
+end
+
+class ArcadiaAboutSplash &lt; TkToplevel
+  attr :progress
+  def initialize
+    #_bgcolor = '#B83333'
+    _bgcolor = '#000000'
+    super()
+    relief 'groove'
+    #relief 'flat'
+    background  _bgcolor
+    highlightbackground  _bgcolor
+    highlightthickness  1
+    borderwidth 2
+    withdraw 
+    overrideredirect(true)
+    
+    @tkLabel3 = TkLabel.new(self){
+      image  TkPhotoImage.new('format'=&gt;'GIF','data' =&gt;A_LOGO_GIF)
+      background  _bgcolor
+      place('x'=&gt; 20,'y' =&gt; 20)
+    }
+    @tkLabel1 = TkLabel.new(self){
+      text  'Arcadia'
+      background  _bgcolor
+      foreground  '#ffffff'
+      font Arcadia.conf('splash.title.font')
+      justify  'left'
+      place('width' =&gt; '190','x' =&gt; 110,'y' =&gt; 10,'height' =&gt; 25)
+    }
+    @tkLabelRuby = TkLabel.new(self){
+      image TkPhotoImage.new('data' =&gt;RUBY_DOCUMENT_GIF)
+      background  _bgcolor
+      place('x'=&gt; 150,'y' =&gt; 40)
+    }
+    @tkLabel2 = TkLabel.new(self){
+      text  'Ruby ide'
+      background  _bgcolor
+      foreground  '#ffffff'
+      font Arcadia.instance['conf']['splash.subtitle.font']
+      justify  'left'
+      place('width' =&gt; '90','x' =&gt; 170,'y' =&gt; 40,'height' =&gt; 19)
+    }
+    @tkLabelVersion = TkLabel.new(self){
+      text  'version: '+$arcadia['applicationParams'].version
+      background  _bgcolor
+      foreground  '#ffffff'
+      font Arcadia.instance['conf']['splash.version.font']
+      justify  'left'
+      place('width' =&gt; '120','x' =&gt; 150,'y' =&gt; 65,'height' =&gt; 19)
+    }
+    @tkLabel21 = TkLabel.new(self){
+      text  'by Antonio Galeone - 2004/2009'
+      background  _bgcolor
+      foreground  '#ffffff'
+      font Arcadia.instance['conf']['splash.credits.font']
+      justify  'left'
+      place('width' =&gt; '210','x' =&gt; 100,'y' =&gt; 95,'height' =&gt; 25)
+    }
+    @tkLabelStep = TkLabel.new(self){
+      text  ''
+      background  _bgcolor
+      foreground  'yellow'
+      font Arcadia.instance['conf']['splash.banner.font']
+      justify  'left'
+      anchor  'w'
+      place('width'=&gt;-5,'relwidth' =&gt; 1,'x' =&gt; 5,'y' =&gt; 160,'height' =&gt; 45)
+    }
+    @progress  = TkVariable.new
+    reset
+    _width = 380
+    _height = 240
+    #_width = 0;_height = 0
+    _x = TkWinfo.screenwidth(self)/2 -  _width / 2
+    _y = TkWinfo.screenheight(self)/2 -  _height / 2
+    geometry = _width.to_s+'x'+_height.to_s+'+'+_x.to_s+'+'+_y.to_s
+    Tk.tk_call('wm', 'geometry', self, geometry )
+    bind(&quot;Double-Button-1&quot;, proc{self.destroy})
+    info = TkApplication.sys_info
+    set_sysinfo(info)
+  end
+
+  def set_sysinfo(_info)
+    @tkLabelStep.text(_info)
+  end
+
+  def set_progress(_max=10)
+    @max = _max
+    Tk::BWidget::ProgressBar.new(self, :width=&gt;150, :height=&gt;10,
+    :background=&gt;'black',
+    :troughcolor=&gt;'black',
+    :foreground=&gt;'#a11934',
+    :variable=&gt;@progress,
+    :borderwidth=&gt;0,
+    :relief=&gt;'flat',
+    :maximum=&gt;_max).place('relwidth' =&gt; '1','y' =&gt; 146,'height' =&gt; 2)
+  end
+
+  def reset
+    @progress.value = -1
+  end
+
+  def next_step(_txt = nil)
+    @progress.numeric += 1
+    labelStep(_txt) if _txt
+  end
+
+  def labelStep(_txt)
+    @tkLabelStep.text = _txt
+    Tk.update
+  end
+
+  def last_step(_txt = nil)
+    @progress.numeric = @max
+    labelStep(_txt) if _txt
+  end
+  
+end
+
+class ArcadiaActionDispatcher
+
+  def initialize(_arcadia)
+    @arcadia = _arcadia
+    Arcadia.attach_listener(self, ActionEvent)
+  end
+  
+  def on_action(_event)
+    if _event.receiver != nil &amp;&amp; _event.receiver.respond_to?(_event.action)
+      if _event.action_args.nil?
+        _event.receiver.send(_event.action)
+      else
+        _event.receiver.send(_event.action, _event.action_args)
+      end
+    end
+  end
+
+end
+
+class ArcadiaGemsWizard
+  def initialize(_arcadia)
+    @arcadia = _arcadia
+    Arcadia.attach_listener(self, NeedRubyGemWizardEvent)
+  end
+  
+  def on_need_ruby_gem_wizard(_event)
+    # ... todo implamentation
+    msg = &quot;Appears that gem : '#{_event.gem_name}' required by : '#{_event.extension_name}' is not installed!\n Do you want to try install it now?&quot; 
+    ans = Tk.messageBox('icon' =&gt; 'error', 'type' =&gt; 'yesno',
+      'title' =&gt; &quot;(Arcadia) Extensions '#{_event.extension_name}'&quot;,
+      'message' =&gt; msg)
+      if  ans == 'yes'
+        _event.add_result(self, 'installed'=&gt;try_to_install_gem(_event.gem_name,_event.gem_repository))
+      else
+        _event.add_result(self, 'installed'=&gt;false)
+      end
+  end
+  
+  def try_to_install_gem(name, repository=nil, version = '&gt;0')
+    ret = false
+    # TODO WIZARD
+    
+#    # rubygems version must be &gt;= 1.2 Gem::RubyGemsVersion
+#    if Gem::RubyGemsVersion &gt;= '1.2'
+#      begin
+#        gem name, version
+#      rescue LoadError, Gem::LoadError =&gt; e
+#        require 'rubygems/gem_runner'
+#        begin
+#          gr = Gem::GemRunner.new
+#          com = %W[install #{name}]
+#          com.concat(%W[--source= #{repository}]) if repository
+#          p com
+#          gr.run(com)
+#        rescue Gem::SystemExitException=&gt;e
+#          if e.exit_code == 0
+#            ret = true
+#            p &quot;Successfully installed. #{e.message}&quot;
+#          else
+#            msg = &quot;Install of '#{name}' (#{version}) failed. #{e.message}&quot;
+#            Tk.messageBox('icon' =&gt; 'error', 
+#              'type' =&gt; 'ok',
+#              'title' =&gt; &quot;(Arcadia) gem&quot;,
+#              'message' =&gt; msg)
+#          end
+#        end
+#      end
+#    end
+    ret
+  end
+  
+end
+
+class ArcadiaDialogManager
+  def initialize(_arcadia)
+    @arcadia = _arcadia
+    Arcadia.attach_listener(self, DialogEvent)
+  end
+
+  def on_dialog(_event)
+    type = _event.type
+    if !DialogEvent::TYPE_PATTERNS.include?(_event.type)
+      type = 'ok'
+    end
+    res_array = type.split('_')
+    icon = _event.level
+    tktype = type.gsub('_','').downcase
+    
+    tkdialog =  Tk::BWidget::MessageDlg.new(
+            'icon' =&gt; icon,
+            'bg' =&gt; Arcadia.conf('background'),
+            'fg' =&gt; Arcadia.conf('foreground'),
+            'type' =&gt; tktype,
+            'title' =&gt; _event.title, 
+            'message' =&gt; _event.msg)
+            
+    tkdialog.configure('font'=&gt;'courier 6')        
+    res = tkdialog.create
+    _event.add_result(self, 'value'=&gt;res_array[res.to_i])
+  end
+
+
+  def on_dialog_old(_event)
+    type = _event.type
+    if !DialogEvent::TYPE_PATTERNS.include?(_event.type)
+      type = 'ok'
+    end
+    icon = _event.level
+    tktype = type.gsub('_','').downcase
+    
+    res =  Tk.messageBox(
+            'icon' =&gt; icon,
+            'type' =&gt; tktype,
+            'title' =&gt; _event.title, 
+            'message' =&gt; _event.msg)
+    _event.add_result(self, 'value'=&gt;res)
+  end
+end
+
+
+class ArcadiaLayout
+#  include Observable
+#  ArcadiaPanelInfo = Struct.new( &quot;ArcadiaPanelInfo&quot;,
+#    :name,
+#    :title,
+#    :frame,
+#    :ffw
+#  )
+
+  def initialize(_arcadia, _frame, _autotab=true)
+    @arcadia = _arcadia
+    @frames = Array.new
+    @frames[0] = Array.new
+    @frames[0][0] = _frame
+   # @domains = Array.new
+   # @domains[0] = Array.new
+   # @domains[0][0] = '_domain_root_'
+    @panels = Hash.new
+    @panels['_domain_root_']= Hash.new
+    @panels['_domain_root_']['root']= _frame
+    @panels['_domain_root_']['sons'] = 	Hash.new
+    @autotab = _autotab
+    @headed = false
+    @wrappers=Hash.new
+    @splitters=Array.new
+    #ArcadiaContractListener.new(self, MainContract, :do_main_event)
+  end
+	
+	def root
+		@panels['_domain_root_']['root']
+	end
+	
+	def raise_panel(_domain, _extension)
+    p = @panels[_domain]
+    if p &amp;&amp; p['notebook'] != nil
+      p['notebook'].raise(_extension)
+      p['notebook'].see(_extension)
+    end
+	end
+
+#  def raise_panel(_domain_name, _name)
+#    @panels[_domain_name]['notebook'].raise(_name) if @panels[_domain_name] &amp;&amp; @panels[_domain_name]['notebook']
+#  end
+
+	def raised?(_domain, _name)
+    ret = true
+    p = @panels[_domain]
+    if p &amp;&amp; p['notebook'] != nil
+      ret=p['notebook'].raise == _name
+    end
+    ret
+	end
+	
+	def raised_fixed_frame(_domain)
+	  ret = nil
+	  p = @panels[_domain]
+    if p &amp;&amp; p['notebook'] != nil
+      raised_name=p['notebook'].raise
+   	  @panels[_domain]['sons'].each{|k,v|
+   	    if raised_name == k 
+   	      ret = v 
+   	      break
+   	    end
+   	  }
+    elsif @panels[_domain]['sons'].length == 1
+      ret = @panels[_domain]['sons'].values[0]
+    end
+    ret
+  end
+  
+  def _prepare_rows(_row,_col, _height, _perc=false, _top_name=nil, _bottom_name=nil)
+    if (@frames[_row][_col] !=  nil)
+      #source_domains = all_domains(@frames[_row][_col])
+      #source_domains = others_domains(@frames[_row][_col], false)
+      _h = AGTkOSplittedFrames.new(self.root,@frames[_row][_col],_height, @arcadia['conf']['layout.splitter.length'].to_i,_perc)
+      @splitters &lt;&lt; _h
+      if @frames[_row + 1] == nil
+      		@frames[_row + 1] = Array.new
+      	#	@domains[_row + 1] = Array.new
+      end
+      @frames[_row][_col] = _h.top_frame
+      
+      _top_name = _row.to_s+'.'+_col.to_s if _top_name == nil
+      @panels[_top_name] = Hash.new
+      @panels[_top_name]['root'] = @frames[_row][_col]
+      @panels[_top_name]['sons'] = 	Hash.new
+      if @panels[_top_name]['root_splitted_frames'].nil?
+        @panels[_top_name]['root_splitted_frames'] = _h 
+      end
+      @panels[_top_name]['splitted_frames'] = _h
+     # @domains[_row][_col] = _top_name
+
+      _bottom_name = (_row+1).to_s+'.'+_col.to_s if _bottom_name == nil
+      
+      if !@panels[_bottom_name].nil?
+        shift_bottom(_row+1, _col)
+      end
+      
+      @panels[_bottom_name] = Hash.new
+      @frames[_row + 1][_col] = _h.bottom_frame
+      @panels[_bottom_name]['root'] = @frames[_row + 1][_col]
+      @panels[_bottom_name]['sons'] = Hash.new
+      if @panels[_bottom_name]['root_splitted_frames'].nil?
+        @panels[_bottom_name]['root_splitted_frames'] = _h 
+      end
+      @panels[_bottom_name]['splitted_frames'] = _h
+    	#	@domains[_row + 1][_col] = _bottom_name
+    end
+  end
+  private :_prepare_rows
+
+  def add_mono_panel(_name=nil)
+    if (@frames[0][0] !=  nil)
+      _name = '0.0' if _name.nil?
+      @panels[_name] = Hash.new
+      @panels[_name]['root'] = @frames[0][0]
+      @panels[_name]['sons'] = 	Hash.new
+    end
+  end
+
+
+  def add_rows(_row,_col, _height, _top_name=nil, _bottom_name=nil)
+  		_prepare_rows(_row,_col, _height, false, _top_name, _bottom_name)
+  end
+
+  def add_rows_perc(_row,_col, _height, _top_name=nil, _bottom_name=nil)
+  		_prepare_rows(_row,_col, _height, true, _top_name, _bottom_name)
+  end
+
+#  def others_domains(_frame, _vertical=true)
+#      if _vertical
+#        splitter_adapter_class = AGTkVSplittedFrames
+#      else
+#        splitter_adapter_class = AGTkOSplittedFrames
+#      end
+#      splitted_adapter = find_splitted_frame(_frame)
+#      consider_it = splitted_adapter.instance_of?(splitter_adapter_class) &amp;&amp; splitted_adapter.frame1 == _frame
+#      if splitted_adapter &amp;&amp; !consider_it &amp;&amp; splitted_adapter != _frame
+#         rif_frame = splitted_adapter.frame
+#         ret = others_domains(rif_frame)
+#      elsif splitted_adapter &amp;&amp; consider_it
+#        ret = domains_on_frame(splitted_adapter.frame2)
+#      else
+#        ret = Array.new
+#      end
+#      ret    
+#  end
+
+  def all_domains(_frame)
+      splitted_adapter = find_splitted_frame(_frame)
+      consider_it = splitted_adapter.kind_of?(AGTkSplittedFrames)
+      if consider_it
+        ret = domains_on_frame(splitted_adapter.frame2).concat(domains_on_frame(splitted_adapter.frame1))
+      else
+        ret = Array.new
+      end
+      ret    
+  end
+
+  def all_domains_cols(_frame)
+    ret = Array.new
+    all_domains(_frame).each{|d|
+      v = d.split('.')[1]
+      ret &lt;&lt; v if !ret.include?(v)
+    }
+    ret
+  end
+
+  def all_domains_rows(_frame)
+    ret = Array.new
+    all_domains(_frame).each{|d|
+      v = d.split('.')[0]
+      ret &lt;&lt; v if !ret.include?(v)
+    }
+    ret
+  end
+
+
+  def _prepare_cols(_row,_col, _width, _perc=false, _left_name=nil, _right_name=nil)
+    if (@frames[_row][_col] !=  nil)
+      #source_domains = all_domains(@frames[_row][_col])
+      #source_domains = others_domains(@frames[_row][_col])
+      _w = AGTkVSplittedFrames.new(self.root,@frames[_row][_col],_width,@arcadia['conf']['layout.splitter.length'].to_i,_perc)
+      @splitters &lt;&lt; _w
+      @frames[_row][_col] = _w.left_frame
+      #@frames[_row][_col + 1] = _w.right_frame
+
+      _left_name = _row.to_s+'.'+_col.to_s if _left_name == nil
+      @panels[_left_name] = Hash.new
+      @panels[_left_name]['root'] = @frames[_row][_col]
+      @panels[_left_name]['sons'] = Hash.new
+      if @panels[_left_name]['root_splitted_frames'].nil?
+        @panels[_left_name]['root_splitted_frames'] = _w 
+      end
+      @panels[_left_name]['splitted_frames'] = _w
+     # @domains[_row][_col] = _left_name
+        
+      _right_name = _row.to_s+'.'+(_col+1).to_s if _right_name == nil
+      if !@panels[_right_name].nil?
+        shift_right(_row, _col+1)
+      end
+
+      @frames[_row][_col + 1] = _w.right_frame
+      @panels[_right_name] = Hash.new
+      @panels[_right_name]['root'] = @frames[_row][_col + 1]
+      @panels[_right_name]['sons'] = Hash.new
+      if @panels[_right_name]['root_splitted_frames'].nil?
+        @panels[_right_name]['root_splitted_frames'] = _w 
+      end
+      @panels[_right_name]['splitted_frames'] = _w
+     # @domains[_row][_col + 1] = _right_name
+    end
+  end
+ 	private :_prepare_cols
+  
+  
+  def domain_name(_row,_col)
+    _row.to_s+'.'+_col.to_s
+  end
+  
+  def shift_right(_row,_col)
+    d = domain_name(_row, _col+1)
+    dj = domain_name(_row, _col)
+    if @panels[d] !=nil
+      shift_right(_row,_col+1)
+    end
+    @panels[d] = @panels[dj]
+    #-------------------------------
+    #@panels[d]['root'].set_domain(d)
+    #-------------------------------
+    @panels[d]['sons'].each{|name,ffw| ffw.domain=d}
+    @frames[_row][_col+1] = @frames[_row][_col]
+   # @domains[_row][_col+1] = @domains[_row][_col]
+    
+    @panels.delete(dj)
+    #@panels[dj] = nil
+    @frames[_row][_col] = nil
+   # @domains[_row][_col] = nil
+  end
+
+  def shift_left(_row,_col)
+    d = domain_name(_row, _col)
+    dj = domain_name(_row, _col+1)
+    if @panels[dj] !=nil
+      @panels[d] = @panels[dj]
+      #-------------------------------
+      #@panels[d]['root'].set_domain(d)
+      #-------------------------------
+      @panels[d]['sons'].each{|name,ffw| ffw.domain=d}
+      @frames[_row][_col] = @frames[_row][_col+1]
+     # @domains[_row][_col] = @domains[_row][_col+1]
+      
+      @panels.delete(dj) # = nil
+      @frames[_row][_col+1] = nil
+     # @domains[_row][_col+1] = nil
+      shift_left(_row,_col+1)
+    end
+  
+  end
+
+  def shift_top(_row,_col)
+    d = domain_name(_row, _col)
+    dj = domain_name(_row+1, _col)
+    if @panels[dj] !=nil
+      @panels[d] = @panels[dj]
+      #-------------------------------
+      #@panels[d]['root'].set_domain(d)
+      #-------------------------------
+      @panels[d]['sons'].each{|name,ffw| ffw.domain=d}
+      @frames[_row][_col] = @frames[_row+1][_col]
+     # @domains[_row][_col] = @domains[_row+1][_col]
+      
+      @panels.delete(dj) # = nil
+      @frames[_row+1][_col] = nil
+     # @domains[_row+1][_col] = nil
+
+      shift_top(_row+1,_col)
+    end
+  
+  end
+
+
+  def shift_bottom(_row, _col)
+    d = domain_name(_row+1, _col)
+    dj = domain_name(_row, _col)
+    if @panels[d] !=nil
+      shift_bottom(_row+1,_col)
+    end
+    @panels[d] = @panels[dj]
+    #-------------------------------
+    #@panels[d]['root'].set_domain(d)
+    #-------------------------------
+    @panels[d]['sons'].each{|name,ffw| ffw.domain=d}
+    if @frames[_row + 1] == nil
+    		@frames[_row + 1] = Array.new
+    	#	@domains[_row + 1] = Array.new
+    end
+    @frames[_row+1][_col] = @frames[_row][_col]
+   # @domains[_row+1][_col] = @domains[_row][_col]
+    
+    @panels.delete(dj)
+    #@panels[dj] = nil
+    @frames[_row][_col] = nil
+   # @domains[_row][_col] = nil
+  end
+  
+  def add_cols(_row,_col, _width, _left_name=nil, _right_name=nil)
+    _prepare_cols(_row,_col, _width, false, _left_name, _right_name)
+  end
+
+  def add_cols_perc(_row,_col, _width, _left_name=nil, _right_name=nil)
+    _prepare_cols(_row,_col, _width, true, _left_name, _right_name)
+  end
+
+  def add_cols_runtime(_domain)
+    saved_root_splitted_frames = @panels[_domain]['root_splitted_frames']
+    _saved = Hash.new
+    _saved.update(@panels[_domain]['sons'])
+    geometry = TkWinfo.geometry(@panels[_domain]['root'])
+    width = geometry.split('x')[0].to_i/2
+    _saved.each{|name,ffw|
+      unregister_panel(ffw, false, false)
+    }
+    unbuild_titled_frame(_domain)
+    _row,_col = _domain.split('.')
+    add_cols(_row.to_i,_col.to_i, width)
+    build_titled_frame(_domain)
+    build_titled_frame(domain_name(_row.to_i,_col.to_i+1))
+    _saved.each{|name,ffw|
+      ffw.domain = _domain
+      register_panel(ffw, ffw.hinner_frame)    
+    }
+    if saved_root_splitted_frames
+      @panels[_domain]['root_splitted_frames']=saved_root_splitted_frames
+    end
+    build_invert_menu(true)
+  end
+
+  def add_rows_runtime(_domain)
+    saved_root_splitted_frames = @panels[_domain]['root_splitted_frames']
+    _saved = Hash.new
+    _saved.update(@panels[_domain]['sons'])
+    geometry = TkWinfo.geometry(@panels[_domain]['root'])
+    height = geometry.split('+')[0].split('x')[1].to_i/2
+    _saved.each{|name,ffw|
+      unregister_panel(ffw, false, false)
+    }
+    unbuild_titled_frame(_domain)
+    _row,_col = _domain.split('.')
+    add_rows(_row.to_i,_col.to_i, height)
+    build_titled_frame(_domain)
+    build_titled_frame(domain_name(_row.to_i+1,_col.to_i))
+    _saved.each{|name,ffw|
+      ffw.domain = _domain
+      register_panel(ffw, ffw.hinner_frame)    
+    }
+    if saved_root_splitted_frames
+      @panels[_domain]['root_splitted_frames']=saved_root_splitted_frames
+    end
+
+    build_invert_menu(true)
+  end
+
+  def domains_on_frame_rows(_frame)
+    ret = Array.new
+    domains_on_frame(_frame).each{|d|
+      v = d.split('.')[0]
+      ret &lt;&lt; v if !ret.include?(v)
+    }
+    ret
+  end
+  
+  def domains_rows(_domains)
+    ret = Array.new
+    if _domains
+      _domains.each{|d|
+        v = d.split('.')[0]
+        ret &lt;&lt; v if !ret.include?(v)
+      }
+    end
+    ret
+  end
+
+  def max_col(_domains, _row)
+    ret = 0
+    if _domains
+      _domains.each{|d|
+        r,c = d.split('.')
+        if r.to_i == _row &amp;&amp; c.to_i &gt; ret
+          ret = c.to_i
+        end
+      }
+    end
+    ret
+  end
+
+  def max_row(_domains, _col)
+    ret = 0
+    if _domains
+      _domains.each{|d|
+        r,c = d.split('.')
+        if c.to_i == _col &amp;&amp; r.to_i &gt; ret
+          ret = r.to_i
+        end
+      }
+    end
+    ret
+  end
+
+  def domains_cols(_domains)
+    ret = Array.new
+    _domains.each{|d|
+      v = d.split('.')[1]
+      ret &lt;&lt; v if !ret.include?(v)
+    }
+    ret
+  end
+
+  
+  def domains_on_frame_cols(_frame)
+    ret = Array.new
+    domains_on_frame(_frame).each{|d|
+      v = d.split('.')[1]
+      ret &lt;&lt; v if !ret.include?(v)
+    }
+    ret
+  end
+
+  def domains_on_splitter(_splitter)
+    domains_on_frame(_splitter.frame1).concat(domains_on_frame(_splitter.frame2))  
+  end
+
+  def domains_on_splitter_cols(_splitter)
+    ret = Array.new
+    domains_on_splitter(_splitter).each{|d|
+      v = d.split('.')[1]
+      ret &lt;&lt; v if !ret.include?(v)
+    }
+    ret
+  end
+
+  def domains_on_splitter_rows(_splitter)
+    ret = Array.new
+    domains_on_splitter(_splitter).each{|d|
+      v = d.split('.')[0]
+      ret &lt;&lt; v if !ret.include?(v)
+    }
+    ret
+  end
+
+
+  def domains_on_frame(_frame)
+    ret_doms = Array.new
+    frame_found = false
+    @panels.keys.each{|dom|
+      if dom != '_domain_root_'
+         if (@panels[dom]['splitted_frames'] != nil &amp;&amp; @panels[dom]['splitted_frames'].frame == _frame) || (@panels[dom]['root_splitted_frames'] != nil &amp;&amp; @panels[dom]['root_splitted_frames'].frame  == _frame)
+           ret_doms.concat(domains_on_frame(@panels[dom]['splitted_frames'].frame1))
+           ret_doms.concat(domains_on_frame(@panels[dom]['splitted_frames'].frame2))
+           frame_found = true
+           break
+         elsif @panels[dom]['notebook'] != nil 
+           cfrs = TkWinfo.children(_frame)
+           if cfrs &amp;&amp; cfrs.length == 1 &amp;&amp; cfrs[0].instance_of?(TkTitledFrame) &amp;&amp; TkWinfo.parent(@panels[dom]['notebook'])== cfrs[0].frame
+             ret_doms &lt;&lt; dom
+             frame_found = true
+           end       
+         elsif @panels[dom]['root'].instance_of?(TkTitledFrame) &amp;&amp; @panels[dom]['root'].parent == _frame 
+             ret_doms &lt;&lt; dom
+             frame_found = true
+         end
+      end
+    }    
+    
+    if !frame_found
+      cfrs = TkWinfo.children(_frame)
+      if cfrs &amp;&amp; cfrs.length == 1 &amp;&amp; cfrs[0].instance_of?(TkTitledFrame)
+        @wrappers.each{|name, ffw|
+          if ffw.hinner_frame.frame == cfrs[0].frame
+            ret_doms &lt;&lt; ffw.domain 
+          end
+        }
+      end
+    end
+    return ret_doms
+  end
+
+  def close_runtime_old(_domain)
+    splitted_adapter = find_splitted_frame(@panels[_domain]['root'])
+    splitted_adapter_frame = splitted_adapter.frame
+    vertical = splitted_adapter.instance_of?(AGTkVSplittedFrames)
+    
+    _row, _col = _domain.split('.')
+    
+    if @frames[_row.to_i][_col.to_i] == splitted_adapter.frame1
+      close_first = true
+    elsif @frames[_row.to_i][_col.to_i] == splitted_adapter.frame2
+      close_first = false
+    end
+    
+    return if close_first.nil?    
+    
+    #source_domains = domains_on_frame(splitted_adapter.frame1).concat(domains_on_frame(splitted_adapter.frame2))
+    #Arcadia.console(self,'msg'=&gt;&quot;domini coinvolti = #{source_domains.to_s}&quot;)
+    
+    @panels[_domain]['sons'].each{|name,ffw|
+      unregister_panel(ffw, false, false)
+    }
+    unbuild_titled_frame(_domain)
+    if close_first
+      #left_frame
+      other_ds = domains_on_frame(@panels[_domain]['splitted_frames'].frame2)
+      if other_ds.length == 1
+        source_domain = other_ds[0]
+      elsif other_ds.length &gt; 1
+        max = other_ds.length-1
+        j = 0
+        while j &lt;= max
+          if source_domain.nil?
+            source_domain = other_ds[j]
+          else
+            r,c = source_domain.split('.')
+            new_r,new_c = other_ds[j].split('.')
+            if new_r.to_i &lt; r.to_i || new_r.to_i == r.to_i &amp;&amp; new_c.to_i &lt; c.to_i
+              source_domain = other_ds[j]
+            end
+          end
+          j = j+1
+        end
+      else
+        if vertical
+          source_domain = domain_name(_row.to_i, _col.to_i+1)
+        else
+          source_domain = domain_name(_row.to_i+1, _col.to_i)
+        end
+      end
+      if vertical
+        ref_source_domain = domain_name(_row.to_i, _col.to_i+1)
+      else
+        ref_source_domain = domain_name(_row.to_i+1, _col.to_i)
+      end
+
+      destination_domain = _domain
+            
+      if @panels[source_domain]['splitted_frames'] != @panels[destination_domain]['splitted_frames']
+        if @panels[source_domain]['root_splitted_frames'] &amp;&amp; @panels[source_domain]['root_splitted_frames'] != @panels[destination_domain]['splitted_frames']
+          other_root_splitted_adapter = @panels[source_domain]['root_splitted_frames']
+        elsif @panels[source_domain]['splitted_frames']
+          other_root_splitted_adapter = @panels[source_domain]['splitted_frames']
+        end
+      end
+
+      if other_root_splitted_adapter
+        p &quot;primo quadrante&quot;
+        other_root_splitted_adapter.detach_frame
+        splitted_adapter.detach_frame
+        splitted_adapter.destroy
+        other_root_splitted_adapter.attach_frame(splitted_adapter_frame)
+        if source_domain == ref_source_domain
+          if vertical
+            rows = domains_on_splitter_rows(other_root_splitted_adapter)
+            rows.each{|r|
+              shift_left(r.to_i,_col.to_i)
+            }
+          else
+            cols = domains_on_splitter_cols(other_root_splitted_adapter)
+            cols.each{|c|
+              shift_top(_row.to_i,c.to_i)
+            }
+          end
+        else
+          @panels.delete(_domain)
+          @frames[_row.to_i][_col.to_i] = nil
+         # @domains[_row.to_i][_col.to_i] = nil
+#          ref_r,ref_c = ref_source_domain.split('.')
+#          real_r,real_c=source_domain.split('.')
+#          gap_r = ref_r.to_i - real_r.to_i
+#          gap_c = ref_c.to_i - real_c.to_i
+#          if gap_r != 0 &amp;&amp; gap_c == 0 # vertical
+#            doms = domains_on_splitter(other_root_splitted_adapter)
+#            doms.each{|d|
+#              r,c=d.split('.')
+#              cur_r = r.to_i+gap_r
+#              cur_domain = &quot;#{cur_r}.#{_col}&quot;
+#              if @panels[cur_domain] != nil
+#                shift_bottom(cur_r,_col.to_i)
+#              end
+#              @panels[cur_domain] = @panels[d]
+#              @panels[cur_domain]['root'].set_domain(cur_domain)
+#              @panels[cur_domain]['sons'].each{|name,ffw| ffw.domain=cur_domain}
+#              @frames[cur_r.to_i][_col.to_i] = @frames[r.to_i][c.to_i]
+#              @domains[cur_r.to_i][_col.to_i] = @domains[r.to_i][c.to_i]
+#              
+#              @panels.delete(d)
+#              @frames[r.to_i][c.to_i] = nil
+#              @domains[r.to_i][c.to_i] = nil
+#            }
+#          elsif gap_c != 0
+#          end
+        end
+        @panels.delete(source_domain)
+        if vertical
+          @frames[_row.to_i][_col.to_i+1] = nil
+         # @domains[_row.to_i][_col.to_i+1] = nil
+        else
+          @frames[_row.to_i+1][_col.to_i] = nil
+         # @domains[_row.to_i+1][_col.to_i] = nil
+        end
+      else
+        p &quot;secondo quadrante&quot;
+        source_save = Hash.new
+        source_save.update(@panels[source_domain]['sons']) if @panels[source_domain]
+        source_save.each{|name,ffw|
+          unregister_panel(ffw, false, false)
+        }
+        splitted_adapter.detach_frame
+        splitted_adapter.destroy
+        @panels[destination_domain]['root']=splitted_adapter_frame
+        @frames[_row.to_i][_col.to_i] = splitted_adapter_frame
+       # @domains[_row.to_i][_col.to_i] = destination_domain
+        build_titled_frame(destination_domain)
+        @panels.delete(source_domain)
+        if vertical
+          @frames[_row.to_i][_col.to_i+1] = nil
+         # @domains[_row.to_i][_col.to_i+1] = nil
+        else
+          @frames[_row.to_i+1][_col.to_i] = nil
+         # @domains[_row.to_i+1][_col.to_i] = nil
+        end
+        source_save.each{|name,ffw|
+          ffw.domain = destination_domain
+          register_panel(ffw, ffw.hinner_frame)
+        }
+        #-----
+        parent_splitted_adapter = find_splitted_frame(@panels[destination_domain]['root'])
+        if  parent_splitted_adapter
+          @panels[destination_domain]['splitted_frames']=parent_splitted_adapter
+        else
+          @panels[destination_domain]['splitted_frames']= nil
+        end
+        #-----
+        source_row,source_col = source_domain.split('.')
+#        shift_left(source_row.to_i,source_col.to_i)
+        if vertical
+          shift_left(source_row.to_i,source_col.to_i-1)
+        else
+          shift_top(source_row.to_i-1,source_col.to_i)
+        end
+      end
+    else  # CLOSE OTHER
+      # verifichiamo se la contro parte &#195;&#402;&#194;&#402;&#195;&#8218;&#194;&#168; uno splitter_adapter
+      other_ds = domains_on_frame(@panels[_domain]['splitted_frames'].frame1)
+      if other_ds.length == 1
+        other_dom = other_ds[0]
+      else
+        if vertical
+          other_dom = domain_name(_row.to_i, _col.to_i-1)
+        else
+          other_dom = domain_name(_row.to_i-1, _col.to_i)
+        end
+      end
+      if @panels[_domain]['splitted_frames'] != @panels[other_dom]['splitted_frames']
+        if @panels[other_dom]['root_splitted_frames'] &amp;&amp; @panels[other_dom]['root_splitted_frames'] != @panels[_domain]['splitted_frames']
+          other_root_splitted_adapter = @panels[other_dom]['root_splitted_frames']
+        elsif @panels[other_dom]['splitted_frames']
+          other_root_splitted_adapter = @panels[other_dom]['splitted_frames']
+        end
+      end
+
+      if other_root_splitted_adapter
+        p &quot;terzo quadrante&quot;
+        other_root_splitted_adapter.detach_frame
+        splitted_adapter.detach_frame
+        splitted_adapter.destroy
+        other_root_splitted_adapter.attach_frame(splitted_adapter_frame)
+
+        @frames[_row.to_i][_col.to_i] = nil
+       # @domains[_row.to_i][_col.to_i] = nil
+        @panels.delete(_domain)
+      else
+        p &quot;quarto quadrante&quot;
+        source_save = Hash.new
+        source_save.update(@panels[other_dom]['sons'])
+        source_save.each{|name,ffw|
+          unregister_panel(ffw, false, false)
+        }
+        splitted_adapter.detach_frame
+        splitted_adapter.destroy
+        @panels[other_dom]['root']=splitted_adapter_frame 
+
+        @frames[_row.to_i][_col.to_i] = nil
+       # @domains[_row.to_i][_col.to_i] = nil
+        build_titled_frame(other_dom)
+        @panels.delete(_domain)
+  
+        source_save.each{|name,ffw|
+          ffw.domain = other_dom
+          register_panel(ffw, ffw.hinner_frame)
+        }
+        #-----
+        parent_splitted_adapter = find_splitted_frame(@panels[other_dom]['root'])
+        if  parent_splitted_adapter
+          @panels[other_dom]['splitted_frames']=parent_splitted_adapter
+        else
+          @panels[other_dom]['splitted_frames']= nil
+        end
+        other_row,other_col = other_dom.split('.')
+        @frames[other_row.to_i][other_col.to_i] = splitted_adapter_frame
+       # @domains[other_row.to_i][other_col.to_i] = other_dom
+#        if vertical
+#          @frames[_row.to_i][_col.to_i-1] = splitted_adapter_frame
+#         # @domains[_row.to_i][_col.to_i-1] = other_dom
+#        else
+#          @frames[_row.to_i-1][_col.to_i] = splitted_adapter_frame
+#         # @domains[_row.to_i-1][_col.to_i] = other_dom
+#        end
+      end
+
+      if vertical
+        shift_left(_row.to_i,_col.to_i)
+      else
+        shift_top(_row.to_i,_col.to_i)
+      end
+    end 
+    build_invert_menu(true)
+  end
+
+  def find_splitted_frame(_start_frame)
+    splitted_frame = _start_frame
+    while splitted_frame != nil &amp;&amp; !splitted_frame.kind_of?(AGTkSplittedFrames)
+      splitted_frame = TkWinfo.parent(splitted_frame)
+    end
+    splitted_frame
+  end
+#--
+  def close_runtime(_domain)
+    splitted_adapter = find_splitted_frame(@panels[_domain]['root'])
+    splitted_adapter_frame = splitted_adapter.frame
+    vertical = splitted_adapter.instance_of?(AGTkVSplittedFrames)
+    _row, _col = _domain.split('.')
+    if @frames[_row.to_i][_col.to_i] == splitted_adapter.frame1
+      other_ds = domains_on_frame(@panels[_domain]['splitted_frames'].frame2)
+    elsif @frames[_row.to_i][_col.to_i] == splitted_adapter.frame2
+      other_ds = domains_on_frame(@panels[_domain]['splitted_frames'].frame1)
+    end
+
+    return if other_ds.nil?    
+
+
+    if other_ds.length == 1
+      other_domain = other_ds[0]
+    elsif other_ds.length &gt; 1
+      max = other_ds.length-1
+      j = 0
+      while j &lt;= max
+        if other_domain.nil?
+          other_domain = other_ds[j]
+        else
+          r,c = other_domain.split('.')
+          new_r,new_c = other_ds[j].split('.')
+          if new_r.to_i &lt; r.to_i || new_r.to_i == r.to_i &amp;&amp; new_c.to_i &lt; c.to_i
+            other_domain = other_ds[j]
+          end
+        end
+        j = j+1
+      end
+    end
+    _other_row, _other_col = other_domain.split('.')
+    @panels[_domain]['sons'].each{|name,ffw|
+      unregister_panel(ffw, false, false)
+    }
+    unbuild_titled_frame(_domain)
+
+    if @panels[other_domain]['splitted_frames'] != @panels[_domain]['splitted_frames']
+      if @panels[other_domain]['root_splitted_frames'].frame == @panels[_domain]['splitted_frames'].frame1 || @panels[other_domain]['root_splitted_frames'].frame == @panels[_domain]['splitted_frames'].frame2
+        other_root_splitted_adapter = @panels[other_domain]['root_splitted_frames']
+      elsif @panels[other_domain]['splitted_frames']
+        other_root_splitted_adapter = @panels[other_domain]['splitted_frames']
+      end
+    end
+
+    @panels.delete(_domain)
+    @frames[_row.to_i][_col.to_i] = nil
+   # @domains[_row.to_i][_col.to_i] = nil
+
+    if other_root_splitted_adapter
+      if other_root_splitted_adapter != @panels[other_domain]['splitted_frames']
+        other_ds.each{|d|
+          if @panels[d]['root_splitted_frames'] == splitted_adapter
+            @panels[d]['root_splitted_frames']=other_root_splitted_adapter
+          end
+        }
+      end
+      other_root_splitted_adapter.detach_frame
+      splitted_adapter.detach_frame
+      @splitters.delete(splitted_adapter)
+      splitted_adapter.destroy
+      other_root_splitted_adapter.attach_frame(splitted_adapter_frame)
+    else
+      other_source_save = Hash.new
+      other_source_save.update(@panels[other_domain]['sons']) if @panels[other_domain]
+      other_source_save.each{|name,ffw|
+        unregister_panel(ffw, false, false)
+      }
+      splitted_adapter.detach_frame
+      splitted_adapter.destroy
+      @panels[other_domain]['root']=splitted_adapter_frame
+      @frames[_other_row.to_i][_other_col.to_i] = splitted_adapter_frame
+      build_titled_frame(other_domain)
+      other_source_save.each{|name,ffw|
+        ffw.domain = other_domain
+        register_panel(ffw, ffw.hinner_frame)
+      }
+      parent_splitted_adapter = find_splitted_frame(@panels[other_domain]['root'])
+      if  parent_splitted_adapter
+        @panels[other_domain]['splitted_frames']=parent_splitted_adapter
+      else
+        @panels[other_domain]['splitted_frames']= nil
+      end
+    end
+    build_invert_menu(true)
+  end
+
+#--
+  
+  def unbuild_titled_frame(domain)
+    if @panels[domain]
+      parent = @panels[domain]['root'].parent
+      @panels[domain]['root'].destroy
+      @panels[domain]['root']=parent
+    end
+  end
+  
+  def add_commons_menu_items(_domain, _menu)
+      _menu.insert('end', :separator)
+      _menu.insert('end',:command,
+          :label=&gt;&quot;add column&quot;,
+          :image=&gt;TkPhotoImage.new('dat'=&gt;ADD_GIF),
+          :compound=&gt;'left',
+          :command=&gt;proc{add_cols_runtime(_domain)},
+          :hidemargin =&gt; true
+      )
+      _menu.insert('end',:command,
+          :label=&gt;&quot;add row&quot;,
+          :image=&gt;TkPhotoImage.new('dat'=&gt;ADD_GIF),
+          :compound=&gt;'left',
+          :command=&gt;proc{add_rows_runtime(_domain)},
+          :hidemargin =&gt; true
+      )
+      if @panels.keys.length &gt; 2
+        _menu.insert('end',:command,
+            :label=&gt;&quot;close&quot;,
+            :image=&gt;TkPhotoImage.new('dat'=&gt;CLOSE_FRAME_GIF),
+            :compound=&gt;'left',
+            :command=&gt;proc{close_runtime(_domain)},
+            :hidemargin =&gt; true
+        )
+      end
+  end
+  
+  def build_titled_frame(domain)
+    if @panels[domain]
+      tframe = TkTitledFrame.new(@panels[domain]['root']).place('x'=&gt;0, 'y'=&gt;0,'relheight'=&gt;1, 'relwidth'=&gt;1)
+      mb = tframe.add_menu_button('ext')
+      # add commons item
+      menu = mb.cget('menu')
+      add_commons_menu_items(domain, menu)
+      @panels[domain]['root']= tframe
+      #-----------------------------------
+#      class &lt;&lt; tframe
+#        def set_domain(_domain)
+#          if @label_domain.nil?
+#            @label_domail = TkLabel.new(self.frame, 'text'=&gt;_domain).pack
+#          else
+#            @label_domain.configure('text'=&gt;_domain)
+#          end
+#        end
+#      end
+#      tframe.set_domain(domain)
+      #-----------------------------------
+    end
+  end
+  
+  def domains
+    ret = Array.new
+    @panels.keys.each{|dom|
+        if dom != '_domain_root_' &amp;&amp; @panels[dom] &amp;&amp; @panels[dom]['root']
+          ret &lt;&lt; dom
+        end
+    }
+    ret
+  end
+  
+  def add_headers
+    @panels.keys.each{|dom|
+        if dom != '_domain_root_' &amp;&amp; @panels[dom] &amp;&amp; @panels[dom]['root']
+          build_titled_frame(dom)
+        end
+    }
+
+#    @domains.each{|row|
+#      row.each{|domain|
+#        build_titled_frame(domain)
+#      }
+#    }
+    @headed = true
+  end
+
+  def headed?
+    @headed
+  end
+
+  def autotab?
+    @autotab
+  end
+
+  def registed?(_domain_name, _name)
+    @panels[_domain_name]['sons'][_name] != nil
+  end
+
+  def change_domain(_target_domain, _source_name)
+    tt1= @panels[_target_domain]['root'].top_text
+    source_domain = @wrappers[_source_name].domain
+    source_has_domain = !source_domain.nil?
+    tt2= @panels[source_domain]['root'].top_text if source_has_domain
+    if @arcadia.conf('layout.exchange_panel_if_no_tabbed')=='true' &amp;&amp; source_has_domain &amp;&amp; @panels[source_domain]['sons'].length ==1 &amp;&amp; @panels[_target_domain]['sons'].length &gt; 0
+      # change ------
+      ffw1 = raised_fixed_frame(_target_domain)
+      ffw2 = @panels[source_domain]['sons'].values[0]
+      unregister_panel(ffw1,false,false) if ffw1
+      unregister_panel(ffw2,false,false)
+      ffw1.domain = source_domain if ffw1
+      ffw2.domain = _target_domain
+      register_panel(ffw1, ffw1.hinner_frame) if ffw1
+      register_panel(ffw2, ffw2.hinner_frame)
+      @panels[_target_domain]['root'].top_text(tt2)
+      @panels[source_domain]['root'].top_text(tt1)
+    elsif source_has_domain &amp;&amp; @panels[source_domain]['sons'].length &gt;= 1
+      ffw2 = @panels[source_domain]['sons'][_source_name]
+      unregister_panel(ffw2, false, false)
+      ffw2.domain = _target_domain
+      register_panel(ffw2, ffw2.hinner_frame)
+      @panels[_target_domain]['root'].top_text(tt2)
+      @panels[source_domain]['root'].top_text('')
+    elsif !source_has_domain
+      ffw2 = @wrappers[_source_name]
+      ffw2.domain = _target_domain
+      register_panel(ffw2, ffw2.hinner_frame)
+      @panels[_target_domain]['root'].top_text('')
+    end
+    # refresh -----
+    build_invert_menu
+  end
+
+
+#  def change_domain_old(_dom1, _dom2, _name2)
+#    tt1= @panels[_dom1]['root'].top_text
+#    tt2= @panels[_dom2]['root'].top_text
+#    if  @panels[_dom2]['sons'].length ==1 &amp;&amp; @panels[_dom1]['sons'].length &gt; 0
+#      # change ------
+#      ffw1 = raised_fixed_frame(_dom1)
+#      ffw2 = @panels[_dom2]['sons'].values[0]
+#      unregister_panel(ffw1,false,false) if ffw1
+#      unregister_panel(ffw2,false,false)
+#      ffw1.domain = _dom2 if ffw1
+#      ffw2.domain = _dom1
+#      register_panel(ffw1, ffw1.hinner_frame) if ffw1
+#      register_panel(ffw2, ffw2.hinner_frame)
+#      @panels[_dom1]['root'].top_text(tt2)
+#      @panels[_dom2]['root'].top_text(tt1)
+#    elsif @panels[_dom2]['sons'].length &gt; 1
+#      ffw2 = @panels[_dom2]['sons'][_name2]
+#      unregister_panel(ffw2, false, false)
+#      ffw2.domain = _dom1
+#      register_panel(ffw2, ffw2.hinner_frame)
+#      @panels[_dom1]['root'].top_text(tt2)
+#      @panels[_dom2]['root'].top_text('')
+#    end
+#    # refresh -----
+#    build_invert_menu
+#  end
+
+  def process_frame(_ffw)
+  #def process_frame(_domain_name, _frame_name)
+    #domain_root = @panels[_domain_name]['sons'][_frame_name]
+    @panels.keys.each{|dom|
+      if  dom != '_domain_root_' &amp;&amp; dom != _ffw.domain &amp;&amp; @panels[dom] &amp;&amp; @panels[dom]['root']
+        titledFrame = @panels[dom]['root']
+        if titledFrame.instance_of?(TkTitledFrame)
+          menu = @panels[dom]['root'].menu_button('ext').cget('menu')
+          menu.insert('0',:command,
+                :label=&gt;_ffw.title,
+                :image=&gt;TkPhotoImage.new('dat'=&gt;ARROW_LEFT_GIF),
+                :compound=&gt;'left',
+                :command=&gt;proc{change_domain(dom, _ffw.name)},
+                :hidemargin =&gt; true
+          )
+        end
+      end
+    }
+  end
+
+  
+  def build_invert_menu(refresh_commons_items=false)
+    @panels.keys.each{|dom|
+      if dom != '_domain_root_' &amp;&amp; @panels[dom] &amp;&amp; @panels[dom]['root']
+        titledFrame = @panels[dom]['root']
+        if titledFrame.instance_of?(TkTitledFrame)
+          menu = titledFrame.menu_button('ext').cget('menu')
+          if refresh_commons_items
+             @panels[dom]['root'].menu_button('ext').cget('menu').delete('0','end')
+             add_commons_menu_items(dom, menu)
+          else
+            if @panels.keys.length &gt; 2
+              i=menu.index('end').to_i-4
+            else
+              i=menu.index('end').to_i-3
+            end
+            if i &gt;= 0
+              end_index = i.to_s
+              @panels[dom]['root'].menu_button('ext').cget('menu').delete('0',end_index)
+            end
+          end
+        end
+      end
+    }
+    
+    @wrappers.each{|name,ffw|
+      process_frame(ffw) #if ffw.domain
+    }
+  end
+  
+#  def register_panel_old(_domain_name, _name, _title)
+#    p = @panels[_domain_name]
+#    if p!=nil
+#      num = p['sons'].length
+#      if @headed
+#        p['root'].title(_title)
+#        if !p['root'].frame.instance_of?(TkFrameAdapter)
+#          wrapper = TkFrameAdapter.new(self.root, Arcadia.style('frame'))
+#          wrapper.attach_frame(p['root'].frame)
+#          p['root'].frame=wrapper
+#        end
+#        root_frame = p['root'].frame
+#        process_register_panel(_domain_name)
+#      else
+#        root_frame = p['root']
+#      end
+#      if (num == 0 &amp;&amp; @autotab)
+#        api = ArcadiaPanelInfo.new(_name,_title,nil)
+#        api.frame = TkFrame.new(root_frame, Arcadia.style('panel')).place('x'=&gt;0, 'y'=&gt;0, 'relwidth'=&gt;1, 'relheight'=&gt;1)
+#        p['sons'][_name] = api
+#        return api.frame
+#      else
+#        if num == 1 &amp;&amp; @autotab &amp;&amp;  p['notebook'] == nil
+#          p['notebook'] = Tk::BWidget::NoteBook.new(root_frame, Arcadia.style('tabpanel')){
+#            tabbevelsize 0
+#            internalborderwidth 0
+#            pack('fill'=&gt;'both', :padx=&gt;0, :pady=&gt;0, :expand =&gt; 'yes')
+#          }
+#          api = p['sons'].values[0]
+#          api_tab_frame = p['notebook'].insert('end',
+#            api.name,
+#            'text'=&gt;api.title,
+#            'raisecmd'=&gt;proc{
+#  					    p['root'].title(api.title)
+#  					    p['root'].top_text('')            
+#               changed
+#              notify_observers('RAISE', api.name)
+#            }
+#          )
+#          api.frame.place('in'=&gt;api_tab_frame, 'x'=&gt;0, 'y'=&gt;0, 'relwidth'=&gt;1, 'relheight'=&gt;1)
+#          api.frame.raise
+#        elsif (num==0 &amp;&amp; !@autotab)
+#          p['notebook'] = Tk::BWidget::NoteBook.new(root_frame){
+#            tabbevelsize 0
+#            internalborderwidth 0
+#            pack('fill'=&gt;'both', :padx=&gt;0, :pady=&gt;0, :expand =&gt; 'yes')
+#          }
+#        end
+#        _panel = p['notebook'].insert('end',_name , 
+#        		'text'=&gt;_title, 
+#          'raisecmd'=&gt;proc{
+#					  p['root'].title(_title)            
+#            changed
+#            notify_observers('RAISE', _name)
+#          }
+#        		)
+#        p['sons'][_name] = ArcadiaPanelInfo.new(_name,_title,_panel)
+#        p['notebook'].raise(_name)
+#        return _panel
+#      end
+#    else
+#      Arcadia.dialog(self, 
+#        'type'=&gt;'ok',
+#        'msg'=&gt;&quot;domain #{_domain_name} do not exist\nfor '#{_title}'!&quot;,
+#        'level'=&gt;'warning' 
+#      )
+#      float_frame = new_float_frame
+#      float_frame.title(_title)
+#      return float_frame.frame
+#    end
+#  end
+
+  def register_panel(_ffw, _adapter=nil)
+    _domain_name = _ffw.domain
+    _name = _ffw.name
+    _title = _ffw.title
+    pan = @panels[_domain_name]
+    @wrappers[_name]=_ffw
+    if pan!=nil
+      num = pan['sons'].length
+      if @headed
+        pan['root'].title(_title)
+        if !pan['root'].frame.instance_of?(TkFrameAdapter) &amp;&amp; num==0
+          if _adapter
+            adapter = _adapter
+          else
+            adapter = TkFrameAdapter.new(self.root, Arcadia.style('frame'))
+          end
+          adapter.attach_frame(pan['root'].frame)
+          adapter.raise
+          #@wrappers[_name]=wrapper
+        end
+        root_frame = pan['root'].frame
+      else
+        root_frame = pan['root']
+      end
+      if (num == 0 &amp;&amp; @autotab)
+        #api = ArcadiaPanelInfo.new(_name,_title,wrapper,_ffw)
+        pan['sons'][_name] = _ffw
+        process_frame(_ffw)
+        return adapter
+      else
+        if num == 1 &amp;&amp; @autotab &amp;&amp;  pan['notebook'] == nil
+          pan['notebook'] = Tk::BWidget::NoteBook.new(root_frame, Arcadia.style('titletabpanel')){
+            tabbevelsize 0
+            internalborderwidth 0
+            pack('fill'=&gt;'both', :padx=&gt;0, :pady=&gt;0, :expand =&gt; 'yes')
+          }
+          api = pan['sons'].values[0]
+          api_tab_frame = pan['notebook'].insert('end',
+            api.name,
+            'text'=&gt;api.title,
+            'raisecmd'=&gt;proc{
+  					    pan['root'].title(api.title)
+  					    pan['root'].top_text('') 
+         	     Arcadia.process_event(LayoutRaisingFrameEvent.new(self,'extension_name'=&gt;_ffw.extension, 'frame_name'=&gt;_ffw.name))
+
+#               changed
+#               notify_observers('RAISE', api.name)
+            }
+          )
+          adapter = api.hinner_frame
+          adapter.detach_frame
+          adapter.attach_frame(api_tab_frame)
+          api.hinner_frame.raise
+        elsif (num==0 &amp;&amp; !@autotab)
+          pan['notebook'] = Tk::BWidget::NoteBook.new(root_frame, Arcadia.style('titletabpanel')){
+            tabbevelsize 0
+            internalborderwidth 0
+            pack('fill'=&gt;'both', :padx=&gt;0, :pady=&gt;0, :expand =&gt; 'yes')
+          }
+        end
+        _panel = pan['notebook'].insert('end',_name , 
+        		'text'=&gt;_title, 
+          'raisecmd'=&gt;proc{
+					  pan['root'].title(_title)            
+      	     Arcadia.process_event(LayoutRaisingFrameEvent.new(self,'extension_name'=&gt;_ffw.extension, 'frame_name'=&gt;_ffw.name))
+#            changed
+#            notify_observers('RAISE', _name)
+          }
+        		)
+        if _adapter
+          adapter = _adapter
+        else
+          adapter = TkFrameAdapter.new(self.root, Arcadia.style('frame'))
+        end
+        adapter.attach_frame(_panel)
+        adapter.raise
+        _panel=adapter
+        #@wrappers[_name]=wrapper
+        #p['sons'][_name] = ArcadiaPanelInfo.new(_name,_title,_panel,_ffw)
+        pan['sons'][_name] = _ffw
+        pan['notebook'].raise(_name)
+        process_frame(_ffw)
+        return _panel
+      end
+    else
+      _ffw.domain = nil
+      process_frame(_ffw)
+      return TkFrameAdapter.new(self.root, Arcadia.style('frame'))
+      
+#
+#      Arcadia.dialog(self, 
+#        'type'=&gt;'ok',
+#        'msg'=&gt;&quot;domain #{_domain_name} do not exist\nfor '#{_title}'!&quot;,
+#        'level'=&gt;'warning' 
+#      )
+#      float_frame = new_float_frame
+#      float_frame.title(_title)
+#      return float_frame.frame
+    end
+  end
+
+
+  def unregister_panel(_ffw, delete_wrapper=true, refresh_menu=true)
+    #p &quot;unregister #{_name} ------&gt; 1&quot;
+    _domain_name = _ffw.domain
+    _name = _ffw.name
+    @panels[_domain_name]['sons'][_name].hinner_frame.detach_frame
+    if delete_wrapper
+      @wrappers.delete(_name).hinner_frame.destroy 
+    else
+      @wrappers[_name].domain=nil
+    end
+    @panels[_domain_name]['sons'].delete(_name)
+    #p &quot;unregister #{_name} ------&gt; 2&quot;
+    if @panels[_domain_name]['sons'].length == 1
+      w = @panels[_domain_name]['sons'].values[0].hinner_frame
+      t = @panels[_domain_name]['sons'].values[0].title
+      w.detach_frame
+      w.attach_frame(@panels[_domain_name]['root'].frame)
+      @panels[_domain_name]['root'].title(t)
+      @panels[_domain_name]['notebook'].destroy
+      @panels[_domain_name]['notebook']=nil
+    elsif @panels[_domain_name]['sons'].length &gt; 1
+      @panels[_domain_name]['notebook'].delete(_name) if @panels[_domain_name]['notebook'].index(_name) &gt; 0
+      #p &quot;unregister #{_name} ------&gt; 3&quot;
+      new_raise_key = @panels[_domain_name]['sons'].keys[@panels[_domain_name]['sons'].length-1]
+      #p &quot;unregister #{_name} ------&gt; 4&quot;
+      @panels[_domain_name]['notebook'].raise(new_raise_key)
+      #p &quot;unregister #{_name} ------&gt; 5&quot;
+    elsif @panels[_domain_name]['sons'].length == 0
+      @panels[_domain_name]['root'].title('')
+    end
+    build_invert_menu if refresh_menu
+  end
+
+  def view_panel
+  end
+
+  def hide_panel
+  end
+
+  def [](_row, _col)
+    @frames[_row][_col]
+  end
+  
+  def frame(_domain_name, _name)
+    @panels[_domain_name]['sons'][_name].frame
+  end
+
+#  def domain_for_frame(_domain_name, _name)
+#    domain(@panels[_domain_name]['sons'][_name].domain)
+#  end
+
+  def domain(_domain_name)
+    @panels[_domain_name]
+  end
+  
+  def domain_root_frame(_domain_name)
+    @panels[_domain_name]['root'].frame
+  end
+  
+  def new_float_frame(_args=nil)
+    if _args.nil?
+     _args = {'x'=&gt;10, 'y'=&gt;10, 'width'=&gt;100, 'height'=&gt;100}
+    end
+    _frame =  TkFloatTitledFrame.new(root)
+    _frame.on_close=proc{_frame.hide}
+    _frame.place(_args)
+    return _frame
+  end
+  
+  def dump_splitter(_splitter)
+    ret = ''
+    if  _splitter.instance_of?(AGTkVSplittedFrames)
+      w = TkWinfo.width(_splitter.frame1) 
+      ret = &quot;c#{w}&quot;
+    elsif _splitter.instance_of?(AGTkOSplittedFrames)
+      h = TkWinfo.height(_splitter.frame1) 
+      ret = &quot;r#{h}&quot;
+    end
+    ret
+  end
+  
+  def splitter_frame_on_frame(_frame)
+    ret=nil
+    @splitters.each{|sp|
+       if sp.frame == _frame
+         ret = sp
+         break 
+       end
+    }
+    ret
+  end
+  
+  def get_hinner_frame(_frame)
+    ret = _frame
+#    child = TkWinfo.children(_frame)[0]
+    TkWinfo.children(_frame).each{|child|
+      if child.instance_of?(TkTitledFrame)
+        ret = child.frame
+        break
+      end
+    }
+#    if child.instance_of?(TkTitledFrame)
+#      ret = child.frame
+#    end
+    ret
+  end
+  
+  def shift_domain_column(_r,_c,_dom)
+    Hash.new.update(_dom).each{|k,d|
+      dr,dc=d.split('.')
+      if dc.to_i &gt;= _c &amp;&amp; dr.to_i == _r 
+        #shift_domain_column(_r,dc.to_i+1,_dom)
+        p &quot;== #{d} --&gt; #{domain_name(_r,dc.to_i+1)}&quot;
+        _dom[k]= domain_name(_r,dc.to_i+1)
+      end
+    }
+  end
+
+  def shift_domain_row(_r,_c,_dom)
+    Hash.new.update(_dom).each{|k,d|
+      dr,dc=d.split('.')
+      if dr.to_i &gt;= _r &amp;&amp; dc.to_i == _c 
+         #shift_domain_row(dr.to_i+1,_c,_dom)
+        p &quot;shift_domain_row == #{d} --&gt; #{domain_name(dr.to_i+1,_c)}&quot;
+        _dom[k]=domain_name(dr.to_i+1,_c)
+      end
+    }
+  end
+
+  def gap_domain_column(_r,_c,_dom)
+    ret = _c
+    Hash.new.update(_dom).each{|k,d|
+      dr,dc=d.split('.')
+      if dc.to_i == _c &amp;&amp; dr.to_i == _r 
+        ret = gap_domain_column(_r,dc.to_i+1,_dom)
+      end
+    }
+    ret
+  end
+
+  def gap_domain_row(_r,_c,_dom)
+    ret = _r
+    Hash.new.update(_dom).each{|k,d|
+      dr,dc=d.split('.')
+      if dr.to_i == _r &amp;&amp; dc.to_i == _c 
+         ret = gap_domain_row(dr.to_i+1,_c,_dom)
+      end
+    }
+    ret
+  end
+
+  
+  def dump_geometry(_r=0,_c=0,_frame=root)
+    spl = Array.new
+    dom = Hash.new
+    ret = [nil,nil,nil,nil]
+    sp = splitter_frame_on_frame(_frame)
+    if sp
+      spl &lt;&lt; &quot;#{domain_name(_r,_c)}#{dump_splitter(sp)}&quot;
+      dom[get_hinner_frame(sp.frame1)]=domain_name(_r,_c)
+      sspl,ddom,rr,cc = dump_geometry(_r, _c, sp.frame1)
+      spl.concat(sspl)
+      dom.update(ddom)
+      if sp.instance_of?(AGTkVSplittedFrames)
+        _c=cc+1
+        _c=gap_domain_column(_r,_c,dom)
+      else
+        _r=rr+1
+        _r=gap_domain_row(_r,_c,dom)
+      end
+      dom[get_hinner_frame(sp.frame2)]=domain_name(_r,_c)
+      sspl,ddom,rr,cc = dump_geometry(_r, _c, sp.frame2)
+      spl.concat(sspl)
+      dom.update(ddom)
+    elsif _frame==root
+      dom[get_hinner_frame(root)]=domain_name(_r,_c) 
+    end
+    ret[0]=spl
+    ret[1]=dom
+    ret[2]=_r
+    ret[3]=_c
+    ret
+  end
 end
\ No newline at end of file</diff>
      <filename>lib/a-core.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d1f65de07205cb5f900b17a1994bd5887f5185e2</id>
    </parent>
  </parents>
  <author>
    <name>Antonio Galeone</name>
    <email>antonio.galeone@gmail.com</email>
  </author>
  <url>http://github.com/angal/arcadia/commit/9f8714bee89de3b25e0211746717ca561900eb0a</url>
  <id>9f8714bee89de3b25e0211746717ca561900eb0a</id>
  <committed-date>2009-10-19T14:53:02-07:00</committed-date>
  <authored-date>2009-10-19T14:53:02-07:00</authored-date>
  <message>refactoring, coderay scanner integration for highlight, added Arcadia.file_icon service</message>
  <tree>cd5ed7badb32a9503332d90a2a3000dc592eaefc</tree>
  <committer>
    <name>Antonio Galeone</name>
    <email>antonio.galeone@gmail.com</email>
  </committer>
</commit>
