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
- #after_build ⇒ Object
- #before_build ⇒ Object
- #build ⇒ Object
- #do_msg_event(_event) ⇒ Object
- #format_time(_time) ⇒ Object
- #out(_txt = nil, _tag = nil) ⇒ Object
- #outln(_txt = nil, _tag = nil) ⇒ Object
- #parse_debug(_from_row = 0) ⇒ Object
Instance Attribute Details
#main_frame ⇒ Object (readonly)
Returns the value of attribute main_frame.
63 64 65 |
# File 'ext/ae-output/ae-output.rb', line 63 def main_frame @main_frame end |
Instance Method Details
#after_build ⇒ Object
78 79 80 81 82 83 |
# File 'ext/ae-output/ae-output.rb', line 78 def after_build MainContract.instance.raise_extension(self, 'domain'=>@arcadia['conf'][@name+'.frame'], 'extension' =>@name, 'channel'=>conf('MsgContract.channel')) end |
#before_build ⇒ Object
65 66 67 68 69 70 71 |
# File 'ext/ae-output/ae-output.rb', line 65 def before_build ArcadiaContractListener.new(self, MsgContract, :do_msg_event) #_frame = @arcadia.layout.register_panel('_rome_',@name, 'Output') @main_frame = OutputView.new(self) @run_threads = Array.new @main_frame.text.tag_configure('error','foreground' => 'red') end |
#build ⇒ Object
74 75 76 |
# File 'ext/ae-output/ae-output.rb', line 74 def build #@ae_file_contract = @arcadia.retrieve_contract(self, EditorActionContract, :file_state) end |
#do_msg_event(_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 |
# File 'ext/ae-output/ae-output.rb', line 89 def do_msg_event(_event) #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 |
#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 |
#out(_txt = nil, _tag = nil) ⇒ Object
159 160 161 162 163 164 165 166 167 |
# File 'ext/ae-output/ae-output.rb', line 159 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
169 170 171 |
# File 'ext/ae-output/ae-output.rb', line 169 def outln(_txt=nil, _tag=nil) self.out(_txt+"\n",_tag) end |
#parse_debug(_from_row = 0) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'ext/ae-output/ae-output.rb', line 115 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{ 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 |