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, #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
3952
3953
3954
|
# File 'ext/ae-editor/ae-editor.rb', line 3952
def ctags_string
@ctags_string
end
|
3952
3953
3954
|
# File 'ext/ae-editor/ae-editor.rb', line 3952
def has_ctags
@has_ctags
end
|
#main_frame ⇒ Object
Returns the value of attribute main_frame.
3953
3954
3955
|
# File 'ext/ae-editor/ae-editor.rb', line 3953
def main_frame
@main_frame
end
|
#splitted_frame ⇒ Object
3950
3951
3952
|
# File 'ext/ae-editor/ae-editor.rb', line 3950
def splitted_frame
@splitted_frame
end
|
Instance Method Details
#accept_complete_code ⇒ Object
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
|
# File 'ext/ae-editor/ae-editor.rb', line 5690
def accept_complete_code
@ok_complete = true
if !defined?(@ok_complete)
end
return @ok_complete
end
|
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
|
# File 'ext/ae-editor/ae-editor.rb', line 4195
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
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
|
# File 'ext/ae-editor/ae-editor.rb', line 4991
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
4973
4974
4975
|
# File 'ext/ae-editor/ae-editor.rb', line 4973
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
4981
4982
4983
4984
4985
4986
4987
4988
4989
|
# File 'ext/ae-editor/ae-editor.rb', line 4981
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
4265
4266
4267
4268
4269
4270
4271
|
# File 'ext/ae-editor/ae-editor.rb', line 4265
def (_text, _is_file=true)
if _is_file
File.dirname(_text)
else
'...'
end
end
|
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
|
# File 'ext/ae-editor/ae-editor.rb', line 4177
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
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
|
# File 'ext/ae-editor/ae-editor.rb', line 5591
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
5227
5228
5229
5230
5231
5232
5233
|
# File 'ext/ae-editor/ae-editor.rb', line 5227
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
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
|
# File 'ext/ae-editor/ae-editor.rb', line 5235
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
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
|
# File 'ext/ae-editor/ae-editor.rb', line 5189
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
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
|
# File 'ext/ae-editor/ae-editor.rb', line 5294
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
5201
5202
5203
5204
5205
5206
5207
5208
|
# File 'ext/ae-editor/ae-editor.rb', line 5201
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
5223
5224
5225
|
# File 'ext/ae-editor/ae-editor.rb', line 5223
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
5163
5164
5165
5166
5167
5168
5169
5170
5171
|
# File 'ext/ae-editor/ae-editor.rb', line 5163
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
5118
5119
5120
5121
5122
5123
|
# File 'ext/ae-editor/ae-editor.rb', line 5118
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
5126
5127
5128
|
# File 'ext/ae-editor/ae-editor.rb', line 5126
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
5113
5114
5115
5116
|
# File 'ext/ae-editor/ae-editor.rb', line 5113
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
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
|
# File 'ext/ae-editor/ae-editor.rb', line 5210
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
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
|
# File 'ext/ae-editor/ae-editor.rb', line 5049
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
5066
5067
5068
5069
|
# File 'ext/ae-editor/ae-editor.rb', line 5066
def chrono_bookmark_clear
@chrono_bookmarks.clear
@chrono_bookmarks_index = - 1
end
|
#chrono_bookmark_move(_n = 0) ⇒ Object
5076
5077
5078
5079
5080
5081
5082
5083
|
# File 'ext/ae-editor/ae-editor.rb', line 5076
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
5071
5072
5073
5074
|
# File 'ext/ae-editor/ae-editor.rb', line 5071
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
5086
5087
5088
5089
|
# File 'ext/ae-editor/ae-editor.rb', line 5086
def chrono_bookmark_prev
return if @chrono_bookmarks == nil || @chrono_bookmarks_index <= 0
chrono_bookmark_move(-1)
end
|
#clear_temp_files ⇒ Object
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
|
# File 'ext/ae-editor/ae-editor.rb', line 4936
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
5583
5584
5585
5586
5587
5588
5589
|
# File 'ext/ae-editor/ae-editor.rb', line 5583
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
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
|
# File 'ext/ae-editor/ae-editor.rb', line 5646
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
5641
5642
5643
5644
|
# File 'ext/ae-editor/ae-editor.rb', line 5641
def close_buffer_frame(_page_frame, _moved=false)
name = page_name(_page_frame)
close_buffer(name, _moved)
end
|
#close_editor(_editor, _force = false) ⇒ Object
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
|
# File 'ext/ae-editor/ae-editor.rb', line 5627
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
5677
5678
5679
5680
|
# File 'ext/ae-editor/ae-editor.rb', line 5677
def close_file(_filename)
_e = @tabs_editor[tab_name(_filename)]
close_editor(_e) if _e
end
|
#close_others_editor(_editor, _mod = true) ⇒ Object
5575
5576
5577
5578
5579
5580
5581
|
# File 'ext/ae-editor/ae-editor.rb', line 5575
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
4968
4969
4970
4971
|
# File 'ext/ae-editor/ae-editor.rb', line 4968
def close_raised
_e = @tabs_editor[resolve_tab_name(@main_frame.raise)]
close_editor(_e) if _e
end
|
#create_find ⇒ Object
4875
4876
4877
4878
4879
|
# File 'ext/ae-editor/ae-editor.rb', line 4875
def create_find
@find = Finder.new(@arcadia.layout.root, self)
@find.on_close=proc{@find.hide}
@find.hide
end
|
#debug_begin ⇒ Object
5247
5248
5249
5250
5251
5252
5253
|
# File 'ext/ae-editor/ae-editor.rb', line 5247
def debug_begin
if @editors_in_debug != nil
@editors_in_debug.clear
else
@editors_in_debug = Array.new
end
end
|
#debug_end ⇒ Object
5255
5256
5257
5258
5259
5260
5261
|
# File 'ext/ae-editor/ae-editor.rb', line 5255
def debug_end
@editors_in_debug.each{|e|
close_editor(e)
}
end
|
#debug_reset ⇒ Object
5263
5264
5265
5266
5267
|
# File 'ext/ae-editor/ae-editor.rb', line 5263
def debug_reset
if @last_index && @last_e
@last_e.unmark_debug(@last_index)
end
end
|
#deduplicate ⇒ Object
4147
4148
4149
4150
4151
4152
|
# File 'ext/ae-editor/ae-editor.rb', line 4147
def deduplicate
@main_frame.pages.each{|page|
main_instance.move_buffer_here(page)
}
super
end
|
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
|
# File 'ext/ae-editor/ae-editor.rb', line 4273
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
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
|
# File 'ext/ae-editor/ae-editor.rb', line 5307
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
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
|
# File 'ext/ae-editor/ae-editor.rb', line 4154
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
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
|
# File 'ext/ae-editor/ae-editor.rb', line 5388
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
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
|
# File 'ext/ae-editor/ae-editor.rb', line 5401
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
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
|
# File 'ext/ae-editor/ae-editor.rb', line 5365
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
4871
4872
4873
|
# File 'ext/ae-editor/ae-editor.rb', line 4871
def get_find
@find
end
|
#highlight_scanner(_ext = nil) ⇒ Object
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
|
# File 'ext/ae-editor/ae-editor.rb', line 4406
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
5332
5333
5334
5335
5336
5337
5338
5339
|
# File 'ext/ae-editor/ae-editor.rb', line 5332
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
4455
4456
4457
|
# File 'ext/ae-editor/ae-editor.rb', line 4455
def language_hash_by_ext(_ext=nil)
@langs_hash_by_ext[_ext]
end
|
#language_hash_by_lang(_lang = nil) ⇒ Object
4459
4460
4461
|
# File 'ext/ae-editor/ae-editor.rb', line 4459
def language_hash_by_lang(_lang=nil)
@langs_hash_by_lang[_lang]
end
|
#load_languages_hash ⇒ Object
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
|
# File 'ext/ae-editor/ae-editor.rb', line 4425
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
5177
5178
5179
5180
5181
5182
|
# File 'ext/ae-editor/ae-editor.rb', line 5177
def make_buffer_string(_str=nil)
value = "[#{@buffer_number.value}] #{_str}"
@last_buffer_str = _str
@buffer_string.value = value
end
|
4302
4303
4304
4305
4306
4307
4308
4309
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
|
# File 'ext/ae-editor/ae-editor.rb', line 4302
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
5465
5466
5467
5468
|
# File 'ext/ae-editor/ae-editor.rb', line 5465
def move_buffer_here(_name)
@main_frame.move_here(_name)
end
|
#name_modified(_name) ⇒ Object
5104
5105
5106
|
# File 'ext/ae-editor/ae-editor.rb', line 5104
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
5096
5097
5098
|
# File 'ext/ae-editor/ae-editor.rb', line 5096
def name_read_only(_name)
'[READ-ONLY] '+_name
end
|
#on_activate_instance(_event) ⇒ Object
4137
4138
4139
4140
4141
4142
4143
4144
4145
|
# File 'ext/ae-editor/ae-editor.rb', line 4137
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
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
|
# File 'ext/ae-editor/ae-editor.rb', line 4715
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
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
|
# File 'ext/ae-editor/ae-editor.rb', line 4394
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
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
|
# File 'ext/ae-editor/ae-editor.rb', line 4594
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
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
|
# File 'ext/ae-editor/ae-editor.rb', line 4672
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
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
|
# File 'ext/ae-editor/ae-editor.rb', line 3995
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
4668
4669
4670
|
# File 'ext/ae-editor/ae-editor.rb', line 4668
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
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
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
4829
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
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
|
# File 'ext/ae-editor/ae-editor.rb', line 4756
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
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
|
# File 'ext/ae-editor/ae-editor.rb', line 4094
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 begin
rescue RuntimeError => e
Arcadia.runtime_error(e)
end
frame.root.add_button(
self.name,
'Close current',
proc{self.activate;Arcadia.process_event(CloseCurrentTabEvent.new(self))},
CLOSE_DOCUMENT_GIF)
frame.root.add_sep(self.name, 1)
@buffer_number = TkVariable.new
@buffer_string = TkVariable.new
@buffer_string.value = ''
@buffer_number.value = 0
@buffer_menu_button = frame.root.(
self.name, 'files', nil, 'right',
{'relief'=>:flat,
'borderwidth'=>1,
'compound'=> 'left',
'anchor'=>'w',
'font'=> "#{Arcadia.conf('titlelabel.font')} italic",
'activebackground'=>Arcadia.conf('titlelabel.background'),
'foreground' => Arcadia.conf('titlecontext.foreground'),
'textvariable'=> @buffer_string
})
@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
4743
4744
4745
4746
4747
4748
4749
4750
|
# File 'ext/ae-editor/ae-editor.rb', line 4743
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
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
|
# File 'ext/ae-editor/ae-editor.rb', line 4382
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
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
|
# File 'ext/ae-editor/ae-editor.rb', line 4907
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
4377
4378
4379
4380
|
# File 'ext/ae-editor/ae-editor.rb', line 4377
def on_initialize(_event)
self.open_last_files
reset_status if @main_frame.pages.empty?
end
|
#on_layout_raising_frame(_event) ⇒ Object
5003
5004
5005
5006
5007
5008
|
# File 'ext/ae-editor/ae-editor.rb', line 5003
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
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
|
# File 'ext/ae-editor/ae-editor.rb', line 5470
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
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
|
# File 'ext/ae-editor/ae-editor.rb', line 5432
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
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
|
# File 'ext/ae-editor/ae-editor.rb', line 5269
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
5017
5018
5019
5020
5021
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
|
# File 'ext/ae-editor/ae-editor.rb', line 5017
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
4173
4174
4175
|
# File 'ext/ae-editor/ae-editor.rb', line 4173
def outline_bar
@@outline_bar
end
|
#page_name(_page_frame) ⇒ Object
5149
5150
5151
5152
5153
|
# File 'ext/ae-editor/ae-editor.rb', line 5149
def page_name(_page_frame)
@main_frame.page_name(_page_frame)
end
|
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
|
# File 'ext/ae-editor/ae-editor.rb', line 4498
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
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
|
# File 'ext/ae-editor/ae-editor.rb', line 5553
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
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
|
# File 'ext/ae-editor/ae-editor.rb', line 5421
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
4950
4951
4952
4953
4954
4955
4956
4957
|
# File 'ext/ae-editor/ae-editor.rb', line 4950
def raised
if @main_frame
_page = @main_frame.raise
return @tabs_editor[resolve_tab_name(_page)]
else
nil
end
end
|
#raised_name ⇒ Object
4959
4960
4961
4962
4963
4964
4965
4966
|
# File 'ext/ae-editor/ae-editor.rb', line 4959
def raised_name
if @main_frame
_page = @main_frame.raise
return resolve_tab_name(_page)
else
nil
end
end
|
#refresh_buffer_string ⇒ Object
5173
5174
5175
|
# File 'ext/ae-editor/ae-editor.rb', line 5173
def refresh_buffer_string
make_buffer_string(@last_buffer_str)
end
|
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
|
# File 'ext/ae-editor/ae-editor.rb', line 4356
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
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
|
# File 'ext/ae-editor/ae-editor.rb', line 5347
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
5537
5538
5539
5540
5541
5542
5543
5544
|
# File 'ext/ae-editor/ae-editor.rb', line 5537
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
5341
5342
5343
5344
5345
|
# File 'ext/ae-editor/ae-editor.rb', line 5341
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
5155
5156
5157
5158
5159
5160
5161
|
# File 'ext/ae-editor/ae-editor.rb', line 5155
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
5686
5687
5688
|
# File 'ext/ae-editor/ae-editor.rb', line 5686
def save_as_file(_filename)
@tabs_editor[tab_name(_filename)].save_as
end
|
#save_file(_filename) ⇒ Object
5682
5683
5684
|
# File 'ext/ae-editor/ae-editor.rb', line 5682
def save_file(_filename)
@tabs_editor[tab_name(_filename)].save
end
|
#show_hide_current_line_numbers ⇒ Object
4886
4887
4888
4889
|
# File 'ext/ae-editor/ae-editor.rb', line 4886
def show_hide_current_line_numbers
_e = active_instance.raised
_e.show_hide_line_numbers if _e
end
|
#show_hide_tabs ⇒ Object
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
|
# File 'ext/ae-editor/ae-editor.rb', line 4891
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
4881
4882
4883
4884
|
# File 'ext/ae-editor/ae-editor.rb', line 4881
def start_find
_e = raised
_e.find if _e
end
|
#tab_file_name(_filename = "") ⇒ Object
5143
5144
5145
5146
5147
|
# File 'ext/ae-editor/ae-editor.rb', line 5143
def tab_file_name(_filename="")
_fstr = File.expand_path(_filename)
_fstr = _filename if _fstr == nil
tab_name(_fstr)
end
|
#tab_name(_str = "") ⇒ Object
5138
5139
5140
5141
|
# File 'ext/ae-editor/ae-editor.rb', line 5138
def tab_name(_str="")
tn = 'ff'+_str.downcase.gsub("/","_").gsub(".","__").gsub(":","___").gsub("\\","____").gsub("*","_____")
resolve_tab_name(tn)
end
|
#tab_title(_tab) ⇒ Object
5130
5131
5132
|
# File 'ext/ae-editor/ae-editor.rb', line 5130
def tab_title(_tab)
@main_frame.page_title(page_name(_tab))
end
|
#tab_title_by_tab_name(_tab_name) ⇒ Object
5134
5135
5136
|
# File 'ext/ae-editor/ae-editor.rb', line 5134
def tab_title_by_tab_name(_tab_name)
@main_frame.page_title(resolve_tab_name(_tab_name))
end
|
#top_text_string ⇒ Object
5184
5185
5186
5187
|
# File 'ext/ae-editor/ae-editor.rb', line 5184
def top_text_string
nil
end
|
#unname_modified(_name) ⇒ Object
5108
5109
5110
|
# File 'ext/ae-editor/ae-editor.rb', line 5108
def unname_modified(_name)
return (_name && _name.strip.length > 0) ? _name.gsub("(...)",'') : nil
end
|
#unname_read_only(_name) ⇒ Object
5100
5101
5102
|
# File 'ext/ae-editor/ae-editor.rb', line 5100
def unname_read_only(_name)
return _name.gsub("[READ-ONLY] ",'')
end
|
#unregister_editor(_buffer_name) ⇒ Object
5546
5547
5548
5549
5550
5551
|
# File 'ext/ae-editor/ae-editor.rb', line 5546
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
|