Class: Output

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

Instance Attribute Summary collapse

Attributes inherited from ArcadiaExt

#arcadia

Instance Method Summary collapse

Methods inherited from ArcadiaExt

#conf, #conf_array, #exec, #float_frame, #frame, #initialize

Constructor Details

This class inherits a constructor from ArcadiaExt

Instance Attribute Details

#main_frameObject (readonly)

Returns the value of attribute main_frame.



145
146
147
# File 'ext/ae-output/ae-output.rb', line 145

def main_frame
  @main_frame
end

Instance Method Details

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



225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'ext/ae-output/ae-output.rb', line 225

def file_binding(_file, _line, _ibegin, _iend)
    tag_name = "tag_#{@j}"
    @main_frame.text.tag_configure(tag_name,
      'foreground' => '#800000',
      '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",
      proc{
        Arcadia.process_event(OpenBufferEvent.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



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

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

#on_after_build(_event) ⇒ Object



156
157
158
# File 'ext/ae-output/ae-output.rb', line 156

def on_after_build(_event)
  self.frame.show
end

#on_before_build(_event) ⇒ Object



147
148
149
150
151
152
153
# File 'ext/ae-output/ae-output.rb', line 147

def on_before_build(_event)
   #ArcadiaContractListener.new(self, MsgContract, :do_msg_event)
   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



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'ext/ae-output/ae-output.rb', line 164

def on_msg(_event)
self.frame.show
  _txt = "\n+--- "+format_time(_event.time)+" ---+\n"+_event.msg.strip+"\n"
  _index_begin = @main_frame.text.index('end')
  @main_frame.text.insert(_index_begin,_txt)
  _index_end = @main_frame.text.index('end')
  case _event.level
    when 'debug'
    		@main_frame.text.tag_remove('simple_msg',_index_begin, _index_end+ '  lineend')
    		@main_frame.text.tag_remove('error_msg',_index_begin, _index_end+ '  lineend')
    		@main_frame.text.tag_add('debug_msg',_index_begin, _index_end+ '  lineend')
    		parse_debug(_index_begin.split('.')[0].to_i) 
    when 'error'
    		@main_frame.text.tag_remove('simple_msg',_index_begin, _index_end+ '  lineend')
    		@main_frame.text.tag_remove('debug_msg',_index_begin, _index_end+ '  lineend')
    		@main_frame.text.tag_add('error_msg',_index_begin, _index_end+ '  lineend')
    		parse_debug(_index_begin.split('.')[0].to_i) 
    else
    		@main_frame.text.tag_remove('error_msg',_index_begin, _index_end+ '  lineend')
    		@main_frame.text.tag_remove('debug_msg',_index_begin, _index_end+ '  lineend')
    		@main_frame.text.tag_add('simple_msg',_index_begin, _index_end+ '  lineend')
  end
		@main_frame.text.tag_add('bord_msg',_index_begin+' linestart', _index_begin+ '  lineend')
		@main_frame.text.tag_add('bord_msg',_index_end+' -1 lines linestart', _index_end+ ' -1 lines  lineend')
		@main_frame.text.see(_index_end)
end

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



248
249
250
251
252
253
254
255
256
# File 'ext/ae-output/ae-output.rb', line 248

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



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

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

#parse_debug(_from_row = 0) ⇒ Object



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
218
219
220
221
222
223
# File 'ext/ae-output/ae-output.rb', line 191

def parse_debug(_from_row=0)
   _row = 0
   @cursor = @main_frame.text.cget('cursor')
   @j=0
   file_tag=Hash.new
   @main_frame.text.value.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]*):(\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)
             @j=@j+1
             _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
    end
   }
end