Class: Finder
Constant Summary
Constants included
from TkResizable
TkResizable::MIN_HEIGHT, TkResizable::MIN_WIDTH
Instance Attribute Summary collapse
#frame, #top
Instance Method Summary
collapse
#head_buttons, #hide, #hide_if_visible, #on_arcadia, #on_close=, #show_grabbed, #title
#resizing_do_move_obj, #resizing_do_press, #start_resizing, #stop_resizing
Methods included from TkMovable
#moving_do_move_obj, #moving_do_press, #start_moving, #stop_moving
#add_fixed_button, #add_fixed_menu_button, #add_fixed_panel, #add_fixed_sep, #create_frame, #head_buttons, #menu_button, #visible?
Constructor Details
#initialize(_frame, _controller) ⇒ Finder
Returns a new instance of Finder.
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
5997
5998
5999
6000
6001
6002
|
# File 'ext/ae-editor/ae-editor.rb', line 5959
def initialize(_frame, _controller)
super(_frame)
@controller = _controller
@forwards = true
@find_action = proc{
hide
do_find_next
}
@b_go.bind('1', @find_action)
@b_replace.bind('1', proc{hide; do_replace})
@b_replace_all.bind('1', proc{hide; do_replace_all})
@e_what_entry.bind_append('KeyRelease'){|e|
case e.keysym
when 'Return'
@find_action.call
Tk.callback_break
else
widget_state
end
}
e2 = TkWinfo.children(@e_with)[0]
e2.bind_append('KeyPress'){|e|
widget_state
}
@last_index='insert'
@goto_line_dialog = GoToLine.new(_frame).hide
@goto_line_dialog.on_close=proc{@goto_line_dialog.hide}
@goto_line_dialog.b_go.bind('1',proc{go_line})
@goto_line_dialog.e_line.bind_append('KeyRelease'){|e|
case e.keysym
when 'Return'
go_line
Tk.callback_break
end
}
end
|
Instance Attribute Details
#e_what ⇒ Object
Returns the value of attribute e_what.
5958
5959
5960
|
# File 'ext/ae-editor/ae-editor.rb', line 5958
def e_what
@e_what
end
|
Instance Method Details
#do_find(_istart = nil) ⇒ Object
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
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
|
# File 'ext/ae-editor/ae-editor.rb', line 6097
def do_find(_istart=nil)
@forwards = @cb_back.cget('onvalue') != @cb_back.cget('variable').value.to_i
_found = false
@idx1 = nil
@idx2 = nil
if @e_what.text.length > 0
update_combo(@e_what.text)
if !_istart && self.editor.text.index('insert')!=nil
_istart ='insert'
elsif defined?(@last_index)
_istart = @last_index
else
_istart = '1.0'
end
options = []
if !@forwards
options << 'backwards'
end
if @cb_reg.cget('onvalue')==@cb_reg.cget('variable').value.to_i
options << 'regexp'
end
if @cb_ignore_case.cget('onvalue')==@cb_ignore_case.cget('variable').value.to_i
options << 'nocase'
end
_index = self.editor.text.tksearch(options,@e_what.text,_istart)
if _index && _index.length>0
self.editor.text.see(_index)
_row, _col = _index.split('.')
_index_sel_end = _row.to_i.to_s+'.'+(_col.to_i+@e_what.text.length).to_i.to_s
if @forwards
@last_index= _index_sel_end
else
@last_index= _row.to_i.to_s+'.'+(_col.to_i-1).to_i.to_s
end
self.editor.text.tag_add('sel', _index,_index_sel_end)
self.editor.text.set_insert(_index)
@idx1 =_index
@idx2 =_index_sel_end
_found = true
@controller.chrono_bookmark_add(self.editor.file, _index)
else
_message = '"'+@e_what.value+'" not found'
Arcadia.hinner_dialog(self, 'type'=>'ok', 'msg'=> _message)
end
else
self.show()
end
self.editor.text.focus
return _found
end
|
#do_find_next ⇒ Object
6154
6155
6156
6157
6158
6159
|
# File 'ext/ae-editor/ae-editor.rb', line 6154
def do_find_next
if @idx1 != nil
self.editor.text.tag_remove('sel',@idx1,@idx2)
end
do_find(@last_index)
end
|
#do_replace ⇒ Object
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
|
# File 'ext/ae-editor/ae-editor.rb', line 6004
def do_replace
if do_find_next
_message = Arcadia.text('ext.editor.search.d.replace.msg', [@e_what.value, @e_with.value])
if Arcadia.hinner_dialog(self, 'type'=>'yes_no', 'msg'=> _message, 'title' => "Replace", 'level' => 'question')=='yes'
self.editor.text.delete(@idx1,@idx2)
self.editor.text.insert(@idx1,@e_with.value)
self.editor.check_modify
end
end
end
|
#do_replace_all ⇒ Object
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
|
# File 'ext/ae-editor/ae-editor.rb', line 6015
def do_replace_all
show_dialog = true
founds = []
while do_find_next
break if founds.include?(@idx1)
founds << @idx1
if show_dialog
_message = Arcadia.text('ext.editor.search.d.replace.msg', [@e_what.value, @e_with.value])
_rc = Arcadia.hinner_dialog(self, 'type'=>'yes_yesall_no_cancel', 'msg'=> _message, 'title' => "Replace", 'level' => 'question')
end
if _rc == 'yes' || _rc == 'yesall'
self.editor.text.delete(@idx1,@idx2)
self.editor.text.insert(@idx1,@e_with.value)
self.editor.check_modify
show_dialog = _rc != 'yesall'
elsif _rc == 'cancel'
break
end
end
end
|
#editor ⇒ Object
6047
6048
6049
6050
6051
6052
|
# File 'ext/ae-editor/ae-editor.rb', line 6047
def editor
if @editor_caller == nil
@editor_caller = @controller.raised
end
return @editor_caller
end
|
#go_line ⇒ Object
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
|
# File 'ext/ae-editor/ae-editor.rb', line 6059
def go_line
if @goto_line_dialog.e_line.value.length > 0
_row = @goto_line_dialog.e_line.value
_index = _row.strip+'.1'
self.editor.text.see(_index)
self.editor.text.tag_remove('selected','1.0','end')
self.editor.text.tag_add('selected',_index,_index+' lineend')
self.editor.text.set_insert(_index)
@controller.chrono_bookmark_add(self.editor.file, _index)
@goto_line_dialog.hide
end
end
|
#show ⇒ Object
6085
6086
6087
6088
|
# File 'ext/ae-editor/ae-editor.rb', line 6085
def show
super
use(@controller.raised)
end
|
#show_go_to_line_dialog ⇒ Object
6054
6055
6056
6057
|
# File 'ext/ae-editor/ae-editor.rb', line 6054
def show_go_to_line_dialog
use(@controller.raised)
@goto_line_dialog.show
end
|
#update_combo(_txt) ⇒ Object
6090
6091
6092
6093
6094
6095
|
# File 'ext/ae-editor/ae-editor.rb', line 6090
def update_combo(_txt)
values = @e_what.cget('values')
if (values != nil && !values.include?(_txt))
@e_what.insert('end', @e_what.value)
end
end
|
#use(_editor) ⇒ Object
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
|
# File 'ext/ae-editor/ae-editor.rb', line 6074
def use(_editor)
if (_editor != @editor_caller)
@last_index='insert'
@editor_caller = _editor
_title = '?'
_title = File.basename(_editor.file) if _editor.file
title(_title)
@goto_line_dialog.title(_title) if @goto_line_dialog
end
end
|
6036
6037
6038
6039
6040
6041
6042
6043
6044
|
# File 'ext/ae-editor/ae-editor.rb', line 6036
def widget_state
if (@e_what.value.length > 0) && (@e_with.value.length > 0)
@b_replace.configure('state'=>'active')
@b_replace_all.configure('state'=>'active')
else
@b_replace.configure('state'=>'disabled')
@b_replace_all.configure('state'=>'disabled')
end
end
|