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
-
#has_ctags_exuberant? ⇒ Boolean
-
#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
-
#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
def on_after_initialize(_event) @editors.each{|e| e.resize_line_num} end.
-
#on_finalize(_event) ⇒ Object
-
#on_initialize(_event) ⇒ Object
-
#on_layout_changed_domain(_event) ⇒ Object
-
#on_layout_raising_frame(_event) ⇒ Object
-
#on_run_cmd(_event) ⇒ Object
-
#open_buffer(_buffer_name = nil, _title = nil, _filename = nil, _lang = nil, _initialize_editing = true) ⇒ Object
-
#open_file(_filename = nil, _text_index = '1.0', _mark_selected = true, _load_file = 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.
-
#open_transient_button(_file) ⇒ Object
-
#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
-
#unmap_last_frame ⇒ 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_raised?, #frame_title, #frame_visible?, #hide_frame, #hinner_dialog, #hinner_splitted_dialog, #hinner_splitted_dialog_titled, #initialize, #maximize, #maximized?, #resize, #restore_default_conf
Constructor Details
This class inherits a constructor from ArcadiaExtPlus
Instance Attribute Details
4329
4330
4331
|
# File 'ext/ae-editor/ae-editor.rb', line 4329
def ctags_string
@ctags_string
end
|
4329
4330
4331
|
# File 'ext/ae-editor/ae-editor.rb', line 4329
def has_ctags
@has_ctags
end
|
#main_frame ⇒ Object
Returns the value of attribute main_frame.
4330
4331
4332
|
# File 'ext/ae-editor/ae-editor.rb', line 4330
def main_frame
@main_frame
end
|
#splitted_frame ⇒ Object
4327
4328
4329
|
# File 'ext/ae-editor/ae-editor.rb', line 4327
def splitted_frame
@splitted_frame
end
|
Instance Method Details
#accept_complete_code ⇒ Object
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
|
# File 'ext/ae-editor/ae-editor.rb', line 6223
def accept_complete_code
@ok_complete = true
if !defined?(@ok_complete)
end
return @ok_complete
end
|
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
4692
4693
4694
4695
|
# File 'ext/ae-editor/ae-editor.rb', line 4636
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
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
|
# File 'ext/ae-editor/ae-editor.rb', line 5482
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
5464
5465
5466
|
# File 'ext/ae-editor/ae-editor.rb', line 5464
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
5472
5473
5474
5475
5476
5477
5478
5479
5480
|
# File 'ext/ae-editor/ae-editor.rb', line 5472
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
4706
4707
4708
4709
4710
4711
4712
|
# File 'ext/ae-editor/ae-editor.rb', line 4706
def (_text, _is_file=true)
if _is_file
File.dirname(_text)
else
'...'
end
end
|
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
|
# File 'ext/ae-editor/ae-editor.rb', line 4618
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
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
|
# File 'ext/ae-editor/ae-editor.rb', line 6120
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
5729
5730
5731
5732
5733
5734
5735
|
# File 'ext/ae-editor/ae-editor.rb', line 5729
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
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
|
# File 'ext/ae-editor/ae-editor.rb', line 5737
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
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
|
# File 'ext/ae-editor/ae-editor.rb', line 5691
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
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
|
# File 'ext/ae-editor/ae-editor.rb', line 5797
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
5703
5704
5705
5706
5707
5708
5709
5710
|
# File 'ext/ae-editor/ae-editor.rb', line 5703
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
5725
5726
5727
|
# File 'ext/ae-editor/ae-editor.rb', line 5725
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
5666
5667
5668
5669
5670
5671
5672
5673
5674
|
# File 'ext/ae-editor/ae-editor.rb', line 5666
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
5621
5622
5623
5624
5625
5626
|
# File 'ext/ae-editor/ae-editor.rb', line 5621
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
5629
5630
5631
|
# File 'ext/ae-editor/ae-editor.rb', line 5629
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
5616
5617
5618
5619
|
# File 'ext/ae-editor/ae-editor.rb', line 5616
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
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
|
# File 'ext/ae-editor/ae-editor.rb', line 5712
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, _new_file, self)
@last_fa.refresh_layout_manager if @last_fa
end
@main_frame.page_title(p_name, _new_text)
end
|
#chrono_bookmark_add(_file, _index) ⇒ Object
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
|
# File 'ext/ae-editor/ae-editor.rb', line 5552
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
5569
5570
5571
5572
|
# File 'ext/ae-editor/ae-editor.rb', line 5569
def chrono_bookmark_clear
@chrono_bookmarks.clear
@chrono_bookmarks_index = - 1
end
|
#chrono_bookmark_move(_n = 0) ⇒ Object
5579
5580
5581
5582
5583
5584
5585
5586
|
# File 'ext/ae-editor/ae-editor.rb', line 5579
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
5574
5575
5576
5577
|
# File 'ext/ae-editor/ae-editor.rb', line 5574
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
5589
5590
5591
5592
|
# File 'ext/ae-editor/ae-editor.rb', line 5589
def chrono_bookmark_prev
return if @chrono_bookmarks == nil || @chrono_bookmarks_index <= 0
chrono_bookmark_move(-1)
end
|
#clear_temp_files ⇒ Object
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
|
# File 'ext/ae-editor/ae-editor.rb', line 5427
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
6112
6113
6114
6115
6116
6117
6118
|
# File 'ext/ae-editor/ae-editor.rb', line 6112
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
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
|
# File 'ext/ae-editor/ae-editor.rb', line 6177
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
if TkWinfo.mapped?(@main_frame.root_frame)
@main_frame.raise(@main_frame.pages[ind])
editor = @tabs_editor[@main_frame.pages[ind]]
end
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
6172
6173
6174
6175
|
# File 'ext/ae-editor/ae-editor.rb', line 6172
def close_buffer_frame(_page_frame, _moved=false)
name = page_name(_page_frame)
close_buffer(name, _moved)
end
|
#close_editor(_editor, _force = false) ⇒ Object
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
|
# File 'ext/ae-editor/ae-editor.rb', line 6156
def close_editor(_editor, _force=false)
if _force || can_close_editor?(_editor)
file = _editor.file
index = _editor.text.nil?? _editor.start_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)
Tk.update
BufferClosedEvent.new(self,'file'=>file,'row'=>r.to_i, 'col'=>c.to_i).shot!
else
return
end
end
|
#close_file(_filename) ⇒ Object
6210
6211
6212
6213
|
# File 'ext/ae-editor/ae-editor.rb', line 6210
def close_file(_filename)
_e = @tabs_editor[tab_name(_filename)]
close_editor(_e) if _e
end
|
#close_others_editor(_editor, _mod = true) ⇒ Object
6104
6105
6106
6107
6108
6109
6110
|
# File 'ext/ae-editor/ae-editor.rb', line 6104
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
5459
5460
5461
5462
|
# File 'ext/ae-editor/ae-editor.rb', line 5459
def close_raised
_e = @tabs_editor[resolve_tab_name(@main_frame.raise)]
close_editor(_e) if _e
end
|
#create_find ⇒ Object
5364
5365
5366
5367
5368
|
# File 'ext/ae-editor/ae-editor.rb', line 5364
def create_find
@find = Finder.new(@arcadia.layout.root, self)
@find.on_close=proc{@find.hide}
@find.hide
end
|
#debug_begin ⇒ Object
5749
5750
5751
5752
5753
5754
5755
|
# File 'ext/ae-editor/ae-editor.rb', line 5749
def debug_begin
if @editors_in_debug != nil
@editors_in_debug.clear
else
@editors_in_debug = Array.new
end
end
|
#debug_end ⇒ Object
5757
5758
5759
5760
5761
5762
5763
|
# File 'ext/ae-editor/ae-editor.rb', line 5757
def debug_end
@editors_in_debug.each{|e|
close_editor(e)
}
end
|
#debug_reset ⇒ Object
5765
5766
5767
5768
5769
|
# File 'ext/ae-editor/ae-editor.rb', line 5765
def debug_reset
if @last_index && @last_e
@last_e.unmark_debug(@last_index)
end
end
|
#deduplicate ⇒ Object
4588
4589
4590
4591
4592
4593
|
# File 'ext/ae-editor/ae-editor.rb', line 4588
def deduplicate
@main_frame.pages.each{|page|
main_instance.move_buffer_here(page)
}
super
end
|
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
|
# File 'ext/ae-editor/ae-editor.rb', line 4714
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 || instances.count == 1
i.(_file, self) if instances.count > 1
i.refresh_buffer_string
end
}
end
end
|
#do_buffer_raise(_name, _title = '...') ⇒ Object
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
|
# File 'ext/ae-editor/ae-editor.rb', line 5810
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)]
_e.load_file_if_not_loaded if _e
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
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
|
# File 'ext/ae-editor/ae-editor.rb', line 4595
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
end
|
#editor_by_page_name(_name) ⇒ Object
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
|
# File 'ext/ae-editor/ae-editor.rb', line 5895
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
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
|
# File 'ext/ae-editor/ae-editor.rb', line 5908
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{|id, e|
if !e.nil? && e.last_tmp_file == _filename
_index = 0
break
end
}
end
return _index != -1
end
|
#editor_of(_filename) ⇒ Object
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
|
# File 'ext/ae-editor/ae-editor.rb', line 5872
def editor_of(_filename)
_ret = nil
@editors.each{|id, e|
if !e.nil? && 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
5360
5361
5362
|
# File 'ext/ae-editor/ae-editor.rb', line 5360
def get_find
@find
end
|
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
|
# File 'ext/ae-editor/ae-editor.rb', line 4333
def has_ctags_exuberant?
ret = false
Arcadia.is_windows? ? @ctags_string="lib/ctags.exe" : @ctags_string='ctags'
ctags_file = Arcadia.which(@ctags_string)
if !ctags_file.nil?
output = ArcadiaUtils.exec("#{ctags_file} --version")
ret = output && output.include?('Exuberant Ctags')
end
ret
end
|
#highlight_scanner(_ext = nil) ⇒ Object
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
|
# File 'ext/ae-editor/ae-editor.rb', line 4850
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
5836
5837
5838
5839
5840
5841
5842
5843
5844
|
# File 'ext/ae-editor/ae-editor.rb', line 5836
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['buffer_encoding'] = Arcadia.new_statusbar_item("Buffer encoding")
@@statusbar_items['file_name'] = Arcadia.new_statusbar_item("File name")
end
end
|
#language_hash_by_ext(_ext = nil) ⇒ Object
4896
4897
4898
|
# File 'ext/ae-editor/ae-editor.rb', line 4896
def language_hash_by_ext(_ext=nil)
@langs_hash_by_ext[_ext]
end
|
#language_hash_by_lang(_lang = nil) ⇒ Object
4900
4901
4902
|
# File 'ext/ae-editor/ae-editor.rb', line 4900
def language_hash_by_lang(_lang=nil)
@langs_hash_by_lang[_lang]
end
|
#load_languages_hash ⇒ Object
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
|
# File 'ext/ae-editor/ae-editor.rb', line 4869
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
5680
5681
5682
5683
5684
|
# File 'ext/ae-editor/ae-editor.rb', line 5680
def make_buffer_string(_str=nil)
value = "[#{@buffer_number.value}] #{_str}"
@last_buffer_str = _str
@buffer_string.value = value
end
|
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
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
|
# File 'ext/ae-editor/ae-editor.rb', line 4743
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
5998
5999
6000
6001
|
# File 'ext/ae-editor/ae-editor.rb', line 5998
def move_buffer_here(_name)
@main_frame.move_here(_name)
end
|
#name_modified(_name) ⇒ Object
5607
5608
5609
|
# File 'ext/ae-editor/ae-editor.rb', line 5607
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
5599
5600
5601
|
# File 'ext/ae-editor/ae-editor.rb', line 5599
def name_read_only(_name)
'[READ-ONLY] '+_name
end
|
#on_activate_instance(_event) ⇒ Object
4578
4579
4580
4581
4582
4583
4584
4585
4586
|
# File 'ext/ae-editor/ae-editor.rb', line 4578
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
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
|
# File 'ext/ae-editor/ae-editor.rb', line 5157
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
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
|
# File 'ext/ae-editor/ae-editor.rb', line 4839
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
end
raised.check_modify
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
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
|
# File 'ext/ae-editor/ae-editor.rb', line 5036
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 && _e.text
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
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 4344
def on_before_build(_event)
@has_ctags = has_ctags_exuberant?
if !@has_ctags
msg = Arcadia.text("ext.editor.e.ctags.msg")
ArcadiaProblemEvent.new(self, "type"=>ArcadiaProblemEvent::DEPENDENCE_MISSING_TYPE,"title"=>Arcadia.text("ext.editor.e.ctags.title"), "detail"=>msg).go!
end
@breakpoints =Array.new
@bookmarks =Array.new
@tabs_file =Hash.new
@tabs_editor =Hash.new
@raw_buffer_name = Hash.new
@editor_seq=-1
@editors =Hash.new
initialize_status
Arcadia.attach_listener(self, BufferEvent)
Arcadia.attach_listener(self, DebugEvent)
Arcadia.attach_listener(self, RunCmdEvent)
Arcadia.attach_listener(self, FocusEvent)
Arcadia.attach_listener(self, BookmarkEvent)
Arcadia.attach_listener(self, LayoutChangedDomainEvent)
end
|
#on_before_debug(_event) ⇒ Object
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
|
# File 'ext/ae-editor/ae-editor.rb', line 5114
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
4413
4414
4415
4416
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
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
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
|
# File 'ext/ae-editor/ae-editor.rb', line 4413
def on_before_run_cmd(_event)
_filename = _event.file
_event.persistent = true
if _filename == "*CURR" || (_filename.nil? && _event && _event.cmd.nil?) || (_filename.nil? && _event && !_event.cmd.nil? && _event.cmd.include?('<<FILE>>'))
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.file != 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]
_event.lang = runner[:lang] if _event.lang.nil?
else
_event.cmd = _event.file
end
end
while _event.cmd.include?('<<INPUT_FILE>>')
input_file = Arcadia.select_file_dialog(MonitorLastUsedDir.get_last_dir, "<<INPUT_FILE>> = ")
if !input_file.nil?
_event.cmd = _event.cmd.sub('<<INPUT_FILE>>', input_file)
end
end
while _event.cmd.include?('<<INPUT_DIR>>')
input_dir = Arcadia.select_dir_dialog(MonitorLastUsedDir.get_last_dir, nil, "<<INPUT_DIR>> = ")
if !input_dir.nil?
_event.cmd = _event.cmd.sub('<<INPUT_DIR>>',input_dir)
end
end
while _event.cmd.include?('<<INPUT_STRING>>')
input_string = Arcadia.open_string_dialog("<<INPUT_STRING>> = ")
if !input_string.nil?
_event.cmd = _event.cmd.sub('<<INPUT_STRING>>', input_string)
end
end
if _event.cmd.include?('<<RUBY>>')
_event.cmd = _event.cmd.gsub('<<RUBY>>',"#{Arcadia.ruby} -r #{Dir.pwd}/lib/iosync")
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
5110
5111
5112
|
# File 'ext/ae-editor/ae-editor.rb', line 5110
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
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
|
# File 'ext/ae-editor/ae-editor.rb', line 5198
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
open_transient_button(_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
if _event.debug == 'yes'
debug_reset
r,c = _index.split('.')
_e = self.open_file_in_debug(_event.file, r)
else
_e = self.open_file(_event.file, _index, select_index)
end
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.select_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
when DeleteFileBufferEvent
if _event.file == nil
er = self.raised
_event.file = er.file if er
end
if _event.file
_title = Arcadia.text("ext.editor.file.d.delete.title")
_msg = Arcadia.text("ext.editor.file.d.delete.msg", [_event.file])
if File.exists?(_event.file) &&
File.ftype(_event.file) == 'file' &&
Arcadia.dialog(self,'type'=>'yes_no', 'level'=>'warning','title' => _title, 'msg'=>_msg)=='yes'
Arcadia.process_event(CloseBufferEvent.new(self,'file'=>_event.file))
begin
File.delete(_event.file)
_event.flag = Event::FLAG_DEFAULT
rescue RuntimeError => e
_event.flag = Event::FLAG_ERROR
Arcadia.runtime_error(e)
end
else
_event.flag = Event::FLAG_ERROR
end
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
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 4533
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_FRAME_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
5185
5186
5187
5188
5189
5190
5191
5192
|
# File 'ext/ae-editor/ae-editor.rb', line 5185
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
def on_after_initialize(_event)
@editors.each{|e| e.resize_line_num}
end
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
|
# File 'ext/ae-editor/ae-editor.rb', line 4827
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
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
|
# File 'ext/ae-editor/ae-editor.rb', line 5398
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.nil?? editor.start_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
4818
4819
4820
4821
|
# File 'ext/ae-editor/ae-editor.rb', line 4818
def on_initialize(_event)
self.open_last_files
reset_status if @main_frame.pages.empty?
end
|
#on_layout_changed_domain(_event) ⇒ Object
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
|
# File 'ext/ae-editor/ae-editor.rb', line 4380
def on_layout_changed_domain(_event)
if @main_frame && !@main_frame.usetabs && self.frame_domain(0) == _event.old_domain
if _event.old_domain == _event.new_domain
if self.frame_raised?(0)
if !@last_fa.nil?
@last_fa.refresh_layout_manager
@last_fa.map(@last_fa_layout_manager)
@last_fa = nil
end
else
unmap_last_frame
end
else
if !@last_fa.nil?
@last_fa.refresh_layout_manager
@last_fa.map(@last_fa_layout_manager)
@last_fa = nil
end
end
end
end
|
#on_layout_raising_frame(_event) ⇒ Object
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
|
# File 'ext/ae-editor/ae-editor.rb', line 5494
def on_layout_raising_frame(_event)
if _event.extension_name && _event.extension_name == "editor" && _event.frame_name=="editor_outline"
_e = raised
change_outline(_e, true) if _e
end
if Arcadia.extension(_event.extension_name) && frame_domain == Arcadia.extension(_event.extension_name).frame_domain
if @main_frame && !@main_frame.usetabs
unmap_last_frame
end
end
end
|
#on_run_cmd(_event) ⇒ Object
4403
4404
4405
4406
4407
4408
4409
4410
4411
|
# File 'ext/ae-editor/ae-editor.rb', line 4403
def on_run_cmd(_event)
case _event
when RunCmdStartedEvent
debug_begin
when RunCmdEndedEvent
debug_reset
debug_end
end
end
|
#open_buffer(_buffer_name = nil, _title = nil, _filename = nil, _lang = nil, _initialize_editing = true) ⇒ Object
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
|
# File 'ext/ae-editor/ae-editor.rb', line 6003
def open_buffer(_buffer_name = nil, _title = nil, _filename=nil, _lang=nil, _initialize_editing=true)
if frame_visible? && !frame_raised?
@arcadia.layout.change_domain(frame_domain, @name)
end
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)
if _initialize_editing
ext= Arcadia.file_extension(_title) || 'rb'
_e.initialize_editing(ext, _lang)
_e.text.set_focus
end
end
begin
if raised != @tabs_editor[resolve_tab_name(_buffer_name)]
@main_frame.raise(resolve_tab_name(_buffer_name)) @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, _load_file = true) ⇒ Object
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
|
# File 'ext/ae-editor/ae-editor.rb', line 5939
def open_file(_filename = nil, _text_index='1.0', _mark_selected=true, _load_file=true)
return if _filename == nil || !File.exist?(_filename) || File.ftype(_filename) != 'file'
if defined?(@opening_file)
while @opening_file
sleep(1)
end
end
@opening_file = true
begin
_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)
if !@tabs_editor[_tab_name].file_loaded
@tabs_editor[_tab_name].reset_highlight
begin
@tabs_editor[_tab_name].load_file_if_not_loaded
rescue RuntimeError => e
close_editor(@tabs_editor[_tab_name], true)
Arcadia.runtime_error(e)
end
end
else
open_buffer(_tab_name, _basefilename, _filename, nil, false)
@tabs_editor[_tab_name].reset_highlight
begin
if _load_file
@tabs_editor[_tab_name].load_file(_filename)
else
@tabs_editor[_tab_name].file = _filename
@tabs_editor[_tab_name].start_index = _text_index
end
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 editor && _load_file
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?
end
ensure
@opening_file = false
end
return editor
end
|
#open_file_in_debug(_filename = nil, _line = nil) ⇒ Object
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
|
# File 'ext/ae-editor/ae-editor.rb', line 5771
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)
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
_editor
end
|
#open_last_files ⇒ Object
def update(_kind,_name)
if _kind == 'RAISE' && _name == 'editor'
_e = raised
change_outline(_e) if _e
end
end
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
|
# File 'ext/ae-editor/ae-editor.rb', line 5513
def open_last_files
@batch_files = true
last_ed = nil
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, false)
else
ed = open_file(_file,'1.0', false, false)
end
if ed && _line_numbers_visible_as_string && ed.line_numbers_visible
ed.line_numbers_visible = _line_numbers_visible_as_string == 'true'
end
last_ed = ed
end
end
@batch_files = false
change_outline(last_ed) if last_ed
to_raise_file = Arcadia.persistent("#{@name}.files.last")
if to_raise_file
ed_to_raise = @tabs_editor[self.tab_file_name(to_raise_file)]
ed_to_raise.load_file_if_not_loaded if ed_to_raise
raise_file(to_raise_file,0)
else
_first_page = @main_frame.pages[0] if @main_frame.pages.length > 0
if _first_page
ed_to_raise = @tabs_editor[_first_page]
ed_to_raise.load_file_if_not_loaded if ed_to_raise
@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
|
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
|
# File 'ext/ae-editor/ae-editor.rb', line 5345
def open_transient_button(_file)
alive_check = proc{
e = @tabs_editor[tab_name(_file)]
@last_transient_file == _file && e && !e.modified_from_opening?
}
abort_action = proc{@last_transient_file=nil}
Arcadia.process_event(SubProcessEvent.new(self,
'abort_dialog_yes'=>false,
'anigif'=>'butterfly.res',
'name'=>File.basename(_file),
'abort_action'=>abort_action,
'alive_check'=>alive_check))
end
|
#outline_bar ⇒ Object
4614
4615
4616
|
# File 'ext/ae-editor/ae-editor.rb', line 4614
def outline_bar
@@outline_bar
end
|
#page_name(_page_frame) ⇒ Object
5652
5653
5654
5655
5656
|
# File 'ext/ae-editor/ae-editor.rb', line 5652
def page_name(_page_frame)
@main_frame.page_name(_page_frame)
end
|
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
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
|
# File 'ext/ae-editor/ae-editor.rb', line 4939
def
@pop_up = Arcadia.wf.(
:parent=> self.frame.hinner_frame,
:tearoff=>0,
:title => '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 = 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
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
|
# File 'ext/ae-editor/ae-editor.rb', line 6081
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
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
|
# File 'ext/ae-editor/ae-editor.rb', line 5928
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
5441
5442
5443
5444
5445
5446
5447
5448
|
# File 'ext/ae-editor/ae-editor.rb', line 5441
def raised
if @main_frame
_page = @main_frame.raise
return @tabs_editor[resolve_tab_name(_page)]
else
nil
end
end
|
#raised_name ⇒ Object
5450
5451
5452
5453
5454
5455
5456
5457
|
# File 'ext/ae-editor/ae-editor.rb', line 5450
def raised_name
if @main_frame
_page = @main_frame.raise
return resolve_tab_name(_page)
else
nil
end
end
|
#refresh_buffer_string ⇒ Object
5676
5677
5678
|
# File 'ext/ae-editor/ae-editor.rb', line 5676
def refresh_buffer_string
make_buffer_string(@last_buffer_str)
end
|
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
|
# File 'ext/ae-editor/ae-editor.rb', line 4797
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
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
|
# File 'ext/ae-editor/ae-editor.rb', line 5853
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.buffer_info['mtime'].localtime if raised.buffer_info['mtime']
@@statusbar_items['buffer_encoding'].text = raised.buffer_info['encoding'] if raised.buffer_info['encoding']
@@statusbar_items['file_size'].text = size_str
else
reset_status
end
end
|
#register_editor(_e, _buffer_name, _file) ⇒ Object
6062
6063
6064
6065
6066
6067
6068
6069
|
# File 'ext/ae-editor/ae-editor.rb', line 6062
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
5846
5847
5848
5849
5850
5851
|
# File 'ext/ae-editor/ae-editor.rb', line 5846
def reset_status
@@statusbar_items['file_name'].text = '?'
@@statusbar_items['file_mtime'].text = '?'
@@statusbar_items['buffer_encoding'].text = '?'
@@statusbar_items['file_size'].text = '?'
end
|
#resolve_tab_name(_tab_name) ⇒ Object
5658
5659
5660
5661
5662
5663
5664
|
# File 'ext/ae-editor/ae-editor.rb', line 5658
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
6219
6220
6221
|
# File 'ext/ae-editor/ae-editor.rb', line 6219
def save_as_file(_filename)
@tabs_editor[tab_name(_filename)].save_as
end
|
#save_file(_filename) ⇒ Object
6215
6216
6217
|
# File 'ext/ae-editor/ae-editor.rb', line 6215
def save_file(_filename)
@tabs_editor[tab_name(_filename)].save
end
|
#show_hide_current_line_numbers ⇒ Object
5375
5376
5377
5378
5379
|
# File 'ext/ae-editor/ae-editor.rb', line 5375
def show_hide_current_line_numbers
return if !self.frame_raised?(0)
_e = active_instance.raised
_e.show_hide_line_numbers if _e
end
|
#show_hide_tabs ⇒ Object
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
|
# File 'ext/ae-editor/ae-editor.rb', line 5381
def show_hide_tabs
return if !self.frame_raised?(0)
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
5370
5371
5372
5373
|
# File 'ext/ae-editor/ae-editor.rb', line 5370
def start_find
_e = raised
_e.find if _e
end
|
#tab_file_name(_filename = "") ⇒ Object
5646
5647
5648
5649
5650
|
# File 'ext/ae-editor/ae-editor.rb', line 5646
def tab_file_name(_filename="")
_fstr = File.expand_path(_filename)
_fstr = _filename if _fstr == nil
tab_name(_fstr)
end
|
#tab_name(_str = "") ⇒ Object
5641
5642
5643
5644
|
# File 'ext/ae-editor/ae-editor.rb', line 5641
def tab_name(_str="")
tn = 'ff'+_str.downcase.gsub("/","_").gsub(".","__").gsub(":","___").gsub("\\","____").gsub("*","_____")
resolve_tab_name(tn)
end
|
#tab_title(_tab) ⇒ Object
5633
5634
5635
|
# File 'ext/ae-editor/ae-editor.rb', line 5633
def tab_title(_tab)
@main_frame.page_title(page_name(_tab))
end
|
#tab_title_by_tab_name(_tab_name) ⇒ Object
5637
5638
5639
|
# File 'ext/ae-editor/ae-editor.rb', line 5637
def tab_title_by_tab_name(_tab_name)
@main_frame.page_title(resolve_tab_name(_tab_name))
end
|
#top_text_string ⇒ Object
5686
5687
5688
5689
|
# File 'ext/ae-editor/ae-editor.rb', line 5686
def top_text_string
nil
end
|
#unmap_last_frame ⇒ Object
4371
4372
4373
4374
4375
4376
4377
4378
|
# File 'ext/ae-editor/ae-editor.rb', line 4371
def unmap_last_frame
@last_fa = @main_frame.page_frame(@main_frame.raise)
if @last_fa
@last_fa.refresh_layout_manager
@last_fa_layout_manager = @last_fa.layout_manager
@last_fa.unmap(@last_fa_layout_manager)
end
end
|
#unname_modified(_name) ⇒ Object
5611
5612
5613
|
# File 'ext/ae-editor/ae-editor.rb', line 5611
def unname_modified(_name)
return (_name && _name.strip.length > 0) ? _name.gsub("(...)",'') : nil
end
|
#unname_read_only(_name) ⇒ Object
5603
5604
5605
|
# File 'ext/ae-editor/ae-editor.rb', line 5603
def unname_read_only(_name)
return _name.gsub("[READ-ONLY] ",'')
end
|
#unregister_editor(_buffer_name) ⇒ Object
6071
6072
6073
6074
6075
6076
6077
6078
6079
|
# File 'ext/ae-editor/ae-editor.rb', line 6071
def unregister_editor(_buffer_name)
e = @tabs_editor.delete(_buffer_name)
@tabs_file.delete(_buffer_name)
@editors.delete(e.id)
if e.file == @last_transient_file
@last_transient_file = nil
end
@raw_buffer_name.delete_if {|key, value| value == _buffer_name}
end
|