Class: AgMultiEditor
Instance Attribute Summary collapse
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) ⇒ Object
-
#breakpoint_del(_file, _line) ⇒ 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_outline(_e, _raised = false) ⇒ 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) ⇒ 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
-
#get_find ⇒ Object
-
#get_tab_from_name(_name = nil) ⇒ Object
-
#highlight_scanner(_ext = nil) ⇒ Object
-
#languages_hash(_ext = nil) ⇒ Object
-
#name_read_only(_name) ⇒ Object
-
#on_after_build(_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_layout_raising_frame(_event) ⇒ Object
-
#open_buffer(_buffer_name = nil, _title = nil, _filename = 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.
-
#page_name(_page_frame) ⇒ Object
-
#pop_up_menu ⇒ Object
-
#raise_file(_filename = nil, _pos = nil) ⇒ Object
-
#raised ⇒ Object
-
#save_as_file(_filename) ⇒ Object
-
#save_file(_filename) ⇒ Object
-
#show_hide_current_line_numbers ⇒ 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_read_only(_name) ⇒ Object
#make_value, #properties_file2hash, properties_group, #resolve_link, #resolve_properties_link
Methods included from Autils
#full_in_path_command, #is_windows?
Methods inherited from ArcadiaExt
#conf, #conf_array, #conf_default, #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 ArcadiaExt
Instance Attribute Details
#breakpoints ⇒ Object
Returns the value of attribute breakpoints.
3307
3308
3309
|
# File 'ext/ae-editor/ae-editor.rb', line 3307
def breakpoints
@breakpoints
end
|
#outline_bar ⇒ Object
Returns the value of attribute outline_bar.
3309
3310
3311
|
# File 'ext/ae-editor/ae-editor.rb', line 3309
def outline_bar
@outline_bar
end
|
#splitted_frame ⇒ Object
Returns the value of attribute splitted_frame.
3308
3309
3310
|
# File 'ext/ae-editor/ae-editor.rb', line 3308
def splitted_frame
@splitted_frame
end
|
Instance Method Details
#accept_complete_code ⇒ Object
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
|
# File 'ext/ae-editor/ae-editor.rb', line 4360
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
|
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
|
# File 'ext/ae-editor/ae-editor.rb', line 3446
def (_filename, is_file=true)
index = 'end'
i_end = @buffer_menu.index('end')
if i_end
0.upto(i_end){|j|
type = @buffer_menu.(j)
if type != 'separator'
label = @buffer_menu.entrycget(j,'label')
if label > _filename
index=j
break
end
end
}
end
@buffer_menu.insert(index,:command,
:label=>_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
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
|
# File 'ext/ae-editor/ae-editor.rb', line 3952
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
3969
3970
3971
3972
|
# File 'ext/ae-editor/ae-editor.rb', line 3969
def bookmark_clear
@bookmarks.clear
@bookmarks_index = - 1
end
|
#bookmark_move(_n = 0) ⇒ Object
3979
3980
3981
3982
3983
3984
3985
3986
|
# File 'ext/ae-editor/ae-editor.rb', line 3979
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
3974
3975
3976
3977
|
# File 'ext/ae-editor/ae-editor.rb', line 3974
def bookmark_next
return if @bookmarks == nil || @bookmarks_index >= @bookmarks.length - 1
bookmark_move(+1)
end
|
#bookmark_prev ⇒ Object
3989
3990
3991
3992
|
# File 'ext/ae-editor/ae-editor.rb', line 3989
def bookmark_prev
return if @bookmarks == nil || @bookmarks_index <= 0
bookmark_move(-1)
end
|
#breakpoint_add(_file, _line) ⇒ Object
#breakpoint_del(_file, _line) ⇒ Object
#breakpoint_lines_on_file(_file) ⇒ Object
3898
3899
3900
3901
3902
3903
3904
3905
3906
|
# File 'ext/ae-editor/ae-editor.rb', line 3898
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
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
|
# File 'ext/ae-editor/ae-editor.rb', line 4286
def can_close_editor?(_editor)
ret = true
if _editor.modified?
filename = page_name(_editor.page_frame)
message = @main_frame.enb.itemcget(filename, 'text')+"\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.enb.itemcget(filename, 'text')+"\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
ret = !_editor.modified_by_others?
else
ret = false
end
end
ret
end
|
#change_file(_old_file, _new_file) ⇒ Object
4064
4065
4066
4067
4068
4069
4070
|
# File 'ext/ae-editor/ae-editor.rb', line 4064
def change_file(_old_file, _new_file)
_tab_name=tab_file_name(_old_file)
_tab = @main_frame.enb.get_frame(_tab_name)
e = @tabs_editor[_tab_name]
e.new_file_name(_new_file) if e
change_file_name(_tab, _new_file)
end
|
#change_file_name(_tab, _new_file) ⇒ Object
4072
4073
4074
4075
4076
4077
|
# File 'ext/ae-editor/ae-editor.rb', line 4072
def change_file_name(_tab, _new_file)
_new_label = File.basename(_new_file)
change_tab_title(_tab, _new_label)
change_tab_icon(_tab, _new_label)
@tabs_file[page_name(_tab)] = _new_file
end
|
#change_outline(_e, _raised = false) ⇒ Object
4120
4121
4122
4123
4124
4125
4126
4127
|
# File 'ext/ae-editor/ae-editor.rb', line 4120
def change_outline(_e, _raised=false)
_raised = _raised || frame(1).raised?
if !@batch_files && _raised
@last_outline_e.hide_outline if @last_outline_e
_e.show_outline
@last_outline_e = _e
end
end
|
#change_tab_icon(_tab, _new_text) ⇒ Object
4060
4061
4062
|
# File 'ext/ae-editor/ae-editor.rb', line 4060
def change_tab_icon(_tab, _new_text)
@main_frame.enb.itemconfigure(page_name(_tab), 'image'=> Arcadia.file_icon(_new_text))
end
|
#change_tab_reset_modify(_tab) ⇒ Object
4046
4047
4048
4049
4050
4051
4052
4053
4054
|
# File 'ext/ae-editor/ae-editor.rb', line 4046
def change_tab_reset_modify(_tab)
if @main_frame.enb.index(page_name(_tab))
_new_name = @main_frame.enb.itemcget(page_name(_tab), 'text').gsub!("(...)",'')
if _new_name
change_tab_title(_tab, _new_name)
end
end
end
|
#change_tab_reset_read_only(_tab) ⇒ Object
4021
4022
4023
4024
4025
4026
|
# File 'ext/ae-editor/ae-editor.rb', line 4021
def change_tab_reset_read_only(_tab)
_new_name = unname_read_only(@main_frame.enb.itemcget(page_name(_tab), 'text'))
if _new_name
change_tab_title(_tab, _new_name)
end
end
|
#change_tab_set_modify(_tab) ⇒ Object
4029
4030
4031
4032
|
# File 'ext/ae-editor/ae-editor.rb', line 4029
def change_tab_set_modify(_tab)
_new_name = '(...)'+@main_frame.enb.itemcget(page_name(_tab), 'text')
change_tab_title(_tab, _new_name)
end
|
#change_tab_set_read_only(_tab) ⇒ Object
4016
4017
4018
4019
|
# File 'ext/ae-editor/ae-editor.rb', line 4016
def change_tab_set_read_only(_tab)
_new_name = name_read_only(@main_frame.enb.itemcget(page_name(_tab), 'text'))
change_tab_title(_tab, _new_name)
end
|
#change_tab_title(_tab, _new_text) ⇒ Object
4056
4057
4058
|
# File 'ext/ae-editor/ae-editor.rb', line 4056
def change_tab_title(_tab, _new_text)
@main_frame.enb.itemconfigure(page_name(_tab), 'text'=> _new_text)
end
|
#close_all_editor(_editor, _mod = true) ⇒ Object
4278
4279
4280
4281
4282
4283
4284
|
# File 'ext/ae-editor/ae-editor.rb', line 4278
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
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
|
# File 'ext/ae-editor/ae-editor.rb', line 4330
def close_buffer(_page_frame)
_name = page_name(_page_frame)
if @tabs_editor[_name] && @tabs_editor[_name].file
(@tabs_editor[_name].file)
else
(tab_title_by_tab_name(_name))
end
@tabs_editor.delete(_name)
_index = @main_frame.enb.index(_name)
@main_frame.enb.delete(_name)
if !@main_frame.enb.pages.empty?
@main_frame.enb.raise(@main_frame.enb.pages[_index-1]) if TkWinfo.mapped?(@main_frame.enb)
else
frame.root.top_text('') if TkWinfo.mapped?(frame.hinner_frame)
end
end
|
#close_editor(_editor, _force = false) ⇒ Object
4321
4322
4323
4324
4325
4326
4327
4328
|
# File 'ext/ae-editor/ae-editor.rb', line 4321
def close_editor(_editor, _force=false)
if _force || can_close_editor?(_editor)
_editor.destroy_outline
close_buffer(_editor.page_frame)
else
return
end
end
|
#close_file(_filename) ⇒ Object
4347
4348
4349
4350
|
# File 'ext/ae-editor/ae-editor.rb', line 4347
def close_file(_filename)
_e = @tabs_editor[tab_name(_filename)]
close_editor(_e) if _e
end
|
#close_others_editor(_editor, _mod = true) ⇒ Object
4270
4271
4272
4273
4274
4275
4276
|
# File 'ext/ae-editor/ae-editor.rb', line 4270
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
3885
3886
3887
3888
|
# File 'ext/ae-editor/ae-editor.rb', line 3885
def close_raised
_e = @tabs_editor[@main_frame.enb.raise]
close_editor(_e) if _e
end
|
#create_find ⇒ Object
3837
3838
3839
3840
3841
|
# File 'ext/ae-editor/ae-editor.rb', line 3837
def create_find
@find = Finder.new(@arcadia.layout.root, self)
@find.on_close=proc{@find.hide}
@find.hide
end
|
#debug_begin ⇒ Object
4079
4080
4081
4082
4083
4084
4085
|
# File 'ext/ae-editor/ae-editor.rb', line 4079
def debug_begin
if @editors_in_debug != nil
@editors_in_debug.clear
else
@editors_in_debug = Array.new
end
end
|
#debug_end ⇒ Object
4087
4088
4089
4090
4091
4092
4093
|
# File 'ext/ae-editor/ae-editor.rb', line 4087
def debug_end
@editors_in_debug.each{|e|
close_editor(e)
}
end
|
#debug_reset ⇒ Object
4095
4096
4097
4098
4099
|
# File 'ext/ae-editor/ae-editor.rb', line 4095
def debug_reset
if @last_index && @last_e
@last_e.unmark_debug(@last_index)
end
end
|
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
|
# File 'ext/ae-editor/ae-editor.rb', line 3477
def (_file)
to_del = -1
i_end = @buffer_menu.index('end')
0.upto(i_end){|j|
type = @buffer_menu.(j)
if type != 'separator'
label = @buffer_menu.entrycget(j,'label')
if label == _file
to_del=j
break
end
end
}
@buffer_menu.delete(to_del) if to_del != -1
end
|
#do_buffer_raise(_name, _title = '...') ⇒ Object
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
|
# File 'ext/ae-editor/ae-editor.rb', line 4129
def do_buffer_raise(_name, _title='...')
_index = @main_frame.enb.index(_name)
_new_caption = '...'
if _index != -1
_e = @tabs_editor[_name]
change_outline(_e) if _e
if _e && _e.file != nil
_new_caption = _e.file
@find.use(_e)
_e.check_file_last_access_time
else
_new_caption = _title
end
end
if @arcadia.layout.headed?
if frame.root.title == frame.title
frame.root.top_text(_new_caption)
end
frame.root.save_caption(frame.name, _new_caption)
end
_title = @tabs_file[_name] != nil ? File.basename(@tabs_file[_name]) :_name
Arcadia.broadcast_event(BufferRaisedEvent.new(self,'title'=>_title, 'file'=>@tabs_file[_name]))
end
|
#editor_exist?(_filename) ⇒ Boolean
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
|
# File 'ext/ae-editor/ae-editor.rb', line 4158
def editor_exist?(_filename)
_basefilename = File.basename(_filename)
_name = self.tab_file_name(_filename)
_index = @main_frame.enb.index(_name)
if _index == -1
_index = @main_frame.enb.index(name_read_only(_name))
end
return _index != -1
end
|
#get_find ⇒ Object
3833
3834
3835
|
# File 'ext/ae-editor/ae-editor.rb', line 3833
def get_find
@find
end
|
#get_tab_from_name(_name = nil) ⇒ Object
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
|
# File 'ext/ae-editor/ae-editor.rb', line 3995
def get_tab_from_name(_name=nil)
return @main_frame.enb.get_frame(_name)
end
|
#highlight_scanner(_ext = nil) ⇒ Object
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
|
# File 'ext/ae-editor/ae-editor.rb', line 3524
def highlight_scanner(_ext=nil)
return nil if _ext.nil?
scanner = nil
@highlight_scanner_hash = Hash.new if !defined?(@highlight_scanner_hash)
lh = languages_hash(_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
|
#languages_hash(_ext = nil) ⇒ Object
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
|
# File 'ext/ae-editor/ae-editor.rb', line 3543
def languages_hash(_ext=nil)
@@langs_hash = Hash.new if !defined?(@@langs_hash)
return nil if _ext.nil?
if @@langs_hash[_ext].nil?
lang_file = File.dirname(__FILE__)+'/langs/'+_ext+'.lang'
if File.exist?(lang_file)
@@langs_hash[_ext] = properties_file2hash(lang_file)
elsif File.exist?(lang_file+'.bind')
b= properties_file2hash(lang_file+'.bind')
if b
if @@langs_hash[b['bind']].nil?
lang_file_bind = File.dirname(__FILE__)+'/langs/'+b['bind']+".lang"
if File.exist?(lang_file_bind)
@@langs_hash[b['bind']]=properties_file2hash(lang_file_bind)
@@langs_hash[_ext]=@@langs_hash[b['bind']]
end
else
@@langs_hash[_ext]=@@langs_hash[b['bind']]
end
end
end
if @@langs_hash[_ext] && @@langs_hash[_ext]['@include'] != nil
include_file = "#{File.dirname(__FILE__)}/langs/#{@@langs_hash[_ext]['@include']}"
if File.exist?(include_file)
include_hash = properties_file2hash(include_file)
@@langs_hash[_ext] = include_hash.merge(@@langs_hash[_ext])
end
end
self.resolve_properties_link(@@langs_hash[_ext], Arcadia.instance['conf']) if @@langs_hash[_ext]
end
@@langs_hash[_ext]
end
|
#name_read_only(_name) ⇒ Object
4008
4009
4010
|
# File 'ext/ae-editor/ae-editor.rb', line 4008
def name_read_only(_name)
'[READ-ONLY] '+_name
end
|
#on_after_build(_event) ⇒ Object
3493
3494
3495
|
# File 'ext/ae-editor/ae-editor.rb', line 3493
def on_after_build(_event)
self.open_last_files
end
|
#on_after_debug(_event) ⇒ Object
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
|
# File 'ext/ae-editor/ae-editor.rb', line 3702
def on_after_debug(_event)
"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
@breakpoints.delete_if{|b| (b[:file]==_event.file && b[:line]==_event.row)}
_e = @tabs_editor[tab_file_name(_event.file)]
_e.remove_tag_breakpoint(_event.row) if _e
end
end
|
#on_after_focus(_event) ⇒ Object
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
|
# File 'ext/ae-editor/ae-editor.rb', line 3508
def on_after_focus(_event)
if raised && _event.focus_widget == raised.text
if [CutTextEvent, PasteTextEvent, UndoTextEvent, RedoTextEvent].include?(_event.class)
if raised.highlighting
line_begin_index = raised.text.index('@0,0')
line_begin = line_begin_index.split('.')[0].to_i
line_end = raised.text.index('@0,'+TkWinfo.height(raised.text).to_s).split('.')[0].to_i + 1
raised.reset_highlight(line_begin)
raised.rehighlightlines(line_begin,line_end,true)
else
raised.check_modify
end
end
end
end
|
#on_before_build(_event) ⇒ Object
#on_before_debug(_event) ⇒ Object
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
|
# File 'ext/ae-editor/ae-editor.rb', line 3674
def on_before_debug(_event)
"on_before_debug #{_event}"
case _event
when StartDebugEvent
_filename = _event.file
if _filename.nil?
current_editor = self.raised
_event.file=current_editor.file if current_editor
end
self.debug_begin
when SetBreakpointEvent
if _event.active == 1
@breakpoints << {:file=>_event.file,:line=>_event.row}
_e = @tabs_editor[tab_file_name(_event.file)]
if _e
_index =_event.row+'.0'
_line = _e.text.get(_index, _index+ ' lineend')
_event.line_code = _line.strip if _line
_e.add_tag_breakpoint(_event.row)
else
_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
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
|
# File 'ext/ae-editor/ae-editor.rb', line 3338
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)
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?('<<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
3670
3671
3672
|
# File 'ext/ae-editor/ae-editor.rb', line 3670
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
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
|
# File 'ext/ae-editor/ae-editor.rb', line 3739
def on_buffer(_event)
case _event
when NewBufferEvent
self.open_buffer
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
self.open_file(_event.file, _index)
elsif _event.text
if _event.title
_tab_name = self.tab_name(_event.title)
self.open_buffer(_tab_name, _event.title)
_e = @tabs_editor[_tab_name]
_e.text_insert('end',_event.text)
_e.reset
_e.refresh
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
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
|
# File 'ext/ae-editor/ae-editor.rb', line 3432
def on_build(_event)
@main_frame = AgMultiEditorView.new(self.frame.hinner_frame)
@outline_bar = AgEditorOutlineToolbar.new(self.frame(1).hinner_frame, self)
create_find
@buffer_menu = frame.root.(self.name, 'files', DOCUMENT_COMBO_GIF, 'right', {'relief'=>:raised, 'borderwidth'=>1}).cget('menu')
frame.root.add_sep(self.name, 1)
frame.root.add_button(
self.name,
'close current',
proc{Arcadia.process_event(CloseCurrentTabEvent.new(self))},
CLOSE_DOCUMENT_GIF)
end
|
#on_debug_step_info(_event) ⇒ Object
3726
3727
3728
3729
3730
3731
3732
3733
|
# File 'ext/ae-editor/ae-editor.rb', line 3726
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
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
|
# File 'ext/ae-editor/ae-editor.rb', line 3497
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
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
|
# File 'ext/ae-editor/ae-editor.rb', line 3853
def on_finalize(_event)
@batch_files = true
_files =''
_raised = self.raised
Arcadia.persistent('editor.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}"
end
close_editor(editor,true)
}
Arcadia.persistent('editor.files.open', _files)
@batch_files = true
end
|
#on_layout_raising_frame(_event) ⇒ Object
3908
3909
3910
3911
3912
3913
|
# File 'ext/ae-editor/ae-editor.rb', line 3908
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) ⇒ Object
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
|
# File 'ext/ae-editor/ae-editor.rb', line 4222
def open_buffer(_buffer_name = nil, _title = nil, _filename=nil)
_index = @main_frame.enb.index(_buffer_name)
if _buffer_name == nil
_title_new = '*new'
_buffer_name = tab_name(_title_new)
end
if _index != -1
_tab = @main_frame.enb.get_frame(_buffer_name)
@main_frame.enb.raise(_buffer_name) if frame_visible?
else
_n = 1
while @main_frame.enb.index(_buffer_name) != -1
_title_new = '*new'+_n.to_s
_buffer_name = tab_name(_title_new)
_n =_n+1
end
if _title == nil
_title = _title_new
end
_tab = @main_frame.enb.insert('end', _buffer_name ,
'text'=> _title,
'image'=> Arcadia.file_icon(_title),
'background'=> Arcadia.style("tabpanel.background"),
'foreground'=> Arcadia.style("tabpanel.foreground"),
'raisecmd'=>proc{do_buffer_raise(_buffer_name, _title)}
)
if _filename
(_filename)
else
(_title, false)
end
_e = AgEditor.new(self, _tab)
ext = Arcadia.file_extension(_title)
ext='rb' if ext.nil?
_e.init_editing(ext)
_e.text.set_focus
@tabs_editor[_buffer_name]=_e
end
@main_frame.enb.move(_buffer_name, 1)
@main_frame.enb.raise(_buffer_name) if frame_visible?
@main_frame.enb.see(_buffer_name)
return _tab
end
|
#open_file(_filename = nil, _text_index = '1.0', _mark_selected = true, _exp = true) ⇒ Object
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
|
# File 'ext/ae-editor/ae-editor.rb', line 4192
def open_file(_filename = nil, _text_index='1.0', _mark_selected=true, _exp=true)
return if _filename == nil || !File.exist?(_filename) || File.ftype(_filename) != 'file'
_basefilename = File.basename(_filename)
_tab_name = self.tab_file_name(_filename)
_index = @main_frame.enb.index(_tab_name)
_exist_buffer = _index != -1
if _exist_buffer
open_buffer(_tab_name)
else
@tabs_file[_tab_name]= _filename
open_buffer(_tab_name, _basefilename, _filename)
@tabs_editor[_tab_name].reset_highlight
begin
@tabs_editor[_tab_name].load_file(_filename)
rescue RuntimeError => e
p "RuntimeError : #{e.message}"
close_editor(@tabs_editor[_tab_name], true)
end
end
if _text_index != nil && _text_index != '1.0' && @tabs_editor[_tab_name]
@tabs_editor[_tab_name].text_see(_text_index)
@tabs_editor[_tab_name].mark_selected(_text_index) if _mark_selected
end
return @tabs_editor[_tab_name]
end
|
#open_file_in_debug(_filename = nil, _line = nil) ⇒ Object
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
|
# File 'ext/ae-editor/ae-editor.rb', line 4101
def open_file_in_debug(_filename=nil, _line=nil)
if _filename && _line && File.exists?(_filename)
@last_index = _line.to_s+'.0'
_editor_exist = editor_exist?(_filename)
@last_e = open_file(_filename, @last_index, false, false)
@last_e.mark_debug(@last_index) if @last_e
if !_editor_exist
@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
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
|
# File 'ext/ae-editor/ae-editor.rb', line 3922
def open_last_files
@batch_files = true
if Arcadia.persistent('editor.files.open')
_files_index =Arcadia.persistent('editor.files.open').split("|")
_files_index.each do |value|
_file,_index = value.split(';')
if _file && _index
open_file(_file,_index,false)
else
open_file(_file)
end
end
end
@batch_files = false
to_raise_file = Arcadia.persistent('editor.files.last')
if to_raise_file
raise_file(to_raise_file,0)
else
_first_page = @main_frame.enb.pages(0) if @main_frame.enb.pages.length > 0
if _first_page
@main_frame.enb.raise(_first_page) if frame_def_visible?
@main_frame.enb.see(_first_page)
end
end
frame(1)
Arcadia.attach_listener(self, LayoutRaisingFrameEvent)
self
end
|
#page_name(_page_frame) ⇒ Object
4042
4043
4044
|
# File 'ext/ae-editor/ae-editor.rb', line 4042
def page_name(_page_frame)
TkWinfo.appname(_page_frame).sub('f','')
end
|
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
|
# File 'ext/ae-editor/ae-editor.rb', line 3578
def
@pop_up = TkMenu.new(
:parent=>@main_frame.enb,
: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.enb.tabbind("Button-3",
proc{|*x|
_x = TkWinfo.pointerx(@main_frame.enb)
_y = TkWinfo.pointery(@main_frame.enb)
@selected_tab_name_from_popup = x[0].split(':')[0]
_index = @main_frame.enb.index(@selected_tab_name_from_popup)
if _index == -1
@selected_tab_name_from_popup = 'ff'+@selected_tab_name_from_popup
_index = @main_frame.enb.index(@selected_tab_name_from_popup)
end
if _index != -1
_file = @tabs_file[(@selected_tab_name_from_popup)] @pop_up.entryconfigure(3, 'label'=> _file)
@pop_up.(_x,_y+10)
end
})
end
|
#raise_file(_filename = nil, _pos = nil) ⇒ Object
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
|
# File 'ext/ae-editor/ae-editor.rb', line 4181
def raise_file(_filename=nil, _pos=nil)
if _filename && frame_def_visible?
tab_name=self.tab_file_name(_filename)
if @main_frame.enb.index(tab_name) != -1
@main_frame.enb.move(tab_name,_pos) if _pos
@main_frame.enb.raise(tab_name)
@main_frame.enb.see(tab_name)
end
end
end
|
#raised ⇒ Object
3880
3881
3882
3883
|
# File 'ext/ae-editor/ae-editor.rb', line 3880
def raised
_page = @main_frame.enb.raise
return @tabs_editor[_page]
end
|
#save_as_file(_filename) ⇒ Object
4356
4357
4358
|
# File 'ext/ae-editor/ae-editor.rb', line 4356
def save_as_file(_filename)
@tabs_editor[tab_name(_filename)].save_as
end
|
#save_file(_filename) ⇒ Object
4352
4353
4354
|
# File 'ext/ae-editor/ae-editor.rb', line 4352
def save_file(_filename)
@tabs_editor[tab_name(_filename)].save
end
|
#show_hide_current_line_numbers ⇒ Object
3848
3849
3850
3851
|
# File 'ext/ae-editor/ae-editor.rb', line 3848
def show_hide_current_line_numbers
_e = raised
_e.show_hide_line_numbers if _e
end
|
#start_find ⇒ Object
3843
3844
3845
3846
|
# File 'ext/ae-editor/ae-editor.rb', line 3843
def start_find
_e = raised
_e.find if _e
end
|
#tab_file_name(_filename = "") ⇒ Object
4175
4176
4177
4178
4179
|
# File 'ext/ae-editor/ae-editor.rb', line 4175
def tab_file_name(_filename="")
_fstr = File.expand_path(_filename)
_fstr = _filename if _fstr == nil
tab_name(_fstr)
end
|
#tab_name(_str = "") ⇒ Object
4170
4171
4172
4173
|
# File 'ext/ae-editor/ae-editor.rb', line 4170
def tab_name(_str="")
'ff'+_str.downcase.gsub("/","_").gsub(".","__").gsub(":","___").gsub("\\","____").gsub("*","_____")
end
|
#tab_title(_tab) ⇒ Object
4034
4035
4036
|
# File 'ext/ae-editor/ae-editor.rb', line 4034
def tab_title(_tab)
@main_frame.enb.itemcget(page_name(_tab), 'text')
end
|
#tab_title_by_tab_name(_tab_name) ⇒ Object
4038
4039
4040
|
# File 'ext/ae-editor/ae-editor.rb', line 4038
def tab_title_by_tab_name(_tab_name)
@main_frame.enb.itemcget(_tab_name, 'text')
end
|
#unname_read_only(_name) ⇒ Object
4012
4013
4014
|
# File 'ext/ae-editor/ae-editor.rb', line 4012
def unname_read_only(_name)
return _name.gsub("[READ-ONLY] ",'')
end
|