Class: AgMultiEditor
Constant Summary
Configurable::ADD_SYMBOL, Configurable::FONT_TYPE_SYMBOL, Configurable::LC_SYMBOL, Configurable::LINK_SYMBOL
Instance Attribute Summary collapse
#index
Attributes inherited from ArcadiaExt
#arcadia, #name
Instance Method Summary
collapse
-
#accept_complete_code ⇒ Object
-
#add_buffer_menu_item(_filename, is_file = true, _sender = self) ⇒ Object
-
#bookmark_lines_on_file(_file) ⇒ Object
-
#breakpoint_add(_file, _line, _id = -1)) ⇒ Object
-
#breakpoint_del(_file, _line, _id = -1)) ⇒ Object
-
#breakpoint_lines_on_file(_file) ⇒ Object
-
#buffer_menu_item_accelerator(_text, _is_file = true) ⇒ Object
def buffer_menu_item_label(_text, _is_file=true) if _is_file # “#File.basename(_text) - #File.dirname(_text)” File.basename(_text) else _text end end.
-
#buffer_menu_item_exist?(_filename) ⇒ Boolean
-
#can_close_editor?(_editor) ⇒ Boolean
-
#change_file(_old_file, _new_file) ⇒ Object
-
#change_file_name(_tab, _new_file) ⇒ Object
-
#change_frame_caption(_name, _new_caption) ⇒ Object
-
#change_outline(_e, _raised = false) ⇒ Object
-
#change_outline_frame_caption(_new_caption) ⇒ Object
-
#change_tab_icon(_tab, _new_text) ⇒ Object
-
#change_tab_reset_modify(_tab) ⇒ Object
-
#change_tab_reset_read_only(_tab) ⇒ Object
-
#change_tab_set_modify(_tab) ⇒ Object
-
#change_tab_set_read_only(_tab) ⇒ Object
-
#change_tab_title(_tab, _new_text, _new_file = nil) ⇒ Object
-
#chrono_bookmark_add(_file, _index) ⇒ Object
-
#chrono_bookmark_clear ⇒ Object
-
#chrono_bookmark_move(_n = 0) ⇒ Object
-
#chrono_bookmark_next ⇒ Object
-
#chrono_bookmark_prev ⇒ Object
-
#clear_temp_files ⇒ Object
-
#close_all_editor(_editor, _mod = true) ⇒ Object
-
#close_buffer(_name, _moved = false) ⇒ Object
-
#close_buffer_frame(_page_frame, _moved = false) ⇒ Object
-
#close_editor(_editor, _force = false) ⇒ Object
-
#close_file(_filename) ⇒ Object
-
#close_others_editor(_editor, _mod = true) ⇒ Object
-
#close_raised ⇒ Object
-
#create_find ⇒ Object
-
#debug_begin ⇒ Object
-
#debug_end ⇒ Object
-
#debug_reset ⇒ Object
-
#deduplicate ⇒ Object
-
#del_buffer_menu_item(_file, _sender = self) ⇒ Object
-
#do_buffer_raise(_name, _title = '...') ⇒ Object
-
#duplicate(_name, _dom) ⇒ Object
-
#editor_by_page_name(_name) ⇒ Object
-
#editor_exist?(_filename) ⇒ Boolean
-
#editor_of(_filename) ⇒ Object
-
#get_find ⇒ Object
-
#highlight_scanner(_ext = nil) ⇒ Object
-
#initialize_status ⇒ Object
-
#language_hash_by_ext(_ext = nil) ⇒ Object
-
#language_hash_by_lang(_lang = nil) ⇒ Object
-
#load_languages_hash ⇒ Object
-
#make_buffer_string(_str = nil) ⇒ Object
-
#mod_buffer_menu_item(_file, _newtext, _newvalue = nil, _sender = self) ⇒ Object
-
#move_buffer_here(_name) ⇒ Object
-
#name_modified(_name) ⇒ Object
-
#name_read_only(_name) ⇒ Object
def get_tab_from_name(_name=nil) return @main_frame.enb.get_frame(_name) end.
-
#on_activate_instance(_event) ⇒ Object
-
#on_after_debug(_event) ⇒ Object
-
#on_after_focus(_event) ⇒ Object
-
#on_before_bookmark(_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.
-
#on_before_build(_event) ⇒ Object
-
#on_before_debug(_event) ⇒ Object
-
#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.
-
#on_before_step_debug(_event) ⇒ Object
-
#on_buffer(_event) ⇒ Object
def on_before_buffer(_event) Arcadia.new_error_msg(self, “on_before_buffer #_event_event.class”) 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.
-
#on_debug_step_info(_event) ⇒ Object
-
#on_exit_query(_event) ⇒ Object
-
#on_finalize(_event) ⇒ Object
-
#on_initialize(_event) ⇒ Object
-
#on_layout_raising_frame(_event) ⇒ Object
-
#open_buffer(_buffer_name = nil, _title = nil, _filename = nil, _lang = nil) ⇒ Object
-
#open_file(_filename = nil, _text_index = '1.0', _mark_selected = true, _exp = true) ⇒ Object
-
#open_file_in_debug(_filename = nil, _line = nil) ⇒ Object
-
#open_last_files ⇒ Object
def update(_kind,_name) if _kind == ‘RAISE’ && _name == ‘editor’ _e = raised change_outline(_e) if _e end end.
-
#outline_bar ⇒ Object
-
#page_name(_page_frame) ⇒ Object
-
#pop_up_menu ⇒ Object
-
#raise_editor(_editor = nil, _text_index = '0.0', _mark_selected = true, _exp = true) ⇒ Object
-
#raise_file(_filename = nil, _pos = nil) ⇒ Object
-
#raised ⇒ Object
-
#raised_name ⇒ Object
-
#refresh_buffer_string ⇒ Object
-
#refresh_selected_buffer_menu_item ⇒ Object
-
#refresh_status ⇒ Object
-
#register_editor(_e, _buffer_name, _file) ⇒ Object
-
#reset_status ⇒ Object
-
#resolve_tab_name(_tab_name) ⇒ Object
-
#save_as_file(_filename) ⇒ Object
-
#save_file(_filename) ⇒ Object
-
#show_hide_current_line_numbers ⇒ Object
-
#show_hide_tabs ⇒ Object
-
#start_find ⇒ Object
-
#tab_file_name(_filename = "") ⇒ Object
-
#tab_name(_str = "") ⇒ Object
-
#tab_title(_tab) ⇒ Object
-
#tab_title_by_tab_name(_tab_name) ⇒ Object
-
#top_text_string ⇒ Object
-
#unname_modified(_name) ⇒ Object
-
#unname_read_only(_name) ⇒ Object
-
#unregister_editor(_buffer_name) ⇒ Object
clear_properties_group_cache, #hash2properties_file, #make_locale_value, #make_value, #properties_file2hash, properties_group, #resolve_locale_value, #resolve_properties_link, #resolve_value
#activate, #activate_main, #active?, #active_instance, #clean_instance, #clone, #exist_name?, #frame, #initialize, #instance_index, instances, #instances, #main_instance, #main_instance?, #new_name, #on_destroy_instance
Methods inherited from ArcadiaExt
#add_to_conf_property, #array_conf, #conf, #conf_array, #conf_default, #del_from_conf_property, #destroy_frame, #exec, #float_frame, #frame, #frame_def_visible?, #frame_domain, #frame_domain_default, #frame_title, #frame_visible?, #hide_frame, #initialize, #maximize, #maximized?, #resize, #restore_default_conf
Constructor Details
This class inherits a constructor from ArcadiaExtPlus
Instance Attribute Details
4067
4068
4069
|
# File 'ext/ae-editor/ae-editor.rb', line 4067
def ctags_string
@ctags_string
end
|
4067
4068
4069
|
# File 'ext/ae-editor/ae-editor.rb', line 4067
def has_ctags
@has_ctags
end
|
#main_frame ⇒ Object
Returns the value of attribute main_frame.
4068
4069
4070
|
# File 'ext/ae-editor/ae-editor.rb', line 4068
def main_frame
@main_frame
end
|
#splitted_frame ⇒ Object
4065
4066
4067
|
# File 'ext/ae-editor/ae-editor.rb', line 4065
def splitted_frame
@splitted_frame
end
|
Instance Method Details
#accept_complete_code ⇒ Object
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
|
# File 'ext/ae-editor/ae-editor.rb', line 5805
def accept_complete_code
@ok_complete = true
if !defined?(@ok_complete)
end
return @ok_complete
end
|
4310
4311
4312
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
4342
4343
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
|
# File 'ext/ae-editor/ae-editor.rb', line 4310
def (_filename, is_file=true, _sender=self)
@buffer_number.numeric += 1
index = 'end'
i_end = @buffer_menu.index('end')
if i_end
0.upto(i_end){|j|
type = @buffer_menu.(j)
if type != 'separator'
value = @buffer_menu.entrycget(j,'value').to_s
if value > _filename
index=j
break
elsif value == _filename
return nil
end
end
}
end
select_buffer = proc{
if _sender == self
if is_file
open_file(_filename)
else
open_buffer(tab_name(_filename))
end
else
if is_file
move_buffer_here(tab_file_name(_filename))
else
move_buffer_here(tab_name(_filename))
end
end
}
label = File.basename(_filename)
item = @buffer_menu.insert(index,:radio,
:label=>label,
:accelerator=>(_filename, is_file),
:value=>_filename,
:image=> Arcadia.file_icon(_filename),
:compound=>'left',
:command=>select_buffer,
:hidemargin => true
)
if _sender == self
instances.each{|i|
if i != self && !i.(_filename)
i.(_filename, is_file, self)
i.refresh_buffer_string
end
}
refresh_buffer_string
end
item
end
|
#bookmark_lines_on_file(_file) ⇒ Object
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
|
# File 'ext/ae-editor/ae-editor.rb', line 5106
def bookmark_lines_on_file(_file)
result = Array.new
@bookmarks.each{|value|
if value[:file]==_file
value[:from_line].upto(value[:to_line]) do |i|
result << i.to_s
end
end
}
return result
end
|
#breakpoint_add(_file, _line, _id = -1)) ⇒ Object
5088
5089
5090
|
# File 'ext/ae-editor/ae-editor.rb', line 5088
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
#breakpoint_lines_on_file(_file) ⇒ Object
5096
5097
5098
5099
5100
5101
5102
5103
5104
|
# File 'ext/ae-editor/ae-editor.rb', line 5096
def breakpoint_lines_on_file(_file)
result = Array.new
@breakpoints.each{|value|
if value[:file]==_file
result << value[:line]
end
}
return result
end
|
def buffer_menu_item_label(_text, _is_file=true)
if _is_file
# "#{File.basename(_text)} - #{File.dirname(_text)}"
File.basename(_text)
else
_text
end
end
4380
4381
4382
4383
4384
4385
4386
|
# File 'ext/ae-editor/ae-editor.rb', line 4380
def (_text, _is_file=true)
if _is_file
File.dirname(_text)
else
'...'
end
end
|
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
|
# File 'ext/ae-editor/ae-editor.rb', line 4292
def (_filename)
exist = false
i_end = @buffer_menu.index('end')
if i_end
0.upto(i_end){|j|
type = @buffer_menu.(j)
if type != 'separator'
value = @buffer_menu.entrycget(j,'value').to_s
if value == _filename
exist = true
break
end
end
}
end
exist
end
|
#can_close_editor?(_editor) ⇒ Boolean
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
|
# File 'ext/ae-editor/ae-editor.rb', line 5706
def can_close_editor?(_editor)
ret = true
if _editor.modified?
filename = page_name(_editor.page_frame)
message = Arcadia.text('ext.editor.file.save_modified.msg', [@main_frame.page_title(filename)])
r=Arcadia.dialog(self,
'type'=>'yes_no_cancel',
'level'=>'warning',
'title'=> Arcadia.text('ext.editor.file.save_modified.title'),
'msg'=>message)
if r=="yes"
_editor.save
ret = !_editor.modified?
elsif r=="cancel"
ret = false
end
elsif _editor.modified_by_others?
filename = page_name(_editor.page_frame)
message = Arcadia.text('ext.editor.file.close_modified_by_other.msg', [@main_frame.page_title(filename)])
r=Arcadia.dialog(self,
'type'=>'yes_no',
'level'=>'warning',
'title'=> Arcadia.text('ext.editor.file.close_modified_by_other.title'),
'msg'=>message)
if r=="yes"
_editor.reset_file_last_access_time
refresh_status
ret = !_editor.modified_by_others?
else
ret = false
end
end
ret
end
|
#change_file(_old_file, _new_file) ⇒ Object
5342
5343
5344
5345
5346
5347
5348
|
# File 'ext/ae-editor/ae-editor.rb', line 5342
def change_file(_old_file, _new_file)
_tab_name=tab_file_name(_old_file)
_tab = @main_frame.page_frame(_tab_name)
e = @tabs_editor[_tab_name]
change_file_name(_tab, _new_file)
e.new_file_name(_new_file) if e
end
|
#change_file_name(_tab, _new_file) ⇒ Object
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
|
# File 'ext/ae-editor/ae-editor.rb', line 5350
def change_file_name(_tab, _new_file)
@tabs_file[page_name(_tab)] = _new_file
@raw_buffer_name[tab_file_name(_new_file)]=page_name(_tab)
_new_label = File.basename(_new_file)
change_tab_title(_tab, _new_label, _new_file)
change_tab_icon(_tab, _new_label)
end
|
#change_frame_caption(_name, _new_caption) ⇒ Object
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
|
# File 'ext/ae-editor/ae-editor.rb', line 5304
def change_frame_caption(_name, _new_caption)
if @arcadia.layout.headed?
if frame.root.title == frame.title || @last_frame_caption != _new_caption
make_buffer_string(@main_frame.page(_name)['text']) if @main_frame.page(_name)
frame.root.top_text(top_text_string, @main_frame.page(_name)['image']) if @main_frame.page(_name)
frame.root.top_text_hint(_new_caption)
@last_frame_caption = _new_caption
end
end
end
|
#change_outline(_e, _raised = false) ⇒ Object
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
|
# File 'ext/ae-editor/ae-editor.rb', line 5409
def change_outline(_e, _raised=false)
return if defined?(@@last_outline_e) && @@last_outline_e == _e
_raised = _raised || main_instance.frame(1).raised?
if !@batch_files && _raised
@@last_outline_e.hide_outline if defined?(@@last_outline_e)
if _e && _e.file
change_outline_frame_caption(File.basename(_e.file))
end
_e.show_outline
@@last_outline_e = _e
end
end
|
#change_outline_frame_caption(_new_caption) ⇒ Object
5316
5317
5318
5319
5320
5321
5322
5323
|
# File 'ext/ae-editor/ae-editor.rb', line 5316
def change_outline_frame_caption(_new_caption)
if @arcadia.layout.headed?
if main_instance.frame(1).root.title == main_instance.frame(1).title
main_instance.frame(1).root.top_text(_new_caption)
end
main_instance.frame(1).root.save_caption(frame.name, _new_caption)
end
end
|
#change_tab_icon(_tab, _new_text) ⇒ Object
5338
5339
5340
|
# File 'ext/ae-editor/ae-editor.rb', line 5338
def change_tab_icon(_tab, _new_text)
@main_frame.page_title(page_name(_tab), nil, Arcadia.file_icon(_new_text))
end
|
#change_tab_reset_modify(_tab) ⇒ Object
5278
5279
5280
5281
5282
5283
5284
5285
5286
|
# File 'ext/ae-editor/ae-editor.rb', line 5278
def change_tab_reset_modify(_tab)
if @main_frame.index(@main_frame.page_name(_tab))
_new_name = unname_modified(@main_frame.page_title(page_name(_tab)))
if _new_name
change_tab_title(_tab, _new_name)
end
end
end
|
#change_tab_reset_read_only(_tab) ⇒ Object
5233
5234
5235
5236
5237
5238
|
# File 'ext/ae-editor/ae-editor.rb', line 5233
def change_tab_reset_read_only(_tab)
_new_name = unname_read_only(@main_frame.page_title(page_name(_tab)))
if _new_name
change_tab_title(_tab, _new_name)
end
end
|
#change_tab_set_modify(_tab) ⇒ Object
5241
5242
5243
|
# File 'ext/ae-editor/ae-editor.rb', line 5241
def change_tab_set_modify(_tab)
change_tab_title(_tab, name_modified(@main_frame.page_title(page_name(_tab))))
end
|
#change_tab_set_read_only(_tab) ⇒ Object
5228
5229
5230
5231
|
# File 'ext/ae-editor/ae-editor.rb', line 5228
def change_tab_set_read_only(_tab)
_new_name = name_read_only(@main_frame.page_title(page_name(_tab)))
change_tab_title(_tab, _new_name)
end
|
#change_tab_title(_tab, _new_text, _new_file = nil) ⇒ Object
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
|
# File 'ext/ae-editor/ae-editor.rb', line 5325
def change_tab_title(_tab, _new_text, _new_file=nil)
p_name = page_name(_tab)
old_text = @main_frame.page_title(p_name)
if @tabs_editor[p_name] && @tabs_editor[p_name].file
(@tabs_editor[p_name].file, _new_text, _new_file, self)
else
(unname_modified(tab_title_by_tab_name(p_name)), _new_text, nil, self)
end
@main_frame.page_title(p_name, _new_text)
end
|
#chrono_bookmark_add(_file, _index) ⇒ Object
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
|
# File 'ext/ae-editor/ae-editor.rb', line 5164
def chrono_bookmark_add(_file, _index)
if @chrono_bookmarks == nil
@chrono_bookmarks = Array.new
@chrono_bookmarks_index = - 1
else
_cur_file, _cur_index = @chrono_bookmarks[@chrono_bookmarks_index]
if _cur_file == _file && _cur_index == _index
return
end
@chrono_bookmarks = @chrono_bookmarks[0..@chrono_bookmarks_index]
end
@chrono_bookmarks << [_file, _index]
@chrono_bookmarks_index = @chrono_bookmarks.length - 1
end
|
#chrono_bookmark_clear ⇒ Object
5181
5182
5183
5184
|
# File 'ext/ae-editor/ae-editor.rb', line 5181
def chrono_bookmark_clear
@chrono_bookmarks.clear
@chrono_bookmarks_index = - 1
end
|
#chrono_bookmark_move(_n = 0) ⇒ Object
5191
5192
5193
5194
5195
5196
5197
5198
|
# File 'ext/ae-editor/ae-editor.rb', line 5191
def chrono_bookmark_move(_n=0)
@chrono_bookmarks_index = @chrono_bookmarks_index + _n
_file, _index = @chrono_bookmarks[@chrono_bookmarks_index]
_line, _col = _index.split('.') if _index
open_file(_file, _index)
end
|
#chrono_bookmark_next ⇒ Object
5186
5187
5188
5189
|
# File 'ext/ae-editor/ae-editor.rb', line 5186
def chrono_bookmark_next
return if @chrono_bookmarks == nil || @chrono_bookmarks_index >= @chrono_bookmarks.length - 1
chrono_bookmark_move(+1)
end
|
#chrono_bookmark_prev ⇒ Object
5201
5202
5203
5204
|
# File 'ext/ae-editor/ae-editor.rb', line 5201
def chrono_bookmark_prev
return if @chrono_bookmarks == nil || @chrono_bookmarks_index <= 0
chrono_bookmark_move(-1)
end
|
#clear_temp_files ⇒ Object
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
|
# File 'ext/ae-editor/ae-editor.rb', line 5051
def clear_temp_files
files = Dir[File.join(Arcadia.instance.local_dir,"*")]
files.each{|f|
if File.stat(f).file? && File.basename(f)[0..1] == '~~'
File.delete(f)
elsif File.stat(f).directory? && File.basename(f)[0..1] == '~~'
Dir[File.join(f,"*")].each{|file|
File.delete(file)
}
Dir.delete(f)
end
}
end
|
#close_all_editor(_editor, _mod = true) ⇒ Object
5698
5699
5700
5701
5702
5703
5704
|
# File 'ext/ae-editor/ae-editor.rb', line 5698
def close_all_editor(_editor, _mod=true)
@batch_files = true
@tabs_editor.values.each do |_e|
close_editor(_e)
end
@batch_files = false
end
|
#close_buffer(_name, _moved = false) ⇒ Object
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
|
# File 'ext/ae-editor/ae-editor.rb', line 5761
def close_buffer(_name, _moved=false)
is_raised = @main_frame.raise == _name
if @tabs_editor[_name] && @tabs_editor[_name].file
(@tabs_editor[_name].file)
else
(unname_modified(tab_title_by_tab_name(_name)))
end
unregister_editor(_name)
_index = @main_frame.index(_name)
@main_frame.delete_page(_name, !_moved)
if is_raised
if !@main_frame.pages.empty? len = @main_frame.pages.length
if _index < len
ind = _index
else
ind = _index-1
end
@main_frame.raise(@main_frame.pages[ind]) if TkWinfo.mapped?(@main_frame.root_frame)
else
frame.root.top_text_clear if TkWinfo.mapped?(frame.hinner_frame)
make_buffer_string("")
reset_status
end
end
end
|
#close_buffer_frame(_page_frame, _moved = false) ⇒ Object
5756
5757
5758
5759
|
# File 'ext/ae-editor/ae-editor.rb', line 5756
def close_buffer_frame(_page_frame, _moved=false)
name = page_name(_page_frame)
close_buffer(name, _moved)
end
|
#close_editor(_editor, _force = false) ⇒ Object
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
|
# File 'ext/ae-editor/ae-editor.rb', line 5742
def close_editor(_editor, _force=false)
if _force || can_close_editor?(_editor)
file = _editor.file
index = _editor.text.index("@0,0")
r,c = index.split('.')
_editor.destroy_outline
change_outline_frame_caption('') if raised==_editor
close_buffer_frame(_editor.page_frame)
BufferClosedEvent.new(self,'file'=>file,'row'=>r.to_i, 'col'=>c.to_i).shot!
else
return
end
end
|
#close_file(_filename) ⇒ Object
5792
5793
5794
5795
|
# File 'ext/ae-editor/ae-editor.rb', line 5792
def close_file(_filename)
_e = @tabs_editor[tab_name(_filename)]
close_editor(_e) if _e
end
|
#close_others_editor(_editor, _mod = true) ⇒ Object
5690
5691
5692
5693
5694
5695
5696
|
# File 'ext/ae-editor/ae-editor.rb', line 5690
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_raised ⇒ Object
5083
5084
5085
5086
|
# File 'ext/ae-editor/ae-editor.rb', line 5083
def close_raised
_e = @tabs_editor[resolve_tab_name(@main_frame.raise)]
close_editor(_e) if _e
end
|
#create_find ⇒ Object
4990
4991
4992
4993
4994
|
# File 'ext/ae-editor/ae-editor.rb', line 4990
def create_find
@find = Finder.new(@arcadia.layout.root, self)
@find.on_close=proc{@find.hide}
@find.hide
end
|
#debug_begin ⇒ Object
5362
5363
5364
5365
5366
5367
5368
|
# File 'ext/ae-editor/ae-editor.rb', line 5362
def debug_begin
if @editors_in_debug != nil
@editors_in_debug.clear
else
@editors_in_debug = Array.new
end
end
|
#debug_end ⇒ Object
5370
5371
5372
5373
5374
5375
5376
|
# File 'ext/ae-editor/ae-editor.rb', line 5370
def debug_end
@editors_in_debug.each{|e|
close_editor(e)
}
end
|
#debug_reset ⇒ Object
5378
5379
5380
5381
5382
|
# File 'ext/ae-editor/ae-editor.rb', line 5378
def debug_reset
if @last_index && @last_e
@last_e.unmark_debug(@last_index)
end
end
|
#deduplicate ⇒ Object
4262
4263
4264
4265
4266
4267
|
# File 'ext/ae-editor/ae-editor.rb', line 4262
def deduplicate
@main_frame.pages.each{|page|
main_instance.move_buffer_here(page)
}
super
end
|
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
|
# File 'ext/ae-editor/ae-editor.rb', line 4388
def (_file, _sender=self)
@buffer_number.numeric -= 1
to_del = -1
i_end = @buffer_menu.index('end')
return if i_end.nil?
0.upto(i_end){|j|
type = @buffer_menu.(j)
if type != 'separator'
value = @buffer_menu.entrycget(j,'value')
if value == _file
to_del=j
break
end
end
}
@buffer_menu.delete(to_del) if to_del != -1
make_buffer_string("") if @buffer_menu.index('end').nil?
if _sender == self
instances.each{|i|
if i != self
i.(_file, self)
i.refresh_buffer_string
end
}
end
end
|
#do_buffer_raise(_name, _title = '...') ⇒ Object
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
|
# File 'ext/ae-editor/ae-editor.rb', line 5422
def do_buffer_raise(_name, _title='...')
_index = @main_frame.index(resolve_tab_name(_name))
_new_caption = '...'
if _index != -1
_e = @tabs_editor[resolve_tab_name(_name)]
change_outline(_e) if _e
if _e && _e.file != nil
_new_caption = _e.file
@find.use(_e)
_e.check_file_last_access_time
else
_new_caption = _title
end
_lang = _e.lang
_e.update_toolbar
end
change_frame_caption(_name, _new_caption)
refresh_status
_title = @tabs_file[_name] != nil ? File.basename(@tabs_file[_name]) :_name
Arcadia.broadcast_event(BufferRaisedEvent.new(self, 'title'=>_title, 'file'=>@tabs_file[_name], 'lang'=>_lang ))
Arcadia.process_event(InputEnterEvent.new(self,'receiver'=>_e.text)) if _e
end
|
#duplicate(_name, _dom) ⇒ Object
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
|
# File 'ext/ae-editor/ae-editor.rb', line 4269
def duplicate(_name, _dom)
instance = super(_name, _dom, false)
i_end = @buffer_menu.index('end')
if i_end
0.upto(i_end){|j|
type = @buffer_menu.(j)
if type != 'separator'
filename = @buffer_menu.entrycget(j,'value').to_s
is_file = filename != nil && File.exists?(filename)
instance.(filename, is_file, self)
end
}
end
instance.move_buffer_here(raised_name)
instance
end
|
#editor_by_page_name(_name) ⇒ Object
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
|
# File 'ext/ae-editor/ae-editor.rb', line 5503
def editor_by_page_name(_name)
_ret = nil
_index = @main_frame.index(resolve_tab_name(_name))
if _index == -1
_name = name_read_only(_name)
_index = @main_frame.index(resolve_tab_name(_name))
end
if _index != -1
_ret = @tabs_editor[resolve_tab_name(_name)]
end
_ret
end
|
#editor_exist?(_filename) ⇒ Boolean
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
|
# File 'ext/ae-editor/ae-editor.rb', line 5516
def editor_exist?(_filename)
_basefilename = File.basename(_filename)
_name = self.tab_file_name(_filename)
_index = @main_frame.index(resolve_tab_name(_name))
if _index == -1
_index = @main_frame.index(resolve_tab_name(name_read_only(_name)))
end
if _index == -1
@editors.each{|e|
if e.last_tmp_file == _filename
_index = 0
break
end
}
end
return _index != -1
end
|
#editor_of(_filename) ⇒ Object
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
|
# File 'ext/ae-editor/ae-editor.rb', line 5480
def editor_of(_filename)
_ret = nil
@editors.each{|e|
if e.file == _filename || e.last_tmp_file == _filename
_ret = e
break
end
}
if _ret.nil?
_basefilename = File.basename(_filename)
_name = self.tab_file_name(_filename)
_index = @main_frame.index(resolve_tab_name(_name))
if _index == -1
_name = name_read_only(_name)
_index = @main_frame.index(resolve_tab_name(_name))
end
if _index != -1
_ret = @tabs_editor[resolve_tab_name(_name)]
end
end
_ret
end
|
#get_find ⇒ Object
4986
4987
4988
|
# File 'ext/ae-editor/ae-editor.rb', line 4986
def get_find
@find
end
|
#highlight_scanner(_ext = nil) ⇒ Object
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
|
# File 'ext/ae-editor/ae-editor.rb', line 4521
def highlight_scanner(_ext=nil)
return nil if _ext.nil?
scanner = nil
@highlight_scanner_hash = Hash.new if !defined?(@highlight_scanner_hash)
lh = language_hash_by_ext(_ext)
if lh && lh['language'] && lh['scanner']
if @highlight_scanner_hash[lh['language']].nil?
case lh['scanner']
when 'coderay'
@highlight_scanner_hash[lh['language']]=CoderayHighlightScanner.new(lh)
when 're'
@highlight_scanner_hash[lh['language']]=ReHighlightScanner.new(lh)
end
end
scanner = @highlight_scanner_hash[lh['language']]
end
scanner
end
|
#initialize_status ⇒ Object
5447
5448
5449
5450
5451
5452
5453
5454
|
# File 'ext/ae-editor/ae-editor.rb', line 5447
def initialize_status
if !defined?(@@statusbar_items)
@@statusbar_items = Hash.new
@@statusbar_items['file_size'] = Arcadia.new_statusbar_item("File size")
@@statusbar_items['file_mtime'] = Arcadia.new_statusbar_item("File modification time")
@@statusbar_items['file_name'] = Arcadia.new_statusbar_item("File name")
end
end
|
#language_hash_by_ext(_ext = nil) ⇒ Object
4570
4571
4572
|
# File 'ext/ae-editor/ae-editor.rb', line 4570
def language_hash_by_ext(_ext=nil)
@langs_hash_by_ext[_ext]
end
|
#language_hash_by_lang(_lang = nil) ⇒ Object
4574
4575
4576
|
# File 'ext/ae-editor/ae-editor.rb', line 4574
def language_hash_by_lang(_lang=nil)
@langs_hash_by_lang[_lang]
end
|
#load_languages_hash ⇒ Object
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
|
# File 'ext/ae-editor/ae-editor.rb', line 4540
def load_languages_hash
@langs_hash_by_ext = Hash.new
@langs_hash_by_lang = Hash.new
lang_files_dir = "#{File.dirname(__FILE__)}/langs"
files = Dir["#{lang_files_dir}/*"].sort
files.each{|lang_file|
af = lang_file.split('.')
if af[-1] == 'lang'
lang_props = properties_file2hash(lang_file)
if lang_props && lang_props['@include'] != nil
include_file = "#{lang_files_dir}/#{lang_props['@include']}"
if File.exist?(include_file)
include_hash = properties_file2hash(include_file)
lang_props = include_hash.merge(lang_props)
end
end
self.resolve_properties_link(lang_props, Arcadia.instance['conf']) if lang_props
lang = lang_props['language']
lang_exts = lang_props['exts'].split(',').collect{|x| x.strip} if lang_props['exts']
@langs_hash_by_lang[lang] = lang_props if lang
lang_exts.each{|ext|
@langs_hash_by_ext[ext] = lang_props
} if lang_exts
end
}
end
|
#make_buffer_string(_str = nil) ⇒ Object
5292
5293
5294
5295
5296
5297
|
# File 'ext/ae-editor/ae-editor.rb', line 5292
def make_buffer_string(_str=nil)
value = "[#{@buffer_number.value}] #{_str}"
@last_buffer_str = _str
@buffer_string.value = value
end
|
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
|
# File 'ext/ae-editor/ae-editor.rb', line 4417
def (_file, _newtext, _newvalue = nil, _sender=self)
to_mod = -1
i_end = @buffer_menu.index('end')
0.upto(i_end){|j|
type = @buffer_menu.(j)
if type != 'separator'
value = @buffer_menu.entrycget(j,'value')
if value == _file
to_mod=j
break
end
end
}
if _file != nil && _newvalue.nil? && File.exists?(_file)
new_accelerator = (_file, true)
else
is_file = _newvalue != nil && File.exists?(_newvalue)
if is_file
new_accelerator = (_newvalue, is_file)
else
new_accelerator = (_newtext, is_file)
end
end
@buffer_menu.entryconfigure(to_mod, 'label'=>_newtext, 'accelerator'=>new_accelerator) if to_mod != -1
if to_mod != -1 && _newvalue != nil
@buffer_menu.entryconfigure(to_mod,
:value => _newvalue,
:image=> Arcadia.file_icon(_newvalue),
:command=>proc{
if is_file
open_file(_newvalue)
else
open_buffer(tab_name(_newvalue))
end
}
)
end
if _sender == self
instances.each{|i|
if i != self && i.(_file)
i.(_file, _newtext, _newvalue, self)
end
}
end
end
|
#move_buffer_here(_name) ⇒ Object
5580
5581
5582
5583
|
# File 'ext/ae-editor/ae-editor.rb', line 5580
def move_buffer_here(_name)
@main_frame.move_here(_name)
end
|
#name_modified(_name) ⇒ Object
5219
5220
5221
|
# File 'ext/ae-editor/ae-editor.rb', line 5219
def name_modified(_name)
'(...)'+_name
end
|
#name_read_only(_name) ⇒ Object
def get_tab_from_name(_name=nil)
return @main_frame.enb.get_frame(_name)
end
5211
5212
5213
|
# File 'ext/ae-editor/ae-editor.rb', line 5211
def name_read_only(_name)
'[READ-ONLY] '+_name
end
|
#on_activate_instance(_event) ⇒ Object
4252
4253
4254
4255
4256
4257
4258
4259
4260
|
# File 'ext/ae-editor/ae-editor.rb', line 4252
def on_activate_instance(_event)
return if defined?(@last_active_instance_name) && @last_active_instance_name == _event.name
if _event.name == @name
refresh_status
_e = raised
change_outline(_e, true) if _e
end
@last_active_instance_name = _event.name if _event.name == @name || exist_name?(_event.name)
end
|
#on_after_debug(_event) ⇒ Object
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
|
# File 'ext/ae-editor/ae-editor.rb', line 4830
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 UnsetBreakpointEvent
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
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
|
# File 'ext/ae-editor/ae-editor.rb', line 4509
def on_after_focus(_event)
if raised && _event.focus_widget == raised.text
if [CutTextEvent, PasteTextEvent, UndoTextEvent, RedoTextEvent].include?(_event.class)
if raised.highlighting
raised.refresh_visible_highlighting
else
raised.check_modify
end
end
end
end
|
#on_before_bookmark(_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
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
|
# File 'ext/ae-editor/ae-editor.rb', line 4709
def on_before_bookmark(_event)
_filename = _event.file
if _filename.nil? || _filename == "*CURR"
current_editor = self.raised
_event.persistent=true
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
else
current_editor = editor_of(_filename)
end
if _event.from_row != nil && _event.to_row == nil
_event.to_row = _event.from_row
elsif _event.from_row == nil && _event.to_row == nil && _event.row != nil
_event.from_row = _event.row
_event.to_row = _event.row
end
if _event.range == nil
_event.range=0
end
if _event.from_row == nil && current_editor != nil
r_sel = current_editor.text.tag_ranges('sel')
if !r_sel.empty?
_event.from_row = r_sel[0][0].split('.')[0].to_i
_event.to_row = r_sel[r_sel.length - 1][1].split('.')[0].to_i
else
_event.from_row = current_editor.text.index('insert').split('.')[0].to_i
_event.to_row = _event.from_row
end
end
case _event
when SetBookmarkEvent
if _event.persistent
@bookmarks << {:file=>_event.file,:from_line=>_event.from_row, :to_line=>_event.to_row}
_e = @tabs_editor[tab_file_name(_event.file)]
else
@bookmarks << {:file=>"__TMP__#{_event.id}",:from_line=>_event.from_row, :to_line=>_event.to_row}
_e = @editors[_event.id]
end
if _e
index_from = "#{_event.from_row}.0"
index_to = "#{_event.to_row}.0 lineend"
_event.content = _e.text.get(index_from, index_to)
_event.from_row.upto(_event.to_row) do |row|
_e.add_tag_bookmark(row)
end
end
when UnsetBookmarkEvent
@bookmarks.delete_if{|b| (b[:file]==_event.file && b[:from_line]==_event.from_row)}
if _event.file && File.exists?(_event.file)
_e = @tabs_editor[tab_file_name(_event.file)]
elsif _event.id
_e = @editors[_event.id]
end
_event.from_row.upto(_event.to_row) do |row|
_e.remove_tag_bookmark(row) if _e
end
end
end
|
#on_before_build(_event) ⇒ Object
#on_before_debug(_event) ⇒ Object
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
|
# File 'ext/ae-editor/ae-editor.rb', line 4787
def on_before_debug(_event)
case _event
when StartDebugEvent
_event.persistent=true
_filename = _event.file
if _filename == "*LAST"
_event.file = Arcadia.persistent('run.file.last')
elsif _filename.nil? || _filename == "*CURR"
current_editor = self.raised
if current_editor
if current_editor.file
_event.file=current_editor.file
else
_event.file=current_editor.create_temp_file
_event.id=current_editor.id
_event.persistent=false
end
end
end
self.debug_begin
when SetBreakpointEvent
if _event.active == 1
if _event.file && File.exists?(_event.file)
@breakpoints << {:file=>_event.file,:line=>_event.row}
_e = @tabs_editor[tab_file_name(_event.file)]
elsif _event.id
@breakpoints << {:file=>"__TMP__#{_event.id}",:line=>_event.row}
_e = @editors[_event.id]
end
if _e
_index =_event.row+'.0'
_line = _e.text.get(_index, _index+ ' lineend')
_event.line_code = _line.strip if _line
_e.add_tag_breakpoint(_event.row)
elsif File.exists?(_event.file)
_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
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
|
# File 'ext/ae-editor/ae-editor.rb', line 4110
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
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)
mr = Arcadia.('runcurr')
if mr
_command = proc{
_event = Arcadia.process_event(
RunCmdEvent.new(self, entry_hash)
)
}
exts = ''
run = Arcadia.runner(entry_hash[:runner])
if run
file_exts = run[:file_exts]
end
mr.insert('0',
:command ,{
:image => Arcadia.file_icon(file_exts),
:label => entry_hash[:title],
:compound => 'left',
:command => _command
}
)
end
end
end
if _event.file == "*LAST"
_event.file = Arcadia.persistent('run.file.last')
_event.cmd = Arcadia.persistent('run.cmd.last')
else
if _event.dir.nil?
_event.dir = File.dirname(_event.file)
end
if _event.cmd.nil?
if _event.runner_name
runner = Arcadia.runner(_event.runner_name)
elsif _event.lang && Arcadia.runner_for_lang(_event.lang)
runner = Arcadia.runner_for_lang(_event.lang)
else
runner = Arcadia.runner_for_file(_event.file)
end
if runner
_event.cmd = runner[:cmd]
else
_event.cmd = _event.file
end
end
if _event.file && _event.cmd.include?('<<RUBY>>')
_event.cmd = _event.cmd.gsub('<<RUBY>>',Arcadia.ruby)
end
if _event.file && _event.cmd.include?('<<FILE>>')
_event.cmd = _event.cmd.gsub('<<FILE>>',_event.file)
end
if _event.dir && _event.cmd.include?('<<DIR>>')
_event.cmd = _event.cmd.gsub('<<DIR>>',_event.dir)
end
if _event.file && _event.cmd.include?('<<FILE_BASENAME_WITHOUT_EXT>>')
_event.cmd = _event.cmd.gsub('<<FILE_BASENAME_WITHOUT_EXT>>',File.basename(_event.file).split('.')[0])
end
if _event.file && _event.cmd.include?('<<FILE_BASENAME>>')
_event.cmd = _event.cmd.gsub('<<FILE_BASENAME>>',File.basename(_event.file))
end
end
_event.title = _event.file if _event.title.nil?
end
|
#on_before_step_debug(_event) ⇒ Object
4783
4784
4785
|
# File 'ext/ae-editor/ae-editor.rb', line 4783
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
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
|
# File 'ext/ae-editor/ae-editor.rb', line 4871
def on_buffer(_event)
case _event
when NewBufferEvent
self.open_buffer(nil, nil, nil, _event.lang)
when OpenBufferEvent
if _event.file
if _event.row
_index = _event.row.to_s+'.0'
elsif !editor_exist?(_event.file) && _event.last_row
_index = _event.last_row.to_s+'.0'
end
if _event.kind_of?(OpenBufferTransientEvent)
if 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
_event.transient = false
end
else
_event.transient = false
end
end
if _event.select_index.nil?
select_index = true
else
select_index = _event.select_index
end
if _event.file == '*CURR'
er = raised
if er && _index != nil
er.text_see(_index)
er.mark_selected(_index) if select_index
end
else
_e = self.open_file(_event.file, _index, select_index)
end
elsif _event.text
if _event.title
_tab_name = self.tab_name(_event.title)
self.open_buffer(_tab_name, _event.title)
_e = @tabs_editor[_tab_name]
_e.text_insert('end',_event.text)
_e.reset
_e.refresh
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
rbea = RBeautify.beautify_string(raised.text_value_lines)
if rbea && rbea.length >1 && !rbea[1]
raised.text_replace_value_with(rbea[0])
else
msg = Arcadia.text('ext.editor.e.prettify.msg', [raised.tab_title])
Arcadia.dialog(self,
'type'=>'ok',
'title' => Arcadia.text("ext.editor.e.prettify.title"),
'msg'=>msg,
'level'=>'error')
end
when MoveBufferEvent
if _event.old_file && _event.new_file && editor_exist?(_event.old_file)
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
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
|
# File 'ext/ae-editor/ae-editor.rb', line 4209
def on_build(_event)
@usetabs = conf('use-tabs')=='yes'
@main_frame = AgMultiEditorView.new(self, self.frame, @usetabs)
@@outline_bar = AgEditorOutlineToolbar.new(self) if !defined?(@@outline_bar)
create_find frame.root.add_button(
self.name,
'Close current',
proc{self.activate;Arcadia.process_event(CloseCurrentTabEvent.new(self))},
CLOSE_DOCUMENT_GIF)
frame.root.add_sep(self.name, 1)
@buffer_number = TkVariable.new
@buffer_string = TkVariable.new
@buffer_string.value = ''
@buffer_number.value = 0
@buffer_menu_button = @main_frame.(self.name, @buffer_string)
begin
rescue RuntimeError => e
Arcadia.runtime_error(e)
end
@buffer_menu = @buffer_menu_button.cget('menu')
@buffer_menu_button.pack('fill'=>'x', 'expand'=>'true', 'side'=> 'left','anchor'=> 'w')
@buffer_menu_button.bind_append("Double-Button-1", proc{frame.root.resize})
load_languages_hash
end
|
#on_debug_step_info(_event) ⇒ Object
4858
4859
4860
4861
4862
4863
4864
4865
|
# File 'ext/ae-editor/ae-editor.rb', line 4858
def on_debug_step_info(_event)
if _event.file
self.open_file_in_debug(_event.file, _event.row)
end
Tk.update
end
|
#on_exit_query(_event) ⇒ Object
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
|
# File 'ext/ae-editor/ae-editor.rb', line 4497
def on_exit_query(_event)
_event.can_exit=true
return if _event.sender.instance_of?(AgMultiEditor) && _event.sender != self
@tabs_editor.each_value{|editor|
_event.can_exit = can_close_editor?(editor)
if !_event.can_exit
_event.break
break
end
}
end
|
#on_finalize(_event) ⇒ Object
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
|
# File 'ext/ae-editor/ae-editor.rb', line 5022
def on_finalize(_event)
@batch_files = true
_files =''
_raised = self.raised
Arcadia.persistent("#{@name}.files.last", _raised.file) if _raised
@tabs_editor.each_value{|editor|
if editor.file != nil
_insert_index = editor.text.index('@0,0')
_files=_files+'|' if _files.strip.length > 0
_files=_files + "#{editor.file};#{_insert_index};#{editor.line_numbers_visible.to_s}"
end
close_editor(editor,true)
}
Arcadia.persistent("#{@name}.files.open", _files)
clear_temp_files
@batch_files = true
end
|
#on_initialize(_event) ⇒ Object
4492
4493
4494
4495
|
# File 'ext/ae-editor/ae-editor.rb', line 4492
def on_initialize(_event)
self.open_last_files
reset_status if @main_frame.pages.empty?
end
|
#on_layout_raising_frame(_event) ⇒ Object
5118
5119
5120
5121
5122
5123
|
# File 'ext/ae-editor/ae-editor.rb', line 5118
def on_layout_raising_frame(_event)
if _event.extension_name == "editor" && _event.frame_name=="editor_outline"
_e = raised
change_outline(_e, true) if _e
end
end
|
#open_buffer(_buffer_name = nil, _title = nil, _filename = nil, _lang = nil) ⇒ Object
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
|
# File 'ext/ae-editor/ae-editor.rb', line 5585
def open_buffer(_buffer_name = nil, _title = nil, _filename=nil, _lang=nil)
if @main_frame.exist_buffer?(resolve_tab_name(_buffer_name))
_tab = @main_frame.page_frame(resolve_tab_name(_buffer_name))
else
if _buffer_name == nil
_title_new = '*new'
tmp_buffer_num = 0
_buffer_name = tab_name(_title_new)
end
_n = 1
while @main_frame.index(_buffer_name) != -1
_title_new = '*new'+_n.to_s
tmp_buffer_num = _n
_buffer_name = tab_name(_title_new)
_n =_n+1
end
if _title == nil
_title = _title_new
if _lang
_image = Arcadia.lang_icon(_lang)
else
_image = Arcadia.lang_icon('Ruby')
end
_ext = language_hash_by_lang(_lang)
else
_image = Arcadia.file_icon(_title)
end
_tab = @main_frame.add_page(_buffer_name, _filename, _title, _image, proc{do_buffer_raise(_buffer_name, _title)})
if _filename
(_filename)
else
(_title, false)
end
_e = AgEditor.new(self, _tab)
register_editor(_e, _buffer_name, _filename)
ext = Arcadia.file_extension(_title)
ext='rb' if ext.nil?
_e.initialize_editing(ext, _lang)
_e.text.set_focus
end
begin
if raised != @tabs_editor[resolve_tab_name(_buffer_name)]
@main_frame.raise(resolve_tab_name(_buffer_name)) if frame_visible?
@main_frame.see(resolve_tab_name(_buffer_name))
end
rescue Exception => e
Arcadia.runtime_error(e)
end
return _tab
end
|
#open_file(_filename = nil, _text_index = '1.0', _mark_selected = true, _exp = true) ⇒ Object
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
|
# File 'ext/ae-editor/ae-editor.rb', line 5547
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)
_exist_buffer = @tabs_file[_tab_name] != nil
if _exist_buffer
open_buffer(_tab_name)
else
open_buffer(_tab_name, _basefilename, _filename)
@tabs_editor[_tab_name].reset_highlight
begin
@tabs_editor[_tab_name].load_file(_filename)
rescue RuntimeError => e
close_editor(@tabs_editor[_tab_name], true)
Arcadia.runtime_error(e)
end
change_outline_frame_caption(File.basename(_filename)) if _filename
end
editor = @tabs_editor[_tab_name]
if _text_index != nil && _text_index != '1.0' && editor
editor.text_see(_text_index)
editor.mark_selected(_text_index) if _mark_selected
end
editor.do_line_update if editor && !editor.highlighted?
return editor
end
|
#open_file_in_debug(_filename = nil, _line = nil) ⇒ Object
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
|
# File 'ext/ae-editor/ae-editor.rb', line 5384
def open_file_in_debug(_filename=nil, _line=nil)
if _filename && _line && File.exists?(_filename)
@last_index = _line.to_s+'.0'
_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.mark_debug(@last_index) if @last_e
if _editor.nil?
@editors_in_debug << @last_e
@last_e.do_line_update
end
else
p "file #{_filename} do not exist !"
end
end
|
#open_last_files ⇒ Object
def update(_kind,_name)
if _kind == 'RAISE' && _name == 'editor'
_e = raised
change_outline(_e) if _e
end
end
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
|
# File 'ext/ae-editor/ae-editor.rb', line 5132
def open_last_files
@batch_files = true
if Arcadia.persistent("#{@name}.files.open")
_files_index =Arcadia.persistent("#{@name}.files.open").split("|")
_files_index.each do |value|
_file,_index,_line_numbers_visible_as_string = value.split(';')
if _file && _index
ed = open_file(_file,_index,false)
else
ed = open_file(_file)
end
if ed && _line_numbers_visible_as_string && ed.line_numbers_visible
ed.line_numbers_visible = _line_numbers_visible_as_string == 'true'
end
end
end
@batch_files = false
to_raise_file = Arcadia.persistent("#{@name}.files.last")
if to_raise_file
raise_file(to_raise_file,0)
else
_first_page = @main_frame.pages[0] if @main_frame.pages.length > 0
if _first_page
@main_frame.raise(_first_page) if frame_def_visible?
@main_frame.see(_first_page)
end
end
main_instance.frame(1)
Arcadia.attach_listener(self, LayoutRaisingFrameEvent)
self
end
|
#outline_bar ⇒ Object
4288
4289
4290
|
# File 'ext/ae-editor/ae-editor.rb', line 4288
def outline_bar
@@outline_bar
end
|
#page_name(_page_frame) ⇒ Object
5264
5265
5266
5267
5268
|
# File 'ext/ae-editor/ae-editor.rb', line 5264
def page_name(_page_frame)
@main_frame.page_name(_page_frame)
end
|
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
|
# File 'ext/ae-editor/ae-editor.rb', line 4613
def
@pop_up = TkMenu.new(
:parent=> self.frame.hinner_frame,
:tearoff=>0,
:title => 'Menu'
)
@pop_up.extend(TkAutoPostMenu)
@pop_up.configure(Arcadia.style('menu'))
@c = @pop_up.insert('end',
:command,
:label=>Arcadia.text('ext.editor.buffer.menu.close'),
:hidemargin => false,
:command=> proc{
if @selected_tab_name_from_popup != nil
_e = @tabs_editor[@selected_tab_name_from_popup]
self.close_editor(_e) if _e
end
}
)
@c = @pop_up.insert('end',
:command,
:label=>Arcadia.text('ext.editor.buffer.menu.close_others'),
:hidemargin => false,
:command=> proc{
if @selected_tab_name_from_popup != nil
_e = @tabs_editor[@selected_tab_name_from_popup]
self.close_others_editor(_e)
end
}
)
@c = @pop_up.insert('end',
:command,
:label=>Arcadia.text('ext.editor.buffer.menu.close_all'),
:hidemargin => false,
:command=> proc{
if @selected_tab_name_from_popup != nil
_e = @tabs_editor[@selected_tab_name_from_popup]
self.close_all_editor(_e)
end
}
)
@pop_up.insert('end',
:command,
:label=>'...',
:state=>'disabled',
:background=>Arcadia.conf('titlelabel.background'),
:font => "#{Arcadia.conf('menu.font')} bold",
:hidemargin => false
)
@main_frame.page_bind("Button-3",
proc{|*x|
_x = TkWinfo.pointerx(@main_frame.root_frame)
_y = TkWinfo.pointery(@main_frame.root_frame)
if @usetabs
@selected_tab_name_from_popup = x[0].split(':')[0]
else
@selected_tab_name_from_popup = @main_frame.raise
end
_index = @main_frame.index(@selected_tab_name_from_popup)
if _index == -1
@selected_tab_name_from_popup = 'ff'+@selected_tab_name_from_popup
_index = @main_frame.index(@selected_tab_name_from_popup)
end
if _index != -1
_file = @tabs_file[(@selected_tab_name_from_popup)] @pop_up.entryconfigure(3, 'label'=> _file)
@pop_up.(_x,_y+10)
end
})
end
|
#raise_editor(_editor = nil, _text_index = '0.0', _mark_selected = true, _exp = true) ⇒ Object
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
|
# File 'ext/ae-editor/ae-editor.rb', line 5668
def raise_editor(_editor = nil, _text_index='0.0', _mark_selected=true, _exp=true)
return if _editor == nil
_tab_name = nil
@tabs_editor.each{|tn,e|
if e == _editor
_tab_name = tn
end
}
if _tab_name
_index = @main_frame.index(resolve_tab_name(_tab_name))
_exist_buffer = _index != -1
if _exist_buffer
open_buffer(_tab_name)
if _text_index != nil && _text_index != '0.0'
_editor.text_see(_text_index)
_editor.mark_selected(_text_index) if _mark_selected
end
end
end
return _editor
end
|
#raise_file(_filename = nil, _pos = nil) ⇒ Object
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
|
# File 'ext/ae-editor/ae-editor.rb', line 5536
def raise_file(_filename=nil, _pos=nil)
if _filename && frame_def_visible?
tab_name=self.tab_file_name(_filename)
if @main_frame.index(tab_name) != -1
@main_frame.move(tab_name,_pos) if _pos
@main_frame.raise(tab_name)
@main_frame.see(tab_name)
end
end
end
|
#raised ⇒ Object
5065
5066
5067
5068
5069
5070
5071
5072
|
# File 'ext/ae-editor/ae-editor.rb', line 5065
def raised
if @main_frame
_page = @main_frame.raise
return @tabs_editor[resolve_tab_name(_page)]
else
nil
end
end
|
#raised_name ⇒ Object
5074
5075
5076
5077
5078
5079
5080
5081
|
# File 'ext/ae-editor/ae-editor.rb', line 5074
def raised_name
if @main_frame
_page = @main_frame.raise
return resolve_tab_name(_page)
else
nil
end
end
|
#refresh_buffer_string ⇒ Object
5288
5289
5290
|
# File 'ext/ae-editor/ae-editor.rb', line 5288
def refresh_buffer_string
make_buffer_string(@last_buffer_str)
end
|
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
|
# File 'ext/ae-editor/ae-editor.rb', line 4471
def
i_end = @buffer_menu.index('end')
p_name = @main_frame.raise
if @tabs_editor[p_name] && @tabs_editor[p_name].file
to_select = @tabs_editor[p_name].file
else
to_select = unname_modified(tab_title_by_tab_name(p_name))
end
0.upto(i_end){|j|
type = @buffer_menu.(j)
if type != 'separator'
value = @buffer_menu.entrycget(j,'value')
if value == to_select
@buffer_menu.entryconfigure(j, 'state'=>'disabled')
else
@buffer_menu.entryconfigure(j, 'state'=>'normal')
end
end
}
end
|
#refresh_status ⇒ Object
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
|
# File 'ext/ae-editor/ae-editor.rb', line 5462
def refresh_status
if raised && raised.file
size = File.size(raised.file)
if size > 1024
size_str = "#{size/1024} kb"
else
size_str = "#{size} b"
end
@@statusbar_items['file_name'].text(File.basename(raised.file))
@@statusbar_items['file_mtime'].text = raised.file_info['mtime'].localtime
@@statusbar_items['file_size'].text = size_str
else
reset_status
end
end
|
#register_editor(_e, _buffer_name, _file) ⇒ Object
5652
5653
5654
5655
5656
5657
5658
5659
|
# File 'ext/ae-editor/ae-editor.rb', line 5652
def register_editor(_e, _buffer_name, _file)
@editor_seq=@editor_seq+1
_e.id=@editor_seq
@editors[@editor_seq]=_e
@tabs_editor[_buffer_name]=_e
@tabs_file[_buffer_name]= _file if _file
@raw_buffer_name[_buffer_name]=_buffer_name
end
|
#reset_status ⇒ Object
5456
5457
5458
5459
5460
|
# File 'ext/ae-editor/ae-editor.rb', line 5456
def reset_status
@@statusbar_items['file_name'].text = '?'
@@statusbar_items['file_mtime'].text = '?'
@@statusbar_items['file_size'].text = '?'
end
|
#resolve_tab_name(_tab_name) ⇒ Object
5270
5271
5272
5273
5274
5275
5276
|
# File 'ext/ae-editor/ae-editor.rb', line 5270
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
5801
5802
5803
|
# File 'ext/ae-editor/ae-editor.rb', line 5801
def save_as_file(_filename)
@tabs_editor[tab_name(_filename)].save_as
end
|
#save_file(_filename) ⇒ Object
5797
5798
5799
|
# File 'ext/ae-editor/ae-editor.rb', line 5797
def save_file(_filename)
@tabs_editor[tab_name(_filename)].save
end
|
#show_hide_current_line_numbers ⇒ Object
5001
5002
5003
5004
|
# File 'ext/ae-editor/ae-editor.rb', line 5001
def show_hide_current_line_numbers
_e = active_instance.raised
_e.show_hide_line_numbers if _e
end
|
#show_hide_tabs ⇒ Object
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
|
# File 'ext/ae-editor/ae-editor.rb', line 5006
def show_hide_tabs
if active?
if @usetabs
@main_frame.switch_2_notabs
@usetabs = false
Arcadia['conf']["#{@name}.use-tabs"]='no'
else
@main_frame.switch_2_tabs
@usetabs = true
Arcadia['conf']["#{@name}.use-tabs"]='yes'
end
else
active_instance.show_hide_tabs
end
end
|
#start_find ⇒ Object
4996
4997
4998
4999
|
# File 'ext/ae-editor/ae-editor.rb', line 4996
def start_find
_e = raised
_e.find if _e
end
|
#tab_file_name(_filename = "") ⇒ Object
5258
5259
5260
5261
5262
|
# File 'ext/ae-editor/ae-editor.rb', line 5258
def tab_file_name(_filename="")
_fstr = File.expand_path(_filename)
_fstr = _filename if _fstr == nil
tab_name(_fstr)
end
|
#tab_name(_str = "") ⇒ Object
5253
5254
5255
5256
|
# File 'ext/ae-editor/ae-editor.rb', line 5253
def tab_name(_str="")
tn = 'ff'+_str.downcase.gsub("/","_").gsub(".","__").gsub(":","___").gsub("\\","____").gsub("*","_____")
resolve_tab_name(tn)
end
|
#tab_title(_tab) ⇒ Object
5245
5246
5247
|
# File 'ext/ae-editor/ae-editor.rb', line 5245
def tab_title(_tab)
@main_frame.page_title(page_name(_tab))
end
|
#tab_title_by_tab_name(_tab_name) ⇒ Object
5249
5250
5251
|
# File 'ext/ae-editor/ae-editor.rb', line 5249
def tab_title_by_tab_name(_tab_name)
@main_frame.page_title(resolve_tab_name(_tab_name))
end
|
#top_text_string ⇒ Object
5299
5300
5301
5302
|
# File 'ext/ae-editor/ae-editor.rb', line 5299
def top_text_string
nil
end
|
#unname_modified(_name) ⇒ Object
5223
5224
5225
|
# File 'ext/ae-editor/ae-editor.rb', line 5223
def unname_modified(_name)
return (_name && _name.strip.length > 0) ? _name.gsub("(...)",'') : nil
end
|
#unname_read_only(_name) ⇒ Object
5215
5216
5217
|
# File 'ext/ae-editor/ae-editor.rb', line 5215
def unname_read_only(_name)
return _name.gsub("[READ-ONLY] ",'')
end
|
#unregister_editor(_buffer_name) ⇒ Object
5661
5662
5663
5664
5665
5666
|
# File 'ext/ae-editor/ae-editor.rb', line 5661
def unregister_editor(_buffer_name)
e = @tabs_editor.delete(_buffer_name)
@tabs_file.delete(_buffer_name)
@editors.delete(e.id)
@raw_buffer_name.delete_if {|key, value| value == _buffer_name}
end
|