arcadia 0.1.3 → 0.2.0

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.
Files changed (56) hide show
  1. data/README +69 -77
  2. data/arcadia.rb +1097 -770
  3. data/base/a-commons.rb +480 -0
  4. data/base/a-contracts.rb +207 -322
  5. data/base/{a-utils.rb → a-tkcommons.rb} +933 -993
  6. data/conf/arcadia.conf +130 -203
  7. data/conf/arcadia.res.rb +1332 -1325
  8. data/ext/ae-action-dispatcher/ae-action-dispatcher.conf +6 -0
  9. data/ext/ae-action-dispatcher/ae-action-dispatcher.rb +22 -0
  10. data/ext/ae-complete-code/ae-complete-code.conf +2 -2
  11. data/ext/ae-complete-code/ae-complete-code.rb +82 -80
  12. data/ext/ae-doc-code/ae-doc-code.conf +2 -2
  13. data/ext/ae-doc-code/ae-doc-code.rb +114 -111
  14. data/ext/ae-editor/ae-editor.conf +110 -105
  15. data/ext/ae-editor/ae-editor.rb +2501 -2287
  16. data/ext/ae-editor/langs/conf.lang +15 -0
  17. data/ext/ae-editor/langs/lang.lang.bind +1 -0
  18. data/ext/ae-editor/langs/rb.lang +67 -0
  19. data/ext/ae-editor/langs/rbw.lang.bind +1 -0
  20. data/ext/ae-event-log/ae-event-log.rb +45 -52
  21. data/ext/ae-file-history/ae-file-history.conf +4 -4
  22. data/ext/ae-file-history/ae-file-history.rb +298 -286
  23. data/ext/ae-flag/ae-flag.conf +6 -6
  24. data/ext/ae-flag/ae-flag.rb +12 -12
  25. data/ext/ae-inspector/ae-inspector.conf +3 -3
  26. data/ext/ae-inspector/ae-inspector.rb +2 -2
  27. data/ext/ae-output-event/ae-output-event.conf +15 -15
  28. data/ext/ae-output/ae-output.conf +5 -3
  29. data/ext/ae-output/ae-output.rb +62 -33
  30. data/ext/ae-palette/ae-palette.conf +3 -3
  31. data/ext/ae-palette/ae-palette.rb +265 -306
  32. data/ext/ae-rad/ae-rad-inspector.rb +1534 -0
  33. data/{base/a-libs.rb → ext/ae-rad/ae-rad-libs.rb} +1118 -846
  34. data/ext/ae-rad/ae-rad-palette.rb +273 -0
  35. data/ext/ae-rad/ae-rad.conf +71 -0
  36. data/ext/ae-rad/ae-rad.rb +56 -0
  37. data/{lib → ext/ae-rad/lib}/tk/al-tk.rb +21 -110
  38. data/{lib → ext/ae-rad/lib}/tk/al-tk.res.rb +0 -0
  39. data/{lib → ext/ae-rad/lib}/tk/al-tkarcadia.rb +26 -26
  40. data/{lib → ext/ae-rad/lib}/tk/al-tkcustom.rb +70 -70
  41. data/{lib → ext/ae-rad/lib}/tkext/al-bwidget.rb +194 -194
  42. data/{lib → ext/ae-rad/lib}/tkext/al-iwidgets.rb +25 -25
  43. data/{lib → ext/ae-rad/lib}/tkext/al-tile.rb +173 -173
  44. data/{lib → ext/ae-rad/lib}/tkext/al-tktable.rb +0 -0
  45. data/ext/ae-ruby-debug/ae-ruby-debug.conf +7 -4
  46. data/ext/ae-ruby-debug/ae-ruby-debug.rb +278 -142
  47. data/ext/ae-search-in-files/ae-search-in-files.conf +15 -0
  48. data/ext/ae-search-in-files/ae-search-in-files.rb +284 -0
  49. data/ext/ae-shell/ae-shell.rb +88 -8
  50. data/ext/ae-shell/sh.rb +7 -0
  51. metadata +93 -79
  52. data/base/a-contracts-work.rb +0 -219
  53. data/base/a-ext.rb +0 -280
  54. data/ext/ae-debug/ae-debug.conf +0 -7
  55. data/ext/ae-debug/ae-debug.rb +0 -601
  56. data/ext/ae-debug/debug1.57.rb +0 -998
@@ -0,0 +1,15 @@
1
+ classes=key,value,operator,comment
2
+ re.key=(.*)\=
3
+ re.value=\=(.*)
4
+ re.operator=\=
5
+ re.comment=#
6
+ re_op.to_line_end=comment
7
+ re_op.only_first=operator
8
+
9
+ hightlight.comment.color.foreground=#007F00
10
+ hightlight.key.color.foreground=#9c342c
11
+ hightlight.key.style=bold
12
+ hightlight.value.color.foreground=#69a0b6
13
+ hightlight.value.style=bold
14
+ hightlight.operator.color.foreground=red
15
+ hightlight.operator.style=bold
@@ -0,0 +1 @@
1
+ bind=conf.lang
@@ -0,0 +1,67 @@
1
+ classes=number,method_name,class_name,module_name,keyword,instance_variable,global_variable,symbol,operator,string,comment
2
+ re.keyword=\b(and|or|unless|end|in|begin|defined?|ensure|redo|super|until|BEGIN|break|do|false|next|rescue|then|when|END|case|else|for|nil|retry|true|while|alias|elsif|if|not|return|undef|yield|require|include)([\(\s\n])|\b(self)([.,+\(\s])|__LINE__|__FILE__|[\s]*def[\s]|[\s]*module[\s]|[\s]*class[\s]
3
+ re.method_name=(def[\s][\s]*)[A-Za-z0-9_]*
4
+ re.instance_variable=([\s]*@)[A-Za-z0-9_]*
5
+ re.global_variable=([\s]*\$)[A-Za-z0-9_]*
6
+ re.class_name=(class[\s][\s]*)[A-Za-z0-9_]*
7
+ re.module_name=(module[\s][\s]*)[A-Za-z0-9_]*
8
+ re.string='(.*)'|"(.*)"
9
+ re.number=\d
10
+ re.operator=[\(\)\[\]\(\)\{\}.:;,\=><\|]
11
+ #re.symbol=(\s|,)(:)[A-Za-z0-9_]*
12
+ re.symbol=[^:](:)[A-Za-z0-9_]*
13
+ re.comment=#
14
+ re_op.to_line_end=comment
15
+
16
+ # override global
17
+ hightlight.sel.color.foreground=black
18
+ hightlight.sel.color.background=#68f914
19
+ hightlight.sel.borderwidth=1
20
+ hightlight.sel.relief=raised
21
+ hightlight.selected.color.background=yellow
22
+ hightlight.tabs.color.foreground=black
23
+ hightlight.tabs.color.background=#b1cfba
24
+ hightlight.tabs.borderwidth=1
25
+ hightlight.tabs.relief=raised
26
+ hightlight.spaces.color.foreground=black
27
+ hightlight.spaces.color.background=#d9f42b
28
+ hightlight.spaces.borderwidth=1
29
+ hightlight.spaces.relief=raised
30
+ #+--------------------------------------------------
31
+
32
+
33
+
34
+ hightlight.keyword.color.foreground=#00007F
35
+ hightlight.keyword.style=bold
36
+ hightlight.method_name.color.foreground=#007F7F
37
+ hightlight.method_name.style=bold
38
+ hightlight.class_name.color.foreground=#0000FF
39
+ hightlight.class_name.style=bold
40
+ hightlight.module_name.color.foreground=#0000FF
41
+ hightlight.module_name.style=bold
42
+ hightlight.instance_variable.color.foreground=#7F7F7F
43
+ hightlight.global_variable.style=bold
44
+ hightlight.global_variable.color.foreground=#db66ca
45
+ hightlight.instance_variable.style=bold
46
+ hightlight.comment.color.foreground=#007F00
47
+ hightlight.string.color.foreground=#7F007F
48
+ hightlight.number.color.foreground=#007F7F
49
+ #hightlight.capitalize.color.foreground=#0000FF
50
+ hightlight.operator.color.foreground=#000000
51
+ hightlight.operator.style=bold
52
+ hightlight.symbol.color.foreground=#bdc175
53
+ hightlight.symbol.style=bold
54
+ hightlight.sel.color.foreground=black
55
+ hightlight.sel.color.background=#68f914
56
+ hightlight.sel.borderwidth=1
57
+ hightlight.sel.relief=raised
58
+ #hightlight.goto.color.foreground=blue
59
+ hightlight.selected.color.background=yellow
60
+ hightlight.tabs.color.foreground=black
61
+ hightlight.tabs.color.background=#b1cfba
62
+ hightlight.tabs.borderwidth=1
63
+ hightlight.tabs.relief=raised
64
+ hightlight.spaces.color.foreground=black
65
+ hightlight.spaces.color.background=#d9f42b
66
+ hightlight.spaces.borderwidth=1
67
+ hightlight.spaces.relief=raised
@@ -0,0 +1 @@
1
+ bind=rb.lang
@@ -1,52 +1,45 @@
1
- #
2
- # ae-event-log.rb - Arcadia Ruby ide
3
- # by Antonio Galeone <antonio-galeone@rubyforge.org>
4
- #
5
-
6
-
7
- class EventLog < ArcadiaExt
8
-
9
- def before_build
10
- ArcadiaContractListener.new(self, ArcadiaContract, :do_event)
11
- end
12
-
13
- def build
14
- #@ae_msg_contract = @arcadia.retrieve_contract(self, MsgContract, nil, 'CH1')
15
- end
16
-
17
- def after_build
18
- end
19
-
20
- def do_event(_event)
21
- if _event.context.sender!=self
22
- message = event_message(_event)
23
- MsgContract.instance.out_simple(self, message,'CH1')
24
- end
25
- end
26
-
27
-
28
- def event_message(_event, _ind="")
29
- message = _ind
30
- if _event.is_action?
31
- message = message + 'ACTION::'
32
- end
33
- message = message +_event.signature+" :\n"
34
- if _event.context
35
- _event.context.instance_variables.sort.each do |key|
36
- _obj_value = _event.context.send(key.gsub('@',''))
37
- _value = _obj_value
38
- if _value == nil
39
- _value = 'nil'
40
- else !_value.instance_of?(String)
41
- _value = _value.to_s
42
- end
43
- message = message + _ind + "\s"*2 + key+' = '+_value+"\n"
44
- if _obj_value != nil && _obj_value.kind_of?(ArcadiaContract::ContractEvent)
45
- message = message + event_message(_obj_value, _ind+"\s"*4)
46
- end
47
- end
48
- end
49
- return message
50
- end
51
-
52
- end
1
+ #
2
+ # ae-event-log.rb - Arcadia Ruby ide
3
+ # by Antonio Galeone <antonio-galeone@rubyforge.org>
4
+ #
5
+
6
+
7
+ class EventLog < ArcadiaExt
8
+
9
+ def on_before_build(_event)
10
+ ArcadiaContractListener.new(self, ArcadiaContract, :do_event)
11
+ end
12
+
13
+ def do_event(_event)
14
+ if _event.context.sender!=self
15
+ message = event_message(_event)
16
+ Arcadia.new_msg(self, message, 'CH1')
17
+ end
18
+ end
19
+
20
+
21
+ def event_message(_event, _ind="")
22
+ message = _ind
23
+ if _event.is_action?
24
+ message = message + 'ACTION::'
25
+ end
26
+ message = message +_event.signature+" :\n"
27
+ if _event.context
28
+ _event.context.instance_variables.sort.each do |key|
29
+ _obj_value = _event.context.send(key.gsub('@',''))
30
+ _value = _obj_value
31
+ if _value == nil
32
+ _value = 'nil'
33
+ else !_value.instance_of?(String)
34
+ _value = _value.to_s
35
+ end
36
+ message = message + _ind + "\s"*2 + key+' = '+_value+"\n"
37
+ if _obj_value != nil && _obj_value.kind_of?(ArcadiaContract::ContractEvent)
38
+ message = message + event_message(_obj_value, _ind+"\s"*4)
39
+ end
40
+ end
41
+ end
42
+ return message
43
+ end
44
+
45
+ end
@@ -1,14 +1,14 @@
1
1
  name=file_history
2
- label=File history
3
- frame=1.0
2
+ labels=File history
3
+ frames=0.0
4
4
  active=yes
5
5
  require=ext/ae-file-history/ae-file-history
6
6
  class=FileH
7
7
 
8
8
  file.name=arcadia.history
9
9
  length=34
10
- font=courier 12
11
- font.bold=courier 12 bold
10
+ font=courier 11
11
+ font.bold=courier 11 bold
12
12
  color.background=#ffffff
13
13
  color.foreground=#000000
14
14
  freebsd::font=courier 12 italic
@@ -1,286 +1,298 @@
1
- #
2
- # ae-file-history.rb - Arcadia Ruby ide
3
- # by Antonio Galeone <antonio-galeone@rubyforge.org>
4
- #
5
- require "base/a-ext"
6
-
7
-
8
- class TreeNode
9
- attr_reader :sons
10
- attr_reader :parent
11
- attr_reader :kind
12
- attr_reader :rif, :label, :helptext
13
- attr_writer :rif, :label, :helptext
14
- def initialize(parent=nil, kind='KClass')
15
- @sons = Array.new
16
- @parent = parent
17
- @kind = kind
18
- @label = ''
19
- if @parent !=nil
20
- @parent.sons << self
21
- end
22
- yield(self) if block_given?
23
- end
24
-
25
- def <=> (other)
26
- self.label.strip <=> other.label.strip
27
- end
28
-
29
- def path
30
- _path = @label
31
- if @parent != nil
32
- _path = @parent.path+_path
33
- end
34
- return _path
35
- end
36
-
37
- def dir(_path)
38
- node = nil
39
- sons.each{|_tree|
40
- if _path[0.._tree.label.length-1] == _tree.label
41
- res = _path[_tree.label.length.._path.length-1]
42
- if ["\\","/"].include?(res[0,1])
43
- node= _tree.dir(res)
44
- end
45
- end
46
- break if node != nil
47
- }
48
- if node == nil
49
- node = TreeNode.new(self,'KDir') do |_node|
50
- _node.label=_path
51
- _node.rif= self.path+_path
52
- end
53
- end
54
- return node
55
- end
56
- end
57
-
58
-
59
-
60
- class FileH < ArcadiaExt
61
- attr_reader :htree
62
-
63
- def before_build
64
- end
65
-
66
- def build
67
- @h_stack = Array.new
68
- do_select_item = proc{|_self|
69
- if _self.selection_get[0].length >0
70
- _selected = ""
71
- _self.selection_get[0].each{|_block|
72
- _selected = _selected + _block.to_s + "\s"
73
- }
74
- _selected = _selected.strip
75
- else
76
- _selected = _self.selection_get[0]
77
- end
78
- _dir, _file = _selected.split('@@@')
79
- if _file
80
- _file = File.expand_path( _file , _dir )
81
- else
82
- _file = Tk.getOpenFile('initialdir'=>_dir)
83
- end
84
- if _file
85
- EditorContract.instance.open_file(self,'file'=>_file)
86
- end
87
- }
88
- _background = conf('color.background')
89
- _foreground = conf('color.foreground')
90
- @font = conf('font')
91
- @font_b = conf('font.bold')
92
-
93
- @htree = Tk::BWidget::Tree.new(self.frame){
94
- relief 'flat'
95
- showlines false
96
- deltay 18
97
- background _background
98
- crossfill _foreground
99
- #dragenabled true
100
- selectcommand proc{ do_select_item.call(self) }
101
- place('relwidth' => 1,'relx' => 0,'x' => '0','y' => '0','relheight' => '1')
102
- }
103
- _scrollcommand = proc{|*args| @htree.yview(*args)}
104
- _scrollbar = TkScrollbar.new(self.frame){|s|
105
- width 8
106
- command _scrollcommand
107
- }.pack('side'=>'right', 'fill'=>'y')
108
- @htree.yscrollcommand proc{|first,last| _scrollbar.set(first,last)}
109
-
110
- self.build_tree
111
- end
112
-
113
- def after_build
114
- ArcadiaContractListener.new(self, EditorContract, :do_editor_event)
115
- end
116
-
117
- def history_file
118
- if !defined?(@arcadia_history_file)
119
- @arcadia_history_file = @arcadia.local_dir+'/'+conf('file.name')
120
- end
121
- return @arcadia_history_file
122
- end
123
-
124
- def do_editor_event(_event)
125
- case _event.signature
126
- when EditorContract::FILE_AFTER_OPEN
127
- if _event.context.file
128
- self.add2history(_event.context.file)
129
- add_to_tree(_event.context.file)
130
- end
131
- when EditorContract::FILE_AFTER_CLOSE
132
- if _event.context.file
133
- end
134
- end
135
- end
136
-
137
- def root
138
- if !defined?(@root)
139
- @root = TreeNode.new(nil, 'KRoot'){|_node|
140
- _node.rif= 'root'
141
- _node.label=''
142
- }
143
- end
144
- return @root
145
- end
146
-
147
- def build_tree
148
- file_dir = Hash.new
149
- nodes = Array.new
150
- if File.exist?(history_file)
151
- f = File::open(history_file,'r')
152
- f_open = $arcadia['pers']['editor.files.open'].split("|") if $arcadia['pers']['editor.files.open']
153
- begin
154
- _lines = f.readlines.collect!{| line | line.chomp+"\n" }.to_s
155
- _lines.sort.each{|_line|
156
- _file = _line.split(';')[0]
157
- if FileTest::exist?(_file)
158
- dir,fil =File.split(File.expand_path(_file))
159
- file_dir[dir] = Array.new if file_dir[dir] == nil
160
- file_dir[dir] << fil if !file_dir[dir].include?(fil)
161
- end
162
- }
163
- ensure
164
- f.close unless f.nil?
165
- end
166
- end
167
-
168
- file_dir.keys.sort.each{|_dir|
169
- node = root.dir(_dir)
170
- file_dir[_dir].each{|file|
171
- TreeNode.new(node, 'KFile'){|_node|
172
- _node.rif= _dir+'@@@'+file
173
- _node.label=file
174
- }
175
- }
176
- }
177
-
178
- @image_kdir = TkPhotoImage.new('dat' => BOOK_GIF)
179
- @image_kfile_rb = TkPhotoImage.new('dat' => RUBY_DOCUMENT_GIF)
180
- @image_kfile = TkPhotoImage.new('dat' => DOCUMENT_GIF)
181
-
182
- build_tree_from_node(root)
183
- end
184
-
185
- def add_to_tree(_file)
186
- _d, _f = File.split(File.expand_path(_file))
187
- _foreground = conf('color.foreground')
188
- node = root.dir(_d)
189
- if !@htree.exist?(node.rif)
190
- @htree.insert('end', 'root' ,node.rif, {
191
- 'text' => _d ,
192
- 'helptext' => _d,
193
- 'deltax'=>-1,
194
- 'fill' => _foreground,
195
- 'font'=>@font,
196
- 'image'=> image('KDir')
197
- }
198
- )
199
- end
200
- _file_node_rif = _d+'@@@'+_f
201
- if !@htree.exist?(_file_node_rif)
202
- @htree.insert('end', node.rif ,_file_node_rif, {
203
- 'text' => _f ,
204
- 'helptext' => _f,
205
- 'deltax'=>-1,
206
- 'fill' => _foreground,
207
- 'font'=>@font_b,
208
- 'image'=> image('KFile',_f)
209
- }
210
- )
211
- end
212
-
213
- end
214
-
215
- def image(_kind, _label='.rb')
216
- if _kind == 'KDir'
217
- return @image_kdir
218
- elsif _kind == 'KFile' && _label.include?('.rb')
219
- return @image_kfile_rb
220
- else
221
- return @image_kfile
222
- end
223
- end
224
-
225
- def build_tree_from_node(_node)
226
- _foreground = conf('color.foreground')
227
- _sorted_sons = _node.sons.sort
228
- for inode in 0.._sorted_sons.length - 1
229
- _son = _sorted_sons[inode]
230
- @htree.insert('end', _son.parent.rif ,_son.rif, {
231
- 'text' => _son.label ,
232
- 'fill' => _foreground,
233
- 'helptext' => _son.helptext,
234
- 'deltax'=>-1,
235
- 'font'=>@font,
236
- 'image'=> image(_son.kind, _son.label)
237
- }
238
- )
239
- build_tree_from_node(_son)
240
- end
241
- end
242
-
243
-
244
- def add2history(_filename, _text_index='1.0')
245
- if _filename
246
- _filename = _filename.downcase.sub(Dir::pwd.downcase+'/',"")
247
- _filename = File.expand_path(_filename)
248
- _filename_index = _filename+";"+_text_index
249
-
250
- if File.exist?(history_file)
251
- f = File::open(history_file,'r')
252
- begin
253
- _lines = f.readlines.collect!{| line | line.chomp}
254
- ensure
255
- f.close unless f.nil?
256
- end
257
- f = File.new(history_file, "w")
258
- begin
259
- if f
260
- _l= conf('length').to_i
261
- f.syswrite(_filename_index+"\n")
262
- _lines[0.._l-1].each{|_line|
263
- _lfile = _line.split(';')
264
- if _lfile
265
- f.syswrite(_line+"\n") if (_lfile[0] != _filename)&&(_line.length > 0)
266
- end
267
- }
268
- end
269
- ensure
270
- f.close unless f.nil?
271
- end
272
- else
273
- dir,fil =File.split(File.expand_path(history_file))
274
- if !File.exist?(dir)
275
- Dir.mkdir(dir)
276
- end
277
- f = File.new(history_file, "w+")
278
- begin
279
- f.syswrite(_filename+"\n") if f
280
- ensure
281
- f.close unless f.nil?
282
- end
283
- end
284
- end
285
- end
286
- end
1
+ #
2
+ # ae-file-history.rb - Arcadia Ruby ide
3
+ # by Antonio Galeone <antonio-galeone@rubyforge.org>
4
+ #
5
+
6
+
7
+ class TreeNode
8
+ attr_reader :sons
9
+ attr_reader :parent
10
+ attr_reader :kind
11
+ attr_reader :rif, :label, :helptext
12
+ attr_writer :rif, :label, :helptext
13
+ def initialize(parent=nil, kind='KClass')
14
+ @sons = Array.new
15
+ @parent = parent
16
+ @kind = kind
17
+ @label = ''
18
+ if @parent !=nil
19
+ @parent.sons << self
20
+ end
21
+ yield(self) if block_given?
22
+ end
23
+
24
+ def <=> (other)
25
+ self.label.strip <=> other.label.strip
26
+ end
27
+
28
+ def path
29
+ _path = @label
30
+ if @parent != nil
31
+ _path = @parent.path+_path
32
+ end
33
+ return _path
34
+ end
35
+
36
+ def dir(_path)
37
+ node = nil
38
+ parent = self
39
+ sons.each{|_tree|
40
+ if _path[0.._tree.label.length-1] == _tree.label
41
+ res = _path[_tree.label.length.._path.length-1]
42
+ if ["\\","/"].include?(res[0,1])
43
+ parent = _tree
44
+ node= _tree.dir(res)
45
+ end
46
+ end
47
+ break if node != nil
48
+ }
49
+ if node == nil
50
+ node = TreeNode.new(parent,'KDir') do |_node|
51
+ _node.label=_path
52
+ _node.rif= parent.path+_path
53
+ end
54
+ end
55
+ return node
56
+ end
57
+ end
58
+
59
+
60
+
61
+ class FileH < ArcadiaExt
62
+ include Autils
63
+ attr_reader :htree
64
+
65
+ def on_build(_event)
66
+ @h_stack = Array.new
67
+ do_select_item = proc{|_self|
68
+ if _self.selection_get[0].length >0
69
+ _selected = ""
70
+ _self.selection_get[0].each{|_block|
71
+ _selected = _selected + _block.to_s + "\s"
72
+ }
73
+ _selected = _selected.strip
74
+ else
75
+ _selected = _self.selection_get[0]
76
+ end
77
+ _dir, _file = _selected.split('@@@')
78
+ if _file
79
+ _file = File.expand_path( _file , _dir )
80
+ else
81
+ _file = Tk.getOpenFile('initialdir'=>_dir)
82
+ end
83
+ if _file
84
+ Arcadia.process_event(OpenBufferEvent.new(self,'file'=>_file))
85
+ #EditorContract.instance.open_file(self,'file'=>_file)
86
+ end
87
+ }
88
+ _background = conf('color.background')
89
+ _foreground = conf('color.foreground')
90
+ @font = conf('font')
91
+ @font_b = conf('font.bold')
92
+
93
+ @htree = Tk::BWidget::Tree.new(self.frame){
94
+ relief 'flat'
95
+ showlines false
96
+ deltay 18
97
+ background _background
98
+ crossfill _foreground
99
+ #dragenabled true
100
+ selectcommand proc{ do_select_item.call(self) }
101
+ place('relwidth' => 1,'relx' => 0,'x' => '0','y' => '0','relheight' => '1')
102
+ }
103
+ _scrollcommand = proc{|*args| @htree.yview(*args)}
104
+ _scrollbar = TkScrollbar.new(self.frame){|s|
105
+ width 8
106
+ command _scrollcommand
107
+ }.pack('side'=>'right', 'fill'=>'y')
108
+ @htree.yscrollcommand proc{|first,last| _scrollbar.set(first,last)}
109
+
110
+ self.build_tree
111
+ end
112
+
113
+ def on_after_build(_event)
114
+ #ArcadiaContractListener.new(self, EditorContract, :do_editor_event)
115
+ Arcadia.add_listener(self, OpenBufferEvent)
116
+ end
117
+
118
+ def history_file
119
+ if !defined?(@arcadia_history_file)
120
+ @arcadia_history_file = @arcadia.local_dir+'/'+conf('file.name')
121
+ end
122
+ return @arcadia_history_file
123
+ end
124
+
125
+ def on_after_open_buffer(_event)
126
+ if _event.file
127
+ self.add2history(_event.file)
128
+ add_to_tree(_event.file)
129
+ end
130
+ end
131
+
132
+ # def do_editor_event(_event)
133
+ # case _event.signature
134
+ # when EditorContract::FILE_AFTER_OPEN
135
+ # if _event.context.file
136
+ # self.add2history(_event.context.file)
137
+ # add_to_tree(_event.context.file)
138
+ # end
139
+ # when EditorContract::FILE_AFTER_CLOSE
140
+ # if _event.context.file
141
+ # end
142
+ # end
143
+ # end
144
+
145
+ def root
146
+ if !defined?(@root)
147
+ @root = TreeNode.new(nil, 'KRoot'){|_node|
148
+ _node.rif= 'root'
149
+ _node.label=''
150
+ }
151
+ end
152
+ return @root
153
+ end
154
+
155
+ def build_tree
156
+ file_dir = Hash.new
157
+ nodes = Array.new
158
+ if File.exist?(history_file)
159
+ f = File::open(history_file,'r')
160
+ f_open = $arcadia['pers']['editor.files.open'].split("|") if $arcadia['pers']['editor.files.open']
161
+ begin
162
+ _lines = f.readlines.collect!{| line | line.chomp+"\n" }.to_s
163
+ _lines.sort.each{|_line|
164
+ _file = _line.split(';')[0]
165
+ if FileTest::exist?(_file)
166
+ dir,fil =File.split(File.expand_path(_file))
167
+ dir = dir.downcase if is_windows?
168
+ fil = fil.downcase if is_windows?
169
+ file_dir[dir] = Array.new if file_dir[dir] == nil
170
+ file_dir[dir] << fil if !file_dir[dir].include?(fil)
171
+ end
172
+ }
173
+ ensure
174
+ f.close unless f.nil?
175
+ end
176
+ end
177
+
178
+ file_dir.keys.sort.each{|_dir|
179
+ node = root.dir(_dir)
180
+ file_dir[_dir].each{|file|
181
+ TreeNode.new(node, 'KFile'){|_node|
182
+ _node.rif= _dir+'@@@'+file
183
+ _node.label=file
184
+ }
185
+ }
186
+ }
187
+
188
+ @image_kdir = TkPhotoImage.new('dat' => BOOK_GIF)
189
+ @image_kfile_rb = TkPhotoImage.new('dat' => RUBY_DOCUMENT_GIF)
190
+ @image_kfile = TkPhotoImage.new('dat' => DOCUMENT_GIF)
191
+
192
+ build_tree_from_node(root)
193
+ end
194
+
195
+ def add_to_tree(_file)
196
+ _d, _f = File.split(File.expand_path(_file))
197
+ _d = _d.downcase if is_windows?
198
+ _f = _f.downcase if is_windows?
199
+ _foreground = conf('color.foreground')
200
+ node = root.dir(_d)
201
+ if !@htree.exist?(node.rif)
202
+ @htree.insert('end', node.parent.rif ,node.rif, {
203
+ 'text' => node.rif ,
204
+ 'helptext' => node.rif,
205
+ 'deltax'=>-1,
206
+ 'fill' => _foreground,
207
+ 'font'=>@font,
208
+ 'image'=> image('KDir')
209
+ }
210
+ )
211
+ end
212
+ _file_node_rif = _d+'@@@'+_f
213
+ if !@htree.exist?(_file_node_rif)
214
+ @htree.insert('end', node.rif ,_file_node_rif, {
215
+ 'text' => _f ,
216
+ 'helptext' => _f,
217
+ 'deltax'=>-1,
218
+ 'fill' => _foreground,
219
+ 'font'=>@font_b,
220
+ 'image'=> image('KFile',_f)
221
+ }
222
+ )
223
+ end
224
+
225
+ end
226
+
227
+ def image(_kind, _label='.rb')
228
+ if _kind == 'KDir'
229
+ return @image_kdir
230
+ elsif _kind == 'KFile' && _label.include?('.rb')
231
+ return @image_kfile_rb
232
+ else
233
+ return @image_kfile
234
+ end
235
+ end
236
+
237
+ def build_tree_from_node(_node)
238
+ _foreground = conf('color.foreground')
239
+ _sorted_sons = _node.sons.sort
240
+ for inode in 0.._sorted_sons.length - 1
241
+ _son = _sorted_sons[inode]
242
+ @htree.insert('end', _son.parent.rif ,_son.rif, {
243
+ 'text' => _son.label ,
244
+ 'fill' => _foreground,
245
+ 'helptext' => _son.helptext,
246
+ 'deltax'=>-1,
247
+ 'font'=>@font,
248
+ 'image'=> image(_son.kind, _son.label)
249
+ }
250
+ )
251
+ build_tree_from_node(_son)
252
+ end
253
+ end
254
+
255
+
256
+ def add2history(_filename, _text_index='1.0')
257
+ if _filename
258
+ _filename = _filename.sub(Dir::pwd+'/',"")
259
+ _filename = File.expand_path(_filename)
260
+ _filename_index = _filename+";"+_text_index
261
+
262
+ if File.exist?(history_file)
263
+ f = File::open(history_file,'r')
264
+ begin
265
+ _lines = f.readlines.collect!{| line | line.chomp}
266
+ ensure
267
+ f.close unless f.nil?
268
+ end
269
+ f = File.new(history_file, "w")
270
+ begin
271
+ if f
272
+ _l= conf('length').to_i
273
+ f.syswrite(_filename_index+"\n")
274
+ _lines[0.._l-2].each{|_line|
275
+ _lfile = _line.split(';')
276
+ if _lfile
277
+ f.syswrite(_line+"\n") if (_lfile[0] != _filename)&&(_line.length > 0)
278
+ end
279
+ }
280
+ end
281
+ ensure
282
+ f.close unless f.nil?
283
+ end
284
+ else
285
+ dir,fil =File.split(File.expand_path(history_file))
286
+ if !File.exist?(dir)
287
+ Dir.mkdir(dir)
288
+ end
289
+ f = File.new(history_file, "w+")
290
+ begin
291
+ f.syswrite(_filename+"\n") if f
292
+ ensure
293
+ f.close unless f.nil?
294
+ end
295
+ end
296
+ end
297
+ end
298
+ end