arcadia 0.1.2.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,80 +1,80 @@
1
- #
2
- # ae-complete-code.rb - Arcadia Ruby ide
3
- # by Antonio Galeone <antonio-galeone@rubyforge.org>
4
- #
5
-
6
- require "base/a-ext"
7
-
8
-
9
- class CompleteCode < ArcadiaExt
10
-
11
- def before_build
12
- end
13
-
14
- def build
15
- end
16
-
17
- def after_build
18
- @complete_command=full_command('rct-complete')
19
- @doc_command=full_command('rct-doc')
20
- @ri_command="ri -T -f plain"
21
- @finder_command="rct-meth-args -n" # ./a-libs.rb:741:AG#publish (_family, args = nil)
22
- if @complete_command !=nil #system(@rct_complete+" "+__FILE__)
23
- ArcadiaContractListener.new(self, EditorContract, :do_editor_event)
24
- else
25
- MsgContract.instance.out_error(self, "Extension ae-complete-code depend upon rct-complete(rcodetools) command (install it or update system path!)")
26
- end
27
- end
28
-
29
- def full_command(_command='rct-complete')
30
- _ret = nil
31
- RUBY_PLATFORM.include?('win32') ? _sep = ';':_sep=':'
32
- ENV['PATH'].split(_sep).each{|_path|
33
- _file = File.join(_path, _command)
34
- if FileTest.exist?(_file)
35
- _ret = _file
36
- end
37
- }
38
- _ret
39
- end
40
-
41
- def do_editor_event(_event)
42
- case _event.signature
43
- when EditorContract::COMPLETE_CODE
44
- if _event.context.file
45
- _event.context.candidates = candidates(_event.context.file, _event.context.line, _event.context.col)
46
- _event.handled(self)
47
- end
48
- end
49
- end
50
-
51
- def candidates(_file, _line, _col)
52
- begin
53
- _options = "--completion-class-info --line="+_line+" --column="+_col
54
- #_options = "--line="+_line+" --column="+_col
55
- _cmp_s = "|ruby "+@complete_command+" "+_options+" "+_file
56
- _ret = nil
57
- open(_cmp_s,"r") do
58
- |f|
59
- _ret = f.readlines.collect!{| line | line.chomp}
60
- #p _ret
61
- end
62
- if _ret.length == 0
63
- _cmp_s_d = _cmp_s+" 2>&1"
64
- _error = nil
65
- open(_cmp_s_d,"r") do
66
- |f|
67
- _error = f.readlines.collect!{| line | line.chomp}
68
- end
69
- if _error != nil && _error.length > 0
70
- MsgContract.instance.out_error(self, "Syntax error in current source")
71
- end
72
- end
73
- _ret
74
- rescue Exception => e
75
- MsgContract.instance.out_error(self, e.to_s)
76
- end
77
- end
78
-
79
- end
80
-
1
+ #
2
+ # ae-complete-code.rb - Arcadia Ruby ide
3
+ # by Antonio Galeone <antonio-galeone@rubyforge.org>
4
+ #
5
+
6
+ require "base/a-ext"
7
+
8
+
9
+ class CompleteCode < ArcadiaExt
10
+
11
+ def before_build
12
+ end
13
+
14
+ def build
15
+ end
16
+
17
+ def after_build
18
+ @complete_command=full_command('rct-complete')
19
+ @doc_command=full_command('rct-doc')
20
+ @ri_command="ri -T -f plain"
21
+ @finder_command="rct-meth-args -n" # ./a-libs.rb:741:AG#publish (_family, args = nil)
22
+ if @complete_command !=nil #system(@rct_complete+" "+__FILE__)
23
+ ArcadiaContractListener.new(self, EditorContract, :do_editor_event)
24
+ else
25
+ MsgContract.instance.out_error(self, "Warning: Extension ae-complete-code depend upon rct-complete(rcodetools) command (install it or update system path!)")
26
+ end
27
+ end
28
+
29
+ def full_command(_command='rct-complete')
30
+ _ret = nil
31
+ RUBY_PLATFORM.include?('win32') ? _sep = ';':_sep=':'
32
+ ENV['PATH'].split(_sep).each{|_path|
33
+ _file = File.join(_path, _command)
34
+ if FileTest.exist?(_file)
35
+ _ret = _file
36
+ end
37
+ }
38
+ _ret
39
+ end
40
+
41
+ def do_editor_event(_event)
42
+ case _event.signature
43
+ when EditorContract::COMPLETE_CODE
44
+ if _event.context.file
45
+ _event.context.candidates = candidates(_event.context.file, _event.context.line, _event.context.col)
46
+ _event.handled(self)
47
+ end
48
+ end
49
+ end
50
+
51
+ def candidates(_file, _line, _col)
52
+ begin
53
+ _options = "--completion-class-info --line="+_line+" --column="+_col
54
+ #_options = "--line="+_line+" --column="+_col
55
+ _cmp_s = "|ruby "+@complete_command+" "+_options+" "+_file
56
+ _ret = nil
57
+ open(_cmp_s,"r") do
58
+ |f|
59
+ _ret = f.readlines.collect!{| line | line.chomp}
60
+ #p _ret
61
+ end
62
+ if _ret.length == 0
63
+ _cmp_s_d = _cmp_s+" 2>&1"
64
+ _error = nil
65
+ open(_cmp_s_d,"r") do
66
+ |f|
67
+ _error = f.readlines.collect!{| line | line.chomp}
68
+ end
69
+ if _error != nil && _error.length > 0
70
+ MsgContract.instance.out_error(self, "Syntax error in current source")
71
+ end
72
+ end
73
+ _ret
74
+ rescue Exception => e
75
+ MsgContract.instance.out_error(self, e.to_s)
76
+ end
77
+ end
78
+
79
+ end
80
+
@@ -1,289 +1,288 @@
1
- #
2
- # ae-doc-code.rb - Arcadia Ruby ide
3
- # by Antonio Galeone <antonio-galeone@rubyforge.org>
4
- #
5
-
6
- require "base/a-ext"
7
-
8
- class DocCode < ArcadiaExt
9
-
10
- def before_build
11
- end
12
-
13
- def build
14
- end
15
-
16
- def after_build
17
- @doc_command=full_command('rct-doc')
18
- @doc_command=full_command('RCT-DOC') if @doc_command == nil
19
- @ri_command=full_command('ri')
20
- if @ri_command !=nil #system(@rct_complete+" "+__FILE__)
21
- ArcadiaContractListener.new(self, EditorContract, :do_editor_event)
22
- else
23
- MsgContract.instance.out_error(self, "Extension ae-doc-code depend upon ri command!")
24
- end
25
- if @doc_command == nil #system(@rct_complete+" "+__FILE__)
26
- MsgContract.instance.out_error(self, "Warning: Extension ae-doc-code depend upon rct-doc command!")
27
- end
28
- end
29
-
30
- def full_command(_command='ri')
31
- _ret = nil
32
- RUBY_PLATFORM.include?('win32') ? _sep = ';':_sep=':'
33
- ENV['PATH'].split(_sep).each{|_path|
34
- _file = File.join(_path, _command)
35
- if FileTest.exist?(_file)
36
- _ret = _file
37
- end
38
- }
39
- _ret
40
- end
41
-
42
- def do_editor_event(_event)
43
- case _event.signature
44
- when EditorContract::DOC_CODE
45
- if _event.context.file && @doc_command != nil
46
- _event.context.doc = doc(_event.context)
47
- if _event.context.doc != nil && _event.context.doc.length >0
48
- raise_doc_code(_event.context)
49
- else
50
- build_doc_tree
51
- end
52
- elsif _event.context.doc_entry
53
- _event.context.doc = doc_entry(_event.context.doc_entry)
54
- _event.context.text = _event.context.doc_entry
55
- if _event.context.doc != nil && _event.context.doc.length >0
56
- raise_doc_code(_event.context)
57
- else
58
- build_doc_tree
59
- end
60
- elsif _event.context.file && @doc_command == nil
61
- build_doc_tree
62
- end
63
- _event.handled(self)
64
- end
65
- end
66
-
67
- def build_doc_tree
68
- if !@doc_tree
69
-
70
- @image_class = TkPhotoImage.new('dat' => ARROW_RIGHT_GIF)
71
- @image_def = TkPhotoImage.new('dat' => TREE_NODE_DEF_GIF)
72
- @image_def_class = TkPhotoImage.new('dat' => TREE_NODE_DEFCLASS_GIF)
73
-
74
-
75
- do_select_item = proc{|_self|
76
- if _self.selection_get[0].length >0
77
- _selected = rif_2_node(_self.selection_get[0])
78
- end
79
- if _selected
80
- EditorContract.instance.doc_code(self, 'doc_entry'=>_selected)
81
- end
82
- }
83
- _background = conf('color.background')
84
- _foreground = conf('color.foreground')
85
- @doc_tree = Tk::BWidget::Tree.new(self.frame){
86
- relief 'flat'
87
- showlines false
88
- deltay 18
89
- background _background
90
- crossfill _foreground
91
- selectcommand proc{ do_select_item.call(self) }
92
- place('relwidth' => 1,'relx' => 0,'x' => '0','y' => '0','relheight' => '1')
93
- }
94
-
95
- _scrollcommand = proc{|*args| @doc_tree.yview(*args)}
96
- _scrollbar = TkScrollbar.new(self.frame){|s|
97
- width 8
98
- command _scrollcommand
99
- }.pack('side'=>'right', 'fill'=>'y')
100
- @doc_tree.yscrollcommand proc{|first,last| _scrollbar.set(first,last)}
101
-
102
- names = doc_entry('--list-names')
103
-
104
- @progress_bar = TkProgressframe.new(@arcadia.layout.root, names.length)
105
- @progress_bar.title('Building doc')
106
- @cancell=false
107
- @progress_bar.on_cancel=proc{cancel}
108
- #@hash_rif = Hash.new
109
- @level = 0
110
- @last_nodes = Array.new
111
- Thread.new do
112
- _last_value = ''
113
- #p 'n�='+ names.length.to_s
114
- names.sort.each do |value|
115
- _value = value.chomp.strip
116
- if _value != _last_value
117
- node(_value)
118
- @progress_bar.title(_value)
119
- _last_value = _value
120
- end
121
- @progress_bar.progress
122
- if @cancell
123
- @progress_bar.destroy
124
- @progress_bar = nil
125
- break
126
- end
127
- end
128
- progress_bar.destroy if @progress_bar != nil
129
- end
130
- end
131
- end
132
-
133
- def cancel
134
- @cancell=true
135
- end
136
-
137
- def node_2_rif(_path)
138
- return _path.gsub('#','@M@').gsub('::','@C@').gsub('|','@P@').gsub('^','@U@')
139
- end
140
-
141
- def rif_2_node(_rif)
142
- return _rif.gsub('@M@','#').gsub('@C@', '::').gsub('@P@', '|').gsub('@U@', '^')
143
- end
144
-
145
- def node(_path)
146
- # _rif = @hash_rif.length
147
- _rif = node_2_rif(_path)
148
- _parent_found = false
149
- while !_parent_found && @level > 0 do
150
- @level = @level - 1
151
- if (@last_nodes[@level] != nil) && _path.include?(@last_nodes[@level])
152
- _full_value = _path.sub(@last_nodes[@level],'')
153
- if _full_value[0..1].include?('#')
154
- _sep = '#'
155
- _value = _full_value[1.._full_value.length-1]
156
- _parent_found = true
157
- elsif _full_value[0..2].include?('::')
158
- _sep = '::'
159
- _value = _full_value[2.._full_value.length-1]
160
- _parent_found = true
161
- else
162
- _parent_found = false
163
- end
164
- end
165
- end
166
- if _parent_found
167
- _parent_path = @last_nodes[@level]
168
- #_parent_rif = @hash_rif[_parent_path]
169
- _parent_rif = node_2_rif(_parent_path)
170
- @level = @level + 1
171
- else
172
- _parent_rif = 'root'
173
- _sep = ''
174
- _value = _path
175
- end
176
-
177
- #@hash_rif[_path]= _rif
178
- @last_nodes[@level] = _path
179
- _background = conf('color.background')
180
-
181
- if _sep.length == 0
182
- _image = @image_class
183
- elsif _sep.include?('#')
184
- _image = @image_def
185
- elsif _sep.include?('::')
186
- _image = @image_def_class
187
- end
188
-
189
- @doc_tree.insert('end', _parent_rif ,_rif, {
190
- 'text' => _value ,
191
- 'helptext' => _path,
192
- 'deltax'=>-1,
193
- 'image'=>_image
194
- }
195
- )
196
- @level = @level + 1
197
- end
198
-
199
- def raise_doc_code(_context)
200
- if @docFrame
201
- @docFrame.tkText.delete('1.0','end')
202
- else
203
- _height = 140
204
- _width = 550
205
- _context.xdoc = TkWinfo.screenwidth(@arcadia.layout.root)/2 if !_context.xdoc
206
- _context.ydoc = TkWinfo.screenheight(@arcadia.layout.root)/2 if !_context.ydoc
207
- _x = _context.xdoc - _width/2
208
- _y = _context.ydoc - _height -20
209
- @docFrame = TkDocframe.new(@arcadia.layout.root).place('x'=>_x, 'y'=>_y, 'width'=>_width, 'height'=>_height)
210
- do_close = proc{
211
- @docFrame.destroy
212
- @docFrame = nil
213
- Tk.callback_break
214
- }
215
- @docFrame.on_close = do_close
216
- @docFrame.tkText.bind_append('KeyPress'){|e|
217
- case e.keysym
218
- when 'Escape'
219
- do_close.call
220
- end
221
- }
222
- @docFrame.tkText.font(conf('font'))
223
- @docFrame.tkText.foreground(conf('color.foreground'))
224
- @docFrame.tkText.background(conf('color.background'))
225
- end
226
-
227
- if _context.doc
228
- @docFrame.tkText.insert('end', _context.doc.to_s)
229
- @docFrame.title(_context.text) if _context.text
230
- else
231
- MsgContract.instance.out_simple(self, 'nulla di dire !')
232
- end
233
- end
234
-
235
-
236
-
237
- def doc_entry(_entry=nil)
238
- _ret = nil
239
- if _entry
240
- _cmp_doc = "|ruby "+@ri_command+" -T -f plain "+_entry
241
- open (_cmp_doc) do |f|
242
- _ret = f.readlines
243
- end
244
- end
245
- _ret
246
- end
247
-
248
- def doc(_context)
249
- begin
250
- _options = "--line="+_context.line+" --column="+_context.col
251
- _cmp_s = "|ruby " + @doc_command +" --use-method-analyzer "+_options +" " +_context.file
252
- _ret = nil
253
- _doc = nil
254
- open(_cmp_s,"r") do
255
- |f|
256
- _doc = f.readlines.collect!{| line | line.chomp}.to_s.strip
257
- end
258
- if _doc.length > 0
259
- _context.text = _doc.to_s
260
- _ret = doc_entry(_context.text)
261
- end
262
- _ret
263
-
264
- rescue Exception => e
265
- _msg = e.to_s + "\n"
266
- e.backtrace.each{|line| _msg = _msg + line + "\n"}
267
- MsgContract.instance.out_error(self, _msg)
268
- end
269
- end
270
-
271
- end
272
-
273
- class TkDocframe < TkFloatTitledFrame
274
- attr_reader :tkText
275
- def initialize(parent=nil, *args)
276
- super(parent)
277
- @tkText = TkText.new(self.frame,
278
- 'wrap'=>'none',
279
- 'relief'=>'groove'
280
- ){|j|
281
- TkScrollbar.new(j){|s|
282
- width 8
283
- command proc{|*args| j.yview(*args)}
284
- j.yscrollcommand proc{|first,last| s.set first,last}
285
- }.pack('side'=>'right', 'fill'=>'y')
286
- }.place('x'=>0, 'y'=>0, 'relheight'=> 1, 'relwidth'=> 1)
287
-
288
- end
289
- end
1
+ #
2
+ # ae-doc-code.rb - Arcadia Ruby ide
3
+ # by Antonio Galeone <antonio-galeone@rubyforge.org>
4
+ #
5
+
6
+ require "base/a-ext"
7
+
8
+ class DocCode < ArcadiaExt
9
+
10
+ def before_build
11
+ end
12
+
13
+ def build
14
+ end
15
+
16
+ def after_build
17
+ @doc_command=full_command('rct-doc')
18
+ @doc_command=full_command('RCT-DOC') if @doc_command == nil
19
+ @ri_command=full_command('ri')
20
+ if @ri_command !=nil #system(@rct_complete+" "+__FILE__)
21
+ ArcadiaContractListener.new(self, EditorContract, :do_editor_event)
22
+ else
23
+ MsgContract.instance.out_error(self, "Extension ae-doc-code depend upon ri command!")
24
+ end
25
+ if @doc_command == nil #system(@rct_complete+" "+__FILE__)
26
+ MsgContract.instance.out_error(self, "Warning: Extension ae-doc-code depend upon rct-doc command!")
27
+ end
28
+ end
29
+
30
+ def full_command(_command='ri')
31
+ _ret = nil
32
+ RUBY_PLATFORM.include?('win32') ? _sep = ';':_sep=':'
33
+ ENV['PATH'].split(_sep).each{|_path|
34
+ _file = File.join(_path, _command)
35
+ if FileTest.exist?(_file)
36
+ _ret = _file
37
+ end
38
+ }
39
+ _ret
40
+ end
41
+
42
+ def do_editor_event(_event)
43
+ case _event.signature
44
+ when EditorContract::DOC_CODE
45
+ if _event.context.file && @doc_command != nil
46
+ _event.context.doc = doc(_event.context)
47
+ if _event.context.doc != nil && _event.context.doc.length >0
48
+ raise_doc_code(_event.context)
49
+ # else
50
+ # build_doc_tree
51
+ end
52
+ elsif _event.context.doc_entry
53
+ _event.context.doc = doc_entry(_event.context.doc_entry)
54
+ _event.context.text = _event.context.doc_entry
55
+ if _event.context.doc != nil && _event.context.doc.length >0
56
+ raise_doc_code(_event.context)
57
+ # else
58
+ # build_doc_tree
59
+ end
60
+ # elsif _event.context.file && @doc_command == nil
61
+ # build_doc_tree
62
+ end
63
+ _event.handled(self)
64
+ when EditorContract::BUILD_DOC_TREE
65
+ build_doc_tree
66
+ end
67
+ end
68
+
69
+ def build_doc_tree
70
+ if !@doc_tree
71
+ @image_class = TkPhotoImage.new('dat' => ARROW_RIGHT_GIF)
72
+ @image_def = TkPhotoImage.new('dat' => TREE_NODE_DEF_GIF)
73
+ @image_def_class = TkPhotoImage.new('dat' => TREE_NODE_DEFCLASS_GIF)
74
+ do_select_item = proc{|_self|
75
+ if _self.selection_get[0].length >0
76
+ _selected = rif_2_node(_self.selection_get[0])
77
+ end
78
+ if _selected
79
+ EditorContract.instance.doc_code(self, 'doc_entry'=>_selected)
80
+ end
81
+ }
82
+ _background = conf('color.background')
83
+ _foreground = conf('color.foreground')
84
+ @doc_tree = Tk::BWidget::Tree.new(self.frame){
85
+ relief 'flat'
86
+ showlines false
87
+ deltay 18
88
+ background _background
89
+ crossfill _foreground
90
+ selectcommand proc{ do_select_item.call(self) }
91
+ place('relwidth' => 1,'relx' => 0,'x' => '0','y' => '0','relheight' => '1')
92
+ }
93
+
94
+ _scrollcommand = proc{|*args| @doc_tree.yview(*args)}
95
+ _scrollbar = TkScrollbar.new(self.frame){|s|
96
+ width 8
97
+ command _scrollcommand
98
+ }.pack('side'=>'right', 'fill'=>'y')
99
+ @doc_tree.yscrollcommand proc{|first,last| _scrollbar.set(first,last)}
100
+
101
+ names = doc_entry('--list-names')
102
+
103
+ @progress_bar = TkProgressframe.new(@arcadia.layout.root, names.length)
104
+ @progress_bar.title('Building doc')
105
+ @cancell=false
106
+ @progress_bar.on_cancel=proc{cancel}
107
+ #@hash_rif = Hash.new
108
+ @level = 0
109
+ @last_nodes = Array.new
110
+ Thread.new do
111
+ _last_value = ''
112
+ #p 'n�='+ names.length.to_s
113
+ names.sort.each do |value|
114
+ _value = value.chomp.strip
115
+ if _value != _last_value
116
+ node(_value)
117
+ @progress_bar.title(_value)
118
+ _last_value = _value
119
+ end
120
+ @progress_bar.progress
121
+ if @cancell
122
+ @progress_bar.destroy
123
+ @progress_bar = nil
124
+ break
125
+ end
126
+ end
127
+ progress_bar.destroy if @progress_bar != nil
128
+ end
129
+ end
130
+ end
131
+
132
+ def cancel
133
+ @cancell=true
134
+ end
135
+
136
+ def node_2_rif(_path)
137
+ return _path.gsub('#','@M@').gsub('::','@C@').gsub('|','@P@').gsub('^','@U@')
138
+ end
139
+
140
+ def rif_2_node(_rif)
141
+ return _rif.gsub('@M@','#').gsub('@C@', '::').gsub('@P@', '|').gsub('@U@', '^')
142
+ end
143
+
144
+ def node(_path)
145
+ # _rif = @hash_rif.length
146
+ _rif = node_2_rif(_path)
147
+ _parent_found = false
148
+ while !_parent_found && @level > 0 do
149
+ @level = @level - 1
150
+ if (@last_nodes[@level] != nil) && _path.include?(@last_nodes[@level])
151
+ _full_value = _path.sub(@last_nodes[@level],'')
152
+ if _full_value[0..1].include?('#')
153
+ _sep = '#'
154
+ _value = _full_value[1.._full_value.length-1]
155
+ _parent_found = true
156
+ elsif _full_value[0..2].include?('::')
157
+ _sep = '::'
158
+ _value = _full_value[2.._full_value.length-1]
159
+ _parent_found = true
160
+ else
161
+ _parent_found = false
162
+ end
163
+ end
164
+ end
165
+ if _parent_found
166
+ _parent_path = @last_nodes[@level]
167
+ #_parent_rif = @hash_rif[_parent_path]
168
+ _parent_rif = node_2_rif(_parent_path)
169
+ @level = @level + 1
170
+ else
171
+ _parent_rif = 'root'
172
+ _sep = ''
173
+ _value = _path
174
+ end
175
+
176
+ #@hash_rif[_path]= _rif
177
+ @last_nodes[@level] = _path
178
+ _background = conf('color.background')
179
+
180
+ if _sep.length == 0
181
+ _image = @image_class
182
+ elsif _sep.include?('#')
183
+ _image = @image_def
184
+ elsif _sep.include?('::')
185
+ _image = @image_def_class
186
+ end
187
+
188
+ @doc_tree.insert('end', _parent_rif ,_rif, {
189
+ 'text' => _value ,
190
+ 'helptext' => _path,
191
+ 'deltax'=>-1,
192
+ 'image'=>_image
193
+ }
194
+ )
195
+ @level = @level + 1
196
+ end
197
+
198
+ def raise_doc_code(_context)
199
+ if @docFrame
200
+ @docFrame.tkText.delete('1.0','end')
201
+ else
202
+ _height = 140
203
+ _width = 550
204
+ _context.xdoc = TkWinfo.screenwidth(@arcadia.layout.root)/2 if !_context.xdoc
205
+ _context.ydoc = TkWinfo.screenheight(@arcadia.layout.root)/2 if !_context.ydoc
206
+ _x = _context.xdoc - _width/2
207
+ _y = _context.ydoc - _height -20
208
+ @docFrame = TkDocframe.new(@arcadia.layout.root).place('x'=>_x, 'y'=>_y, 'width'=>_width, 'height'=>_height)
209
+ do_close = proc{
210
+ @docFrame.destroy
211
+ @docFrame = nil
212
+ Tk.callback_break
213
+ }
214
+ @docFrame.on_close = do_close
215
+ @docFrame.tkText.bind_append('KeyPress'){|e|
216
+ case e.keysym
217
+ when 'Escape'
218
+ do_close.call
219
+ end
220
+ }
221
+ @docFrame.tkText.font(conf('font'))
222
+ @docFrame.tkText.foreground(conf('color.foreground'))
223
+ @docFrame.tkText.background(conf('color.background'))
224
+ end
225
+
226
+ if _context.doc
227
+ @docFrame.tkText.insert('end', _context.doc.to_s)
228
+ @docFrame.title(_context.text) if _context.text
229
+ else
230
+ MsgContract.instance.out_simple(self, 'nulla di dire !')
231
+ end
232
+ end
233
+
234
+
235
+
236
+ def doc_entry(_entry=nil)
237
+ _ret = nil
238
+ if _entry
239
+ _cmp_doc = "|ruby "+@ri_command+" -T -f plain "+_entry
240
+ open (_cmp_doc) do |f|
241
+ _ret = f.readlines
242
+ end
243
+ end
244
+ _ret
245
+ end
246
+
247
+ def doc(_context)
248
+ begin
249
+ _options = "--line="+_context.line+" --column="+_context.col
250
+ _cmp_s = "|ruby " + @doc_command +" --use-method-analyzer "+_options +" " +_context.file
251
+ _ret = nil
252
+ _doc = nil
253
+ open(_cmp_s,"r") do
254
+ |f|
255
+ _doc = f.readlines.collect!{| line | line.chomp}.to_s.strip
256
+ end
257
+ if _doc.length > 0
258
+ _context.text = _doc.to_s
259
+ _ret = doc_entry(_context.text)
260
+ end
261
+ _ret
262
+
263
+ rescue Exception => e
264
+ _msg = e.to_s + "\n"
265
+ e.backtrace.each{|line| _msg = _msg + line + "\n"}
266
+ MsgContract.instance.out_error(self, _msg)
267
+ end
268
+ end
269
+
270
+ end
271
+
272
+ class TkDocframe < TkFloatTitledFrame
273
+ attr_reader :tkText
274
+ def initialize(parent=nil, *args)
275
+ super(parent)
276
+ @tkText = TkText.new(self.frame,
277
+ 'wrap'=>'none',
278
+ 'relief'=>'groove'
279
+ ){|j|
280
+ TkScrollbar.new(j){|s|
281
+ width 8
282
+ command proc{|*args| j.yview(*args)}
283
+ j.yscrollcommand proc{|first,last| s.set first,last}
284
+ }.pack('side'=>'right', 'fill'=>'y')
285
+ }.place('x'=>0, 'y'=>0, 'relheight'=> 1, 'relwidth'=> 1)
286
+
287
+ end
288
+ end