Class: Output
Constant Summary
collapse
- MARKSUF =
'mark-'
- PROMPT =
'>>>'
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?, #hide_frame, #initialize, #maximize, #maximized?, #resize, #restore_default_conf
Constructor Details
This class inherits a constructor from ArcadiaExt
Instance Attribute Details
#main_frame ⇒ Object
Returns the value of attribute main_frame.
158
159
160
|
# File 'ext/ae-output/ae-output.rb', line 158
def main_frame
@main_frame
end
|
Instance Method Details
#file_binding(_file, _line, _ibegin, _iend) ⇒ Object
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
|
# File 'ext/ae-output/ae-output.rb', line 326
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,"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
|
177
178
179
|
# File 'ext/ae-output/ae-output.rb', line 177
def format_time(_time)
_time.strftime("at %a %d-%b-%Y %H:%M:%S")
end
|
#next_tag_name ⇒ Object
321
322
323
324
|
# File 'ext/ae-output/ae-output.rb', line 321
def next_tag_name
@tag_seq = @tag_seq + 1
"tag_#{@tag_seq}"
end
|
#on_after_build(_event) ⇒ Object
173
174
175
|
# File 'ext/ae-output/ae-output.rb', line 173
def on_after_build(_event)
self.frame.show
end
|
#on_before_build(_event) ⇒ Object
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
|
# File 'ext/ae-output/ae-output.rb', line 259
def on_input_keyboard_query(_event)
@prompt_active = true
sync_insert("end","#{PROMPT}",'bord_msg')
@main_frame.text.focus
@main_frame.text.see("end")
@main_frame.input_buffer = nil
while @main_frame.input_buffer.nil? && !_event.is_breaked?
sleep(0.1)
end
if !_event.is_breaked?
_event.add_result(self, 'input'=>@main_frame.input_buffer)
else
if @main_frame.text.get("end -1 lines linestart", "end -1 lines lineend").strip == PROMPT
@main_frame.text.delete("end -1 lines linestart", "end -1 lines lineend")
end
end
@main_frame.input_buffer = nil
@prompt_active = false
end
|
#on_msg(_event) ⇒ Object
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
# File 'ext/ae-output/ae-output.rb', line 181
def on_msg(_event)
self.frame.show if !self.frame.raised?
if _event.mark
_mark_index = _event.mark.sub(MARKSUF,'');
_index_begin = "#{_mark_index} + 1 lines + 1 chars"
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))
sync_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
sync_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")
end
|
#out(_txt = nil, _tag = nil) ⇒ Object
354
355
356
357
358
359
360
361
362
363
|
# File 'ext/ae-output/ae-output.rb', line 354
def out(_txt=nil, _tag=nil)
if @main_frame && _txt
sync_insert('end', _txt, _tag)
end
end
|
#outln(_txt = nil, _tag = nil) ⇒ Object
365
366
367
|
# File 'ext/ae-output/ae-output.rb', line 365
def outln(_txt=nil, _tag=nil)
self.out(_txt+"\n",_tag)
end
|
#parse_debug(_from_row = 0, _to_row = -1)) ⇒ Object
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
# File 'ext/ae-output/ae-output.rb', line 281
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
_end = 0
re = Regexp.new('([\w\:]*[\.\/]*[\/A-Za-z_\-\.]*[\.\/\w\d]*[(<<current buffer>>)]*):(\d*)')
m = re.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
}
end
end
|
#sync_insert(_index, _txt, _tag = nil) ⇒ Object
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 237
def sync_insert(_index, _txt, _tag=nil)
begin
while @writing
sleep(0.1)
end
@writing = true
if @prompt_active
start = @main_frame.text.get("#{_index} -1 lines linestart", _index).strip
if start == PROMPT
_index = "#{_index} -1 lines linestart"
end
end
if _tag
@main_frame.text.insert(_index, _txt, _tag)
else
@main_frame.text.insert(_index, _txt)
end
ensure
@writing = false
end
end
|