arcadia 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/README +132 -134
  2. data/bin/arcadia +13 -0
  3. data/conf/arcadia.conf +196 -3
  4. data/conf/arcadia.init.rb +27 -6
  5. data/conf/arcadia.res.rb +10 -0
  6. data/ext/ae-complete-code/ae-complete-code.rb +76 -82
  7. data/ext/ae-doc-code/ae-doc-code.rb +295 -291
  8. data/ext/ae-editor/ae-editor.conf +88 -67
  9. data/ext/ae-editor/ae-editor.rb +400 -202
  10. data/ext/ae-editor/langs/conf.lang +16 -5
  11. data/ext/ae-editor/langs/lang.lang.bind +1 -1
  12. data/ext/ae-editor/langs/rb.lang +77 -41
  13. data/ext/ae-editor/langs/rbw.lang.bind +1 -1
  14. data/ext/ae-event-log/ae-event-log.rb +46 -45
  15. data/ext/ae-file-history/ae-file-history.conf +1 -1
  16. data/ext/ae-file-history/ae-file-history.rb +373 -298
  17. data/ext/ae-output/ae-output.conf +2 -0
  18. data/ext/ae-output/ae-output.rb +200 -202
  19. data/ext/ae-rad/ae-rad-inspector.rb +64 -70
  20. data/ext/ae-rad/ae-rad-palette.rb +14 -14
  21. data/ext/ae-rad/ae-rad.conf +2 -0
  22. data/ext/ae-rad/lib/tk/al-tk.rb +2991 -2987
  23. data/ext/ae-rad/lib/tk/al-tkarcadia.rb +26 -26
  24. data/ext/ae-ruby-debug/ae-ruby-debug.conf +8 -8
  25. data/ext/ae-ruby-debug/ae-ruby-debug.rb +1566 -1465
  26. data/ext/ae-search-in-files/ae-search-in-files.rb +294 -284
  27. data/ext/ae-shell/ae-shell.rb +20 -11
  28. data/{base → lib}/a-commons.rb +291 -80
  29. data/{base → lib}/a-contracts.rb +40 -18
  30. data/{arcadia.rb → lib/a-core.rb} +238 -148
  31. data/{base → lib}/a-tkcommons.rb +81 -63
  32. metadata +64 -65
  33. data/ext/ae-action-dispatcher/ae-action-dispatcher.conf +0 -6
  34. data/ext/ae-action-dispatcher/ae-action-dispatcher.rb +0 -22
  35. data/ext/ae-inspector/ae-inspector.conf +0 -7
  36. data/ext/ae-inspector/ae-inspector.rb +0 -1519
  37. data/ext/ae-palette/ae-palette.conf +0 -7
  38. data/ext/ae-palette/ae-palette.rb +0 -265
@@ -2,12 +2,33 @@
2
2
 
3
3
  begin
4
4
  require 'tk'
5
- rescue LoadError
6
- p '+-----------------------------------------+'
7
- p '| Arcadia require ruby tk |'
8
- p '| you must install before run ... |'
9
- p '+-----------------------------------------+'
10
- exit
5
+ rescue LoadError => e
6
+ print <<EOL
7
+ +--------------------------------------------+
8
+ | Arcadia require ruby-tk extension |
9
+ | and tcl/tk run-time |
10
+ | you must install before run ... |
11
+ +--------------------------------------------+
12
+ EOL
13
+ i=30
14
+ l=i
15
+ msg=e.message
16
+ while l < msg.length
17
+ while l < msg.length-1 && msg[l..l]!="\s"
18
+ l=l+1
19
+ end
20
+ msg = msg[0..l]+"\n"+"\s"*4+msg[l+1..-1]
21
+ l=l+i
22
+ end
23
+ print <<EOL
24
+ ---Tk LoadError Details-----------------------
25
+ Platform : "#{RUBY_PLATFORM}"
26
+ Ruby version : "#{RUBY_VERSION}"
27
+ Message :
28
+ "#{msg}"
29
+ ----------------------------------------------
30
+ EOL
31
+ exit
11
32
  end
12
33
 
13
34
  Tk.tk_call "eval","set auto_path [concat $::auto_path tcl]"
@@ -1330,3 +1330,13 @@ R0lGODlhEAAQAIABAPEoAP///yH+FUNyZWF0ZWQgd2l0aCBUaGUgR0lNUAAh
1330
1330
  +QQBCgABACwAAAAAEAAQAAACIoyPqcutAKN8DFAJg012m35poHeMY1hqF6Zy
1331
1331
  1YNNzkzXSAEAOw==
1332
1332
  EOS
1333
+
1334
+ KEYBOARD_GIF=<<EOS
1335
+ R0lGODlhGgAVAOMOAAAAAJmZmWZmZj8/P8zMzB8fH7+/v09PT4+Pj9/f339/
1336
+ fw8PD2ZmZjMzM////////yH+FUNyZWF0ZWQgd2l0aCBUaGUgR0lNUAAh+QQB
1337
+ FAAPACwAAAAAGgAVAAAEtfDJSes7yeotA8gclRhGRSxHOCUC4AKDoghLA6rN
1338
+ ghiBMLgFxS3kIaiOB8ExRDA0BKSodDqVIBqyrHbLnRUIg+GyEkAMOoqHQfgI
1339
+ pBMKA7ykCEjW58fvoQCU9gYAcYIPMHcKeU0xBj4BBgNQM3gGRmqIFIQ/JYaX
1340
+ fRR4Ent9fwBqgoFphpZ5Pm0DRq1gAbJ6SqsVa11ZJZ+XFH0vwS9pvXkrVFNi
1341
+ awKVYxYIsw0D09TV1tcNGBEAOw==
1342
+ EOS
@@ -1,82 +1,76 @@
1
- #
2
- # ae-complete-code.rb - Arcadia Ruby ide
3
- # by Antonio Galeone <antonio-galeone@rubyforge.org>
4
- #
5
-
6
-
7
-
8
- class CompleteCode < ArcadiaExt
9
-
10
- def on_after_build(_event)
11
- @complete_command=full_command('rct-complete')
12
- @doc_command=full_command('rct-doc')
13
- @ri_command="ri -T -f plain"
14
- @finder_command="rct-meth-args -n"
15
- if @complete_command !=nil #system(@rct_complete+" "+__FILE__)
16
- Arcadia.add_listener(self, CompleteCodeEvent)
17
- #ArcadiaContractListener.new(self, EditorContract, :do_editor_event)
18
- else
19
- Arcadia.new_error_msg(self, "Warning: Extension ae-complete-code depend upon rct-complete(rcodetools) command (install it or update system path!)")
20
- end
21
- end
22
-
23
- def full_command(_command='rct-complete')
24
- _ret = nil
25
- RUBY_PLATFORM.include?('win32') ? _sep = ';':_sep=':'
26
- ENV['PATH'].split(_sep).each{|_path|
27
- _file = File.join(_path, _command)
28
- if FileTest.exist?(_file)
29
- _ret = _file
30
- end
31
- }
32
- _ret
33
- end
34
-
35
- def on_complete_code(_event)
36
- if _event.file
37
- _event.add_result(self,'candidates'=>candidates(_event.file, _event.row, _event.col))
38
- # _event.results << CompleteCodeEvent::CompleteCodeResult.new(self)
39
- # _event.results[0].candidates = candidates(_event.file, _event.row, _event.col)
40
- end
41
- end
42
-
43
- # def do_editor_event(_event)
44
- # case _event.signature
45
- # when EditorContract::COMPLETE_CODE
46
- # if _event.context.file
47
- # _event.context.candidates = candidates(_event.context.file, _event.context.line, _event.context.col)
48
- # _event.handled(self)
49
- # end
50
- # end
51
- # end
52
-
53
- def candidates(_file, _line, _col)
54
- begin
55
- _options = "--completion-class-info --line="+_line+" --column="+_col
56
- #_options = "--line="+_line+" --column="+_col
57
- _cmp_s = "|ruby "+@complete_command+" "+_options+" "+_file
58
- _ret = nil
59
- open(_cmp_s,"r") do
60
- |f|
61
- _ret = f.readlines.collect!{| line | line.chomp}
62
- #p _ret
63
- end
64
- if _ret.length == 0
65
- _cmp_s_d = _cmp_s+" 2>&1"
66
- _error = nil
67
- open(_cmp_s_d,"r") do
68
- |f|
69
- _error = f.readlines.collect!{| line | line.chomp}
70
- end
71
- if _error != nil && _error.length > 0
72
- Arcadia.new_error_msg(self, "Syntax error in current source")
73
- end
74
- end
75
- _ret
76
- rescue Exception => e
77
- Arcadia.new_error_msg(self, e.to_s)
78
- end
79
- end
80
-
81
- end
82
-
1
+ #
2
+ # ae-complete-code.rb - Arcadia Ruby ide
3
+ # by Antonio Galeone <antonio-galeone@rubyforge.org>
4
+ #
5
+
6
+
7
+
8
+ class CompleteCode < ArcadiaExt
9
+
10
+ def on_after_build(_event)
11
+ @complete_command=full_command('rct-complete')
12
+ @doc_command=full_command('rct-doc')
13
+ @ri_command="ri -T -f plain"
14
+ @finder_command="rct-meth-args -n"
15
+ if @complete_command !=nil #system(@rct_complete+" "+__FILE__)
16
+ Arcadia.attach_listener(self, CompleteCodeEvent)
17
+ else
18
+ Arcadia.console(self, 'msg'=>"Warning: Extension ae-complete-code depend upon rct-complete(rcodetools) command (install it or update system path!)", 'level'=>'error')
19
+ #Arcadia.new_error_msg(self, "Warning: Extension ae-complete-code depend upon rct-complete(rcodetools) command (install it or update system path!)")
20
+ end
21
+ end
22
+
23
+ def full_command(_command='rct-complete')
24
+ _ret = nil
25
+ RUBY_PLATFORM.include?('win32') ? _sep = ';':_sep=':'
26
+ ENV['PATH'].split(_sep).each{|_path|
27
+ _file = File.join(_path, _command)
28
+ if FileTest.exist?(_file)
29
+ _ret = _file
30
+ end
31
+ }
32
+ _ret
33
+ end
34
+
35
+ def on_complete_code(_event)
36
+ if _event.file
37
+ _event.add_result(self,'candidates'=>candidates(_event.file, _event.row, _event.col))
38
+ end
39
+ end
40
+
41
+ def enance(_file, line)
42
+
43
+ end
44
+
45
+ def candidates(_file, _line, _col)
46
+ begin
47
+ _options = "--completion-class-info --dev --fork --line="+_line+" --column="+_col
48
+ #_options = "--line="+_line+" --column="+_col
49
+ _cmp_s = "|ruby "+@complete_command+" "+_options+" "+_file
50
+ _ret = nil
51
+ open(_cmp_s,"r") do
52
+ |f|
53
+ _ret = f.readlines.collect!{| line | line.chomp}
54
+ #p _ret
55
+ end
56
+ if _ret.length == 0
57
+ _cmp_s_d = _cmp_s+" 2>&1"
58
+ _error = nil
59
+ open(_cmp_s_d,"r") do
60
+ |f|
61
+ _error = f.readlines.collect!{| line | line.chomp}
62
+ end
63
+ if _error != nil && _error.length > 0
64
+ Arcadia.console(self, 'msg'=>"Syntax error in current source", 'level'=>'error')
65
+ #Arcadia.new_error_msg(self, "Syntax error in current source")
66
+ end
67
+ end
68
+ _ret
69
+ rescue Exception => e
70
+ Arcadia.console(self, 'msg'=>e.to_s, 'level'=>'error')
71
+ #Arcadia.new_error_msg(self, e.to_s)
72
+ end
73
+ end
74
+
75
+ end
76
+
@@ -1,291 +1,295 @@
1
- #
2
- # ae-doc-code.rb - Arcadia Ruby ide
3
- # by Antonio Galeone <antonio-galeone@rubyforge.org>
4
- #
5
-
6
-
7
- class DocCode < ArcadiaExt
8
- def on_after_build(_event)
9
- @doc_command=full_command('rct-doc')
10
- @doc_command=full_command('RCT-DOC') if @doc_command == nil
11
- @ri_command=full_command('ri')
12
- if @ri_command !=nil #system(@rct_complete+" "+__FILE__)
13
- Arcadia.add_listener(self, DocCodeEvent)
14
- #ArcadiaContractListener.new(self, EditorContract, :do_editor_event)
15
- else
16
- Arcadia.new_error_msg(self, "Extension ae-doc-code depend upon ri command!")
17
- end
18
- if @doc_command == nil #system(@rct_complete+" "+__FILE__)
19
- Arcadia.new_error_msg(self, "Warning: Extension ae-doc-code depend upon rct-doc command!")
20
- end
21
- end
22
-
23
- def full_command(_command='ri')
24
- _ret = nil
25
- RUBY_PLATFORM.include?('win32') ? _sep = ';':_sep=':'
26
- ENV['PATH'].split(_sep).each{|_path|
27
- _file = File.join(_path, _command)
28
- if FileTest.exist?(_file)
29
- _ret = _file
30
- end
31
- }
32
- _ret
33
- end
34
-
35
- def on_doc_code(_event)
36
- if _event.file && @doc_command != nil
37
- res = _event.add_result(self)
38
- res.doc = doc(_event)
39
- elsif _event.doc_entry
40
- _event.add_result(self, 'doc'=>doc_entry(_event.doc_entry),'title'=>_event.doc_entry)
41
- end
42
- end
43
-
44
- def on_after_doc_code(_event)
45
- res = _event.results[0]
46
- if res !=nil && res.doc != nil && res.doc.length >0
47
- raise_doc_code(_event)
48
- end
49
- end
50
-
51
- def raise_doc_code(_context)
52
- if @docFrame
53
- @docFrame.tkText.delete('1.0','end')
54
- else
55
- _height = 140
56
- _width = 550
57
- _context.xdoc = TkWinfo.screenwidth(@arcadia.layout.root)/2 if !_context.xdoc
58
- _context.ydoc = TkWinfo.screenheight(@arcadia.layout.root)/2 if !_context.ydoc
59
- _x = _context.xdoc - _width/2
60
- _y = _context.ydoc - _height -20
61
- _x = 0 if _x < 0
62
- _y = 0 if _y < 0
63
- @docFrame = TkDocframe.new(@arcadia.layout.root).place('x'=>_x, 'y'=>_y, 'width'=>_width, 'height'=>_height)
64
- do_close = proc{
65
- @docFrame.destroy
66
- @docFrame = nil
67
- Tk.callback_break
68
- }
69
- @docFrame.on_close = do_close
70
- @docFrame.tkText.bind_append('KeyPress'){|e|
71
- case e.keysym
72
- when 'Escape'
73
- do_close.call
74
- end
75
- }
76
- @docFrame.tkText.font(conf('font'))
77
- @docFrame.tkText.foreground(conf('color.foreground'))
78
- @docFrame.tkText.background(conf('color.background'))
79
- end
80
- res = _context.results[0]
81
- if res.doc
82
- @docFrame.tkText.insert('end', res.doc.to_s)
83
- @docFrame.title(res.title) if res.title
84
- else
85
- Arcadia.new_msg(self, 'nulla di dire !')
86
- end
87
- end
88
-
89
- def doc_entry(_entry=nil)
90
- _ret = nil
91
- if _entry
92
- _cmp_doc = "|ruby "+@ri_command+" -T -f plain "+_entry
93
- open (_cmp_doc) do |f|
94
- _ret = f.readlines
95
- end
96
- end
97
- _ret
98
- end
99
-
100
- def doc(_context)
101
- begin
102
- _options = "--line="+_context.row+" --column="+_context.col
103
- _cmp_s = "|ruby " + @doc_command +" --use-method-analyzer "+_options +" " +_context.file
104
- _ret = nil
105
- _doc = nil
106
- open(_cmp_s,"r") do
107
- |f|
108
- _doc = f.readlines.collect!{| line | line.chomp}.to_s.strip
109
- end
110
- if _doc.length > 0
111
- _context.results[0].title = _doc.to_s if _context.results[0]
112
- _ret = doc_entry(_context.results[0].title)
113
- end
114
- _ret
115
-
116
- rescue Exception => e
117
- _msg = e.to_s + "\n"
118
- e.backtrace.each{|line| _msg = _msg + line + "\n"}
119
- Arcadia.new_error_msg(self, _msg)
120
- end
121
- end
122
-
123
-
124
- # def do_editor_event(_event)
125
- # case _event.signature
126
- # when EditorContract::DOC_CODE
127
- # if _event.context.file && @doc_command != nil
128
- # _event.context.doc = doc(_event.context)
129
- # if _event.context.doc != nil && _event.context.doc.length >0
130
- # raise_doc_code(_event.context)
131
- # end
132
- # elsif _event.context.doc_entry
133
- # _event.context.doc = doc_entry(_event.context.doc_entry)
134
- # _event.context.text = _event.context.doc_entry
135
- # if _event.context.doc != nil && _event.context.doc.length >0
136
- # raise_doc_code(_event.context)
137
- # end
138
- # end
139
- # _event.handled(self)
140
- # when EditorContract::BUILD_DOC_TREE
141
- # build_doc_tree
142
- # end
143
- # end
144
-
145
- def build_doc_tree
146
- if !@doc_tree
147
- @image_class = TkPhotoImage.new('dat' => ARROW_RIGHT_GIF)
148
- @image_def = TkPhotoImage.new('dat' => TREE_NODE_DEF_GIF)
149
- @image_def_class = TkPhotoImage.new('dat' => TREE_NODE_DEFCLASS_GIF)
150
- do_select_item = proc{|_self|
151
- if _self.selection_get[0].length >0
152
- _selected = rif_2_node(_self.selection_get[0])
153
- end
154
- if _selected
155
- EditorContract.instance.doc_code(self, 'doc_entry'=>_selected)
156
- end
157
- }
158
- _background = conf('color.background')
159
- _foreground = conf('color.foreground')
160
- @doc_tree = Tk::BWidget::Tree.new(self.frame){
161
- relief 'flat'
162
- showlines false
163
- deltay 18
164
- background _background
165
- crossfill _foreground
166
- selectcommand proc{ do_select_item.call(self) }
167
- place('relwidth' => 1,'relx' => 0,'x' => '0','y' => '0','relheight' => '1')
168
- }
169
-
170
- _scrollcommand = proc{|*args| @doc_tree.yview(*args)}
171
- _scrollbar = TkScrollbar.new(self.frame){|s|
172
- width 8
173
- command _scrollcommand
174
- }.pack('side'=>'right', 'fill'=>'y')
175
- @doc_tree.yscrollcommand proc{|first,last| _scrollbar.set(first,last)}
176
-
177
- names = doc_entry('--list-names')
178
-
179
- @progress_bar = TkProgressframe.new(@arcadia.layout.root, names.length)
180
- @progress_bar.title('Building doc')
181
- @cancell=false
182
- @progress_bar.on_cancel=proc{cancel}
183
- #@hash_rif = Hash.new
184
- @level = 0
185
- @last_nodes = Array.new
186
- Thread.new do
187
- _last_value = ''
188
- #p 'n�='+ names.length.to_s
189
- names.sort.each do |value|
190
- _value = value.chomp.strip
191
- if _value != _last_value
192
- node(_value)
193
- @progress_bar.title(_value)
194
- _last_value = _value
195
- end
196
- @progress_bar.progress
197
- if @cancell
198
- @progress_bar.destroy
199
- @progress_bar = nil
200
- break
201
- end
202
- end
203
- progress_bar.destroy if @progress_bar != nil
204
- end
205
- end
206
- end
207
-
208
- def cancel
209
- @cancell=true
210
- end
211
-
212
- def node_2_rif(_path)
213
- return _path.gsub('#','@M@').gsub('::','@C@').gsub('|','@P@').gsub('^','@U@')
214
- end
215
-
216
- def rif_2_node(_rif)
217
- return _rif.gsub('@M@','#').gsub('@C@', '::').gsub('@P@', '|').gsub('@U@', '^')
218
- end
219
-
220
- def node(_path)
221
- # _rif = @hash_rif.length
222
- _rif = node_2_rif(_path)
223
- _parent_found = false
224
- while !_parent_found && @level > 0 do
225
- @level = @level - 1
226
- if (@last_nodes[@level] != nil) && _path.include?(@last_nodes[@level])
227
- _full_value = _path.sub(@last_nodes[@level],'')
228
- if _full_value[0..1].include?('#')
229
- _sep = '#'
230
- _value = _full_value[1.._full_value.length-1]
231
- _parent_found = true
232
- elsif _full_value[0..2].include?('::')
233
- _sep = '::'
234
- _value = _full_value[2.._full_value.length-1]
235
- _parent_found = true
236
- else
237
- _parent_found = false
238
- end
239
- end
240
- end
241
- if _parent_found
242
- _parent_path = @last_nodes[@level]
243
- #_parent_rif = @hash_rif[_parent_path]
244
- _parent_rif = node_2_rif(_parent_path)
245
- @level = @level + 1
246
- else
247
- _parent_rif = 'root'
248
- _sep = ''
249
- _value = _path
250
- end
251
-
252
- #@hash_rif[_path]= _rif
253
- @last_nodes[@level] = _path
254
- _background = conf('color.background')
255
-
256
- if _sep.length == 0
257
- _image = @image_class
258
- elsif _sep.include?('#')
259
- _image = @image_def
260
- elsif _sep.include?('::')
261
- _image = @image_def_class
262
- end
263
-
264
- @doc_tree.insert('end', _parent_rif ,_rif, {
265
- 'text' => _value ,
266
- 'helptext' => _path,
267
- 'deltax'=>-1,
268
- 'image'=>_image
269
- }
270
- )
271
- @level = @level + 1
272
- end
273
- end
274
-
275
- class TkDocframe < TkFloatTitledFrame
276
- attr_reader :tkText
277
- def initialize(parent=nil, *args)
278
- super(parent)
279
- @tkText = TkText.new(self.frame,
280
- 'wrap'=>'none',
281
- 'relief'=>'groove'
282
- ){|j|
283
- TkScrollbar.new(j){|s|
284
- width 8
285
- command proc{|*args| j.yview(*args)}
286
- j.yscrollcommand proc{|first,last| s.set first,last}
287
- }.pack('side'=>'right', 'fill'=>'y')
288
- }.place('x'=>0, 'y'=>0, 'relheight'=> 1, 'relwidth'=> 1)
289
-
290
- end
291
- end
1
+ #
2
+ # ae-doc-code.rb - Arcadia Ruby ide
3
+ # by Antonio Galeone <antonio-galeone@rubyforge.org>
4
+ #
5
+
6
+
7
+ class DocCode < ArcadiaExt
8
+ def on_after_build(_event)
9
+ @doc_command=full_command('rct-doc')
10
+ @doc_command=full_command('RCT-DOC') if @doc_command == nil
11
+ @ri_command=full_command('ri')
12
+ if @ri_command !=nil #system(@rct_complete+" "+__FILE__)
13
+ Arcadia.attach_listener(self, DocCodeEvent)
14
+ #ArcadiaContractListener.new(self, EditorContract, :do_editor_event)
15
+ else
16
+ Arcadia.console(self, 'msg'=>"Warning: Extension ae-doc-code depend upon ri command!", 'level'=>'error')
17
+ #Arcadia.new_error_msg(self, "Warning: Extension ae-doc-code depend upon ri command!")
18
+ end
19
+ if @doc_command == nil #system(@rct_complete+" "+__FILE__)
20
+ Arcadia.console(self, 'msg'=>"Warning: Extension ae-doc-code depend upon rct-doc command!", 'level'=>'error')
21
+ #Arcadia.new_error_msg(self, "Warning: Extension ae-doc-code depend upon rct-doc command!")
22
+ end
23
+ end
24
+
25
+ def full_command(_command='ri')
26
+ _ret = nil
27
+ RUBY_PLATFORM.include?('win32') ? _sep = ';':_sep=':'
28
+ ENV['PATH'].split(_sep).each{|_path|
29
+ _file = File.join(_path, _command)
30
+ if FileTest.exist?(_file)
31
+ _ret = _file
32
+ end
33
+ }
34
+ _ret
35
+ end
36
+
37
+ def on_doc_code(_event)
38
+ if _event.file && @doc_command != nil
39
+ res = _event.add_result(self)
40
+ res.doc = doc(_event)
41
+ elsif _event.doc_entry
42
+ _event.add_result(self, 'doc'=>doc_entry(_event.doc_entry),'title'=>_event.doc_entry)
43
+ end
44
+ end
45
+
46
+ def on_after_doc_code(_event)
47
+ res = _event.results[0]
48
+ if res !=nil && res.doc != nil && res.doc.length >0
49
+ raise_doc_code(_event)
50
+ end
51
+ end
52
+
53
+ def raise_doc_code(_context)
54
+ if @docFrame
55
+ @docFrame.tkText.delete('1.0','end')
56
+ else
57
+ _height = 140
58
+ _width = 550
59
+ _context.xdoc = TkWinfo.screenwidth(@arcadia.layout.root)/2 if !_context.xdoc
60
+ _context.ydoc = TkWinfo.screenheight(@arcadia.layout.root)/2 if !_context.ydoc
61
+ _x = _context.xdoc - _width/2
62
+ _y = _context.ydoc - _height -20
63
+ _x = 0 if _x < 0
64
+ _y = 0 if _y < 0
65
+ @docFrame = TkDocframe.new(@arcadia.layout.root).place('x'=>_x, 'y'=>_y, 'width'=>_width, 'height'=>_height)
66
+ do_close = proc{
67
+ @docFrame.destroy
68
+ @docFrame = nil
69
+ Tk.callback_break
70
+ }
71
+ @docFrame.on_close = do_close
72
+ @docFrame.tkText.bind_append('KeyPress'){|e|
73
+ case e.keysym
74
+ when 'Escape'
75
+ do_close.call
76
+ end
77
+ }
78
+ @docFrame.tkText.font(conf('font'))
79
+ @docFrame.tkText.foreground(conf('color.foreground'))
80
+ @docFrame.tkText.background(conf('color.background'))
81
+ end
82
+ res = _context.results[0]
83
+ if res.doc
84
+ @docFrame.tkText.insert('end', res.doc.to_s)
85
+ @docFrame.title(res.title) if res.title
86
+ else
87
+ Arcadia.console(self,'msg'=>'???')
88
+ #Arcadia.new_msg(self, 'nulla di dire !')
89
+ end
90
+ end
91
+
92
+ def doc_entry(_entry=nil)
93
+ _ret = nil
94
+ if _entry
95
+ _cmp_doc = "|ruby "+@ri_command+" -T -f plain "+_entry
96
+ open (_cmp_doc) do |f|
97
+ _ret = f.readlines
98
+ end
99
+ end
100
+ _ret
101
+ end
102
+
103
+ def doc(_context)
104
+ begin
105
+ _options = "--line="+_context.row+" --column="+_context.col
106
+ _cmp_s = "|ruby " + @doc_command +" --use-method-analyzer "+_options +" " +_context.file
107
+ _ret = nil
108
+ _doc = nil
109
+ open(_cmp_s,"r") do
110
+ |f|
111
+ _doc = f.readlines.collect!{| line | line.chomp}.to_s.strip
112
+ end
113
+ if _doc.length > 0
114
+ _context.results[0].title = _doc.to_s if _context.results[0]
115
+ _ret = doc_entry(_context.results[0].title)
116
+ end
117
+ _ret
118
+
119
+ rescue Exception => e
120
+ _msg = e.to_s + "\n"
121
+ e.backtrace.each{|line| _msg = _msg + line + "\n"}
122
+ Arcadia.console(self, 'msg'=>_msg, 'level'=>'error')
123
+ #Arcadia.new_error_msg(self, _msg)
124
+ end
125
+ end
126
+
127
+
128
+ # def do_editor_event(_event)
129
+ # case _event.signature
130
+ # when EditorContract::DOC_CODE
131
+ # if _event.context.file && @doc_command != nil
132
+ # _event.context.doc = doc(_event.context)
133
+ # if _event.context.doc != nil && _event.context.doc.length >0
134
+ # raise_doc_code(_event.context)
135
+ # end
136
+ # elsif _event.context.doc_entry
137
+ # _event.context.doc = doc_entry(_event.context.doc_entry)
138
+ # _event.context.text = _event.context.doc_entry
139
+ # if _event.context.doc != nil && _event.context.doc.length >0
140
+ # raise_doc_code(_event.context)
141
+ # end
142
+ # end
143
+ # _event.handled(self)
144
+ # when EditorContract::BUILD_DOC_TREE
145
+ # build_doc_tree
146
+ # end
147
+ # end
148
+
149
+ def build_doc_tree
150
+ if !@doc_tree
151
+ @image_class = TkPhotoImage.new('dat' => ARROW_RIGHT_GIF)
152
+ @image_def = TkPhotoImage.new('dat' => TREE_NODE_DEF_GIF)
153
+ @image_def_class = TkPhotoImage.new('dat' => TREE_NODE_DEFCLASS_GIF)
154
+ do_select_item = proc{|_self|
155
+ if _self.selection_get[0].length >0
156
+ _selected = rif_2_node(_self.selection_get[0])
157
+ end
158
+ if _selected
159
+ EditorContract.instance.doc_code(self, 'doc_entry'=>_selected)
160
+ end
161
+ }
162
+ _background = conf('color.background')
163
+ _foreground = conf('color.foreground')
164
+ @doc_tree = Tk::BWidget::Tree.new(self.frame){
165
+ relief 'flat'
166
+ showlines false
167
+ deltay 18
168
+ background _background
169
+ crossfill _foreground
170
+ selectcommand proc{ do_select_item.call(self) }
171
+ place('relwidth' => 1,'relx' => 0,'x' => '0','y' => '0','relheight' => '1')
172
+ }
173
+
174
+ _scrollcommand = proc{|*args| @doc_tree.yview(*args)}
175
+ _scrollbar = TkScrollbar.new(self.frame, Arcadia.style('scrollbar')){|s|
176
+ width 8
177
+ command _scrollcommand
178
+ }.pack('side'=>'right', 'fill'=>'y')
179
+ @doc_tree.yscrollcommand proc{|first,last| _scrollbar.set(first,last)}
180
+
181
+ names = doc_entry('--list-names')
182
+
183
+ @progress_bar = TkProgressframe.new(@arcadia.layout.root, names.length)
184
+ @progress_bar.title('Building doc')
185
+ @cancell=false
186
+ @progress_bar.on_cancel=proc{cancel}
187
+ #@hash_rif = Hash.new
188
+ @level = 0
189
+ @last_nodes = Array.new
190
+ Thread.new do
191
+ _last_value = ''
192
+ #p 'n�='+ names.length.to_s
193
+ names.sort.each do |value|
194
+ _value = value.chomp.strip
195
+ if _value != _last_value
196
+ node(_value)
197
+ @progress_bar.title(_value)
198
+ _last_value = _value
199
+ end
200
+ @progress_bar.progress
201
+ if @cancell
202
+ @progress_bar.destroy
203
+ @progress_bar = nil
204
+ break
205
+ end
206
+ end
207
+ progress_bar.destroy if @progress_bar != nil
208
+ end
209
+ end
210
+ end
211
+
212
+ def cancel
213
+ @cancell=true
214
+ end
215
+
216
+ def node_2_rif(_path)
217
+ return _path.gsub('#','@M@').gsub('::','@C@').gsub('|','@P@').gsub('^','@U@')
218
+ end
219
+
220
+ def rif_2_node(_rif)
221
+ return _rif.gsub('@M@','#').gsub('@C@', '::').gsub('@P@', '|').gsub('@U@', '^')
222
+ end
223
+
224
+ def node(_path)
225
+ # _rif = @hash_rif.length
226
+ _rif = node_2_rif(_path)
227
+ _parent_found = false
228
+ while !_parent_found && @level > 0 do
229
+ @level = @level - 1
230
+ if (@last_nodes[@level] != nil) && _path.include?(@last_nodes[@level])
231
+ _full_value = _path.sub(@last_nodes[@level],'')
232
+ if _full_value[0..1].include?('#')
233
+ _sep = '#'
234
+ _value = _full_value[1.._full_value.length-1]
235
+ _parent_found = true
236
+ elsif _full_value[0..2].include?('::')
237
+ _sep = '::'
238
+ _value = _full_value[2.._full_value.length-1]
239
+ _parent_found = true
240
+ else
241
+ _parent_found = false
242
+ end
243
+ end
244
+ end
245
+ if _parent_found
246
+ _parent_path = @last_nodes[@level]
247
+ #_parent_rif = @hash_rif[_parent_path]
248
+ _parent_rif = node_2_rif(_parent_path)
249
+ @level = @level + 1
250
+ else
251
+ _parent_rif = 'root'
252
+ _sep = ''
253
+ _value = _path
254
+ end
255
+
256
+ #@hash_rif[_path]= _rif
257
+ @last_nodes[@level] = _path
258
+ _background = conf('color.background')
259
+
260
+ if _sep.length == 0
261
+ _image = @image_class
262
+ elsif _sep.include?('#')
263
+ _image = @image_def
264
+ elsif _sep.include?('::')
265
+ _image = @image_def_class
266
+ end
267
+
268
+ @doc_tree.insert('end', _parent_rif ,_rif, {
269
+ 'text' => _value ,
270
+ 'helptext' => _path,
271
+ 'deltax'=>-1,
272
+ 'image'=>_image
273
+ }
274
+ )
275
+ @level = @level + 1
276
+ end
277
+ end
278
+
279
+ class TkDocframe < TkFloatTitledFrame
280
+ attr_reader :tkText
281
+ def initialize(parent=nil, *args)
282
+ super(parent)
283
+ @tkText = TkText.new(self.frame,
284
+ 'wrap'=>'none',
285
+ 'relief'=>'groove'
286
+ ){|j|
287
+ TkScrollbar.new(j, Arcadia.style('scrollbar')){|s|
288
+ width 8
289
+ command proc{|*args| j.yview(*args)}
290
+ j.yscrollcommand proc{|first,last| s.set first,last}
291
+ }.pack('side'=>'right', 'fill'=>'y')
292
+ }.place('x'=>0, 'y'=>0, 'relheight'=> 1, 'relwidth'=> 1)
293
+
294
+ end
295
+ end