Class: AgMultiEditor

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

Instance Attribute Summary collapse

Attributes inherited from ArcadiaExt

#arcadia, #name

Instance Method Summary collapse

Methods included from Configurable

#make_value, #properties_file2hash, properties_group, #resolve_link, #resolve_properties_link

Methods inherited from ArcadiaExt

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

Constructor Details

This class inherits a constructor from ArcadiaExt

Instance Attribute Details

#outline_barObject (readonly)

Returns the value of attribute outline_bar.



3333
3334
3335
# File 'ext/ae-editor/ae-editor.rb', line 3333

def outline_bar
  @outline_bar
end

#splitted_frameObject (readonly)

attr_reader :breakpoints



3332
3333
3334
# File 'ext/ae-editor/ae-editor.rb', line 3332

def splitted_frame
  @splitted_frame
end

Instance Method Details

#accept_complete_codeObject



4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
# File 'ext/ae-editor/ae-editor.rb', line 4515

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) ⇒ Object



3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
# File 'ext/ae-editor/ae-editor.rb', line 3473

def add_buffer_menu_item(_filename, is_file=true)
  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')
        if value > _filename
          index=j
          break
        end
      end
    }
  end

  @buffer_menu.insert(index,:radio,
    :label=>File.basename(_filename),
   # :variable=>TkVariable.new(_filename),
    :value=>_filename,
    :image=> Arcadia.file_icon(_filename),
    :compound=>'left',
    :command=>proc{
      if is_file
        open_file(_filename)
      else
        open_buffer(tab_name(_filename))             
      end
    },
    :hidemargin => true
  )
end

#bookmark_add(_file, _index) ⇒ Object



4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
# File 'ext/ae-editor/ae-editor.rb', line 4018

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



4035
4036
4037
4038
# File 'ext/ae-editor/ae-editor.rb', line 4035

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

#bookmark_move(_n = 0) ⇒ Object



4045
4046
4047
4048
4049
4050
4051
4052
# File 'ext/ae-editor/ae-editor.rb', line 4045

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



4040
4041
4042
4043
# File 'ext/ae-editor/ae-editor.rb', line 4040

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

#bookmark_prevObject



4055
4056
4057
4058
# File 'ext/ae-editor/ae-editor.rb', line 4055

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

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



3953
3954
3955
# File 'ext/ae-editor/ae-editor.rb', line 3953

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



3957
3958
3959
# File 'ext/ae-editor/ae-editor.rb', line 3957

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



3961
3962
3963
3964
3965
3966
3967
3968
3969
# File 'ext/ae-editor/ae-editor.rb', line 3961

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

#can_close_editor?(_editor) ⇒ Boolean

Returns:

  • (Boolean)


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
# File 'ext/ae-editor/ae-editor.rb', line 4438

def can_close_editor?(_editor)
  ret = true
  if _editor.modified?
    filename = page_name(_editor.page_frame)
    message = @main_frame.enb.itemcget(filename, 'text')+"\n modified. Save?"
    r=Arcadia.dialog(self,
        'type'=>'yes_no_cancel', 
        'level'=>'warning',
        'title'=> 'Confirm saving', 
        '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 = @main_frame.enb.itemcget(filename, 'text')+"\n modified by other process. Continue closing?"
    r=Arcadia.dialog(self,
        'type'=>'yes_no', 
        'level'=>'warning',
        'title'=> 'Continue closing', 
        'msg'=>message)
    if r=="yes"
      _editor.reset_file_last_access_time
      ret = !_editor.modified_by_others?
    else
      ret = false
      #raise_file(filename) 
    end
  end
  ret
end

#change_file(_old_file, _new_file) ⇒ Object



4159
4160
4161
4162
4163
4164
4165
# File 'ext/ae-editor/ae-editor.rb', line 4159

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.new_file_name(_new_file) if e
  change_file_name(_tab, _new_file)
end

#change_file_name(_tab, _new_file) ⇒ Object



4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
# File 'ext/ae-editor/ae-editor.rb', line 4167

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)
  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(_new_caption) ⇒ Object



4142
4143
4144
4145
4146
4147
4148
4149
# File 'ext/ae-editor/ae-editor.rb', line 4142

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

#change_outline(_e, _raised = false) ⇒ Object



4227
4228
4229
4230
4231
4232
4233
4234
# File 'ext/ae-editor/ae-editor.rb', line 4227

def change_outline(_e, _raised=false)
  _raised = _raised || frame(1).raised?
  if !@batch_files && _raised
    @last_outline_e.hide_outline if @last_outline_e
    _e.show_outline
    @last_outline_e = _e
  end
end

#change_tab_icon(_tab, _new_text) ⇒ Object



4155
4156
4157
# File 'ext/ae-editor/ae-editor.rb', line 4155

def change_tab_icon(_tab, _new_text)
  @main_frame.enb.itemconfigure(page_name(_tab), 'image'=> Arcadia.file_icon(_new_text))
end

#change_tab_reset_modify(_tab) ⇒ Object



4132
4133
4134
4135
4136
4137
4138
4139
4140
# File 'ext/ae-editor/ae-editor.rb', line 4132

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

#change_tab_reset_read_only(_tab) ⇒ Object



4087
4088
4089
4090
4091
4092
# File 'ext/ae-editor/ae-editor.rb', line 4087

def change_tab_reset_read_only(_tab)
  _new_name = unname_read_only(@main_frame.enb.itemcget(page_name(_tab), 'text'))
  if _new_name
    change_tab_title(_tab, _new_name)
  end
end

#change_tab_set_modify(_tab) ⇒ Object



4095
4096
4097
4098
# File 'ext/ae-editor/ae-editor.rb', line 4095

def change_tab_set_modify(_tab)
  _new_name = '(...)'+@main_frame.enb.itemcget(page_name(_tab), 'text')
  change_tab_title(_tab, _new_name)
end

#change_tab_set_read_only(_tab) ⇒ Object



4082
4083
4084
4085
# File 'ext/ae-editor/ae-editor.rb', line 4082

def change_tab_set_read_only(_tab)
  _new_name = name_read_only(@main_frame.enb.itemcget(page_name(_tab), 'text'))
  change_tab_title(_tab, _new_name)
end

#change_tab_title(_tab, _new_text) ⇒ Object



4151
4152
4153
# File 'ext/ae-editor/ae-editor.rb', line 4151

def change_tab_title(_tab, _new_text)
  @main_frame.enb.itemconfigure(page_name(_tab), 'text'=> _new_text)
end

#clear_temp_filesObject



3934
3935
3936
3937
3938
3939
3940
3941
# File 'ext/ae-editor/ae-editor.rb', line 3934

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

#close_all_editor(_editor, _mod = true) ⇒ Object



4430
4431
4432
4433
4434
4435
4436
# File 'ext/ae-editor/ae-editor.rb', line 4430

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(_page_frame) ⇒ Object



4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
# File 'ext/ae-editor/ae-editor.rb', line 4482

def close_buffer(_page_frame)
  _name = page_name(_page_frame)
  if @tabs_editor[_name] && @tabs_editor[_name].file
    del_buffer_menu_item(@tabs_editor[_name].file)
  else
    del_buffer_menu_item(tab_title_by_tab_name(_name))
  end
  @tabs_editor.delete(_name)
  @tabs_file.delete(_name)
  @raw_buffer_name.delete_if {|key, value| value == _name }  
 
  _index = @main_frame.enb.index(_name)
  @main_frame.enb.delete(_name)
  if !@main_frame.enb.pages.empty?
    @main_frame.enb.raise(@main_frame.enb.pages[_index-1]) if TkWinfo.mapped?(@main_frame.enb)
  else
    frame.root.top_text('') if TkWinfo.mapped?(frame.hinner_frame)
  end
end

#close_editor(_editor, _force = false) ⇒ Object



4473
4474
4475
4476
4477
4478
4479
4480
# File 'ext/ae-editor/ae-editor.rb', line 4473

def close_editor(_editor, _force=false)
  if _force || can_close_editor?(_editor)
    _editor.destroy_outline
    close_buffer(_editor.page_frame)
  else
    return
  end
end

#close_file(_filename) ⇒ Object



4502
4503
4504
4505
# File 'ext/ae-editor/ae-editor.rb', line 4502

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

#close_others_editor(_editor, _mod = true) ⇒ Object



4422
4423
4424
4425
4426
4427
4428
# File 'ext/ae-editor/ae-editor.rb', line 4422

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



3948
3949
3950
3951
# File 'ext/ae-editor/ae-editor.rb', line 3948

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

#create_findObject



3889
3890
3891
3892
3893
# File 'ext/ae-editor/ae-editor.rb', line 3889

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

#debug_beginObject



4180
4181
4182
4183
4184
4185
4186
# File 'ext/ae-editor/ae-editor.rb', line 4180

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

#debug_endObject



4188
4189
4190
4191
4192
4193
4194
# File 'ext/ae-editor/ae-editor.rb', line 4188

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

#debug_resetObject



4196
4197
4198
4199
4200
# File 'ext/ae-editor/ae-editor.rb', line 4196

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

#del_buffer_menu_item(_file) ⇒ Object



3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
# File 'ext/ae-editor/ae-editor.rb', line 3508

def del_buffer_menu_item(_file)
  to_del = -1
  i_end = @buffer_menu.index('end')
  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
end

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



4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
# File 'ext/ae-editor/ae-editor.rb', line 4236

def do_buffer_raise(_name, _title='...')
  _index = @main_frame.enb.index(resolve_tab_name(_name))
  _new_caption = '...'
  if _index != -1
    #_name = @main_frame.enb.pages(_index)
    #_tab = get_tab_from_name(_name)
    #@main_frame.enb.raise(_name)
    _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
  end
  change_frame_caption(_new_caption)
  _title = @tabs_file[_name] != nil ? File.basename(@tabs_file[_name]) :_name
  Arcadia.broadcast_event(BufferRaisedEvent.new(self,'title'=>_title, 'file'=>@tabs_file[_name]))
  #EditorContract.instance.buffer_raised(self, 'title'=>_title, 'file'=>@tabs_file[_name])
end

#editor_exist?(_filename) ⇒ Boolean

Returns:

  • (Boolean)


4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
# File 'ext/ae-editor/ae-editor.rb', line 4282

def editor_exist?(_filename)
  _basefilename = File.basename(_filename)
  #_basename = _basefilename.split('.')[0]+'_'+_basefilename.split('.')[1]
  
  _name = self.tab_file_name(_filename)
  _index = @main_frame.enb.index(resolve_tab_name(_name))
  if _index == -1
    _index = @main_frame.enb.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



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

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.enb.index(resolve_tab_name(_name))
    if _index == -1
      _name = name_read_only(_name)
      _index = @main_frame.enb.index(resolve_tab_name(_name))
    end
    if _index != -1
      _ret = @tabs_editor[resolve_tab_name(_name)]
    end
  end
  _ret
end

#get_findObject



3885
3886
3887
# File 'ext/ae-editor/ae-editor.rb', line 3885

def get_find
  @find
end

#get_tab_from_name(_name = nil) ⇒ Object



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

def get_tab_from_name(_name=nil)
  return @main_frame.enb.get_frame(_name)
#    if _name
#      @tabs_name.each{
#        |key,value|
#        if value.to_s==_name.to_s
#          return key
#        end
#      }
#      return nil
#    end
end

#highlight_scanner(_ext = nil) ⇒ Object



3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
# File 'ext/ae-editor/ae-editor.rb', line 3557

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 && 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

#languages_hash(_ext = nil) ⇒ Object



3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
# File 'ext/ae-editor/ae-editor.rb', line 3576

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']+".lang"
          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] && @@langs_hash[_ext]['@include'] != nil
      include_file = "#{File.dirname(__FILE__)}/langs/#{@@langs_hash[_ext]['@include']}"
      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

#name_read_only(_name) ⇒ Object



4074
4075
4076
# File 'ext/ae-editor/ae-editor.rb', line 4074

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

#on_after_build(_event) ⇒ Object



3526
3527
3528
# File 'ext/ae-editor/ae-editor.rb', line 3526

def on_after_build(_event)
  self.open_last_files
end

#on_after_debug(_event) ⇒ Object



3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
# File 'ext/ae-editor/ae-editor.rb', line 3750

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



3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
# File 'ext/ae-editor/ae-editor.rb', line 3541

def on_after_focus(_event)
  if raised && _event.focus_widget == raised.text
    if [CutTextEvent, PasteTextEvent, UndoTextEvent, RedoTextEvent].include?(_event.class)
      if raised.highlighting
        line_begin_index = raised.text.index('@0,0')
        line_begin = line_begin_index.split('.')[0].to_i
        line_end = raised.text.index('@0,'+TkWinfo.height(raised.text).to_s).split('.')[0].to_i + 1
        raised.reset_highlight(line_begin)
        raised.rehighlightlines(line_begin,line_end,true)
      else
        raised.check_modify
      end      
    end
  end
end

#on_before_build(_event) ⇒ Object



3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
# File 'ext/ae-editor/ae-editor.rb', line 3334

def on_before_build(_event)
  @breakpoints =Array.new
  @tabs_file =Hash.new
  @tabs_editor =Hash.new
  @raw_buffer_name = Hash.new 
  @editor_seq=-1
  @editors =Array.new
  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



3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
# File 'ext/ae-editor/ae-editor.rb', line 3707

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
          @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) 
        else
          # 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


3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
# File 'ext/ae-editor/ae-editor.rb', line 3365

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)
      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?('<<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


3703
3704
3705
# File 'ext/ae-editor/ae-editor.rb', line 3703

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


3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
# File 'ext/ae-editor/ae-editor.rb', line 3791

def on_buffer(_event)
  #Arcadia.new_error_msg(self, "on_buffer #{_event.class}")
  case _event
    when NewBufferEvent
      self.open_buffer
    when OpenBufferEvent
      if _event.file
        if _event.row
          _index = _event.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
        self.open_file(_event.file, _index)
      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 = "Problems in prettify #{raised.tab_title}"
        Arcadia.dialog(self, 
          'type'=>'ok', 
          'title' => "(Arcadia) code prettify", 
          '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


3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
# File 'ext/ae-editor/ae-editor.rb', line 3459

def on_build(_event)
  @main_frame = AgMultiEditorView.new(self.frame.hinner_frame)
  @outline_bar = AgEditorOutlineToolbar.new(self.frame(1).hinner_frame, self)
  create_find # this is the "find within current file" one
  pop_up_menu
  @buffer_menu = frame.root.add_menu_button(self.name, 'files', DOCUMENT_COMBO_GIF, 'right', {'relief'=>:raised, 'borderwidth'=>1}).cget('menu')
  frame.root.add_sep(self.name, 1)
  frame.root.add_button(
    self.name,
    'close current',
    proc{Arcadia.process_event(CloseCurrentTabEvent.new(self))}, 
    CLOSE_DOCUMENT_GIF)
end

#on_debug_step_info(_event) ⇒ Object



3778
3779
3780
3781
3782
3783
3784
3785
# File 'ext/ae-editor/ae-editor.rb', line 3778

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



3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
# File 'ext/ae-editor/ae-editor.rb', line 3530

def on_exit_query(_event)
  _event.can_exit=true
  @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



3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
# File 'ext/ae-editor/ae-editor.rb', line 3905

def on_finalize(_event)
  @batch_files = true
  _files =''
  _raised = self.raised
  Arcadia.persistent('editor.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('editor.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_layout_raising_frame(_event) ⇒ Object



3971
3972
3973
3974
3975
3976
# File 'ext/ae-editor/ae-editor.rb', line 3971

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) ⇒ Object



4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
# File 'ext/ae-editor/ae-editor.rb', line 4344

def open_buffer(_buffer_name = nil, _title = nil, _filename=nil)
  _index = @main_frame.enb.index(resolve_tab_name(_buffer_name))
  if _buffer_name == nil
  		_title_new = '*new'
  		tmp_buffer_num = 0
  		_buffer_name = tab_name(_title_new)
  		#_buffer_name = tab_name('new')
  end
  
  if _index != -1
    _tab = @main_frame.enb.get_frame(resolve_tab_name(_buffer_name))
    @main_frame.enb.raise(resolve_tab_name(_buffer_name)) if frame_visible?
  else
    _n = 1
    while @main_frame.enb.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
    end
    _tab = @main_frame.enb.insert('end', _buffer_name ,
      'text'=> _title,
      'image'=> Arcadia.file_icon(_title),
      'background'=> Arcadia.style("tabpanel")["background"],
      'foreground'=> Arcadia.style("tabpanel")["foreground"],
      'raisecmd'=>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)
    @editor_seq=@editor_seq+1
    _e.id=@editor_seq
    @editors[@editor_seq]=_e
    ext = Arcadia.file_extension(_title)
    ext='rb' if ext.nil?
    _e.init_editing(ext)
    _e.text.set_focus
    #@tabs_file[_buffer_name]= nil
    @tabs_editor[_buffer_name]=_e
  end
  if raised != @tabs_editor[resolve_tab_name(_buffer_name)]
    @main_frame.enb.move(resolve_tab_name(_buffer_name), 1)
    @main_frame.enb.raise(resolve_tab_name(_buffer_name)) if frame_visible?
    @main_frame.enb.see(resolve_tab_name(_buffer_name))
  end
  return _tab
end

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



4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
# File 'ext/ae-editor/ae-editor.rb', line 4313

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)
  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)
    end
  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

  return editor
end

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



4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
# File 'ext/ae-editor/ae-editor.rb', line 4202

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


3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
# File 'ext/ae-editor/ae-editor.rb', line 3985

def open_last_files
  @batch_files = true
  if Arcadia.persistent('editor.files.open')
    _files_index =Arcadia.persistent('editor.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('editor.files.last')
  if to_raise_file
    raise_file(to_raise_file,0)
  else
    _first_page = @main_frame.enb.pages(0) if @main_frame.enb.pages.length > 0
    if _first_page
      @main_frame.enb.raise(_first_page) if frame_def_visible?
      @main_frame.enb.see(_first_page)
    end
  end
  frame(1)
  #@arcadia.layout.add_observer(self)
  Arcadia.attach_listener(self, LayoutRaisingFrameEvent)
  self
end

#page_name(_page_frame) ⇒ Object



4119
4120
4121
4122
# File 'ext/ae-editor/ae-editor.rb', line 4119

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

#pop_up_menuObject



3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
# File 'ext/ae-editor/ae-editor.rb', line 3611

def pop_up_menu
  @pop_up = TkMenu.new(
    :parent=>@main_frame.enb,
    :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=>'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=>'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=>'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.enb.tabbind("Button-3",
    proc{|*x|
      _x = TkWinfo.pointerx(@main_frame.enb)
      _y = TkWinfo.pointery(@main_frame.enb)
      @selected_tab_name_from_popup = x[0].split(':')[0]
      _index = @main_frame.enb.index(@selected_tab_name_from_popup)
      if _index == -1 
        @selected_tab_name_from_popup = 'ff'+@selected_tab_name_from_popup
        _index = @main_frame.enb.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



4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
# File 'ext/ae-editor/ae-editor.rb', line 4400

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.enb.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



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

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

#raisedObject



3943
3944
3945
3946
# File 'ext/ae-editor/ae-editor.rb', line 3943

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

#resolve_tab_name(_tab_name) ⇒ Object



4124
4125
4126
4127
4128
4129
4130
# File 'ext/ae-editor/ae-editor.rb', line 4124

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



4511
4512
4513
# File 'ext/ae-editor/ae-editor.rb', line 4511

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

#save_file(_filename) ⇒ Object



4507
4508
4509
# File 'ext/ae-editor/ae-editor.rb', line 4507

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

#show_hide_current_line_numbersObject



3900
3901
3902
3903
# File 'ext/ae-editor/ae-editor.rb', line 3900

def show_hide_current_line_numbers
  _e = raised
  _e.show_hide_line_numbers if _e
end

#start_findObject



3895
3896
3897
3898
# File 'ext/ae-editor/ae-editor.rb', line 3895

def start_find
  _e = raised
  _e.find if _e
end

#tab_file_name(_filename = "") ⇒ Object



4113
4114
4115
4116
4117
# File 'ext/ae-editor/ae-editor.rb', line 4113

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

#tab_name(_str = "") ⇒ Object



4108
4109
4110
4111
# File 'ext/ae-editor/ae-editor.rb', line 4108

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

#tab_title(_tab) ⇒ Object



4100
4101
4102
# File 'ext/ae-editor/ae-editor.rb', line 4100

def tab_title(_tab)
  @main_frame.enb.itemcget(page_name(_tab), 'text')
end

#tab_title_by_tab_name(_tab_name) ⇒ Object



4104
4105
4106
# File 'ext/ae-editor/ae-editor.rb', line 4104

def tab_title_by_tab_name(_tab_name)
  @main_frame.enb.itemcget(resolve_tab_name(_tab_name), 'text')
end

#unname_read_only(_name) ⇒ Object



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

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