Class: Output

Inherits:
ArcadiaExt show all
Defined in:
ext/ae-output/ae-output.rb

Constant Summary collapse

MARKSUF =
'mark-'

Instance Attribute Summary collapse

Attributes inherited from ArcadiaExt

#arcadia, #name

Instance Method Summary collapse

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 ArcadiaExt

Instance Attribute Details

#main_frameObject (readonly)

Returns the value of attribute main_frame.



148
149
150
# File 'ext/ae-output/ae-output.rb', line 148

def main_frame
  @main_frame
end

Instance Method Details

#file_binding(_file, _line, _ibegin, _iend) ⇒ Object



264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# File 'ext/ae-output/ae-output.rb', line 264

def file_binding(_file, _line, _ibegin, _iend)
  if _file == '<<current buffer>>'
    _file = "*CURR"
  end
  _line = '0' if _line.nil? || _line.strip.length == 0
  tag_name = next_tag_name
  @main_frame.text.tag_configure(tag_name,
  'foreground' => Arcadia.conf('hightlight.link.foreground'),
  'borderwidth'=>0,
  'relief'=>'flat',
  'underline'=>true
  )
  @main_frame.text.tag_add(tag_name,_ibegin,_iend)
  #@main_frame.text.tag_bind(tag_name,"Double-ButtonPress-1",
  @main_frame.text.tag_bind(tag_name,"ButtonPress-1",
  proc{
    Arcadia.process_event(OpenBufferTransientEvent.new(self,'file'=>_file, 'row'=>_line))
  }
  )
  @main_frame.text.tag_bind(tag_name,"Enter",
  proc{@main_frame.text.configure('cursor'=> 'hand2')}
  )
  @main_frame.text.tag_bind(tag_name,"Leave",
  proc{@main_frame.text.configure('cursor'=> @cursor)}
  )

end

#format_time(_time) ⇒ Object



164
165
166
# File 'ext/ae-output/ae-output.rb', line 164

def format_time(_time)
  _time.strftime("at %a %d-%b-%Y %H:%M:%S")
end

#next_tag_nameObject



259
260
261
262
# File 'ext/ae-output/ae-output.rb', line 259

def next_tag_name
  @tag_seq = @tag_seq + 1 
  "tag_#{@tag_seq}"
end

#on_after_build(_event) ⇒ Object



160
161
162
# File 'ext/ae-output/ae-output.rb', line 160

def on_after_build(_event)
  self.frame.show
end

#on_before_build(_event) ⇒ Object



150
151
152
153
154
155
156
157
# File 'ext/ae-output/ae-output.rb', line 150

def on_before_build(_event)
  #ArcadiaContractListener.new(self, MsgContract, :do_msg_event)
  @tag_seq = 0
  Arcadia.attach_listener(self, MsgEvent)
  #_frame = @arcadia.layout.register_panel('_rome_',@name, 'Output')
  @main_frame = OutputView.new(self)
  @run_threads = Array.new
end

#on_msg(_event) ⇒ Object



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'ext/ae-output/ae-output.rb', line 168

def on_msg(_event)
  self.frame.show
  if _event.mark
    _mark_index = _event.mark.sub(MARKSUF,'');
    _index_begin = "#{_mark_index} + 1 lines + 1 chars"
    #_index_begin = "#{@main_frame.text.index(_event.mark)} + 1 lines + 1 chars"
    #       _b = Tk::BWidget::Button.new(@main_frame.text,
    #         'helptext'=>Time.now.strftime("-> %d-%b-%Y %H:%M:%S"),
    #         'background'=>Arcadia.style('edit')['background'],
    #         'borderwidth'=>0,
    #         'image'=> TkPhotoImage.new('data' => ITEM_LOG_GIF),
    #         'relief'=>'flat')
    #       TkTextWindow.new(@main_frame.text, _index_begin, 'window'=> _b)
    #       TkTextImage.new(@main_frame.text, _index_begin, 'padx'=>0, 'pady'=>0, 'image'=> TkPhotoImage.new('data' => ITEM_LOG_GIF))
  else
    @main_frame.text.insert("end","\n")
    _index_begin = @main_frame.text.index('end')
    TkTextImage.new(@main_frame.text, _index_begin, 'padx'=>0, 'pady'=>0, 'image'=> Arcadia.image_res(ITEM_START_LOG_GIF))
    @main_frame.text.insert("end"," +--- #{format_time(_event.time)} ---+\n", 'bord_msg')
  end
  if _event.append
    _index_begin = "#{@main_frame.text.index(_index_begin)} - 2 lines lineend"
    _txt = _event.msg
  elsif _event.msg[-1] == "\n"
    _txt = _event.msg
  else
    _txt = "#{_event.msg}\n"
  end
#    if _event.level == 'error'
#      TkTextImage.new(@main_frame.text, _index_begin, 'padx'=>0, 'pady'=>0, 'image'=> TkPhotoImage.new('data' => ERROR_9X9_GIF))
#    end
  @main_frame.text.insert(_index_begin,_txt, "#{_event.level}_msg")
  _index_end = @main_frame.text.index('end')
  if ['debug','error'].include?(_event.level)
    parse_begin_row = _index_begin.split('.')[0].to_i-2
    parse_end_row = _index_end.split('.')[0].to_i
    parse_debug(parse_begin_row, parse_end_row)
  end
  @main_frame.text.see(_index_end)
  @main_frame.text.mark_unset(_event.mark)
  _event.mark="#{MARKSUF}#{_index_end}"
  @main_frame.text.mark_set(_event.mark, "#{_index_end} - 1 lines -1 chars")
  #     if _event.instance_of?(MsgRunEvent)
  #       _b = TkButton.new(@main_frame.text,
  #         'command'=>proc{_event.abort_action.call;_b.destroy},
  #         'image'=> TkPhotoImage.new('data' => CLOSE_GIF),
  #         'relief'=>'groove')
  #       TkTextWindow.new(@main_frame.text, 'end', 'window'=> _b)
  #     end
end

#out(_txt = nil, _tag = nil) ⇒ Object



292
293
294
295
296
297
298
299
300
# File 'ext/ae-output/ae-output.rb', line 292

def out(_txt=nil, _tag=nil)
  if @main_frame && _txt
    if _tag
      @main_frame.text.insert('end',_txt, _tag)
    else
      @main_frame.text.insert('end',_txt)
    end
  end
end

#outln(_txt = nil, _tag = nil) ⇒ Object



302
303
304
# File 'ext/ae-output/ae-output.rb', line 302

def outln(_txt=nil, _tag=nil)
  self.out(_txt+"\n",_tag)
end

#parse_debug(_from_row = 0, _to_row = -1)) ⇒ Object



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'ext/ae-output/ae-output.rb', line 219

def parse_debug(_from_row=0, _to_row=-1)
  return if _from_row == _to_row
  _row = _from_row
  @cursor = @main_frame.text.cget('cursor')
  file_tag=Hash.new
  if String.method_defined?(:lines)
    lines = @main_frame.text.value.lines.to_a[_from_row.._to_row]
  else
    lines = @main_frame.text.value.to_a[_from_row.._to_row]
  end
  
  if lines
    lines.each{|l|
      _row = _row+1
      #if _row >= _from_row
      _end = 0
      #m = /([\.\/]*[\/A-Za-z_\-\.]*[\.\/\w\d]*\.rb):(\d*)/.match(l)
      re = Regexp.new('([\w\:]*[\.\/]*[\/A-Za-z_\-\.]*[\.\/\w\d]*[(<<current buffer>>)]*):(\d*)')
      m = re.match(l)
      #m = /([\.\/]*[\/A-Za-z_\-\.]*[\.\/\w\d]*):(\d*)/.match(l)
      while m
        _txt = m.post_match
        if m[1] && m[2]
          _file = m[1]
          if File.exist?(_file) || _file=="<<current buffer>>"  
             _line = m[2]
            _ibegin = _row.to_s+'.'+(m.begin(1)+_end).to_s
            _iend = _row.to_s+'.'+(m.end(2)+_end).to_s
            file_binding(_file, _line, _ibegin, _iend)
          end
          _end = m.end(2) + _end
        end
        m = re.match(_txt)
      end
      #m = re.match(_txt)
      #end
    }
  end
end