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.



2777
2778
2779
# File 'ext/ae-editor/ae-editor.rb', line 2777

def breakpoints
  @breakpoints
end

#splitted_frameObject (readonly)

Returns the value of attribute splitted_frame.



2778
2779
2780
# File 'ext/ae-editor/ae-editor.rb', line 2778

def splitted_frame
  @splitted_frame
end

Instance Method Details

#accept_complete_codeObject



3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
# File 'ext/ae-editor/ae-editor.rb', line 3461

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



3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
# File 'ext/ae-editor/ae-editor.rb', line 3135

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



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

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

#bookmark_move(_n = 0) ⇒ Object



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

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



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

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

#bookmark_prevObject



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

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

#breakpoint_add(_file, _line) ⇒ Object



3080
3081
3082
# File 'ext/ae-editor/ae-editor.rb', line 3080

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

#breakpoint_del(_file, _line) ⇒ Object



3084
3085
3086
# File 'ext/ae-editor/ae-editor.rb', line 3084

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

#breakpoint_lines_on_file(_file) ⇒ Object



3088
3089
3090
3091
3092
3093
3094
3095
3096
# File 'ext/ae-editor/ae-editor.rb', line 3088

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_name(_tab, _new_file) ⇒ Object



3233
3234
3235
3236
3237
# File 'ext/ae-editor/ae-editor.rb', line 3233

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



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

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



3221
3222
3223
3224
3225
3226
3227
# File 'ext/ae-editor/ae-editor.rb', line 3221

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



3204
3205
3206
3207
3208
3209
# File 'ext/ae-editor/ae-editor.rb', line 3204

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



3212
3213
3214
3215
# File 'ext/ae-editor/ae-editor.rb', line 3212

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



3199
3200
3201
3202
# File 'ext/ae-editor/ae-editor.rb', line 3199

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



3229
3230
3231
# File 'ext/ae-editor/ae-editor.rb', line 3229

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



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

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



3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
# File 'ext/ae-editor/ae-editor.rb', line 3420

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



3449
3450
3451
# File 'ext/ae-editor/ae-editor.rb', line 3449

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

#close_others_editor(_editor, _mod = true) ⇒ Object



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

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



3071
3072
3073
3074
3075
3076
3077
3078
# File 'ext/ae-editor/ae-editor.rb', line 3071

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

  #_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



3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
# File 'ext/ae-editor/ae-editor.rb', line 3437

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



3033
3034
3035
3036
3037
# File 'ext/ae-editor/ae-editor.rb', line 3033

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

#debug_beginObject



3239
3240
3241
3242
3243
3244
3245
# File 'ext/ae-editor/ae-editor.rb', line 3239

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

#debug_endObject



3247
3248
3249
3250
3251
3252
3253
# File 'ext/ae-editor/ae-editor.rb', line 3247

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

#debug_resetObject



3255
3256
3257
3258
3259
# File 'ext/ae-editor/ae-editor.rb', line 3255

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

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



3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
# File 'ext/ae-editor/ae-editor.rb', line 3287

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)


3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
# File 'ext/ae-editor/ae-editor.rb', line 3313

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



3028
3029
3030
# File 'ext/ae-editor/ae-editor.rb', line 3028

def get_find
  @find
end

#get_tab_from_name(_name = nil) ⇒ Object



3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
# File 'ext/ae-editor/ae-editor.rb', line 3178

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



3191
3192
3193
# File 'ext/ae-editor/ae-editor.rb', line 3191

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

#on_after_build(_event) ⇒ Object



2820
2821
2822
# File 'ext/ae-editor/ae-editor.rb', line 2820

def on_after_build(_event)
  self.open_last_files
end

#on_after_debug(_event) ⇒ Object



2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
# File 'ext/ae-editor/ae-editor.rb', line 2936

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



2779
2780
2781
2782
2783
2784
2785
2786
2787
# File 'ext/ae-editor/ae-editor.rb', line 2779

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



2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
# File 'ext/ae-editor/ae-editor.rb', line 2916

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



2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
# File 'ext/ae-editor/ae-editor.rb', line 2790

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



2805
2806
2807
2808
2809
2810
2811
# File 'ext/ae-editor/ae-editor.rb', line 2805

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


2912
2913
2914
# File 'ext/ae-editor/ae-editor.rb', line 2912

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


2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
# File 'ext/ae-editor/ae-editor.rb', line 2974

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

#on_build(_event) ⇒ Object



2813
2814
2815
2816
2817
2818
# File 'ext/ae-editor/ae-editor.rb', line 2813

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



2961
2962
2963
2964
2965
2966
2967
2968
# File 'ext/ae-editor/ae-editor.rb', line 2961

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



3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
# File 'ext/ae-editor/ae-editor.rb', line 3044

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



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

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



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

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



3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
# File 'ext/ae-editor/ae-editor.rb', line 3336

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



3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
# File 'ext/ae-editor/ae-editor.rb', line 3261

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


3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
# File 'ext/ae-editor/ae-editor.rb', line 3112

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



3217
3218
3219
# File 'ext/ae-editor/ae-editor.rb', line 3217

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

#pop_up_menuObject



2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
# File 'ext/ae-editor/ae-editor.rb', line 2824

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



3066
3067
3068
3069
# File 'ext/ae-editor/ae-editor.rb', line 3066

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

#save_as_file(_filename) ⇒ Object



3457
3458
3459
# File 'ext/ae-editor/ae-editor.rb', line 3457

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

#save_file(_filename) ⇒ Object



3453
3454
3455
# File 'ext/ae-editor/ae-editor.rb', line 3453

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

#start_findObject



3039
3040
3041
3042
# File 'ext/ae-editor/ae-editor.rb', line 3039

def start_find
  _e = raised
  _e.find if _e
end

#tab_file_name(_filename = "") ⇒ Object



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

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

#tab_name(_str = "") ⇒ Object



3325
3326
3327
3328
# File 'ext/ae-editor/ae-editor.rb', line 3325

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

#unname_read_only(_name) ⇒ Object



3195
3196
3197
# File 'ext/ae-editor/ae-editor.rb', line 3195

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