Class: AgMultiEditor

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

Instance Attribute Summary collapse

Attributes inherited from ArcadiaExt

#arcadia

Instance Method Summary collapse

Methods included from Autils

#full_in_path_command, #is_windows?

Methods inherited from ArcadiaExt

#conf, #conf_array, #exec, #float_frame, #frame, #initialize

Constructor Details

This class inherits a constructor from ArcadiaExt

Instance Attribute Details

#breakpointsObject (readonly)

Returns the value of attribute breakpoints.



2831
2832
2833
# File 'ext/ae-editor/ae-editor.rb', line 2831

def breakpoints
  @breakpoints
end

#splitted_frameObject (readonly)

Returns the value of attribute splitted_frame.



2832
2833
2834
# File 'ext/ae-editor/ae-editor.rb', line 2832

def splitted_frame
  @splitted_frame
end

Instance Method Details

#accept_complete_codeObject



3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
# File 'ext/ae-editor/ae-editor.rb', line 3545

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

#bookmark_add(_file, _index) ⇒ Object



3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
# File 'ext/ae-editor/ae-editor.rb', line 3209

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



3226
3227
3228
3229
# File 'ext/ae-editor/ae-editor.rb', line 3226

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

#bookmark_move(_n = 0) ⇒ Object



3236
3237
3238
3239
3240
3241
3242
3243
# File 'ext/ae-editor/ae-editor.rb', line 3236

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



3231
3232
3233
3234
# File 'ext/ae-editor/ae-editor.rb', line 3231

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

#bookmark_prevObject



3246
3247
3248
3249
# File 'ext/ae-editor/ae-editor.rb', line 3246

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

#breakpoint_add(_file, _line) ⇒ Object



3154
3155
3156
# File 'ext/ae-editor/ae-editor.rb', line 3154

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

#breakpoint_del(_file, _line) ⇒ Object



3158
3159
3160
# File 'ext/ae-editor/ae-editor.rb', line 3158

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

#breakpoint_lines_on_file(_file) ⇒ Object



3162
3163
3164
3165
3166
3167
3168
3169
3170
# File 'ext/ae-editor/ae-editor.rb', line 3162

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

#change_file(_old_file, _new_file) ⇒ Object



3307
3308
3309
3310
3311
3312
3313
# File 'ext/ae-editor/ae-editor.rb', line 3307

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

#change_file_name(_tab, _new_file) ⇒ Object



3315
3316
3317
3318
3319
# File 'ext/ae-editor/ae-editor.rb', line 3315

def change_file_name(_tab, _new_file)
  _new_label = File.basename(_new_file)
  change_tab_title(_tab, _new_label)
  @tabs_file[page_name(_tab)] = _new_file
end

#change_outline(_e, _raised = false) ⇒ Object



3360
3361
3362
3363
3364
3365
3366
3367
# File 'ext/ae-editor/ae-editor.rb', line 3360

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



3295
3296
3297
3298
3299
3300
3301
# File 'ext/ae-editor/ae-editor.rb', line 3295

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

#change_tab_reset_read_only(_tab) ⇒ Object



3278
3279
3280
3281
3282
3283
# File 'ext/ae-editor/ae-editor.rb', line 3278

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



3286
3287
3288
3289
# File 'ext/ae-editor/ae-editor.rb', line 3286

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



3273
3274
3275
3276
# File 'ext/ae-editor/ae-editor.rb', line 3273

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



3303
3304
3305
# File 'ext/ae-editor/ae-editor.rb', line 3303

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

#close_all_editor(_editor, _mod = true) ⇒ Object



3495
3496
3497
3498
3499
3500
3501
# File 'ext/ae-editor/ae-editor.rb', line 3495

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_editor(_editor, _mod = true) ⇒ Object



3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
# File 'ext/ae-editor/ae-editor.rb', line 3503

def close_editor(_editor, _mod=true)
  if ((_mod)&&(_editor.modified?))
    _message = @main_frame.enb.itemcget(page_name(_editor.page_frame), 'text')+"\n modified. Save?"
    _r = TkDialog2.new('message'=>_message, 'buttons'=>['Ok','No','Cancel']).show()
    if _r == 0
      _editor.save
    elsif _r == 1
      close_tab(_editor.page_frame)
    elsif _r == 2
      return
    end
  else
    close_tab(_editor.page_frame)
  end
  #EditorContract.instance.file_closed(self, 'file'=>_editor.file)
end

#close_file(_filename) ⇒ Object



3532
3533
3534
3535
# File 'ext/ae-editor/ae-editor.rb', line 3532

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

#close_others_editor(_editor, _mod = true) ⇒ Object



3487
3488
3489
3490
3491
3492
3493
# File 'ext/ae-editor/ae-editor.rb', line 3487

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



3144
3145
3146
3147
3148
3149
3150
3151
3152
# File 'ext/ae-editor/ae-editor.rb', line 3144

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

  #_page = @main_frame.enb.raise
  #_editor = @tabs_editor[_page]
  #_row = _editor.text_insert_index.split('.')[0].strip.to_i
  #close_editor(_editor)
end

#close_tab(_page_frame) ⇒ Object



3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
# File 'ext/ae-editor/ae-editor.rb', line 3520

def close_tab(_page_frame)
  _name = page_name(_page_frame)
  @tabs_editor.delete(_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.top_text('') if TkWinfo.mapped?(frame.hinner_frame)
  end
end

#create_findObject



3105
3106
3107
3108
3109
# File 'ext/ae-editor/ae-editor.rb', line 3105

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

#debug_beginObject



3321
3322
3323
3324
3325
3326
3327
# File 'ext/ae-editor/ae-editor.rb', line 3321

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

#debug_endObject



3329
3330
3331
3332
3333
3334
3335
# File 'ext/ae-editor/ae-editor.rb', line 3329

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

#debug_resetObject



3337
3338
3339
3340
3341
# File 'ext/ae-editor/ae-editor.rb', line 3337

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

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



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

def do_buffer_raise(_name, _title='...')
  _index = @main_frame.enb.index(_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[_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
  if @arcadia.layout.headed?
    frame.top_text(_new_caption)
    #@arcadia.layout.domain(@arcadia['conf'][@name+'.frame'])['root'].top_text(_new_caption)
  end
  _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)


3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
# File 'ext/ae-editor/ae-editor.rb', line 3395

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(_name)
  if _index == -1
    _index = @main_frame.enb.index(name_read_only(_name))
  end
  return _index != -1
end

#get_findObject



3100
3101
3102
# File 'ext/ae-editor/ae-editor.rb', line 3100

def get_find
  @find
end

#get_tab_from_name(_name = nil) ⇒ Object



3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
# File 'ext/ae-editor/ae-editor.rb', line 3252

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

#name_read_only(_name) ⇒ Object



3265
3266
3267
# File 'ext/ae-editor/ae-editor.rb', line 3265

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

#on_after_build(_event) ⇒ Object



2874
2875
2876
# File 'ext/ae-editor/ae-editor.rb', line 2874

def on_after_build(_event)
  self.open_last_files
end

#on_after_debug(_event) ⇒ Object



2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
# File 'ext/ae-editor/ae-editor.rb', line 2990

def on_after_debug(_event)
  case _event
    when StartDebugEvent
      self.debug_begin
    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}"
      @breakpoints.delete_if{|b| (b[:file]==_event.file && b[:line]==_event.row)}
      _e = @tabs_editor[tab_file_name(_event.file)]
      _e.remove_tag_breakpoint(_event.row) if _e
  end
end

#on_before_build(_event) ⇒ Object



2833
2834
2835
2836
2837
2838
2839
2840
2841
# File 'ext/ae-editor/ae-editor.rb', line 2833

def on_before_build(_event)
  @breakpoints =Array.new
  @tabs_file =Hash.new
  @tabs_editor =Hash.new
  Arcadia.attach_listener(self, BufferEvent)
  Arcadia.attach_listener(self, DebugEvent)
  Arcadia.attach_listener(self, RunRubyFileEvent)
  Arcadia.attach_listener(self, StartDebugEvent)
end

#on_before_debug(_event) ⇒ Object



2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
# File 'ext/ae-editor/ae-editor.rb', line 2970

def on_before_debug(_event)
  case _event
    when SetBreakpointEvent
      if _event.active == 1
        @breakpoints << {:file=>_event.file,:line=>_event.row}
        _e = @tabs_editor[tab_file_name(_event.file)]
        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_ruby_file(_event) ⇒ Object



2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
# File 'ext/ae-editor/ae-editor.rb', line 2844

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

#on_before_start_debug(_event) ⇒ Object



2859
2860
2861
2862
2863
2864
2865
# File 'ext/ae-editor/ae-editor.rb', line 2859

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

#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


2966
2967
2968
# File 'ext/ae-editor/ae-editor.rb', line 2966

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


3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
# File 'ext/ae-editor/ae-editor.rb', line 3028

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 = Tk.getOpenFile
        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
    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 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



2867
2868
2869
2870
2871
2872
# File 'ext/ae-editor/ae-editor.rb', line 2867

def on_build(_event)
  @main_frame = AgMultiEditorView.new(self.frame.hinner_frame)
  create_find
  pop_up_menu
  #self.open_last_files
end

#on_debug_step_info(_event) ⇒ Object



3015
3016
3017
3018
3019
3020
3021
3022
# File 'ext/ae-editor/ae-editor.rb', line 3015

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



3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
# File 'ext/ae-editor/ae-editor.rb', line 3116

def on_finalize(_event)
  @batch_files = true
  _files =''
  @tabs_editor.each_value{|editor|
    if editor.file != nil
      _files=_files+'|' if _files.strip.length > 0
      _files=_files + editor.file
    end
    #p editor.text.dump_tag('0.1',editor.text.index('end'))
    close_editor(editor)
  }
  Arcadia.persistent('editor.files.open', _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



3172
3173
3174
3175
3176
3177
# File 'ext/ae-editor/ae-editor.rb', line 3172

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, w1 = 150) ⇒ Object



3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
# File 'ext/ae-editor/ae-editor.rb', line 3447

def open_buffer(_buffer_name = nil, _title = nil, w1=150)
  _index = @main_frame.enb.index(_buffer_name)
  if _buffer_name == nil
  		_buffer_name = tab_name('new')
  		_title_new = '*new'
  end
  
  if _index != -1
    _tab = @main_frame.enb.get_frame(_buffer_name)
    @main_frame.enb.raise(_buffer_name)
  else
    _n = 1
    while @main_frame.enb.index(_buffer_name) != -1
      _title_new = '*new'+_n.to_s
      _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,
      'background'=> Arcadia.style("tabpanel.background"),
      'foreground'=> Arcadia.style("tabpanel.foreground"),
      'raisecmd'=>proc{do_buffer_raise(_buffer_name, _title)}
    )
    _e = AgEditor.new(self, _tab)
    ext = _e.file_extension(_title)
    ext='rb' if ext.nil?
    _e.init_editing(ext, w1)
    _e.text.set_focus
    #@tabs_file[_buffer_name]= nil
    @tabs_editor[_buffer_name]=_e
  end
  @main_frame.enb.move(_buffer_name, 1)
  @main_frame.enb.raise(_buffer_name)
  @main_frame.enb.see(_buffer_name)
  return _tab
end

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



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

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
  
  if _exist_buffer
    open_buffer(_tab_name)
  else
    @tabs_file[_tab_name]= _filename
    if _exp
      open_buffer(_tab_name, _basefilename)
    else
      open_buffer(_tab_name, _basefilename,0)
    end
    #@tabs_file[_tab_name]= _filename
    @tabs_editor[_tab_name].load_file(_filename)
  end
  
  if _text_index != nil && _text_index != '1.0'
    @tabs_editor[_tab_name].text_see(_text_index)
    @tabs_editor[_tab_name].mark_selected(_text_index) if _mark_selected 
  end

  return @tabs_editor[_tab_name]
end

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



3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
# File 'ext/ae-editor/ae-editor.rb', line 3343

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

#open_last_filesObject

def update(_kind,_name)

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


3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
# File 'ext/ae-editor/ae-editor.rb', line 3186

def open_last_files
  @batch_files = true
  if $arcadia['pers']['editor.files.open']
    _files_index =$arcadia['pers']['editor.files.open'].split("|")
    _files_index.each do |value| 
      _file,_index = value.split(';')
      if _file
        open_file(_file,_index)
      end
    end
  end
  @batch_files = false
  _first_page = @main_frame.enb.pages(0) if @main_frame.enb.pages.length > 0
  if _first_page
    @main_frame.enb.raise(_first_page)
    @main_frame.enb.see(_first_page)
  end
  frame(1)
  #@arcadia.layout.add_observer(self)
  Arcadia.attach_listener(self, LayoutRaisingFrameEvent)
  self
end

#page_name(_page_frame) ⇒ Object



3291
3292
3293
# File 'ext/ae-editor/ae-editor.rb', line 3291

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

#pop_up_menuObject



2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
# File 'ext/ae-editor/ae-editor.rb', line 2878

def pop_up_menu
  @pop_up = TkMenu.new(
    :parent=>@main_frame.enb,
    :tearoff=>0,
    :title => 'Menu'
  )
  @pop_up.configure(Arcadia.style('menu'))
  #Arcadia.instance.main_menu.update_style(@pop_up)
  @pop_up.insert('end',
    :command,
    :label=>'...',
    :state=>'disabled',
    :background=>Arcadia.conf('titlelabel.background'),
    :font => "#{Arcadia.conf('menu.font')} bold",
    :hidemargin => true
  )

  @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
    }
  )

  @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 =  @main_frame.enb.itemcget(@selected_tab_name_from_popup, 'text')
        @pop_up.entryconfigure(0, 'label'=>_file)
        @pop_up.popup(_x,_y)
      end
    })
end

#raisedObject



3139
3140
3141
3142
# File 'ext/ae-editor/ae-editor.rb', line 3139

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

#save_as_file(_filename) ⇒ Object



3541
3542
3543
# File 'ext/ae-editor/ae-editor.rb', line 3541

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

#save_file(_filename) ⇒ Object



3537
3538
3539
# File 'ext/ae-editor/ae-editor.rb', line 3537

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

#start_findObject



3111
3112
3113
3114
# File 'ext/ae-editor/ae-editor.rb', line 3111

def start_find
  _e = raised
  _e.find if _e
end

#tab_file_name(_filename = "") ⇒ Object



3412
3413
3414
3415
3416
# File 'ext/ae-editor/ae-editor.rb', line 3412

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

#tab_name(_str = "") ⇒ Object



3407
3408
3409
3410
# File 'ext/ae-editor/ae-editor.rb', line 3407

def tab_name(_str="")
  #_str = _str.downcase if is_windows?
  'ff'+_str.downcase.gsub("/","_").gsub(".","_").gsub(":","_").gsub("\\","_")
end

#unname_read_only(_name) ⇒ Object



3269
3270
3271
# File 'ext/ae-editor/ae-editor.rb', line 3269

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