Class: Output
- Inherits:
-
ArcadiaExt
- Object
- ArcadiaExt
- Output
- Defined in:
- ext/ae-output/ae-output.rb
Instance Attribute Summary collapse
-
#main_frame ⇒ Object
readonly
Returns the value of attribute main_frame.
Instance Method Summary collapse
- #format_time(_time) ⇒ Object
- #on_after_build(_event) ⇒ Object
- #on_before_build(_event) ⇒ Object
- #on_msg(_event) ⇒ Object
- #out(_txt = nil, _tag = nil) ⇒ Object
- #outln(_txt = nil, _tag = nil) ⇒ Object
-
#parse_debug(_from_row = 0) ⇒ Object
def do_msg_event(_event) self.frame_raise #p _event.context.text.class _txt = “n+— ”+format_time(_event.time)+“ —
\n"
_event.context.text.strip+”n“ _index_begin = @main_frame.text.index(‘end’) @main_frame.text.insert(_index_begin,_txt) _index_end = @main_frame.text.index(‘end’) if _event.context.type == MsgContract::TYPE_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(‘.’).to_i) elsif _event.context.type == MsgContract::TYPE_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(‘.’).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.
Instance Attribute Details
#main_frame ⇒ Object (readonly)
Returns the value of attribute main_frame.
66 67 68 |
# File 'ext/ae-output/ae-output.rb', line 66 def main_frame @main_frame end |
Instance Method Details
#format_time(_time) ⇒ Object
85 86 87 |
# File 'ext/ae-output/ae-output.rb', line 85 def format_time(_time) _time.strftime("at %a %d-%b-%Y %H:%M:%S") end |
#on_after_build(_event) ⇒ Object
77 78 79 80 81 82 83 |
# File 'ext/ae-output/ae-output.rb', line 77 def on_after_build(_event) self.frame_raise # MainContract.instance.raise_extension(self, # 'domain'=>@arcadia['conf'][@name+'.frame'], # 'extension' =>@name, # 'channel'=>conf('MsgContract.channel')) end |
#on_before_build(_event) ⇒ Object
68 69 70 71 72 73 74 |
# File 'ext/ae-output/ae-output.rb', line 68 def on_before_build(_event) #ArcadiaContractListener.new(self, MsgContract, :do_msg_event) Arcadia.add_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
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'ext/ae-output/ae-output.rb', line 89 def on_msg(_event) self.frame_raise _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 when DebugMsgEvent @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 ErrorMsgEvent @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
188 189 190 191 192 193 194 195 196 |
# File 'ext/ae-output/ae-output.rb', line 188 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
198 199 200 |
# File 'ext/ae-output/ae-output.rb', line 198 def outln(_txt=nil, _tag=nil) self.out(_txt+"\n",_tag) end |
#parse_debug(_from_row = 0) ⇒ Object
def do_msg_event(_event)
self.frame_raise
#p _event.context.text.class
_txt = "\n+--- "+format_time(_event.time)+" ---+\n"+_event.context.text.strip+"\n"
_index_begin = @main_frame.text.index('end')
@main_frame.text.insert(_index_begin,_txt)
_index_end = @main_frame.text.index('end')
if _event.context.type == MsgContract::TYPE_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)
elsif _event.context.type == MsgContract::TYPE_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
143 144 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 180 181 182 183 184 185 186 |
# File 'ext/ae-output/ae-output.rb', line 143 def parse_debug(_from_row=0) _row = 0 _cursor = @main_frame.text.cget('cursor') @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) while m _txt = m.post_match if m[1] && m[2] _file = m[1] _line = m[2] _ibegin = _row.to_s+'.'+(m.begin(1)+_end).to_s _iend = _row.to_s+'.'+(m.end(2)+_end).to_s _end = m.end(2) + _end @main_frame.text.tag_configure(_row, 'foreground' => '#800000', 'borderwidth'=>0, 'relief'=>'flat', 'underline'=>true ) @main_frame.text.tag_add(_row,_ibegin,_iend) @main_frame.text.tag_bind(_row,"Double-ButtonPress-1", proc{ Arcadia.process_event(OpenBufferEvent.new(self,'file'=>_file, 'row'=>_line)) #EditorContract.instance.open_file(self, 'file'=>_file, 'line'=>_line) } ) @main_frame.text.tag_bind(_row,"Enter", proc{@main_frame.text.configure('cursor'=> 'hand2')} ) @main_frame.text.tag_bind(_row,"Leave", proc{@main_frame.text.configure('cursor'=> _cursor)} ) end m = /([A-Za-z]*[\.:]{0,1}[\/\w\d]*\.rb):(\d*)/.match(_txt) end end } end |