Class: AgMultiEditor
Constant Summary
Configurable::ADD_SYMBOL, Configurable::FONT_TYPE_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) ⇒ Object
-
#bookmark_add(_file, _index) ⇒ Object
-
#bookmark_clear ⇒ Object
-
#bookmark_move(_n = 0) ⇒ Object
-
#bookmark_next ⇒ Object
-
#bookmark_prev ⇒ Object
-
#breakpoint_add(_file, _line, _id = -1)) ⇒ Object
-
#breakpoint_del(_file, _line, _id = -1)) ⇒ Object
-
#breakpoint_lines_on_file(_file) ⇒ Object
-
#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
-
#clear_temp_files ⇒ Object
-
#close_all_editor(_editor, _mod = true) ⇒ Object
-
#close_buffer(_page_frame) ⇒ 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
-
#del_buffer_menu_item(_file) ⇒ Object
-
#do_buffer_raise(_name, _title = '...') ⇒ 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
-
#mod_buffer_menu_item(_file, _newtext, _newvalue = nil) ⇒ 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_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
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_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
-
#refresh_selected_buffer_menu_item ⇒ Object
-
#refresh_status ⇒ 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
-
#unname_modified(_name) ⇒ Object
-
#unname_read_only(_name) ⇒ Object
clear_properties_group_cache, #make_value, #properties_file2hash, properties_group, #resolve_properties_link, #resolve_value
#activate, #activate_main, #active?, #active_instance, #clone, #deduplicate, #duplicate, #exist_name?, #initialize, #instance_index, #instances, instances, #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_visible?, #initialize, #maximize, #maximized?, #resize, #restore_default_conf
Constructor Details
This class inherits a constructor from ArcadiaExtPlus
Instance Attribute Details
3853
3854
3855
|
# File 'ext/ae-editor/ae-editor.rb', line 3853
def ctags_string
@ctags_string
end
|
3853
3854
3855
|
# File 'ext/ae-editor/ae-editor.rb', line 3853
def has_ctags
@has_ctags
end
|
#splitted_frame ⇒ Object
3851
3852
3853
|
# File 'ext/ae-editor/ae-editor.rb', line 3851
def splitted_frame
@splitted_frame
end
|
Instance Method Details
#accept_complete_code ⇒ Object
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
|
# File 'ext/ae-editor/ae-editor.rb', line 5276
def accept_complete_code
@ok_complete = true
if !defined?(@ok_complete)
msg =<<EOS
"Complete code" is actually based on rcodetools
that exec code for retreave candidades.
So it can be dangerous for example if you write system call.
Do you want to activate it?
EOS
@ok_complete = Arcadia.dialog(self,
'level'=>'warning',
'type'=>'yes_no',
'title' => '(Arcadia) Complete code',
'msg'=>msg.upcase)=='yes'
end
return @ok_complete
end
|
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
|
# File 'ext/ae-editor/ae-editor.rb', line 4030
def (_filename, is_file=true)
@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
end
end
}
end
@buffer_menu.insert(index,:radio,
:label=>File.basename(_filename),
:value=>_filename,
:image=> Arcadia.file_icon(_filename),
:compound=>'left',
:command=>proc{
if is_file
open_file(_filename)
else
open_buffer(tab_name(_filename))
end
},
:hidemargin => true
)
end
|
#bookmark_add(_file, _index) ⇒ Object
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
|
# File 'ext/ae-editor/ae-editor.rb', line 4704
def bookmark_add(_file, _index)
if @bookmarks == nil
@bookmarks = Array.new
@bookmarks_index = - 1
else
_cur_file, _cur_index = @bookmarks[@bookmarks_index]
if _cur_file == _file && _cur_index == _index
return
end
@bookmarks = @bookmarks[0..@bookmarks_index]
end
@bookmarks << [_file, _index]
@bookmarks_index = @bookmarks.length - 1
end
|
#bookmark_clear ⇒ Object
4721
4722
4723
4724
|
# File 'ext/ae-editor/ae-editor.rb', line 4721
def bookmark_clear
@bookmarks.clear
@bookmarks_index = - 1
end
|
#bookmark_move(_n = 0) ⇒ Object
4731
4732
4733
4734
4735
4736
4737
4738
|
# File 'ext/ae-editor/ae-editor.rb', line 4731
def bookmark_move(_n=0)
@bookmarks_index = @bookmarks_index + _n
_file, _index = @bookmarks[@bookmarks_index]
_line, _col = _index.split('.') if _index
open_file(_file, _index)
end
|
#bookmark_next ⇒ Object
4726
4727
4728
4729
|
# File 'ext/ae-editor/ae-editor.rb', line 4726
def bookmark_next
return if @bookmarks == nil || @bookmarks_index >= @bookmarks.length - 1
bookmark_move(+1)
end
|
#bookmark_prev ⇒ Object
4741
4742
4743
4744
|
# File 'ext/ae-editor/ae-editor.rb', line 4741
def bookmark_prev
return if @bookmarks == nil || @bookmarks_index <= 0
bookmark_move(-1)
end
|
#breakpoint_add(_file, _line, _id = -1)) ⇒ Object
4640
4641
4642
|
# File 'ext/ae-editor/ae-editor.rb', line 4640
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
4648
4649
4650
4651
4652
4653
4654
4655
4656
|
# File 'ext/ae-editor/ae-editor.rb', line 4648
def breakpoint_lines_on_file(_file)
result = Array.new
@breakpoints.each{|value|
if value[:file]==_file
result << value[:line]
end
}
return result
end
|
#can_close_editor?(_editor) ⇒ Boolean
5192
5193
5194
5195
5196
5197
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
|
# File 'ext/ae-editor/ae-editor.rb', line 5192
def can_close_editor?(_editor)
ret = true
if _editor.modified?
filename = page_name(_editor.page_frame)
message = @main_frame.page_title(filename)+"\n modified. Save?"
r=Arcadia.dialog(self,
'type'=>'yes_no_cancel',
'level'=>'warning',
'title'=> 'Confirm saving',
'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 = @main_frame.page_title(filename)+"\n modified by other process. Continue closing?"
r=Arcadia.dialog(self,
'type'=>'yes_no',
'level'=>'warning',
'title'=> 'Continue closing',
'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
4865
4866
4867
4868
4869
4870
4871
|
# File 'ext/ae-editor/ae-editor.rb', line 4865
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
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
|
# File 'ext/ae-editor/ae-editor.rb', line 4873
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
4828
4829
4830
4831
4832
4833
4834
4835
4836
|
# File 'ext/ae-editor/ae-editor.rb', line 4828
def change_frame_caption(_name, _new_caption)
if @arcadia.layout.headed?
if frame.root.title == frame.title
frame.root.top_text(@main_frame.page(_name)['text'], @main_frame.page(_name)['image']) if @main_frame.page(_name)
frame.root.top_text_hint(_new_caption)
end
frame.root.save_caption(frame.name, @main_frame.page(_name)['text'], @main_frame.page(_name)['image'])
end
end
|
#change_outline(_e, _raised = false) ⇒ Object
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
|
# File 'ext/ae-editor/ae-editor.rb', line 4933
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
4839
4840
4841
4842
4843
4844
4845
4846
|
# File 'ext/ae-editor/ae-editor.rb', line 4839
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
4861
4862
4863
|
# File 'ext/ae-editor/ae-editor.rb', line 4861
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
4818
4819
4820
4821
4822
4823
4824
4825
4826
|
# File 'ext/ae-editor/ae-editor.rb', line 4818
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
4773
4774
4775
4776
4777
4778
|
# File 'ext/ae-editor/ae-editor.rb', line 4773
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
4781
4782
4783
|
# File 'ext/ae-editor/ae-editor.rb', line 4781
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
4768
4769
4770
4771
|
# File 'ext/ae-editor/ae-editor.rb', line 4768
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
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
|
# File 'ext/ae-editor/ae-editor.rb', line 4848
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)
else
(unname_modified(tab_title_by_tab_name(p_name)), _new_text)
end
@main_frame.page_title(p_name, _new_text)
end
|
#clear_temp_files ⇒ Object
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
|
# File 'ext/ae-editor/ae-editor.rb', line 4612
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
5184
5185
5186
5187
5188
5189
5190
|
# File 'ext/ae-editor/ae-editor.rb', line 5184
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(_page_frame) ⇒ Object
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
|
# File 'ext/ae-editor/ae-editor.rb', line 5242
def close_buffer(_page_frame)
_name = page_name(_page_frame)
if @tabs_editor[_name] && @tabs_editor[_name].file
(@tabs_editor[_name].file)
else
(unname_modified(tab_title_by_tab_name(_name)))
end
@tabs_editor.delete(_name)
@tabs_file.delete(_name)
@raw_buffer_name.delete_if {|key, value| value == _name }
_index = @main_frame.index(_name)
@main_frame.delete_page(_name)
if !@main_frame.pages.empty?
@main_frame.raise(@main_frame.pages[_index-1]) if TkWinfo.mapped?(@main_frame.root_frame)
else
frame.root.top_text_clear if TkWinfo.mapped?(frame.hinner_frame)
reset_status
end
end
|
#close_editor(_editor, _force = false) ⇒ Object
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
|
# File 'ext/ae-editor/ae-editor.rb', line 5228
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(_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
5263
5264
5265
5266
|
# File 'ext/ae-editor/ae-editor.rb', line 5263
def close_file(_filename)
_e = @tabs_editor[tab_name(_filename)]
close_editor(_e) if _e
end
|
#close_others_editor(_editor, _mod = true) ⇒ Object
5176
5177
5178
5179
5180
5181
5182
|
# File 'ext/ae-editor/ae-editor.rb', line 5176
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
4635
4636
4637
4638
|
# File 'ext/ae-editor/ae-editor.rb', line 4635
def close_raised
_e = @tabs_editor[resolve_tab_name(@main_frame.raise)]
close_editor(_e) if _e
end
|
#create_find ⇒ Object
4551
4552
4553
4554
4555
|
# File 'ext/ae-editor/ae-editor.rb', line 4551
def create_find
@find = Finder.new(@arcadia.layout.root, self)
@find.on_close=proc{@find.hide}
@find.hide
end
|
#debug_begin ⇒ Object
4886
4887
4888
4889
4890
4891
4892
|
# File 'ext/ae-editor/ae-editor.rb', line 4886
def debug_begin
if @editors_in_debug != nil
@editors_in_debug.clear
else
@editors_in_debug = Array.new
end
end
|
#debug_end ⇒ Object
4894
4895
4896
4897
4898
4899
4900
|
# File 'ext/ae-editor/ae-editor.rb', line 4894
def debug_end
@editors_in_debug.each{|e|
close_editor(e)
}
end
|
#debug_reset ⇒ Object
4902
4903
4904
4905
4906
|
# File 'ext/ae-editor/ae-editor.rb', line 4902
def debug_reset
if @last_index && @last_e
@last_e.unmark_debug(@last_index)
end
end
|
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
|
# File 'ext/ae-editor/ae-editor.rb', line 4065
def (_file)
@buffer_number.numeric -= 1
to_del = -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_del=j
break
end
end
}
@buffer_menu.delete(to_del) if to_del != -1
end
|
#do_buffer_raise(_name, _title = '...') ⇒ Object
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
|
# File 'ext/ae-editor/ae-editor.rb', line 4946
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
|
#editor_exist?(_filename) ⇒ Boolean
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
|
# File 'ext/ae-editor/ae-editor.rb', line 5027
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
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
|
# File 'ext/ae-editor/ae-editor.rb', line 5004
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
4547
4548
4549
|
# File 'ext/ae-editor/ae-editor.rb', line 4547
def get_find
@find
end
|
#highlight_scanner(_ext = nil) ⇒ Object
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
|
# File 'ext/ae-editor/ae-editor.rb', line 4163
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
4971
4972
4973
4974
4975
4976
4977
4978
|
# File 'ext/ae-editor/ae-editor.rb', line 4971
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
4212
4213
4214
|
# File 'ext/ae-editor/ae-editor.rb', line 4212
def language_hash_by_ext(_ext=nil)
@langs_hash_by_ext[_ext]
end
|
#language_hash_by_lang(_lang = nil) ⇒ Object
4216
4217
4218
|
# File 'ext/ae-editor/ae-editor.rb', line 4216
def language_hash_by_lang(_lang=nil)
@langs_hash_by_lang[_lang]
end
|
#load_languages_hash ⇒ Object
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
|
# File 'ext/ae-editor/ae-editor.rb', line 4182
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
|
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
|
# File 'ext/ae-editor/ae-editor.rb', line 4084
def (_file, _newtext, _newvalue = nil)
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
}
@buffer_menu.entryconfigure(to_mod, 'label'=>_newtext) if to_mod != -1
if to_mod != -1 && _newvalue != nil
is_file = File.exists?(_newvalue)
@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
end
|
#name_modified(_name) ⇒ Object
4759
4760
4761
|
# File 'ext/ae-editor/ae-editor.rb', line 4759
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
4751
4752
4753
|
# File 'ext/ae-editor/ae-editor.rb', line 4751
def name_read_only(_name)
'[READ-ONLY] '+_name
end
|
#on_activate_instance(_event) ⇒ Object
4016
4017
4018
4019
4020
4021
4022
4023
4024
|
# File 'ext/ae-editor/ae-editor.rb', line 4016
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
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
|
# File 'ext/ae-editor/ae-editor.rb', line 4398
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
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
|
# File 'ext/ae-editor/ae-editor.rb', line 4151
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_build(_event) ⇒ Object
#on_before_debug(_event) ⇒ Object
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
|
# File 'ext/ae-editor/ae-editor.rb', line 4355
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
@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)
else
_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
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
|
# File 'ext/ae-editor/ae-editor.rb', line 3892
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
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
4351
4352
4353
|
# File 'ext/ae-editor/ae-editor.rb', line 4351
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
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
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
|
# File 'ext/ae-editor/ae-editor.rb', line 4439
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'
end
if _event.kind_of?(OpenBufferTransientEvent) && conf('close-last-if-not-modified')=="yes"
if defined?(@last_transient_file) && !@last_transient_file.nil? && @last_transient_file != _event.file
_e = @tabs_editor[tab_name(@last_transient_file)]
if _e && !_e.modified_from_opening?
close_editor(_e)
end
end
if !editor_exist?(_event.file)
@last_transient_file = _event.file
else
@last_transient_file = nil
end
end
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 = "Problems in prettify #{raised.tab_title}"
Arcadia.dialog(self,
'type'=>'ok',
'title' => "(Arcadia) code prettify",
'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
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
|
# File 'ext/ae-editor/ae-editor.rb', line 3991
def on_build(_event)
@usetabs = conf('use-tabs')=='yes'
@main_frame = AgMultiEditorView.new(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_number.value = 0
@buffer_menu = frame.root.(
self.name, 'files', DOCUMENT_COMBO_GIF, 'right',
{'relief'=>:raised, 'borderwidth'=>1, 'compound'=> 'left','anchor'=>'w', 'textvariable'=> @buffer_number, 'width'=>40}).cget('menu')
load_languages_hash
end
|
#on_debug_step_info(_event) ⇒ Object
4426
4427
4428
4429
4430
4431
4432
4433
|
# File 'ext/ae-editor/ae-editor.rb', line 4426
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
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
|
# File 'ext/ae-editor/ae-editor.rb', line 4140
def on_exit_query(_event)
_event.can_exit=true
@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
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
|
# File 'ext/ae-editor/ae-editor.rb', line 4583
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
4135
4136
4137
4138
|
# File 'ext/ae-editor/ae-editor.rb', line 4135
def on_initialize(_event)
self.open_last_files
reset_status if @main_frame.pages.empty?
end
|
#on_layout_raising_frame(_event) ⇒ Object
4658
4659
4660
4661
4662
4663
|
# File 'ext/ae-editor/ae-editor.rb', line 4658
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
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
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
|
# File 'ext/ae-editor/ae-editor.rb', line 5091
def open_buffer(_buffer_name = nil, _title = nil, _filename=nil, _lang=nil)
_index = @main_frame.index(resolve_tab_name(_buffer_name))
if _buffer_name == nil
_title_new = '*new'
tmp_buffer_num = 0
_buffer_name = tab_name(_title_new)
end
if _index != -1
_tab = @main_frame.page_frame(resolve_tab_name(_buffer_name))
@main_frame.raise(resolve_tab_name(_buffer_name)) if frame_visible?
else
_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)})
@raw_buffer_name[_buffer_name]=_buffer_name
if _filename
(_filename)
else
(_title, false)
end
_e = AgEditor.new(self, _tab)
@editor_seq=@editor_seq+1
_e.id=@editor_seq
@editors[@editor_seq]=_e
ext = Arcadia.file_extension(_title)
ext='rb' if ext.nil?
_e.initialize_editing(ext, _lang)
_e.text.set_focus
@tabs_editor[_buffer_name]=_e
end
begin
if raised != @tabs_editor[resolve_tab_name(_buffer_name)]
@main_frame.move(resolve_tab_name(_buffer_name), 0)
@main_frame.raise(resolve_tab_name(_buffer_name)) if frame_visible?
@main_frame.see(resolve_tab_name(_buffer_name))
else
@main_frame.move(resolve_tab_name(_buffer_name), 0)
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
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
|
# File 'ext/ae-editor/ae-editor.rb', line 5058
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
@tabs_file[_tab_name]= _filename
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.highlighted?
return editor
end
|
#open_file_in_debug(_filename = nil, _line = nil) ⇒ Object
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
|
# File 'ext/ae-editor/ae-editor.rb', line 4908
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
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
|
# File 'ext/ae-editor/ae-editor.rb', line 4672
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
4026
4027
4028
|
# File 'ext/ae-editor/ae-editor.rb', line 4026
def outline_bar
@@outline_bar
end
|
#page_name(_page_frame) ⇒ Object
4804
4805
4806
4807
4808
|
# File 'ext/ae-editor/ae-editor.rb', line 4804
def page_name(_page_frame)
@main_frame.page_name(_page_frame)
end
|
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
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
4301
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
|
# File 'ext/ae-editor/ae-editor.rb', line 4255
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=>'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=>'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=>'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
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
|
# File 'ext/ae-editor/ae-editor.rb', line 5154
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
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
|
# File 'ext/ae-editor/ae-editor.rb', line 5047
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
4626
4627
4628
4629
4630
4631
4632
4633
|
# File 'ext/ae-editor/ae-editor.rb', line 4626
def raised
if @main_frame
_page = @main_frame.raise
return @tabs_editor[resolve_tab_name(_page)]
else
nil
end
end
|
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
|
# File 'ext/ae-editor/ae-editor.rb', line 4114
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
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
|
# File 'ext/ae-editor/ae-editor.rb', line 4986
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
|
#reset_status ⇒ Object
4980
4981
4982
4983
4984
|
# File 'ext/ae-editor/ae-editor.rb', line 4980
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
4810
4811
4812
4813
4814
4815
4816
|
# File 'ext/ae-editor/ae-editor.rb', line 4810
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
5272
5273
5274
|
# File 'ext/ae-editor/ae-editor.rb', line 5272
def save_as_file(_filename)
@tabs_editor[tab_name(_filename)].save_as
end
|
#save_file(_filename) ⇒ Object
5268
5269
5270
|
# File 'ext/ae-editor/ae-editor.rb', line 5268
def save_file(_filename)
@tabs_editor[tab_name(_filename)].save
end
|
#show_hide_current_line_numbers ⇒ Object
4562
4563
4564
4565
|
# File 'ext/ae-editor/ae-editor.rb', line 4562
def show_hide_current_line_numbers
_e = active_instance.raised
_e.show_hide_line_numbers if _e
end
|
#show_hide_tabs ⇒ Object
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
|
# File 'ext/ae-editor/ae-editor.rb', line 4567
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
4557
4558
4559
4560
|
# File 'ext/ae-editor/ae-editor.rb', line 4557
def start_find
_e = raised
_e.find if _e
end
|
#tab_file_name(_filename = "") ⇒ Object
4798
4799
4800
4801
4802
|
# File 'ext/ae-editor/ae-editor.rb', line 4798
def tab_file_name(_filename="")
_fstr = File.expand_path(_filename)
_fstr = _filename if _fstr == nil
tab_name(_fstr)
end
|
#tab_name(_str = "") ⇒ Object
4793
4794
4795
4796
|
# File 'ext/ae-editor/ae-editor.rb', line 4793
def tab_name(_str="")
tn = 'ff'+_str.downcase.gsub("/","_").gsub(".","__").gsub(":","___").gsub("\\","____").gsub("*","_____")
resolve_tab_name(tn)
end
|
#tab_title(_tab) ⇒ Object
4785
4786
4787
|
# File 'ext/ae-editor/ae-editor.rb', line 4785
def tab_title(_tab)
@main_frame.page_title(page_name(_tab))
end
|
#tab_title_by_tab_name(_tab_name) ⇒ Object
4789
4790
4791
|
# File 'ext/ae-editor/ae-editor.rb', line 4789
def tab_title_by_tab_name(_tab_name)
@main_frame.page_title(resolve_tab_name(_tab_name))
end
|
#unname_modified(_name) ⇒ Object
4763
4764
4765
|
# File 'ext/ae-editor/ae-editor.rb', line 4763
def unname_modified(_name)
return _name.gsub("(...)",'')
end
|
#unname_read_only(_name) ⇒ Object
4755
4756
4757
|
# File 'ext/ae-editor/ae-editor.rb', line 4755
def unname_read_only(_name)
return _name.gsub("[READ-ONLY] ",'')
end
|