Class: AgMultiEditor

Inherits:
ArcadiaExtPlus show all
Includes:
Configurable
Defined in:
ext/ae-editor/ae-editor.rb

Constant Summary

Constants included from Configurable

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

Instance Attribute Summary collapse

Attributes inherited from ArcadiaExtPlus

#index

Attributes inherited from ArcadiaExt

#arcadia, #name

Instance Method Summary collapse

Methods included from Configurable

clear_properties_group_cache, #hash2properties_file, #make_locale_value, #make_value, #properties_file2hash, properties_group, #resolve_locale_value, #resolve_properties_link, #resolve_value

Methods inherited from ArcadiaExtPlus

#activate, #activate_main, #active?, #active_instance, #clean_instance, #clone, #deduplicate, #exist_name?, #frame, #initialize, #instance_index, instances, #instances, #main_instance, #main_instance?, #new_name, #on_destroy_instance

Methods inherited from ArcadiaExt

#add_to_conf_property, #array_conf, #conf, #conf_array, #conf_default, #del_from_conf_property, #exec, #float_frame, #frame, #frame_def_visible?, #frame_domain, #frame_domain_default, #frame_visible?, #hide_frame, #initialize, #maximize, #maximized?, #resize, #restore_default_conf

Constructor Details

This class inherits a constructor from ArcadiaExtPlus

Instance Attribute Details

#ctags_stringObject (readonly)

attr_reader :outline_bar



3867
3868
3869
# File 'ext/ae-editor/ae-editor.rb', line 3867

def ctags_string
  @ctags_string
end

#has_ctagsObject (readonly)

attr_reader :outline_bar



3867
3868
3869
# File 'ext/ae-editor/ae-editor.rb', line 3867

def has_ctags
  @has_ctags
end

#main_frameObject (readonly)

Returns the value of attribute main_frame.



3868
3869
3870
# File 'ext/ae-editor/ae-editor.rb', line 3868

def main_frame
  @main_frame
end

#splitted_frameObject (readonly)

attr_reader :breakpoints



3865
3866
3867
# File 'ext/ae-editor/ae-editor.rb', line 3865

def splitted_frame
  @splitted_frame
end

Instance Method Details

#accept_complete_codeObject



5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
# File 'ext/ae-editor/ae-editor.rb', line 5499

def accept_complete_code
  @ok_complete = true
  if !defined?(@ok_complete)
  
#msg =<<EOS
#"Complete code" is actually based on rcodetools 
#that exec code for retreave candidades. 
#So it can be dangerous for example if you write system call. 
#Do you want to activate it?
#EOS
#      @ok_complete = Arcadia.dialog(self, 
#        'level'=>'warning',
#        'type'=>'yes_no', 
#        'title' => '(Arcadia) Complete code', 
#        'msg'=>msg.upcase)=='yes'
    
  end
  return @ok_complete
end

#add_buffer_menu_item(_filename, is_file = true, _sender = self) ⇒ Object



4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
# File 'ext/ae-editor/ae-editor.rb', line 4101

def add_buffer_menu_item(_filename, is_file=true, _sender=self)
  @buffer_number.numeric += 1
  index = 'end'
  i_end = @buffer_menu.index('end')
  if i_end
    0.upto(i_end){|j|
      type = @buffer_menu.menutype(j)
      if type != 'separator'
        #label = @buffer_menu.entrycget(j,'label')
        #if label > _filename
        value = @buffer_menu.entrycget(j,'value').to_s
        if value > _filename
          index=j
          break
        elsif value == _filename
          return nil
        end
      end
    }
  end
  select_buffer = proc{
    if _sender == self
      if is_file
        open_file(_filename)
      else
        open_buffer(tab_name(_filename))             
      end
    else
      if is_file
        move_buffer_here(tab_file_name(_filename))
      else
        move_buffer_here(tab_name(_filename))
      end
    end
  }
  label = File.basename(_filename)
#    if _sender != self
#      label = "-->#{label}"
#    end
  item = @buffer_menu.insert(index,:radio,
    :label=>label,
#      :label=>buffer_menu_item_label(_filename, is_file),
    :accelerator=>buffer_menu_item_accelerator(_filename, is_file),
    :value=>_filename,
    :image=> Arcadia.file_icon(_filename),
    :compound=>'left',
    :command=>select_buffer,
    :hidemargin => true
  )
  if _sender == self
    instances.each{|i|
      if i != self && !i.buffer_menu_item_exist?(_filename)
        i.add_buffer_menu_item(_filename, is_file, self)
        i.refresh_buffer_string
      end
    }
    refresh_buffer_string
  end
  item
end

#bookmark_add(_file, _index) ⇒ Object



4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
# File 'ext/ae-editor/ae-editor.rb', line 4864

def bookmark_add(_file, _index)
  if @bookmarks == nil
    @bookmarks = Array.new
    @bookmarks_index = - 1 
  else
    _cur_file, _cur_index = @bookmarks[@bookmarks_index]
    if _cur_file == _file && _cur_index == _index
      #@arcadia.outln('uguale ----> '+_file+':'+_index)
      return 
    end
    @bookmarks = @bookmarks[0..@bookmarks_index]
  end
  @bookmarks << [_file, _index]
  @bookmarks_index = @bookmarks.length - 1
  #@arcadia.outln('add ----> '+_file+':'+_index)
end

#bookmark_clearObject



4881
4882
4883
4884
# File 'ext/ae-editor/ae-editor.rb', line 4881

def bookmark_clear
  @bookmarks.clear
  @bookmarks_index = - 1
end

#bookmark_move(_n = 0) ⇒ Object



4891
4892
4893
4894
4895
4896
4897
4898
# File 'ext/ae-editor/ae-editor.rb', line 4891

def bookmark_move(_n=0)
  @bookmarks_index = @bookmarks_index + _n
  #Tk.messageBox('message'=>@bookmarks_index.to_s)
  _file, _index = @bookmarks[@bookmarks_index]
  _line, _col = _index.split('.') if _index
  open_file(_file, _index)
  #openfile(@bookmarks[@bookmarks_index])
end

#bookmark_nextObject



4886
4887
4888
4889
# File 'ext/ae-editor/ae-editor.rb', line 4886

def bookmark_next
  return if @bookmarks == nil || @bookmarks_index >= @bookmarks.length - 1
  bookmark_move(+1)
end

#bookmark_prevObject



4901
4902
4903
4904
# File 'ext/ae-editor/ae-editor.rb', line 4901

def bookmark_prev
  return if @bookmarks == nil || @bookmarks_index <= 0
  bookmark_move(-1)
end

#breakpoint_add(_file, _line, _id = -1)) ⇒ Object



4800
4801
4802
# File 'ext/ae-editor/ae-editor.rb', line 4800

def breakpoint_add(_file,_line,_id=-1)
  Arcadia.process_event(SetBreakpointEvent.new(self, 'id'=>_id, 'file'=>_file, 'row'=>_line, 'active'=>1))
end

#breakpoint_del(_file, _line, _id = -1)) ⇒ Object



4804
4805
4806
# File 'ext/ae-editor/ae-editor.rb', line 4804

def breakpoint_del(_file,_line,_id=-1)
  Arcadia.process_event(UnsetBreakpointEvent.new(self, 'id'=>_id, 'file'=>_file, 'row'=>_line))
end

#breakpoint_lines_on_file(_file) ⇒ Object



4808
4809
4810
4811
4812
4813
4814
4815
4816
# File 'ext/ae-editor/ae-editor.rb', line 4808

def breakpoint_lines_on_file(_file)
  result = Array.new
  @breakpoints.each{|value|
    if value[:file]==_file
      result << value[:line]
    end
  }
  return result
end

#buffer_menu_item_accelerator(_text, _is_file = true) ⇒ Object

def buffer_menu_item_label(_text, _is_file=true)

  if _is_file
  #  "#{File.basename(_text)} - #{File.dirname(_text)}"
    File.basename(_text)
  else
    _text
  end
end


4171
4172
4173
4174
4175
4176
4177
# File 'ext/ae-editor/ae-editor.rb', line 4171

def buffer_menu_item_accelerator(_text, _is_file=true)
  if _is_file
    File.dirname(_text)
  else
    '...'
  end
end

#buffer_menu_item_exist?(_filename) ⇒ Boolean

Returns:

  • (Boolean)


4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
# File 'ext/ae-editor/ae-editor.rb', line 4083

def buffer_menu_item_exist?(_filename)
  exist = false
  i_end = @buffer_menu.index('end')
  if i_end
    0.upto(i_end){|j|
      type = @buffer_menu.menutype(j)
      if type != 'separator'
        value = @buffer_menu.entrycget(j,'value').to_s
        if value == _filename
          exist = true
          break
        end
      end
    }
  end
  exist
end

#can_close_editor?(_editor) ⇒ Boolean

Returns:

  • (Boolean)


5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
# File 'ext/ae-editor/ae-editor.rb', line 5409

def can_close_editor?(_editor)
  ret = true
  if _editor.modified?
    filename = page_name(_editor.page_frame)
    message = Arcadia.text('ext.editor.file.save_modified.msg', [@main_frame.page_title(filename)])
    r=Arcadia.dialog(self,
        'type'=>'yes_no_cancel', 
        'level'=>'warning',
        'title'=> Arcadia.text('ext.editor.file.save_modified.title'), 
        'msg'=>message)
    if r=="yes"
      _editor.save
      ret = !_editor.modified?
    elsif r=="cancel"
      ret = false
    end
  elsif _editor.modified_by_others?
    filename = page_name(_editor.page_frame)      
    message = Arcadia.text('ext.editor.file.close_modified_by_other.msg', [@main_frame.page_title(filename)])
    r=Arcadia.dialog(self,
        'type'=>'yes_no', 
        'level'=>'warning',
        'title'=> Arcadia.text('ext.editor.file.close_modified_by_other.title'), 
        'msg'=>message)
    if r=="yes"
      _editor.reset_file_last_access_time
      refresh_status
      ret = !_editor.modified_by_others?
    else
      ret = false
      #raise_file(filename) 
    end
  end
  ret
end

#change_file(_old_file, _new_file) ⇒ Object



5045
5046
5047
5048
5049
5050
5051
# File 'ext/ae-editor/ae-editor.rb', line 5045

def change_file(_old_file, _new_file)
  _tab_name=tab_file_name(_old_file)
  _tab = @main_frame.page_frame(_tab_name)
  e =  @tabs_editor[_tab_name]
  change_file_name(_tab, _new_file)
  e.new_file_name(_new_file) if e
end

#change_file_name(_tab, _new_file) ⇒ Object



5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
# File 'ext/ae-editor/ae-editor.rb', line 5053

def change_file_name(_tab, _new_file)
  @tabs_file[page_name(_tab)] = _new_file
  @raw_buffer_name[tab_file_name(_new_file)]=page_name(_tab)
  _new_label = File.basename(_new_file)
  change_tab_title(_tab, _new_label, _new_file)
  change_tab_icon(_tab, _new_label)
  #change_frame_caption(_new_file)
  #@tabs_editor[tab_file_name(_new_file)]=@tabs_editor[page_name(_tab)]
  #@tabs_file[tab_file_name(_new_file)] = _new_file
  #@tabs_editor[tab_file_name(_new_file)] = editor_of(_new_file)
end

#change_frame_caption(_name, _new_caption) ⇒ Object



5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
# File 'ext/ae-editor/ae-editor.rb', line 5004

def change_frame_caption(_name, _new_caption)
  if @arcadia.layout.headed?
    if frame.root.title == frame.title || @last_frame_caption != _new_caption
      make_buffer_string(@main_frame.page(_name)['text']) if @main_frame.page(_name)
      #@buffer_menu_button.configure('image'=>@main_frame.page(_name)['image']) if @main_frame.page(_name)
#        frame.root.top_text(@main_frame.page(_name)['text'], @main_frame.page(_name)['image']) if @main_frame.page(_name)
      frame.root.top_text(top_text_string, @main_frame.page(_name)['image']) if @main_frame.page(_name)
      frame.root.top_text_hint(_new_caption)
      @last_frame_caption = _new_caption
    end  
#      frame.root.save_caption(frame.name, @main_frame.page(_name)['text'], @main_frame.page(_name)['image'])
  end
end

#change_outline(_e, _raised = false) ⇒ Object



5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
# File 'ext/ae-editor/ae-editor.rb', line 5112

def change_outline(_e, _raised=false)
  return if defined?(@@last_outline_e) && @@last_outline_e == _e
  _raised = _raised || main_instance.frame(1).raised?
  if !@batch_files && _raised
    @@last_outline_e.hide_outline if defined?(@@last_outline_e)
    if _e && _e.file
      change_outline_frame_caption(File.basename(_e.file))
    end
    _e.show_outline
    @@last_outline_e = _e
  end
end

#change_outline_frame_caption(_new_caption) ⇒ Object



5019
5020
5021
5022
5023
5024
5025
5026
# File 'ext/ae-editor/ae-editor.rb', line 5019

def change_outline_frame_caption(_new_caption)
  if @arcadia.layout.headed?
    if main_instance.frame(1).root.title == main_instance.frame(1).title
      main_instance.frame(1).root.top_text(_new_caption)
    end  
    main_instance.frame(1).root.save_caption(frame.name, _new_caption)
  end
end

#change_tab_icon(_tab, _new_text) ⇒ Object



5041
5042
5043
# File 'ext/ae-editor/ae-editor.rb', line 5041

def change_tab_icon(_tab, _new_text)
  @main_frame.page_title(page_name(_tab), nil, Arcadia.file_icon(_new_text))
end

#change_tab_reset_modify(_tab) ⇒ Object



4978
4979
4980
4981
4982
4983
4984
4985
4986
# File 'ext/ae-editor/ae-editor.rb', line 4978

def change_tab_reset_modify(_tab)
  #_new_name = @main_frame.enb.itemcget(@tabs_name[_tab], 'text').gsub!("(...)",'')
  if @main_frame.index(@main_frame.page_name(_tab))
   _new_name = unname_modified(@main_frame.page_title(page_name(_tab)))
   	if _new_name
      change_tab_title(_tab, _new_name)
   	end
  end
end

#change_tab_reset_read_only(_tab) ⇒ Object



4933
4934
4935
4936
4937
4938
# File 'ext/ae-editor/ae-editor.rb', line 4933

def change_tab_reset_read_only(_tab)
  _new_name = unname_read_only(@main_frame.page_title(page_name(_tab)))
  if _new_name
    change_tab_title(_tab, _new_name)
  end
end

#change_tab_set_modify(_tab) ⇒ Object



4941
4942
4943
# File 'ext/ae-editor/ae-editor.rb', line 4941

def change_tab_set_modify(_tab)
  change_tab_title(_tab, name_modified(@main_frame.page_title(page_name(_tab))))
end

#change_tab_set_read_only(_tab) ⇒ Object



4928
4929
4930
4931
# File 'ext/ae-editor/ae-editor.rb', line 4928

def change_tab_set_read_only(_tab)
  _new_name = name_read_only(@main_frame.page_title(page_name(_tab)))
  change_tab_title(_tab, _new_name)
end

#change_tab_title(_tab, _new_text, _new_file = nil) ⇒ Object



5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
# File 'ext/ae-editor/ae-editor.rb', line 5028

def change_tab_title(_tab, _new_text, _new_file=nil)
  p_name = page_name(_tab)
  old_text = @main_frame.page_title(p_name)

  if @tabs_editor[p_name] && @tabs_editor[p_name].file
    mod_buffer_menu_item(@tabs_editor[p_name].file, _new_text, _new_file, self)
  else
    mod_buffer_menu_item(unname_modified(tab_title_by_tab_name(p_name)), _new_text, nil, self)
  end
#    mod_buffer_menu_item(@main_frame.page(p_name)['file'], _new_text)
  @main_frame.page_title(p_name, _new_text)
end

#clear_temp_filesObject



4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
# File 'ext/ae-editor/ae-editor.rb', line 4763

def clear_temp_files
  files = Dir[File.join(Arcadia.instance.local_dir,"*")]
  files.each{|f|
    if File.stat(f).file? && File.basename(f)[0..1] == '~~'
      File.delete(f)
    elsif File.stat(f).directory? && File.basename(f)[0..1] == '~~'
      Dir[File.join(f,"*")].each{|file|
        File.delete(file)
      }
      Dir.delete(f)        
    end
  }
end

#close_all_editor(_editor, _mod = true) ⇒ Object



5401
5402
5403
5404
5405
5406
5407
# File 'ext/ae-editor/ae-editor.rb', line 5401

def close_all_editor(_editor, _mod=true)
  @batch_files = true
		@tabs_editor.values.each do |_e|
		    close_editor(_e)
		end
  @batch_files = false
end

#close_buffer(_name, _moved = false) ⇒ Object



5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
# File 'ext/ae-editor/ae-editor.rb', line 5464

def close_buffer(_name, _moved=false)
  is_raised = @main_frame.raise == _name
  if @tabs_editor[_name] && @tabs_editor[_name].file
    del_buffer_menu_item(@tabs_editor[_name].file)
  else
    del_buffer_menu_item(unname_modified(tab_title_by_tab_name(_name)))
  end
#    @tabs_editor.delete(_name)
#    @tabs_file.delete(_name)
  unregister_editor(_name)  
#    @raw_buffer_name.delete_if {|key, value| value == _name }
  _index = @main_frame.index(_name)
  @main_frame.delete_page(_name, !_moved)
  if !@main_frame.pages.empty? && is_raised
    @main_frame.raise(@main_frame.pages[_index-1]) if TkWinfo.mapped?(@main_frame.root_frame)
  else
    frame.root.top_text_clear if TkWinfo.mapped?(frame.hinner_frame)
    make_buffer_string("")
    reset_status
  end
end

#close_buffer_frame(_page_frame, _moved = false) ⇒ Object



5459
5460
5461
5462
# File 'ext/ae-editor/ae-editor.rb', line 5459

def close_buffer_frame(_page_frame, _moved=false)
  name = page_name(_page_frame)
  close_buffer(name, _moved)
end

#close_editor(_editor, _force = false) ⇒ Object



5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
# File 'ext/ae-editor/ae-editor.rb', line 5445

def close_editor(_editor, _force=false)
  if _force || can_close_editor?(_editor)
    file = _editor.file
    index = _editor.text.index("@0,0")
    r,c = index.split('.')
    _editor.destroy_outline
    change_outline_frame_caption('') if raised==_editor      
    close_buffer_frame(_editor.page_frame)
    BufferClosedEvent.new(self,'file'=>file,'row'=>r.to_i, 'col'=>c.to_i).shot!
  else
    return
  end
end

#close_file(_filename) ⇒ Object



5486
5487
5488
5489
# File 'ext/ae-editor/ae-editor.rb', line 5486

def close_file(_filename)
  _e = @tabs_editor[tab_name(_filename)]
  close_editor(_e) if _e
end

#close_others_editor(_editor, _mod = true) ⇒ Object



5393
5394
5395
5396
5397
5398
5399
# File 'ext/ae-editor/ae-editor.rb', line 5393

def close_others_editor(_editor, _mod=true)
  @batch_files = true
		@tabs_editor.values.each do |_e|
		    close_editor(_e) if _e != _editor
		end
  @batch_files = false
end

#close_raisedObject



4795
4796
4797
4798
# File 'ext/ae-editor/ae-editor.rb', line 4795

def close_raised
  _e = @tabs_editor[resolve_tab_name(@main_frame.raise)]
  close_editor(_e) if _e
end

#create_findObject



4702
4703
4704
4705
4706
# File 'ext/ae-editor/ae-editor.rb', line 4702

def create_find
  @find = Finder.new(@arcadia.layout.root, self)
  @find.on_close=proc{@find.hide}
  @find.hide
end

#debug_beginObject



5065
5066
5067
5068
5069
5070
5071
# File 'ext/ae-editor/ae-editor.rb', line 5065

def debug_begin
  if @editors_in_debug != nil
    @editors_in_debug.clear
  else
    @editors_in_debug = Array.new
  end
end

#debug_endObject



5073
5074
5075
5076
5077
5078
5079
# File 'ext/ae-editor/ae-editor.rb', line 5073

def debug_end
  #debug_reset
  @editors_in_debug.each{|e|
    close_editor(e)
    #p "close editor #{e.file}"
  }
end

#debug_resetObject



5081
5082
5083
5084
5085
# File 'ext/ae-editor/ae-editor.rb', line 5081

def debug_reset
  if @last_index && @last_e
    @last_e.unmark_debug(@last_index)
  end
end

#del_buffer_menu_item(_file, _sender = self) ⇒ Object



4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
# File 'ext/ae-editor/ae-editor.rb', line 4179

def del_buffer_menu_item(_file, _sender=self)
  @buffer_number.numeric -= 1
  to_del = -1
  i_end = @buffer_menu.index('end')
  return if i_end.nil?
  0.upto(i_end){|j|
    type = @buffer_menu.menutype(j)
    if type != 'separator'
      #label = @buffer_menu.entrycget(j,'label')
      #if label == _file
      value = @buffer_menu.entrycget(j,'value')
      if value == _file
        to_del=j
        break
      end
    end
  }
  @buffer_menu.delete(to_del) if to_del != -1
  make_buffer_string("") if @buffer_menu.index('end').nil?
  if _sender == self
    instances.each{|i|
      if i != self
        i.del_buffer_menu_item(_file, self)
        i.refresh_buffer_string
      end
    }
  end
end

#do_buffer_raise(_name, _title = '...') ⇒ Object



5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
# File 'ext/ae-editor/ae-editor.rb', line 5125

def do_buffer_raise(_name, _title='...')
  _index = @main_frame.index(resolve_tab_name(_name))
  _new_caption = '...'
  if _index != -1
    _e = @tabs_editor[resolve_tab_name(_name)]
    change_outline(_e) if _e
    if _e && _e.file != nil
      _new_caption = _e.file
      @find.use(_e)
      _e.check_file_last_access_time
    else
      _new_caption = _title
    end
    _lang = _e.lang
    _e.update_toolbar
  end
  change_frame_caption(_name, _new_caption)
  refresh_status
  _title = @tabs_file[_name] != nil ? File.basename(@tabs_file[_name]) :_name
  Arcadia.broadcast_event(BufferRaisedEvent.new(self, 'title'=>_title, 'file'=>@tabs_file[_name], 'lang'=>_lang ))
  Arcadia.process_event(InputEnterEvent.new(self,'receiver'=>_e.text)) if _e
  refresh_selected_buffer_menu_item
  #EditorContract.instance.buffer_raised(self, 'title'=>_title, 'file'=>@tabs_file[_name])
end

#duplicate(_name = new_name) ⇒ Object



4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
# File 'ext/ae-editor/ae-editor.rb', line 4060

def duplicate(_name=new_name)
  instance = super(_name)    
  i_end = @buffer_menu.index('end')
  if i_end
    0.upto(i_end){|j|
      type = @buffer_menu.menutype(j)
      if type != 'separator'
        #label = @buffer_menu.entrycget(j,'label')
        #if label > _filename
        filename = @buffer_menu.entrycget(j,'value').to_s
        is_file = filename != nil && File.exists?(filename)
        instance.add_buffer_menu_item(filename, is_file, self)
      end
    }
  end
  instance.move_buffer_here(raised_name)
  instance
end

#editor_by_page_name(_name) ⇒ Object



5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
# File 'ext/ae-editor/ae-editor.rb', line 5206

def editor_by_page_name(_name)
  _ret = nil
  _index = @main_frame.index(resolve_tab_name(_name))
  if _index == -1
    _name = name_read_only(_name)
    _index = @main_frame.index(resolve_tab_name(_name))
  end
  if _index != -1
    _ret = @tabs_editor[resolve_tab_name(_name)]
  end
  _ret
end

#editor_exist?(_filename) ⇒ Boolean

Returns:

  • (Boolean)


5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
# File 'ext/ae-editor/ae-editor.rb', line 5219

def editor_exist?(_filename)
  _basefilename = File.basename(_filename)
  #_basename = _basefilename.split('.')[0]+'_'+_basefilename.split('.')[1]
  
  _name = self.tab_file_name(_filename)
  _index = @main_frame.index(resolve_tab_name(_name))
  if _index == -1
    _index = @main_frame.index(resolve_tab_name(name_read_only(_name)))
  end
  if _index == -1
    @editors.each{|e|
      if e.last_tmp_file == _filename
        _index = 0
        break
      end
    } 
  end
  return _index != -1
end

#editor_of(_filename) ⇒ Object



5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
# File 'ext/ae-editor/ae-editor.rb', line 5183

def editor_of(_filename)
  _ret = nil
  @editors.each{|e|
    if e.file == _filename || e.last_tmp_file == _filename
      _ret = e
      break
    end
  } 
  if _ret.nil?
    _basefilename = File.basename(_filename)
    _name = self.tab_file_name(_filename)
    _index = @main_frame.index(resolve_tab_name(_name))
    if _index == -1
      _name = name_read_only(_name)
      _index = @main_frame.index(resolve_tab_name(_name))
    end
    if _index != -1
      _ret = @tabs_editor[resolve_tab_name(_name)]
    end
  end
  _ret
end

#get_findObject



4698
4699
4700
# File 'ext/ae-editor/ae-editor.rb', line 4698

def get_find
  @find
end

#highlight_scanner(_ext = nil) ⇒ Object



4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
# File 'ext/ae-editor/ae-editor.rb', line 4312

def highlight_scanner(_ext=nil)
  return nil if _ext.nil?
  scanner = nil
  @highlight_scanner_hash = Hash.new if !defined?(@highlight_scanner_hash)
  lh = language_hash_by_ext(_ext)
  if lh && lh['language'] && 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

#initialize_statusObject



5150
5151
5152
5153
5154
5155
5156
5157
# File 'ext/ae-editor/ae-editor.rb', line 5150

def initialize_status
  if !defined?(@@statusbar_items)
    @@statusbar_items = Hash.new
    @@statusbar_items['file_size'] = Arcadia.new_statusbar_item("File size")
    @@statusbar_items['file_mtime'] = Arcadia.new_statusbar_item("File modification time")
    @@statusbar_items['file_name'] = Arcadia.new_statusbar_item("File name")
  end
end

#language_hash_by_ext(_ext = nil) ⇒ Object



4361
4362
4363
# File 'ext/ae-editor/ae-editor.rb', line 4361

def language_hash_by_ext(_ext=nil)
  @langs_hash_by_ext[_ext]
end

#language_hash_by_lang(_lang = nil) ⇒ Object



4365
4366
4367
# File 'ext/ae-editor/ae-editor.rb', line 4365

def language_hash_by_lang(_lang=nil)
  @langs_hash_by_lang[_lang]
end

#load_languages_hashObject



4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
# File 'ext/ae-editor/ae-editor.rb', line 4331

def load_languages_hash
  @langs_hash_by_ext = Hash.new
  @langs_hash_by_lang = Hash.new
  lang_files_dir = "#{File.dirname(__FILE__)}/langs"
  files = Dir["#{lang_files_dir}/*"].sort
	 files.each{|lang_file|
    af = lang_file.split('.')
    if af[-1] == 'lang'
  	   lang_props = properties_file2hash(lang_file)
      if lang_props && lang_props['@include'] != nil
        include_file = "#{lang_files_dir}/#{lang_props['@include']}"
        if File.exist?(include_file)
          include_hash = properties_file2hash(include_file)
          lang_props = include_hash.merge(lang_props)
        end
      end 
      self.resolve_properties_link(lang_props, Arcadia.instance['conf']) if lang_props
      lang = lang_props['language']
      lang_exts = lang_props['exts'].split(',').collect{|x| x.strip} if lang_props['exts']
      @langs_hash_by_lang[lang] = lang_props if lang
      lang_exts.each{|ext|
        @langs_hash_by_ext[ext] = lang_props
      } if lang_exts
    
    
    
    end
  }
end

#make_buffer_string(_str = nil) ⇒ Object



4992
4993
4994
4995
4996
4997
# File 'ext/ae-editor/ae-editor.rb', line 4992

def make_buffer_string(_str=nil)
  value = "[#{@buffer_number.value}] #{_str}"
  #@buffer_menu_button.configure(:text => )
  @last_buffer_str = _str
  @buffer_string.value = value
end

#mod_buffer_menu_item(_file, _newtext, _newvalue = nil, _sender = self) ⇒ Object



4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
# File 'ext/ae-editor/ae-editor.rb', line 4208

def mod_buffer_menu_item(_file, _newtext, _newvalue = nil, _sender=self)
  to_mod = -1
  i_end = @buffer_menu.index('end')
  0.upto(i_end){|j|
    type = @buffer_menu.menutype(j)
    if type != 'separator'
      value = @buffer_menu.entrycget(j,'value')
      if value == _file
        to_mod=j
        break
      end
    end
  }
  if _file != nil && _newvalue.nil? && File.exists?(_file)
    #new_label = buffer_menu_item_label(_file, true)
    new_accelerator = buffer_menu_item_accelerator(_file, true)
  else
    is_file = _newvalue != nil && File.exists?(_newvalue)
    if is_file
     # new_label = buffer_menu_item_label(_newvalue, is_file)
      new_accelerator = buffer_menu_item_accelerator(_newvalue, is_file)
    else
      #new_label = buffer_menu_item_label(_newtext, is_file)
      new_accelerator = buffer_menu_item_accelerator(_newtext, is_file)
    end
  end  
  
  @buffer_menu.entryconfigure(to_mod, 'label'=>_newtext, 'accelerator'=>new_accelerator) if to_mod != -1
#    @buffer_menu.entryconfigure(to_mod, 'label'=>_newtext) if to_mod != -1
  if to_mod != -1 && _newvalue != nil
#      is_file = File.exists?(_newvalue)
    @buffer_menu.entryconfigure(to_mod, 
      :value => _newvalue,
      :image=> Arcadia.file_icon(_newvalue),
      :command=>proc{
        if is_file
          open_file(_newvalue)
        else
          open_buffer(tab_name(_newvalue))             
        end
      }
    )
  end
  if _sender == self
    instances.each{|i|
      if i != self && i.buffer_menu_item_exist?(_file)
        i.mod_buffer_menu_item(_file, _newtext, _newvalue, self)
        #i.refresh_buffer_string
      end
    }
  end
  
end

#move_buffer_here(_name) ⇒ Object



5283
5284
5285
5286
# File 'ext/ae-editor/ae-editor.rb', line 5283

def move_buffer_here(_name)
  @main_frame.move_here(_name)
  #@raw_buffer_name[_name]=_name
end

#name_modified(_name) ⇒ Object



4919
4920
4921
# File 'ext/ae-editor/ae-editor.rb', line 4919

def name_modified(_name)
  '(...)'+_name
end

#name_read_only(_name) ⇒ Object

def get_tab_from_name(_name=nil)

  return @main_frame.enb.get_frame(_name)
end


4911
4912
4913
# File 'ext/ae-editor/ae-editor.rb', line 4911

def name_read_only(_name)
  '[READ-ONLY] '+_name
end

#on_activate_instance(_event) ⇒ Object



4050
4051
4052
4053
4054
4055
4056
4057
4058
# File 'ext/ae-editor/ae-editor.rb', line 4050

def on_activate_instance(_event)
  return if defined?(@last_active_instance_name) && @last_active_instance_name == _event.name
  if _event.name == @name
    refresh_status
    _e = raised
    change_outline(_e, true) if  _e      
  end
  @last_active_instance_name = _event.name if _event.name == @name || exist_name?(_event.name)
end

#on_after_debug(_event) ⇒ Object



4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
# File 'ext/ae-editor/ae-editor.rb', line 4547

def on_after_debug(_event)
  case _event
    when StepDebugEvent
      if _event.command == :quit_yes 
        self.debug_end
      elsif _event.command == :quit_no 
        @last_e.mark_debug(@last_index) if @last_e
      end
#      when SetBreakpointEvent
#        if _event.active == 1
#          @breakpoints << {:file=>_event.file,:line=>_event.row}
#          _e = @tabs_editor[tab_file_name(_event.file)]
#          _e.add_tag_breakpoint(_event.row) if _e
#        end
    when UnsetBreakpointEvent
      #p "ae-editor : UnsetBreakpointEvent file : #{_event.file}"
      #p "ae-editor : UnsetBreakpointEvent _event.row : #{_event.row}"
      if _event.file
        @breakpoints.delete_if{|b| (b[:file]==_event.file && b[:line]==_event.row)}
        _e = @tabs_editor[tab_file_name(_event.file)]
      elsif _event.id
        @breakpoints.delete_if{|b| (b[:file]=="__TMP__#{_event.id}" && b[:line]==_event.row)}
        _e = @editors[_event.id]
      end
      _e.remove_tag_breakpoint(_event.row) if _e
  end
end

#on_after_focus(_event) ⇒ Object



4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
# File 'ext/ae-editor/ae-editor.rb', line 4300

def on_after_focus(_event)
  if raised && _event.focus_widget == raised.text
    if [CutTextEvent, PasteTextEvent, UndoTextEvent, RedoTextEvent].include?(_event.class)
      if raised.highlighting
        raised.refresh_visible_highlighting
      else
        raised.check_modify
      end      
    end
  end
end

#on_before_build(_event) ⇒ Object



3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
# File 'ext/ae-editor/ae-editor.rb', line 3870

def on_before_build(_event)
  Arcadia.is_windows? ? @ctags_string="lib/ctags.exe" : @ctags_string='ctags'
  @has_ctags = !Arcadia.which(@ctags_string).nil?
  if !@has_ctags
    msg = Arcadia.text("ext.editor.e.ctags.msg")
    ArcadiaProblemEvent.new(self, "type"=>ArcadiaProblemEvent::DEPENDENCE_MISSING_TYPE,"title"=>Arcadia.text("ext.editor.e.ctags.title"), "detail"=>msg).go!
  end
  @breakpoints =Array.new
  @tabs_file =Hash.new
  @tabs_editor =Hash.new
  @raw_buffer_name = Hash.new 
  @editor_seq=-1
  @editors =Array.new
  initialize_status
  #@statusbar_item.pack('side'=>'left','anchor'=>'e','expand'=>'yes')
  Arcadia.attach_listener(self, BufferEvent)
  Arcadia.attach_listener(self, DebugEvent)
#  Arcadia.attach_listener(self, RunRubyFileEvent)
  Arcadia.attach_listener(self, RunCmdEvent)
# Arcadia.attach_listener(self, StartDebugEvent)
  Arcadia.attach_listener(self, FocusEvent)
end

#on_before_debug(_event) ⇒ Object



4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
# File 'ext/ae-editor/ae-editor.rb', line 4504

def on_before_debug(_event)
  case _event
    when StartDebugEvent
      _event.persistent=true
      _filename = _event.file
      if _filename  == "*LAST"
        _event.file = Arcadia.persistent('run.file.last')
      elsif _filename.nil? || _filename == "*CURR"
        current_editor = self.raised
        if current_editor
          if current_editor.file
            _event.file=current_editor.file
          else
            _event.file=current_editor.create_temp_file
            _event.id=current_editor.id
            _event.persistent=false
          end
        end
      end
      self.debug_begin
    when SetBreakpointEvent
      if _event.active == 1
        if _event.file && File.exists?(_event.file)
          @breakpoints << {:file=>_event.file,:line=>_event.row}
          _e = @tabs_editor[tab_file_name(_event.file)]
        elsif _event.id
          @breakpoints << {:file=>"__TMP__#{_event.id}",:line=>_event.row}
          _e = @editors[_event.id]
        end
        if _e
          _index =_event.row+'.0'
          _line = _e.text.get(_index, _index+ '  lineend')
          _event.line_code = _line.strip if _line
          _e.add_tag_breakpoint(_event.row) 
        elsif File.exists?(_event.file)
          # TODO: 
          _line = File.readlines(_event.file)[_event.row.to_i-1]
          _event.line_code = _line.strip if _line
        end
      end
  end  
end

#on_before_run_cmd(_event) ⇒ Object

def on_before_run_ruby_file(_event)

  _filename = _event.file
  if _filename.nil?
    current_editor = self.raised
     if current_editor
       if current_editor.file
         _event.file = current_editor.file
         _event.persistent = true
       else
         _event.file = current_editor.create_temp_file
       end
     end
  end
end


3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
# File 'ext/ae-editor/ae-editor.rb', line 3908

def on_before_run_cmd(_event)
  _filename = _event.file
  _event.persistent = true
  if _filename.nil? || _filename == "*CURR"
    current_editor = self.raised
    if current_editor
      if current_editor.file
        _event.file = current_editor.file
      else
        _event.persistent = false
        _event.file = current_editor.create_temp_file
        _event.title = current_editor.tab_title
      end
    end
    # here insert persistent entry of runner instance
    bn = File.basename(_event.file) 
    if _event.persistent && _event.runner_name && Arcadia.persistent("runners.#{bn}").nil?
      entry_hash = Hash.new
      entry_hash[:runner]= _event.runner_name
      entry_hash[:file]= _event.file
      entry_hash[:dir]= _event.dir if _event.dir
      entry_hash[:title]= "#{bn}"
      
      Arcadia.persistent("runners.#{bn}", entry_hash.inspect)
      # here add new menu' item
      mr = Arcadia.menu_root('runcurr')
      if mr
        _command = proc{
            _event = Arcadia.process_event(
            RunCmdEvent.new(self, entry_hash)
          )
        }
        exts = ''
        run = Arcadia.runner(entry_hash[:runner])
        if run
          file_exts = run[:file_exts]
        end
        
        mr.insert('0', 
          :command ,{
            :image => Arcadia.file_icon(file_exts),
            :label => entry_hash[:title],
            :compound => 'left',
            :command => _command
          }
        )
      end
    end
  end
 
  if _event.file  == "*LAST"
    _event.file = Arcadia.persistent('run.file.last')
    _event.cmd = Arcadia.persistent('run.cmd.last')
  else
    if _event.dir.nil?
      _event.dir = File.dirname(_event.file)
    end
    
    if _event.cmd.nil?
      if _event.runner_name
        runner = Arcadia.runner(_event.runner_name)
      elsif _event.lang && Arcadia.runner_for_lang(_event.lang)
        runner = Arcadia.runner_for_lang(_event.lang)
      else
        runner = Arcadia.runner_for_file(_event.file)
      end
      if runner
        _event.cmd = runner[:cmd]
      else
        _event.cmd = _event.file
      end        
    end
    if _event.file && _event.cmd.include?('<<RUBY>>')
      _event.cmd = _event.cmd.gsub('<<RUBY>>',Arcadia.ruby)
    end
    if _event.file && _event.cmd.include?('<<FILE>>')
      _event.cmd = _event.cmd.gsub('<<FILE>>',_event.file)
    end
    if _event.dir && _event.cmd.include?('<<DIR>>')
      _event.cmd = _event.cmd.gsub('<<DIR>>',_event.dir)
    end
    if _event.file && _event.cmd.include?('<<FILE_BASENAME_WITHOUT_EXT>>')
      _event.cmd = _event.cmd.gsub('<<FILE_BASENAME_WITHOUT_EXT>>',File.basename(_event.file).split('.')[0])
    end
    if _event.file && _event.cmd.include?('<<FILE_BASENAME>>')
      _event.cmd = _event.cmd.gsub('<<FILE_BASENAME>>',File.basename(_event.file))
    end
  end 
  _event.title = _event.file if _event.title.nil?
end

#on_before_step_debug(_event) ⇒ Object

case _event.signature

    when DebugContract::DEBUG_BEGIN
      self.debug_begin
    when DebugContract::DEBUG_END
      self.debug_end
    when DebugContract::DEBUG_STEP
      if _event.context.file
        self.open_file_in_debug(_event.context.file, _event.context.line)
      end
  end
end


4500
4501
4502
# File 'ext/ae-editor/ae-editor.rb', line 4500

def on_before_step_debug(_event)
  debug_reset
end

#on_buffer(_event) ⇒ Object

def on_before_buffer(_event)

Arcadia.new_error_msg(self, "on_before_buffer #{_event.class}")
end


4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
# File 'ext/ae-editor/ae-editor.rb', line 4588

def on_buffer(_event)
  #Arcadia.new_error_msg(self, "on_buffer #{_event.class}")
  case _event
    when NewBufferEvent
      self.open_buffer(nil, nil, nil, _event.lang)
    when OpenBufferEvent
      if _event.file
        if _event.row
          _index = _event.row.to_s+'.0' 
        elsif !editor_exist?(_event.file) && _event.last_row
          _index = _event.last_row.to_s+'.0' 
        end
        if _event.kind_of?(OpenBufferTransientEvent) && conf('close-last-if-not-modified')=="yes"
          if defined?(@last_transient_file) && !@last_transient_file.nil? && @last_transient_file != _event.file
            _e = @tabs_editor[tab_name(@last_transient_file)]
            if _e && !_e.modified_from_opening?
              close_editor(_e)
            end
          end
          if !editor_exist?(_event.file)
            @last_transient_file = _event.file
          else
            @last_transient_file = nil
          end
        end
        if _event.select_index.nil? 
          select_index = true
        else
          select_index = _event.select_index
        end
        if _event.file == '*CURR'
          er = raised
          if er && _index != nil
            er.text_see(_index)
            er.mark_selected(_index) if select_index
          end   
        else
          _e = self.open_file(_event.file, _index, select_index)
          #_e.do_line_update
        end
      elsif _event.text
        if _event.title 
          _tab_name = self.tab_name(_event.title)
          self.open_buffer(_tab_name, _event.title)
          _e = @tabs_editor[_tab_name]
          _e.text_insert('end',_event.text)
          _e.reset
          _e.refresh
          #add_reverse_item(_e)
        end
      else
        _event.file = Arcadia.open_file_dialog
        self.open_file(_event.file)
      end
    when CloseBufferEvent
      if _event.file
        self.close_file(_event.file)
      end
    when SaveAsBufferEvent
      if _event.file == nil
        self.raised.save_as
      else
        self.save_as_file(_event.file)          
      end
      _event.new_file = self.raised.file
    when SaveBufferEvent
      if _event.file == nil && _event.title == nil 
        self.raised.save
      elsif _event.file != nil
        self.save_file(_event.file)
      elsif _event.title != nil
        self.save_file(_event.title)
      end
    when SearchBufferEvent
      if _event.what == nil
        @find.show
      end
    when GoToLineBufferEvent
      if _event.line == nil
        @find.show_go_to_line_dialog
      end
    when CloseCurrentTabEvent
       close_raised
    when PrettifyTextEvent
#        require 'rbeautify.rb' # gem
#        self.raised.save # so we can beautify it kludgely here...
#        path = raised.file
#        RBeautify.beautify_file(path)
#        self.raised.reload

      rbea = RBeautify.beautify_string(raised.text_value_lines)
      if rbea && rbea.length >1 && !rbea[1]
        raised.text_replace_value_with(rbea[0])
      else
        msg = Arcadia.text('ext.editor.e.prettify.msg', [raised.tab_title])
        Arcadia.dialog(self, 
          'type'=>'ok', 
          'title' => Arcadia.text("ext.editor.e.prettify.title"), 
          'msg'=>msg,
          'level'=>'error')
      end
      
    when MoveBufferEvent
      if _event.old_file && _event.new_file && editor_exist?(_event.old_file)
        #close_file(_event.old_file)
        change_file(_event.old_file, _event.new_file)          
      end
  end
end

#on_build(_event) ⇒ Object

def on_before_start_debug(_event)

  _filename = _event.file
  if _filename.nil?
    current_editor = self.raised
    _event.file =current_editor.file if current_editor
  end
end


4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
# File 'ext/ae-editor/ae-editor.rb', line 4007

def on_build(_event)
#    self.frame.hinner_frame.bind_append("Enter", proc{activate})
  @usetabs = conf('use-tabs')=='yes'
  @main_frame = AgMultiEditorView.new(self, self.frame, @usetabs)
  @@outline_bar = AgEditorOutlineToolbar.new(self) if !defined?(@@outline_bar)
  create_find # this is the "find within current file" one
  begin
    pop_up_menu
  rescue RuntimeError => e
    Arcadia.runtime_error(e)
  end
  frame.root.add_button(
    self.name,
    'Close current',
    proc{self.activate;Arcadia.process_event(CloseCurrentTabEvent.new(self))}, 
    CLOSE_DOCUMENT_GIF)
  frame.root.add_sep(self.name, 1)
  @buffer_number = TkVariable.new
  @buffer_string = TkVariable.new
  @buffer_string.value = ''
#    @buffer_string = ''
  @buffer_number.value = 0
  @buffer_menu_button = frame.root.add_menu_button(
#      self.name, 'files', DOCUMENT_COMBO_GIF, 'right', 
    self.name, 'files', nil, 'right', 
#      {'relief'=>:raised, 'borderwidth'=>1, 'compound'=> 'left','anchor'=>'w', 'textvariable'=> @buffer_string, 'width'=>40})
    {'relief'=>:flat, 
     'borderwidth'=>1, 
     'compound'=> 'left',
     'anchor'=>'w',
     'font'=> "#{Arcadia.conf('titlelabel.font')} italic",
     'activebackground'=>Arcadia.conf('titlelabel.background'),
     'foreground' => Arcadia.conf('titlecontext.foreground'),
     'textvariable'=> @buffer_string
     #'text'=> @buffer_string
     })
  @buffer_menu = @buffer_menu_button.cget('menu')
  @buffer_menu_button.pack('fill'=>'x', 'expand'=>'true', 'side'=> 'left','anchor'=> 'w')
#    TkWinfo.parent(TkWinfo.parent(@buffer_menu_button).frame).pack('fill'=>'x', 'expand'=>'true', 'side'=> 'right','anchor'=> 'w')
  @buffer_menu_button.bind_append("Double-Button-1", proc{frame.root.resize})
  load_languages_hash
end

#on_debug_step_info(_event) ⇒ Object



4575
4576
4577
4578
4579
4580
4581
4582
# File 'ext/ae-editor/ae-editor.rb', line 4575

def on_debug_step_info(_event)
  #Arcadia.new_debug_msg(self, "file: #{_event.file}:#{_event.row}")
  #Arcadia.console(self, :msg=> "ae-editor -> DebugStepInfoEvent")
  if _event.file
    self.open_file_in_debug(_event.file, _event.row)
  end
  Tk.update
end

#on_exit_query(_event) ⇒ Object



4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
# File 'ext/ae-editor/ae-editor.rb', line 4288

def on_exit_query(_event)    
  _event.can_exit=true
  return if _event.sender.instance_of?(AgMultiEditor) && _event.sender != self 
  @tabs_editor.each_value{|editor|
    _event.can_exit = can_close_editor?(editor)
    if !_event.can_exit
      _event.break
      break 
    end
  }
end

#on_finalize(_event) ⇒ Object



4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
# File 'ext/ae-editor/ae-editor.rb', line 4734

def on_finalize(_event)
  @batch_files = true
  _files =''
  _raised = self.raised
  Arcadia.persistent("#{@name}.files.last", _raised.file) if _raised
  @tabs_editor.each_value{|editor|
    if editor.file != nil
      #_insert_index = editor.text.index('insert')
      _insert_index = editor.text.index('@0,0')
      _files=_files+'|' if _files.strip.length > 0
      _files=_files + "#{editor.file};#{_insert_index};#{editor.line_numbers_visible.to_s}"
    end
    #p editor.text.dump_tag('0.1',editor.text.index('end'))
    close_editor(editor,true)
  }
  Arcadia.persistent("#{@name}.files.open", _files)
  clear_temp_files
#    _breakpoints = '';
#    @breakpoints.each{|point|
#      if point[:file] != nil
#        _breakpoints=_breakpoints+'|' if _breakpoints.strip.length > 0
#        _breakpoints=_breakpoints + "#{point[:file]}@@@#{point[:line]}"
#      end
#    }
#    Arcadia.persistent('editor.debug_breakpoints', _breakpoints)
  @batch_files = true
end

#on_initialize(_event) ⇒ Object



4283
4284
4285
4286
# File 'ext/ae-editor/ae-editor.rb', line 4283

def on_initialize(_event)
  self.open_last_files
  reset_status if @main_frame.pages.empty?
end

#on_layout_raising_frame(_event) ⇒ Object



4818
4819
4820
4821
4822
4823
# File 'ext/ae-editor/ae-editor.rb', line 4818

def on_layout_raising_frame(_event)
  if _event.extension_name == "editor" && _event.frame_name=="editor_outline"
    _e = raised
    change_outline(_e, true) if  _e
  end
end

#open_buffer(_buffer_name = nil, _title = nil, _filename = nil, _lang = nil) ⇒ Object



5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
# File 'ext/ae-editor/ae-editor.rb', line 5288

def open_buffer(_buffer_name = nil, _title = nil, _filename=nil, _lang=nil)
  #_index = @main_frame.index(resolve_tab_name(_buffer_name))
  if @main_frame.exist_buffer?(resolve_tab_name(_buffer_name))
    _tab = @main_frame.page_frame(resolve_tab_name(_buffer_name))
    #@main_frame.raise(resolve_tab_name(_buffer_name)) if frame_visible?
  else
    if _buffer_name == nil
    		_title_new = '*new'
    		tmp_buffer_num = 0
    		_buffer_name = tab_name(_title_new)
    		#_buffer_name = tab_name('new')
    end
    _n = 1
    while @main_frame.index(_buffer_name) != -1
      _title_new = '*new'+_n.to_s
      tmp_buffer_num = _n
      _buffer_name = tab_name(_title_new)
      #_buffer_name = tab_name('new')+_n.to_s
      _n =_n+1
    end
    if _title == nil
      _title =  _title_new
      if _lang
        _image = Arcadia.lang_icon(_lang)
      else
        _image = Arcadia.lang_icon('Ruby')
      end  
      _ext = language_hash_by_lang(_lang)
    else
      _image = Arcadia.file_icon(_title)
    end
    _tab = @main_frame.add_page(_buffer_name, _filename, _title, _image, proc{do_buffer_raise(_buffer_name, _title)})
#      @raw_buffer_name[_buffer_name]=_buffer_name
    if _filename
      add_buffer_menu_item(_filename)
    else
      add_buffer_menu_item(_title, false)
    end
    _e = AgEditor.new(self, _tab)
    register_editor(_e, _buffer_name, _filename)
#      @editor_seq=@editor_seq+1
#      _e.id=@editor_seq
#      @editors[@editor_seq]=_e
#      @tabs_editor[_buffer_name]=_e
    ext = Arcadia.file_extension(_title)
    ext='rb' if ext.nil?
    _e.initialize_editing(ext, _lang)
    _e.text.set_focus
  end
  begin
    if raised != @tabs_editor[resolve_tab_name(_buffer_name)]
      @main_frame.raise(resolve_tab_name(_buffer_name)) if frame_visible?
      @main_frame.see(resolve_tab_name(_buffer_name))
    end
#      if raised != @tabs_editor[resolve_tab_name(_buffer_name)]
#        @main_frame.move(resolve_tab_name(_buffer_name), 0)
#        @main_frame.raise(resolve_tab_name(_buffer_name)) if frame_visible?
#        @main_frame.see(resolve_tab_name(_buffer_name))
#      else
#        @main_frame.move(resolve_tab_name(_buffer_name), 0)
#      end
  rescue Exception => e
    Arcadia.runtime_error(e)
  end
  return _tab
end

#open_file(_filename = nil, _text_index = '1.0', _mark_selected = true, _exp = true) ⇒ Object



5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
# File 'ext/ae-editor/ae-editor.rb', line 5250

def open_file(_filename = nil, _text_index='1.0', _mark_selected=true, _exp=true)
  return if _filename == nil || !File.exist?(_filename) || File.ftype(_filename) != 'file'
  _basefilename = File.basename(_filename)
  _tab_name = self.tab_file_name(_filename)
  #_index = @main_frame.enb.index(_tab_name)
  #_exist_buffer = _index != -1
  _exist_buffer = @tabs_file[_tab_name] != nil
  if _exist_buffer
    open_buffer(_tab_name)
    # ??? _text_index = nil 
  else
#      @tabs_file[_tab_name]= _filename
    open_buffer(_tab_name, _basefilename, _filename)
    @tabs_editor[_tab_name].reset_highlight
    begin
      @tabs_editor[_tab_name].load_file(_filename)
    rescue RuntimeError => e
      #Arcadia.dialog(self,'type'=>'ok', 'level'=>'error','title' => 'RuntimeError', 'msg'=>"RuntimeError : #{e.message}")
      #p "RuntimeError : #{e.message}"
      close_editor(@tabs_editor[_tab_name], true)
      Arcadia.runtime_error(e)
    end
    change_outline_frame_caption(File.basename(_filename)) if _filename    
  end
  editor = @tabs_editor[_tab_name]
  if _text_index != nil && _text_index != '1.0' && editor
    editor.text_see(_text_index)
    editor.mark_selected(_text_index) if _mark_selected 
  end
  editor.do_line_update if editor && !editor.highlighted?
  return editor
end

#open_file_in_debug(_filename = nil, _line = nil) ⇒ Object



5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
# File 'ext/ae-editor/ae-editor.rb', line 5087

def open_file_in_debug(_filename=nil, _line=nil)
  #debug_reset
  if _filename && _line && File.exists?(_filename)
    @last_index = _line.to_s+'.0'
    #_editor_exist = editor_exist?(_filename)
    _editor = editor_of(_filename)
    if _editor
      @last_e = raise_editor(_editor, @last_index, false, false)
    else
      @last_e = open_file(_filename, @last_index, false, false)
    end
    #@last_e.hide_exp
    @last_e.mark_debug(@last_index) if @last_e
    #if !_editor_exist
    if _editor.nil?
      @editors_in_debug <<  @last_e
      # workaround for hightlight
      #p "add editor for close #{_filename}"
      @last_e.do_line_update
    end
  else
    p "file #{_filename} do not exist !"
  end
end

#open_last_filesObject

def update(_kind,_name)

  if _kind == 'RAISE' && _name == 'editor'
    _e = raised
    change_outline(_e) if  _e
  end
end


4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
# File 'ext/ae-editor/ae-editor.rb', line 4832

def open_last_files
  @batch_files = true
  if Arcadia.persistent("#{@name}.files.open")
    _files_index =Arcadia.persistent("#{@name}.files.open").split("|")
    _files_index.each do |value| 
      _file,_index,_line_numbers_visible_as_string = value.split(';')
      if _file && _index
        ed = open_file(_file,_index,false)
      else
        ed = open_file(_file)
      end
      if ed && _line_numbers_visible_as_string && ed.line_numbers_visible
        ed.line_numbers_visible = _line_numbers_visible_as_string == 'true'
      end
    end
  end
  @batch_files = false
  to_raise_file = Arcadia.persistent("#{@name}.files.last")
  if to_raise_file
    raise_file(to_raise_file,0)
  else
    _first_page = @main_frame.pages[0] if @main_frame.pages.length > 0
    if _first_page
      @main_frame.raise(_first_page) if frame_def_visible?
      @main_frame.see(_first_page)
    end
  end
  main_instance.frame(1)
  Arcadia.attach_listener(self, LayoutRaisingFrameEvent)
  self
end

#outline_barObject



4079
4080
4081
# File 'ext/ae-editor/ae-editor.rb', line 4079

def outline_bar
  @@outline_bar
end

#page_name(_page_frame) ⇒ Object



4964
4965
4966
4967
4968
# File 'ext/ae-editor/ae-editor.rb', line 4964

def page_name(_page_frame)
  @main_frame.page_name(_page_frame)
#    pn = TkWinfo.appname(_page_frame).sub('f','')
#    resolve_tab_name(pn)
end

#pop_up_menuObject



4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
# File 'ext/ae-editor/ae-editor.rb', line 4404

def pop_up_menu
  @pop_up = TkMenu.new(
    :parent=> self.frame.hinner_frame,
    :tearoff=>0,
    :title => 'Menu'
  )
  @pop_up.extend(TkAutoPostMenu)
  @pop_up.configure(Arcadia.style('menu'))
  #Arcadia.instance.main_menu.update_style(@pop_up)


  @c = @pop_up.insert('end',
    :command,
    :label=>Arcadia.text('ext.editor.buffer.menu.close'),
    #:font => conf('font'),
    :hidemargin => false,
    :command=> proc{
      if @selected_tab_name_from_popup != nil
        _e = @tabs_editor[@selected_tab_name_from_popup]
        self.close_editor(_e) if _e
      end
    }
  )
  @c = @pop_up.insert('end',
    :command,
    :label=>Arcadia.text('ext.editor.buffer.menu.close_others'),
    #:font => conf('font'),
    :hidemargin => false,
    :command=> proc{
      if @selected_tab_name_from_popup != nil
        _e = @tabs_editor[@selected_tab_name_from_popup]
        self.close_others_editor(_e)
      end
    }
  )
  @c = @pop_up.insert('end',
    :command,
    :label=>Arcadia.text('ext.editor.buffer.menu.close_all'),
    #:font => conf('font'),
    :hidemargin => false,
    :command=> proc{
      if @selected_tab_name_from_popup != nil
        _e = @tabs_editor[@selected_tab_name_from_popup]
        self.close_all_editor(_e)
      end
    }
  )

  @pop_up.insert('end',
    :command,
    :label=>'...',
    :state=>'disabled',
    :background=>Arcadia.conf('titlelabel.background'),
    :font => "#{Arcadia.conf('menu.font')} bold",
    :hidemargin => false
  )

  @main_frame.page_bind("Button-3",
    proc{|*x|
      _x = TkWinfo.pointerx(@main_frame.root_frame)
      _y = TkWinfo.pointery(@main_frame.root_frame)
      if @usetabs
        @selected_tab_name_from_popup = x[0].split(':')[0]
      else
        @selected_tab_name_from_popup = @main_frame.raise
      end
      _index = @main_frame.index(@selected_tab_name_from_popup)
      if _index == -1 
        @selected_tab_name_from_popup = 'ff'+@selected_tab_name_from_popup
        _index = @main_frame.index(@selected_tab_name_from_popup)
      end

      if _index != -1 
        _file = @tabs_file[(@selected_tab_name_from_popup)] # full path of file
        @pop_up.entryconfigure(3, 'label'=> _file)
        @pop_up.popup(_x,_y+10)
      end
    })
end

#raise_editor(_editor = nil, _text_index = '0.0', _mark_selected = true, _exp = true) ⇒ Object



5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
# File 'ext/ae-editor/ae-editor.rb', line 5371

def raise_editor(_editor = nil, _text_index='0.0', _mark_selected=true, _exp=true)
  return if _editor == nil
  _tab_name = nil
  @tabs_editor.each{|tn,e|
    if e == _editor
      _tab_name = tn
    end
  }
  if _tab_name
    _index = @main_frame.index(resolve_tab_name(_tab_name))
    _exist_buffer = _index != -1
    if _exist_buffer
      open_buffer(_tab_name)
      if _text_index != nil && _text_index != '0.0'
        _editor.text_see(_text_index)
        _editor.mark_selected(_text_index) if _mark_selected 
      end
    end
  end
  return _editor
end

#raise_file(_filename = nil, _pos = nil) ⇒ Object



5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
# File 'ext/ae-editor/ae-editor.rb', line 5239

def raise_file(_filename=nil, _pos=nil)
  if _filename && frame_def_visible?
    tab_name=self.tab_file_name(_filename)
    if  @main_frame.index(tab_name) != -1
        @main_frame.move(tab_name,_pos) if _pos
        @main_frame.raise(tab_name)
        @main_frame.see(tab_name)
    end
  end    
end

#raisedObject



4777
4778
4779
4780
4781
4782
4783
4784
# File 'ext/ae-editor/ae-editor.rb', line 4777

def raised
  if @main_frame
    _page = @main_frame.raise
    return @tabs_editor[resolve_tab_name(_page)]
  else
    nil
  end
end

#raised_nameObject



4786
4787
4788
4789
4790
4791
4792
4793
# File 'ext/ae-editor/ae-editor.rb', line 4786

def raised_name
  if @main_frame
    _page = @main_frame.raise
    return resolve_tab_name(_page)
  else
    nil
  end
end

#refresh_buffer_stringObject



4988
4989
4990
# File 'ext/ae-editor/ae-editor.rb', line 4988

def refresh_buffer_string
  make_buffer_string(@last_buffer_str)
end

#refresh_selected_buffer_menu_itemObject



4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
# File 'ext/ae-editor/ae-editor.rb', line 4262

def refresh_selected_buffer_menu_item
  i_end = @buffer_menu.index('end')
  p_name =  @main_frame.raise
  if @tabs_editor[p_name] && @tabs_editor[p_name].file
    to_select = @tabs_editor[p_name].file
  else
    to_select = unname_modified(tab_title_by_tab_name(p_name))
  end
  0.upto(i_end){|j|
    type = @buffer_menu.menutype(j)
    if type != 'separator'
      value = @buffer_menu.entrycget(j,'value')
      if value == to_select
        @buffer_menu.entryconfigure(j, 'state'=>'disabled')
      else
        @buffer_menu.entryconfigure(j, 'state'=>'normal')
      end
    end
  }
end

#refresh_statusObject



5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
# File 'ext/ae-editor/ae-editor.rb', line 5165

def refresh_status
  #@statusbar_item.text("#{_title} | #{_e.file_info['mtime'].strftime("%d/%m/%Y %H:%m:%S") if _e}")
  if raised && raised.file
    size = File.size(raised.file)
    if size > 1024
      size_str = "#{size/1024} kb"
    else
      size_str = "#{size} b"      
    end
    @@statusbar_items['file_name'].text(File.basename(raised.file))
    @@statusbar_items['file_mtime'].text =  raised.file_info['mtime'].localtime
    @@statusbar_items['file_size'].text = size_str 
    #@statusbar_item.text("#{File.basename(raised.file)} | #{raised.file_info['mtime'].localtime} | #{size_str}")
  else
    reset_status
  end
end

#register_editor(_e, _buffer_name, _file) ⇒ Object



5355
5356
5357
5358
5359
5360
5361
5362
# File 'ext/ae-editor/ae-editor.rb', line 5355

def register_editor(_e, _buffer_name, _file)
  @editor_seq=@editor_seq+1
  _e.id=@editor_seq
  @editors[@editor_seq]=_e
  @tabs_editor[_buffer_name]=_e
  @tabs_file[_buffer_name]= _file if _file 
  @raw_buffer_name[_buffer_name]=_buffer_name
end

#reset_statusObject



5159
5160
5161
5162
5163
# File 'ext/ae-editor/ae-editor.rb', line 5159

def reset_status
  @@statusbar_items['file_name'].text = '?'
  @@statusbar_items['file_mtime'].text =  '?'
  @@statusbar_items['file_size'].text = '?' 
end

#resolve_tab_name(_tab_name) ⇒ Object



4970
4971
4972
4973
4974
4975
4976
# File 'ext/ae-editor/ae-editor.rb', line 4970

def resolve_tab_name(_tab_name)
  if @raw_buffer_name[_tab_name]
    return @raw_buffer_name[_tab_name]
  else
    return _tab_name
  end 
end

#save_as_file(_filename) ⇒ Object



5495
5496
5497
# File 'ext/ae-editor/ae-editor.rb', line 5495

def save_as_file(_filename)
  @tabs_editor[tab_name(_filename)].save_as
end

#save_file(_filename) ⇒ Object



5491
5492
5493
# File 'ext/ae-editor/ae-editor.rb', line 5491

def save_file(_filename)
  @tabs_editor[tab_name(_filename)].save
end

#show_hide_current_line_numbersObject



4713
4714
4715
4716
# File 'ext/ae-editor/ae-editor.rb', line 4713

def show_hide_current_line_numbers
  _e = active_instance.raised
  _e.show_hide_line_numbers if _e
end

#show_hide_tabsObject



4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
# File 'ext/ae-editor/ae-editor.rb', line 4718

def show_hide_tabs
  if active? 
    if @usetabs
      @main_frame.switch_2_notabs
      @usetabs = false
      Arcadia['conf']["#{@name}.use-tabs"]='no'
    else
      @main_frame.switch_2_tabs
      @usetabs = true
      Arcadia['conf']["#{@name}.use-tabs"]='yes'
    end
  else
    active_instance.show_hide_tabs
  end
end

#start_findObject



4708
4709
4710
4711
# File 'ext/ae-editor/ae-editor.rb', line 4708

def start_find
  _e = raised
  _e.find if _e
end

#tab_file_name(_filename = "") ⇒ Object



4958
4959
4960
4961
4962
# File 'ext/ae-editor/ae-editor.rb', line 4958

def tab_file_name(_filename="")
  _fstr = File.expand_path(_filename)
  _fstr =  _filename if _fstr == nil
  tab_name(_fstr)
end

#tab_name(_str = "") ⇒ Object



4953
4954
4955
4956
# File 'ext/ae-editor/ae-editor.rb', line 4953

def tab_name(_str="")
  tn = 'ff'+_str.downcase.gsub("/","_").gsub(".","__").gsub(":","___").gsub("\\","____").gsub("*","_____")
  resolve_tab_name(tn)
end

#tab_title(_tab) ⇒ Object



4945
4946
4947
# File 'ext/ae-editor/ae-editor.rb', line 4945

def tab_title(_tab)
  @main_frame.page_title(page_name(_tab))
end

#tab_title_by_tab_name(_tab_name) ⇒ Object



4949
4950
4951
# File 'ext/ae-editor/ae-editor.rb', line 4949

def tab_title_by_tab_name(_tab_name)
  @main_frame.page_title(resolve_tab_name(_tab_name))
end

#top_text_stringObject



4999
5000
5001
5002
# File 'ext/ae-editor/ae-editor.rb', line 4999

def top_text_string
  nil
  #"[#{@buffer_number.value}]"
end

#unname_modified(_name) ⇒ Object



4923
4924
4925
# File 'ext/ae-editor/ae-editor.rb', line 4923

def unname_modified(_name)
  return _name.gsub("(...)",'')
end

#unname_read_only(_name) ⇒ Object



4915
4916
4917
# File 'ext/ae-editor/ae-editor.rb', line 4915

def unname_read_only(_name)
  return _name.gsub("[READ-ONLY] ",'')
end

#unregister_editor(_buffer_name) ⇒ Object



5364
5365
5366
5367
5368
5369
# File 'ext/ae-editor/ae-editor.rb', line 5364

def unregister_editor(_buffer_name)
  e = @tabs_editor.delete(_buffer_name)
  @tabs_file.delete(_buffer_name)
  @editors.delete(e.id)
  @raw_buffer_name.delete_if {|key, value| value == _buffer_name}
end