Class: SearchOutput

Inherits:
Object
  • Object
show all
Defined in:
ext/ae-search-in-files/ae-search-in-files.rb

Instance Method Summary collapse

Constructor Details

#initialize(_ext) ⇒ SearchOutput

Returns a new instance of SearchOutput.


145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'ext/ae-search-in-files/ae-search-in-files.rb', line 145

def initialize(_ext)
  @sequence = 0
  @ext = _ext
#    left_frame = TkFrame.new(@ext.frame.hinner_frame, Arcadia.style('panel')).place('x' => '0','y' => '0','relheight' => '1','width' => '25')
  @results = {}
  _open_file = proc do |tree, sel|
    n_parent, n = sel.split('@@@')
    Arcadia.process_event(OpenBufferTransientEvent.new(self,'file'=>@results[n_parent][n][0], 'row'=>@results[n_parent][n][1]))  if n && @results[n_parent][n]
  end
  @tree = BWidgetTreePatched.new(@ext.frame.hinner_frame, Arcadia.style('treepanel')){
  #@tree = BWidgetTreePatched.new(@ext.hinner_dialog, Arcadia.style('treepanel')){
  #@tree = BWidgetTreePatched.new(@ext.hinner_splitted_dialog, Arcadia.style('treepanel')){
    selectcommand(_open_file)
    deltay 15
  }
#    @tree.extend(TkScrollableWidget).show(25,0)
  @tree.extend(TkScrollableWidget).show(0,0)
  
#    _proc_clear = proc{clear_tree}

  _ext.frame.root.add_button(_ext.name,  Arcadia.text('ext.search_in_files.button.clear.hint'), proc{clear_tree}, CLEAR_GIF) if _ext

  
#    @button_u = Tk::BWidget::Button.new(left_frame, Arcadia.style('toolbarbutton')){
#      image  Arcadia.image_res(CLEAR_GIF)
#      helptext 'ext.search_in_files.button.clear.hint'
#      command _proc_clear
#      relief 'groove'
#      pack('side' =>'top', 'anchor'=>'n',:padx=>0, :pady=>0)
#    }
  
  @found_color=Arcadia.conf('activeforeground')
  @not_found_color= Arcadia.conf('hightlight.comment.foreground')
  @item_color=Arcadia.conf('treeitem.fill')
end

Instance Method Details

#add_result(_node, _file, _line = '', _line_text = '') ⇒ Object


211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'ext/ae-search-in-files/ae-search-in-files.rb', line 211

def add_result(_node, _file, _line='', _line_text='')
  @count = @count+1
  @tree.itemconfigure(_node, 'fill'=>@found_color, 'text'=>@text_result+' { '+@count.to_s+' found }')
  _text = _file+':'+_line+' : '+_line_text
  _node_name = new_node_name
  @tree.insert('end', _node ,_node+'@@@'+_node_name, {
    'fill'=>@item_color,
    'anchor'=>'w',
    'font' => Arcadia.conf('treeitem.font'),
    'text' =>  _text.strip
  })
  @results[_node][_node_name]=[_file,_line]
  Tk.update
end

#clear_treeObject


181
182
183
184
# File 'ext/ae-search-in-files/ae-search-in-files.rb', line 181

def clear_tree
  @tree.delete(@tree.nodes('root'))
  @results.clear
end

#new_node_nameObject


186
187
188
189
# File 'ext/ae-search-in-files/ae-search-in-files.rb', line 186

def new_node_name
  @sequence = @sequence + 1
  return 'n'+@sequence.to_s
end

#new_result(_text, _length = 0) ⇒ Object


191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'ext/ae-search-in-files/ae-search-in-files.rb', line 191

def new_result(_text, _length=0)
  @results.each_key{|key| @tree.close_tree(key)}
  _r_node = new_node_name
  @text_result = _text
  #_text = _text + ' { '+_length.to_s+' found }'
  #_length > 0 ? _color='#3f941b':_color = 'red'
  @tree.insert('end', 'root' ,_r_node, {
    'fill'=>@not_found_color,
    'open'=>true,
    'anchor'=>'w',
    'font' => "#{Arcadia.conf('treeitem.font')} bold",
    'text' =>  _text
  })
  Tk.update
  @results[_r_node]={}
  @count = 0
  @tree.set_focus
  return _r_node
end