arcadia 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +69 -77
- data/arcadia.rb +1097 -770
- data/base/a-commons.rb +480 -0
- data/base/a-contracts.rb +207 -322
- data/base/{a-utils.rb → a-tkcommons.rb} +933 -993
- data/conf/arcadia.conf +130 -203
- data/conf/arcadia.res.rb +1332 -1325
- data/ext/ae-action-dispatcher/ae-action-dispatcher.conf +6 -0
- data/ext/ae-action-dispatcher/ae-action-dispatcher.rb +22 -0
- data/ext/ae-complete-code/ae-complete-code.conf +2 -2
- data/ext/ae-complete-code/ae-complete-code.rb +82 -80
- data/ext/ae-doc-code/ae-doc-code.conf +2 -2
- data/ext/ae-doc-code/ae-doc-code.rb +114 -111
- data/ext/ae-editor/ae-editor.conf +110 -105
- data/ext/ae-editor/ae-editor.rb +2501 -2287
- data/ext/ae-editor/langs/conf.lang +15 -0
- data/ext/ae-editor/langs/lang.lang.bind +1 -0
- data/ext/ae-editor/langs/rb.lang +67 -0
- data/ext/ae-editor/langs/rbw.lang.bind +1 -0
- data/ext/ae-event-log/ae-event-log.rb +45 -52
- data/ext/ae-file-history/ae-file-history.conf +4 -4
- data/ext/ae-file-history/ae-file-history.rb +298 -286
- data/ext/ae-flag/ae-flag.conf +6 -6
- data/ext/ae-flag/ae-flag.rb +12 -12
- data/ext/ae-inspector/ae-inspector.conf +3 -3
- data/ext/ae-inspector/ae-inspector.rb +2 -2
- data/ext/ae-output-event/ae-output-event.conf +15 -15
- data/ext/ae-output/ae-output.conf +5 -3
- data/ext/ae-output/ae-output.rb +62 -33
- data/ext/ae-palette/ae-palette.conf +3 -3
- data/ext/ae-palette/ae-palette.rb +265 -306
- data/ext/ae-rad/ae-rad-inspector.rb +1534 -0
- data/{base/a-libs.rb → ext/ae-rad/ae-rad-libs.rb} +1118 -846
- data/ext/ae-rad/ae-rad-palette.rb +273 -0
- data/ext/ae-rad/ae-rad.conf +71 -0
- data/ext/ae-rad/ae-rad.rb +56 -0
- data/{lib → ext/ae-rad/lib}/tk/al-tk.rb +21 -110
- data/{lib → ext/ae-rad/lib}/tk/al-tk.res.rb +0 -0
- data/{lib → ext/ae-rad/lib}/tk/al-tkarcadia.rb +26 -26
- data/{lib → ext/ae-rad/lib}/tk/al-tkcustom.rb +70 -70
- data/{lib → ext/ae-rad/lib}/tkext/al-bwidget.rb +194 -194
- data/{lib → ext/ae-rad/lib}/tkext/al-iwidgets.rb +25 -25
- data/{lib → ext/ae-rad/lib}/tkext/al-tile.rb +173 -173
- data/{lib → ext/ae-rad/lib}/tkext/al-tktable.rb +0 -0
- data/ext/ae-ruby-debug/ae-ruby-debug.conf +7 -4
- data/ext/ae-ruby-debug/ae-ruby-debug.rb +278 -142
- data/ext/ae-search-in-files/ae-search-in-files.conf +15 -0
- data/ext/ae-search-in-files/ae-search-in-files.rb +284 -0
- data/ext/ae-shell/ae-shell.rb +88 -8
- data/ext/ae-shell/sh.rb +7 -0
- metadata +93 -79
- data/base/a-contracts-work.rb +0 -219
- data/base/a-ext.rb +0 -280
- data/ext/ae-debug/ae-debug.conf +0 -7
- data/ext/ae-debug/ae-debug.rb +0 -601
- data/ext/ae-debug/debug1.57.rb +0 -998
@@ -1,105 +1,110 @@
|
|
1
|
-
name=editor
|
2
|
-
|
3
|
-
|
4
|
-
active=yes
|
5
|
-
require=ext/ae-editor/ae-editor
|
6
|
-
class=AgMultiEditor
|
7
|
-
|
8
|
-
tabs=0.5c left
|
9
|
-
# to use tab key set tab-replace-width-space=0
|
10
|
-
tab-replace-width-space=2
|
11
|
-
|
12
|
-
#tabs
|
13
|
-
tabs.font=courier
|
14
|
-
freebsd::tabs.font=courier 12
|
15
|
-
win::tabs.font={Courier New} 9
|
16
|
-
#tabs.side=bottom
|
17
|
-
tabs.side=top
|
18
|
-
|
19
|
-
# editor
|
20
|
-
font=courier
|
21
|
-
font.bold=courier
|
22
|
-
freebsd::font=courier 12
|
23
|
-
freebsd::font.bold=courier 12 bold
|
24
|
-
win::font={Courier New} 9
|
25
|
-
win::font.bold={Courier New} 9 bold
|
26
|
-
#+--------------------------------------------------
|
27
|
-
#color.background=#
|
28
|
-
#color.foreground=white
|
29
|
-
#color.insertbackground=#ff8000
|
30
|
-
#hightlight.keyword.color.foreground=#800000
|
31
|
-
#hightlight.variable.color.foreground=#f9c6f8
|
32
|
-
#hightlight.comment.color.foreground=#4aff4a
|
33
|
-
#hightlight.string.color.foreground=#8080ff
|
34
|
-
#hightlight.number.color.foreground=red
|
35
|
-
#hightlight.capitalize.color.foreground=#ffff00
|
36
|
-
#hightlight.select.color.foreground=yellow
|
37
|
-
#hightlight.select.color.background=blue
|
38
|
-
#hightlight.goto.color.foreground=blue
|
39
|
-
#hightlight.goto.color.background=yellow
|
40
|
-
#+--------------------------------------------------
|
41
|
-
#+--------------------------------------------------
|
42
|
-
color.background=#FFFFFF
|
43
|
-
color.foreground=#7F7F7F
|
44
|
-
color.insertbackground=#ff8000
|
45
|
-
hightlight.keyword.color.foreground=#00007F
|
46
|
-
hightlight.keyword.style=bold
|
47
|
-
hightlight.method_name.color.foreground=#007F7F
|
48
|
-
hightlight.method_name.style=bold
|
49
|
-
hightlight.class_name.color.foreground=#0000FF
|
50
|
-
hightlight.class_name.style=bold
|
51
|
-
hightlight.module_name.color.foreground=#0000FF
|
52
|
-
hightlight.module_name.style=bold
|
53
|
-
hightlight.instance_variable.color.foreground=#7F7F7F
|
54
|
-
hightlight.instance_variable.style=bold
|
55
|
-
hightlight.comment.color.foreground=#007F00
|
56
|
-
hightlight.string.color.foreground=#7F007F
|
57
|
-
hightlight.number.color.foreground=#007F7F
|
58
|
-
#hightlight.capitalize.color.foreground=#0000FF
|
59
|
-
hightlight.operator.color.foreground=#000000
|
60
|
-
hightlight.operator.style=bold
|
61
|
-
hightlight.sel.color.foreground=black
|
62
|
-
hightlight.sel.color.background=#68f914
|
63
|
-
hightlight.sel.borderwidth=1
|
64
|
-
hightlight.sel.relief=raised
|
65
|
-
|
66
|
-
hightlight.
|
67
|
-
hightlight.
|
68
|
-
hightlight.
|
69
|
-
hightlight.
|
70
|
-
hightlight.
|
71
|
-
hightlight.
|
72
|
-
hightlight.
|
73
|
-
hightlight.
|
74
|
-
hightlight.
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
line_number_panel.color.
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
explorer_panel.tree.
|
93
|
-
|
94
|
-
|
95
|
-
explorer_panel.
|
96
|
-
|
97
|
-
|
98
|
-
explorer_panel.tree.
|
99
|
-
explorer_panel.tree.
|
100
|
-
|
101
|
-
explorer_panel.tree.
|
102
|
-
explorer_panel.tree.
|
103
|
-
|
104
|
-
|
105
|
-
|
1
|
+
name=editor
|
2
|
+
labels=Editor
|
3
|
+
frames=0.1
|
4
|
+
active=yes
|
5
|
+
require=ext/ae-editor/ae-editor
|
6
|
+
class=AgMultiEditor
|
7
|
+
|
8
|
+
tabs=0.5c left
|
9
|
+
# to use tab key set tab-replace-width-space=0
|
10
|
+
tab-replace-width-space=2
|
11
|
+
|
12
|
+
#tabs
|
13
|
+
tabs.font=courier 11
|
14
|
+
freebsd::tabs.font=courier 12
|
15
|
+
win::tabs.font={Courier New} 9
|
16
|
+
#tabs.side=bottom
|
17
|
+
tabs.side=top
|
18
|
+
|
19
|
+
# editor
|
20
|
+
font=courier 11
|
21
|
+
font.bold=courier 11 bold
|
22
|
+
freebsd::font=courier 12
|
23
|
+
freebsd::font.bold=courier 12 bold
|
24
|
+
win::font={Courier New} 9
|
25
|
+
win::font.bold={Courier New} 9 bold
|
26
|
+
#+--------------------------------------------------
|
27
|
+
#color.background=#000000
|
28
|
+
#color.foreground=white
|
29
|
+
#color.insertbackground=#ff8000
|
30
|
+
#hightlight.keyword.color.foreground=#800000
|
31
|
+
#hightlight.variable.color.foreground=#f9c6f8
|
32
|
+
#hightlight.comment.color.foreground=#4aff4a
|
33
|
+
#hightlight.string.color.foreground=#8080ff
|
34
|
+
#hightlight.number.color.foreground=red
|
35
|
+
#hightlight.capitalize.color.foreground=#ffff00
|
36
|
+
#hightlight.select.color.foreground=yellow
|
37
|
+
#hightlight.select.color.background=blue
|
38
|
+
#hightlight.goto.color.foreground=blue
|
39
|
+
#hightlight.goto.color.background=yellow
|
40
|
+
#+--------------------------------------------------
|
41
|
+
#+--------------------------------------------------
|
42
|
+
color.background=#FFFFFF
|
43
|
+
color.foreground=#7F7F7F
|
44
|
+
color.insertbackground=#ff8000
|
45
|
+
hightlight.keyword.color.foreground=#00007F
|
46
|
+
hightlight.keyword.style=bold
|
47
|
+
hightlight.method_name.color.foreground=#007F7F
|
48
|
+
hightlight.method_name.style=bold
|
49
|
+
hightlight.class_name.color.foreground=#0000FF
|
50
|
+
hightlight.class_name.style=bold
|
51
|
+
hightlight.module_name.color.foreground=#0000FF
|
52
|
+
hightlight.module_name.style=bold
|
53
|
+
hightlight.instance_variable.color.foreground=#7F7F7F
|
54
|
+
hightlight.instance_variable.style=bold
|
55
|
+
hightlight.comment.color.foreground=#007F00
|
56
|
+
hightlight.string.color.foreground=#7F007F
|
57
|
+
hightlight.number.color.foreground=#007F7F
|
58
|
+
#hightlight.capitalize.color.foreground=#0000FF
|
59
|
+
hightlight.operator.color.foreground=#000000
|
60
|
+
hightlight.operator.style=bold
|
61
|
+
hightlight.sel.color.foreground=black
|
62
|
+
hightlight.sel.color.background=#68f914
|
63
|
+
hightlight.sel.borderwidth=1
|
64
|
+
hightlight.sel.relief=raised
|
65
|
+
hightlight.debug.color.foreground=black
|
66
|
+
hightlight.debug.color.background=#b3c1d9
|
67
|
+
hightlight.debug.borderwidth=2
|
68
|
+
hightlight.debug.relief=groove
|
69
|
+
#hightlight.goto.color.foreground=blue
|
70
|
+
hightlight.selected.color.background=yellow
|
71
|
+
hightlight.tabs.color.foreground=black
|
72
|
+
hightlight.tabs.color.background=#b1cfba
|
73
|
+
hightlight.tabs.borderwidth=1
|
74
|
+
hightlight.tabs.relief=raised
|
75
|
+
hightlight.spaces.color.foreground=black
|
76
|
+
hightlight.spaces.color.background=#d9f42b
|
77
|
+
hightlight.spaces.borderwidth=1
|
78
|
+
hightlight.spaces.relief=raised
|
79
|
+
#+--------------------------------------------------
|
80
|
+
|
81
|
+
|
82
|
+
# line number
|
83
|
+
#line_number_panel.color.background=#6e6e6e
|
84
|
+
#line_number_panel.color.foreground=white
|
85
|
+
|
86
|
+
line_number_panel.color.background=#e1e1e1
|
87
|
+
#line_number_panel.color.background=#FFFFFF
|
88
|
+
line_number_panel.color.foreground=#333333
|
89
|
+
|
90
|
+
|
91
|
+
# tree explorer
|
92
|
+
explorer_panel.tree.color.background=#ffffff
|
93
|
+
explorer_panel.tree.color.foreground=white
|
94
|
+
#explorer_panel.tabs.side=bottom
|
95
|
+
explorer_panel.tabs.side=top
|
96
|
+
|
97
|
+
explorer_panel.tree.font=courier 11
|
98
|
+
freebsd::explorer_panel.tree.font=courier 12
|
99
|
+
win::explorer_panel.tree.font={Courier New} 9
|
100
|
+
explorer_panel.tree.class.color.foreground=#a42019
|
101
|
+
explorer_panel.tree.class.font=times 10 bold
|
102
|
+
win::explorer_panel.tree.class.font=times 10 bold
|
103
|
+
explorer_panel.tree.def.color.foreground=blue
|
104
|
+
explorer_panel.tree.def.font=times 10
|
105
|
+
win::explorer_panel.tree.def.font=times 10
|
106
|
+
explorer_panel.tree.module.color.foreground=#1b691e
|
107
|
+
explorer_panel.tree.module.font=times 8 bold
|
108
|
+
win::explorer_panel.tree.module.font={Courier New} 9 bold
|
109
|
+
|
110
|
+
#:::::::::::::::: Editor group ::::::::::::::::::::::<end>
|
data/ext/ae-editor/ae-editor.rb
CHANGED
@@ -1,2287 +1,2501 @@
|
|
1
|
-
#
|
2
|
-
# ae-editor.rb - Arcadia Ruby ide
|
3
|
-
# by Antonio Galeone <antonio-galeone@rubyforge.org>
|
4
|
-
#
|
5
|
-
|
6
|
-
require 'tk'
|
7
|
-
require 'tktext'
|
8
|
-
require 'base/a-
|
9
|
-
|
10
|
-
|
11
|
-
class TreeNode
|
12
|
-
attr_reader :sons
|
13
|
-
attr_reader :parent
|
14
|
-
attr_reader :kind
|
15
|
-
attr_reader :rif, :label, :helptext
|
16
|
-
attr_writer :rif, :label, :helptext
|
17
|
-
def initialize(parent=nil, kind='KClass')
|
18
|
-
@sons = Array.new
|
19
|
-
@parent = parent
|
20
|
-
@kind = kind
|
21
|
-
if @parent !=nil
|
22
|
-
@parent.sons << self
|
23
|
-
end
|
24
|
-
yield(self) if block_given?
|
25
|
-
end
|
26
|
-
|
27
|
-
def <=> (other)
|
28
|
-
self.label.strip <=> other.label.strip
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class AgEditor
|
33
|
-
|
34
|
-
attr_reader :
|
35
|
-
attr_reader :
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
@
|
40
|
-
@
|
41
|
-
@
|
42
|
-
@
|
43
|
-
@
|
44
|
-
@
|
45
|
-
@
|
46
|
-
@
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
@tree_thread
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
:
|
110
|
-
|
111
|
-
|
112
|
-
:command
|
113
|
-
|
114
|
-
|
115
|
-
proc{
|
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
|
-
|
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
|
-
@text.
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
@text.bind("
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
@text.
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
@text.
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
when '
|
309
|
-
@
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
end
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
end
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
@text_line_num.
|
447
|
-
@text_line_num.tag_configure('
|
448
|
-
|
449
|
-
'background'
|
450
|
-
'
|
451
|
-
'relief'=>'
|
452
|
-
)
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
@
|
468
|
-
|
469
|
-
'
|
470
|
-
'
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
@
|
484
|
-
@
|
485
|
-
@
|
486
|
-
@
|
487
|
-
@
|
488
|
-
@
|
489
|
-
@
|
490
|
-
@
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
)
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
:
|
562
|
-
|
563
|
-
|
564
|
-
:command
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
:
|
572
|
-
:
|
573
|
-
:
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
:
|
580
|
-
:
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
:
|
593
|
-
:
|
594
|
-
:
|
595
|
-
)
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
:command
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
#----
|
621
|
-
|
622
|
-
:parent=>@pop_up,
|
623
|
-
:tearoff=>0,
|
624
|
-
:title => '
|
625
|
-
)
|
626
|
-
|
627
|
-
|
628
|
-
:command,
|
629
|
-
:label=>'
|
630
|
-
:hidemargin => false,
|
631
|
-
:command=> proc{
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
:
|
645
|
-
:
|
646
|
-
:
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
:
|
654
|
-
:
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
_sub_code.insert('end',
|
659
|
-
:command,
|
660
|
-
:label=>'
|
661
|
-
:hidemargin => false,
|
662
|
-
:command=> proc{
|
663
|
-
)
|
664
|
-
|
665
|
-
_sub_code.insert('end',
|
666
|
-
:command,
|
667
|
-
:label=>'
|
668
|
-
:hidemargin => false,
|
669
|
-
:command=> proc{
|
670
|
-
)
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
:
|
675
|
-
:
|
676
|
-
:
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
proc{
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
@
|
840
|
-
@
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
end
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
@
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
if
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
end
|
893
|
-
|
894
|
-
def
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
if
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
end
|
1128
|
-
end
|
1129
|
-
|
1130
|
-
def
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
if
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
@
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
end
|
1219
|
-
|
1220
|
-
def
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
)
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
#
|
1585
|
-
#
|
1586
|
-
#
|
1587
|
-
#
|
1588
|
-
#
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
return
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
@
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1815
|
-
|
1816
|
-
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
1849
|
-
end
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
1876
|
-
return
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1883
|
-
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
1887
|
-
|
1888
|
-
|
1889
|
-
|
1890
|
-
|
1891
|
-
|
1892
|
-
|
1893
|
-
|
1894
|
-
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
|
1907
|
-
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
|
1926
|
-
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1940
|
-
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
1947
|
-
|
1948
|
-
|
1949
|
-
|
1950
|
-
|
1951
|
-
|
1952
|
-
|
1953
|
-
|
1954
|
-
|
1955
|
-
|
1956
|
-
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
1962
|
-
@
|
1963
|
-
|
1964
|
-
|
1965
|
-
|
1966
|
-
|
1967
|
-
|
1968
|
-
|
1969
|
-
|
1970
|
-
|
1971
|
-
|
1972
|
-
|
1973
|
-
|
1974
|
-
|
1975
|
-
|
1976
|
-
|
1977
|
-
|
1978
|
-
|
1979
|
-
|
1980
|
-
|
1981
|
-
|
1982
|
-
|
1983
|
-
|
1984
|
-
@
|
1985
|
-
|
1986
|
-
|
1987
|
-
|
1988
|
-
|
1989
|
-
|
1990
|
-
|
1991
|
-
|
1992
|
-
|
1993
|
-
|
1994
|
-
|
1995
|
-
|
1996
|
-
|
1997
|
-
|
1998
|
-
|
1999
|
-
|
2000
|
-
|
2001
|
-
|
2002
|
-
|
2003
|
-
|
2004
|
-
|
2005
|
-
|
2006
|
-
|
2007
|
-
|
2008
|
-
|
2009
|
-
|
2010
|
-
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
2014
|
-
|
2015
|
-
|
2016
|
-
|
2017
|
-
|
2018
|
-
|
2019
|
-
|
2020
|
-
|
2021
|
-
|
2022
|
-
|
2023
|
-
|
2024
|
-
|
2025
|
-
|
2026
|
-
|
2027
|
-
|
2028
|
-
|
2029
|
-
|
2030
|
-
|
2031
|
-
|
2032
|
-
|
2033
|
-
|
2034
|
-
|
2035
|
-
|
2036
|
-
|
2037
|
-
|
2038
|
-
|
2039
|
-
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2043
|
-
|
2044
|
-
|
2045
|
-
|
2046
|
-
|
2047
|
-
|
2048
|
-
|
2049
|
-
|
2050
|
-
|
2051
|
-
|
2052
|
-
|
2053
|
-
|
2054
|
-
|
2055
|
-
|
2056
|
-
|
2057
|
-
|
2058
|
-
|
2059
|
-
|
2060
|
-
|
2061
|
-
|
2062
|
-
|
2063
|
-
|
2064
|
-
|
2065
|
-
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
2069
|
-
|
2070
|
-
|
2071
|
-
|
2072
|
-
|
2073
|
-
|
2074
|
-
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
2080
|
-
|
2081
|
-
|
2082
|
-
|
2083
|
-
|
2084
|
-
|
2085
|
-
|
2086
|
-
|
2087
|
-
|
2088
|
-
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2092
|
-
|
2093
|
-
|
2094
|
-
|
2095
|
-
|
2096
|
-
|
2097
|
-
|
2098
|
-
|
2099
|
-
|
2100
|
-
|
2101
|
-
|
2102
|
-
|
2103
|
-
|
2104
|
-
|
2105
|
-
|
2106
|
-
|
2107
|
-
|
2108
|
-
|
2109
|
-
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2114
|
-
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2119
|
-
end
|
2120
|
-
|
2121
|
-
|
2122
|
-
|
2123
|
-
|
2124
|
-
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2134
|
-
|
2135
|
-
|
2136
|
-
|
2137
|
-
|
2138
|
-
|
2139
|
-
|
2140
|
-
|
2141
|
-
|
2142
|
-
|
2143
|
-
|
2144
|
-
|
2145
|
-
|
2146
|
-
|
2147
|
-
|
2148
|
-
|
2149
|
-
|
2150
|
-
|
2151
|
-
|
2152
|
-
|
2153
|
-
|
2154
|
-
|
2155
|
-
|
2156
|
-
|
2157
|
-
|
2158
|
-
|
2159
|
-
|
2160
|
-
|
2161
|
-
|
2162
|
-
|
2163
|
-
|
2164
|
-
|
2165
|
-
|
2166
|
-
|
2167
|
-
|
2168
|
-
|
2169
|
-
|
2170
|
-
|
2171
|
-
|
2172
|
-
|
2173
|
-
|
2174
|
-
|
2175
|
-
|
2176
|
-
|
2177
|
-
|
2178
|
-
|
2179
|
-
|
2180
|
-
|
2181
|
-
|
2182
|
-
|
2183
|
-
|
2184
|
-
|
2185
|
-
|
2186
|
-
|
2187
|
-
|
2188
|
-
|
2189
|
-
|
2190
|
-
|
2191
|
-
|
2192
|
-
|
2193
|
-
|
2194
|
-
|
2195
|
-
|
2196
|
-
|
2197
|
-
|
2198
|
-
|
2199
|
-
|
2200
|
-
|
2201
|
-
|
2202
|
-
|
2203
|
-
|
2204
|
-
|
2205
|
-
|
2206
|
-
|
2207
|
-
|
2208
|
-
|
2209
|
-
|
2210
|
-
|
2211
|
-
|
2212
|
-
|
2213
|
-
|
2214
|
-
|
2215
|
-
|
2216
|
-
|
2217
|
-
|
2218
|
-
|
2219
|
-
|
2220
|
-
|
2221
|
-
|
2222
|
-
|
2223
|
-
|
2224
|
-
|
2225
|
-
|
2226
|
-
|
2227
|
-
|
2228
|
-
|
2229
|
-
|
2230
|
-
|
2231
|
-
|
2232
|
-
|
2233
|
-
|
2234
|
-
|
2235
|
-
|
2236
|
-
|
2237
|
-
|
2238
|
-
|
2239
|
-
|
2240
|
-
|
2241
|
-
|
2242
|
-
|
2243
|
-
|
2244
|
-
|
2245
|
-
|
2246
|
-
|
2247
|
-
|
2248
|
-
|
2249
|
-
|
2250
|
-
|
2251
|
-
|
2252
|
-
|
2253
|
-
|
2254
|
-
|
2255
|
-
|
2256
|
-
|
2257
|
-
|
2258
|
-
|
2259
|
-
|
2260
|
-
|
2261
|
-
|
2262
|
-
|
2263
|
-
|
2264
|
-
|
2265
|
-
|
2266
|
-
|
2267
|
-
|
2268
|
-
|
2269
|
-
|
2270
|
-
|
2271
|
-
|
2272
|
-
|
2273
|
-
|
2274
|
-
|
2275
|
-
|
2276
|
-
@
|
2277
|
-
|
2278
|
-
|
2279
|
-
|
2280
|
-
|
2281
|
-
|
2282
|
-
|
2283
|
-
|
2284
|
-
|
2285
|
-
|
2286
|
-
|
2287
|
-
end
|
1
|
+
#
|
2
|
+
# ae-editor.rb - Arcadia Ruby ide
|
3
|
+
# by Antonio Galeone <antonio-galeone@rubyforge.org>
|
4
|
+
#
|
5
|
+
|
6
|
+
require 'tk'
|
7
|
+
require 'tktext'
|
8
|
+
require 'base/a-tkcommons'
|
9
|
+
|
10
|
+
|
11
|
+
class TreeNode
|
12
|
+
attr_reader :sons
|
13
|
+
attr_reader :parent
|
14
|
+
attr_reader :kind
|
15
|
+
attr_reader :rif, :label, :helptext
|
16
|
+
attr_writer :rif, :label, :helptext
|
17
|
+
def initialize(parent=nil, kind='KClass')
|
18
|
+
@sons = Array.new
|
19
|
+
@parent = parent
|
20
|
+
@kind = kind
|
21
|
+
if @parent !=nil
|
22
|
+
@parent.sons << self
|
23
|
+
end
|
24
|
+
yield(self) if block_given?
|
25
|
+
end
|
26
|
+
|
27
|
+
def <=> (other)
|
28
|
+
self.label.strip <=> other.label.strip
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class AgEditor
|
33
|
+
include Configurable
|
34
|
+
attr_reader :file
|
35
|
+
attr_reader :read_only
|
36
|
+
attr_reader :page_frame
|
37
|
+
attr_reader :text, :root
|
38
|
+
def initialize(_controller, _page_frame)
|
39
|
+
@controller = _controller
|
40
|
+
@page_frame = _page_frame
|
41
|
+
@set_mod = false
|
42
|
+
@font = @controller.conf('font')
|
43
|
+
@font_bold = @controller.conf('font.bold')
|
44
|
+
@font_metrics = TkFont.new(@font).metrics
|
45
|
+
@font_metrics_bold = TkFont.new(@font_bold).metrics
|
46
|
+
@highlighting = false
|
47
|
+
@classbrowsing = false
|
48
|
+
@find = @controller.get_find
|
49
|
+
@read_only=false
|
50
|
+
end
|
51
|
+
|
52
|
+
def initialize_tree(_frame)
|
53
|
+
@classbrowsing = true
|
54
|
+
@nb = Tk::BWidget::NoteBook.new(_frame){
|
55
|
+
tabbevelsize 0
|
56
|
+
internalborderwidth 0
|
57
|
+
activeforeground 'red'
|
58
|
+
activebackground 'yellow'
|
59
|
+
borderwidth 1
|
60
|
+
side $arcadia['conf']['editor.explorer_panel.tabs.side']
|
61
|
+
font $arcadia['conf']['editor.tabs.font']
|
62
|
+
pack('fill'=>'both', :padx=>0, :pady=>0, :expand => 'yes')
|
63
|
+
}
|
64
|
+
@nb_tab_exp = @nb.insert('end','exp' ,'text'=>'Source Tree' )
|
65
|
+
@nb.raise('exp')
|
66
|
+
_tree_goto = proc{|_self|
|
67
|
+
_line = _self.selection_get[0]
|
68
|
+
_index =_line.to_s+'.0'
|
69
|
+
_hinner_text = @tree_exp.itemcget(_line,'text').strip
|
70
|
+
_editor_line = @text.get(_index, _index+ ' lineend')
|
71
|
+
if !_editor_line.include?(_hinner_text)
|
72
|
+
Arcadia.new_msg(self, "... rebuild tree \n")
|
73
|
+
if @tree_thread && @tree_thread.alive?
|
74
|
+
@tree_thread.exit
|
75
|
+
end
|
76
|
+
@tree_thread = Thread.new{
|
77
|
+
build_tree(_line)
|
78
|
+
Tk.update
|
79
|
+
}
|
80
|
+
_line = _self.selection_get[0]
|
81
|
+
_index =_line.to_s+'.0'
|
82
|
+
end
|
83
|
+
@text.see(_index)
|
84
|
+
@text.tag_remove('selected','1.0','end')
|
85
|
+
@text.tag_add('selected',_line.to_s+'.0',(_line+1).to_s+'.0')
|
86
|
+
}
|
87
|
+
@tree_exp = Tk::BWidget::Tree.new(@nb_tab_exp){
|
88
|
+
background '#FFFFFF'
|
89
|
+
relief 'flat'
|
90
|
+
showlines false
|
91
|
+
deltay 18
|
92
|
+
dragenabled true
|
93
|
+
selectcommand proc{ _tree_goto.call(self) }
|
94
|
+
place('relwidth' => 1,'relx' => 0,'x' => '0','y' => '0','relheight' => '1','rely' => 0,'height' => 1,'bordermode' => 'inside','width' => '50')
|
95
|
+
}
|
96
|
+
|
97
|
+
_c_explo = proc{|*args| @tree_exp.yview(*args)}
|
98
|
+
_s_explo = TkScrollbar.new(@nb_tab_exp){|s|
|
99
|
+
width 8
|
100
|
+
command _c_explo
|
101
|
+
}.pack('side'=>'right', 'fill'=>'y')
|
102
|
+
@tree_exp.yscrollcommand proc{|first,last| _s_explo.set first,last}
|
103
|
+
pop_up_menu_tree
|
104
|
+
end
|
105
|
+
|
106
|
+
def pop_up_menu_tree
|
107
|
+
@pop_up_tree = TkMenu.new(
|
108
|
+
:parent=>@tree_exp,
|
109
|
+
:title => 'Menu tree'
|
110
|
+
)
|
111
|
+
@pop_up_tree.insert('end',
|
112
|
+
:command,
|
113
|
+
:label=>'Rebuild',
|
114
|
+
:hidemargin => false,
|
115
|
+
:command=> proc{build_tree}
|
116
|
+
)
|
117
|
+
@tree_exp.bind_append("Button-3",
|
118
|
+
proc{|x,y|
|
119
|
+
_x = TkWinfo.pointerx(@tree_exp)
|
120
|
+
_y = TkWinfo.pointery(@tree_exp)
|
121
|
+
@pop_up_tree.popup(_x,_y)
|
122
|
+
},
|
123
|
+
"%x %y")
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
def initialize_text(_frame)
|
128
|
+
@v_scroll = TkScrollbar.new(_frame,
|
129
|
+
'orient'=>'vertical',
|
130
|
+
'relief'=>'flat'
|
131
|
+
).pack('side' => 'right', 'fill' => 'y')
|
132
|
+
@text = TkText.new(@fm1.right_frame){|j|
|
133
|
+
wrap 'none'
|
134
|
+
relief 'flat'
|
135
|
+
undo true
|
136
|
+
insertofftime 200
|
137
|
+
insertontime 200
|
138
|
+
insertbackground $arcadia['conf']['editor.color.insertbackground']
|
139
|
+
background $arcadia['conf']['editor.color.background']
|
140
|
+
foreground $arcadia['conf']['editor.color.foreground']
|
141
|
+
highlightcolor $arcadia['conf']['editor.color.background']
|
142
|
+
highlightthickness 0
|
143
|
+
insertwidth 3
|
144
|
+
exportselection true
|
145
|
+
autoseparators true
|
146
|
+
padx 0
|
147
|
+
tabs $arcadia['conf']['editor.tabs']
|
148
|
+
place(
|
149
|
+
'x'=>0,
|
150
|
+
'y'=>0,
|
151
|
+
'width' => -15,
|
152
|
+
'relheight'=>1,
|
153
|
+
'relwidth'=>1,
|
154
|
+
'bordermode'=>'outside'
|
155
|
+
)
|
156
|
+
}
|
157
|
+
@text.configure('font', @font);
|
158
|
+
|
159
|
+
do_tag_configure_global('debug')
|
160
|
+
@text.tag_configure('eval','foreground' => 'yellow', 'background' =>'red','borderwidth'=>1, 'relief'=>'raised')
|
161
|
+
@text.tag_configure('errline','borderwidth'=>1, 'relief'=>'groove')
|
162
|
+
#@text.tag_configure('debug', 'background' =>'#b9c6d9', 'borderwidth'=>1 ,'relief'=>'raise')
|
163
|
+
@buffer = text_value
|
164
|
+
pop_up_menu
|
165
|
+
end
|
166
|
+
|
167
|
+
def create_temp_file
|
168
|
+
_file = @file+'~~'
|
169
|
+
f = File.new(@file+'~~', "w")
|
170
|
+
begin
|
171
|
+
if f
|
172
|
+
f.syswrite(text_value)
|
173
|
+
end
|
174
|
+
ensure
|
175
|
+
f.close unless f.nil?
|
176
|
+
end
|
177
|
+
_file
|
178
|
+
end
|
179
|
+
|
180
|
+
def initialize_text_binding
|
181
|
+
@v_scroll.command(proc{|*args|
|
182
|
+
@text.yview *args
|
183
|
+
})
|
184
|
+
@text.yscrollcommand(proc{|first,last| @v_scroll.set(first,last)
|
185
|
+
self.do_line_update()
|
186
|
+
})
|
187
|
+
@text.tag_bind('selected', 'Enter', proc{@text.tag_remove('selected','1.0','end')})
|
188
|
+
|
189
|
+
@text.bind("Enter", proc{check_file_last_access_time})
|
190
|
+
# @text.bind("ButtonPress-1", proc{
|
191
|
+
# _code = $arcadia['rad'].palette.give_me_code
|
192
|
+
# @text.insert('insert', _code) if _code
|
193
|
+
# })
|
194
|
+
|
195
|
+
@text.bind("Control-KeyPress"){|e|
|
196
|
+
case e.keysym
|
197
|
+
when 'space'
|
198
|
+
line, col = @text.index('insert').split('.')
|
199
|
+
_file = create_temp_file
|
200
|
+
#EditorContract.instance.complete_code(self, 'file'=>_file, 'line'=>line.to_s, 'col'=>col.to_s)
|
201
|
+
begin
|
202
|
+
event = Arcadia.process_event(CompleteCodeEvent.new(self, 'file'=>_file, 'row'=>line.to_s, 'col'=>col.to_s))
|
203
|
+
ensure
|
204
|
+
File.delete(_file) if File.exist?(_file)
|
205
|
+
end
|
206
|
+
@controller.raise_complete_code(event)
|
207
|
+
when 'z'
|
208
|
+
_b = @text.index('insert').split('.')[0].to_i
|
209
|
+
@text.edit_undo
|
210
|
+
_e = @text.index('insert').split('.')[0].to_i
|
211
|
+
if @highlighting
|
212
|
+
for j in _b..._e
|
213
|
+
rehighlightline(j)
|
214
|
+
end
|
215
|
+
end
|
216
|
+
break
|
217
|
+
when 'c'
|
218
|
+
@text.text_copy
|
219
|
+
break
|
220
|
+
when 'x'
|
221
|
+
@text.text_cut
|
222
|
+
break
|
223
|
+
when 'v'
|
224
|
+
_b = @text.index('insert').split('.')[0].to_i
|
225
|
+
@text.text_paste
|
226
|
+
_e = @text.index('insert').split('.')[0].to_i
|
227
|
+
if @highlighting
|
228
|
+
for j in _b..._e
|
229
|
+
rehighlightline(j)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
break
|
233
|
+
end
|
234
|
+
case e.keysym
|
235
|
+
when 's'
|
236
|
+
save
|
237
|
+
when 'f'
|
238
|
+
_r = @text.tag_ranges('sel')
|
239
|
+
if _r.length>0
|
240
|
+
_text=@text.get(_r[0][0],_r[0][1])
|
241
|
+
if _text.length > 0
|
242
|
+
@find.e_what.text(_text)
|
243
|
+
end
|
244
|
+
else
|
245
|
+
end
|
246
|
+
@find.use(self)
|
247
|
+
@find.e_what.focus
|
248
|
+
@find.show
|
249
|
+
when 'egrave'
|
250
|
+
@text.insert('insert',"{")
|
251
|
+
when 'plus'
|
252
|
+
@text.insert('insert',"}")
|
253
|
+
end
|
254
|
+
}
|
255
|
+
|
256
|
+
@text.bind("Control-Shift-KeyPress"){|e|
|
257
|
+
case e.keysym
|
258
|
+
when 'I'
|
259
|
+
_r = @text.tag_ranges('sel')
|
260
|
+
_row_begin = _r[0][0].split('.')[0].to_i
|
261
|
+
_row_end = _r[_r.length - 1][1].split('.')[0].to_i
|
262
|
+
n_space = $arcadia['conf']['editor.tab-replace-width-space'].to_i
|
263
|
+
if n_space > 0
|
264
|
+
suf = "\s"*n_space
|
265
|
+
else
|
266
|
+
suf = "\t"
|
267
|
+
end
|
268
|
+
|
269
|
+
for _row in _row_begin..._row_end
|
270
|
+
@text.insert(_row.to_s+'.0',suf)
|
271
|
+
end
|
272
|
+
when 'U'
|
273
|
+
_r = @text.tag_ranges('sel')
|
274
|
+
_row_begin = _r[0][0].split('.')[0].to_i
|
275
|
+
_row_end = _r[_r.length - 1][1].split('.')[0].to_i
|
276
|
+
n_space = $arcadia['conf']['editor.tab-replace-width-space'].to_i
|
277
|
+
if n_space > 0
|
278
|
+
suf = "\s"*n_space
|
279
|
+
else
|
280
|
+
suf = "\t"
|
281
|
+
end
|
282
|
+
_l_suf = suf.length.to_s
|
283
|
+
for _row in _row_begin..._row_end
|
284
|
+
if @text.get(_row.to_s+'.0',_row.to_s+'.'+_l_suf) == suf
|
285
|
+
@text.delete(_row.to_s+'.0',_row.to_s+'.'+_l_suf)
|
286
|
+
end
|
287
|
+
end
|
288
|
+
when 'C'
|
289
|
+
_r = @text.tag_ranges('sel')
|
290
|
+
_row_begin = _r[0][0].split('.')[0].to_i
|
291
|
+
_row_end = _r[_r.length - 1][1].split('.')[0].to_i
|
292
|
+
|
293
|
+
for _row in _row_begin..._row_end
|
294
|
+
if @text.get(_row.to_s+'.0',_row.to_s+'.1') == "#"
|
295
|
+
@text.delete(_row.to_s+'.0',_row.to_s+'.1')
|
296
|
+
else
|
297
|
+
@text.insert(_row.to_s+'.0',"#")
|
298
|
+
end
|
299
|
+
rehighlightline(_row) if @highlighting
|
300
|
+
end
|
301
|
+
|
302
|
+
end
|
303
|
+
}
|
304
|
+
|
305
|
+
@text.bind("KeyPress"){|e|
|
306
|
+
case e.keysym
|
307
|
+
#when 'Return'
|
308
|
+
when 'BackSpace'
|
309
|
+
_index = @text.index('insert')
|
310
|
+
_row, _col = _index.split('.')
|
311
|
+
rehighlightline(_row.to_i) if @highlighting
|
312
|
+
when 'Delete'
|
313
|
+
_index = @text.index('insert')
|
314
|
+
_row, _col = _index.split('.')
|
315
|
+
rehighlightline(_row.to_i) if @highlighting
|
316
|
+
when 'F5'
|
317
|
+
save
|
318
|
+
$arcadia['shell'].run(@file.to_s)
|
319
|
+
when 'F3'
|
320
|
+
@find.do_find_next
|
321
|
+
when 'F1'
|
322
|
+
line, col = @text.index('insert').split('.')
|
323
|
+
_x, _y = @controller.xy_insert
|
324
|
+
_file = create_temp_file
|
325
|
+
begin
|
326
|
+
Arcadia.process_event(DocCodeEvent.new(self, 'file'=>_file, 'row'=>line.to_s, 'col'=>col.to_s, 'xdoc'=>_x, 'ydoc'=>_y))
|
327
|
+
ensure
|
328
|
+
File.delete(_file) if File.exist?(_file)
|
329
|
+
end
|
330
|
+
#EditorContract.instance.doc_code(@controller, 'file'=>_file, 'line'=>line.to_s, 'col'=>col.to_s, 'xdoc'=>_x, 'ydoc'=>_y)
|
331
|
+
when 'Tab'
|
332
|
+
n_space = $arcadia['conf']['editor.tab-replace-width-space'].to_i
|
333
|
+
_r = @text.tag_ranges('sel')
|
334
|
+
if _r && _r[0]
|
335
|
+
_row_begin = _r[0][0].split('.')[0].to_i
|
336
|
+
_row_end = _r[_r.length - 1][1].split('.')[0].to_i
|
337
|
+
if n_space > 0
|
338
|
+
suf = "\s"*n_space
|
339
|
+
else
|
340
|
+
suf = "\t"
|
341
|
+
end
|
342
|
+
for _row in _row_begin..._row_end
|
343
|
+
@text.insert(_row.to_s+'.0', suf)
|
344
|
+
end
|
345
|
+
break
|
346
|
+
elsif n_space > 0
|
347
|
+
@text.insert('insert', "\s"*n_space)
|
348
|
+
break
|
349
|
+
end
|
350
|
+
end
|
351
|
+
}
|
352
|
+
|
353
|
+
@text.bind("KeyRelease"){|e|
|
354
|
+
case e.keysym
|
355
|
+
when 'Control_L','Return', 'Control_V', 'BackSpace', 'Delete'
|
356
|
+
if modified?
|
357
|
+
set_modify
|
358
|
+
else
|
359
|
+
reset_modify
|
360
|
+
end
|
361
|
+
do_line_update
|
362
|
+
when 'Right','Left','Down', 'Up'
|
363
|
+
# do nil
|
364
|
+
else
|
365
|
+
check_modify
|
366
|
+
end
|
367
|
+
|
368
|
+
case e.keysym
|
369
|
+
when 'Return'
|
370
|
+
_index = @text.index('insert')
|
371
|
+
_row, _col = _index.split('.')
|
372
|
+
_txt = @text.get((_row.to_i-1).to_s+'.0',_index)
|
373
|
+
if _txt.length > 0
|
374
|
+
m = /\s*/.match(_txt)
|
375
|
+
if m
|
376
|
+
if (m[0] != "\n")
|
377
|
+
_sm = m[0]
|
378
|
+
_sm = _sm.sub(/\n/,"")
|
379
|
+
@text.insert('insert',_sm)
|
380
|
+
end
|
381
|
+
end
|
382
|
+
end
|
383
|
+
if _row.to_i + 1 == @text.index('end').split('.')[0].to_i
|
384
|
+
do_line_update
|
385
|
+
end
|
386
|
+
else
|
387
|
+
if @highlighting && /\w/.match(e.keysym)
|
388
|
+
rehighlightline(@text.index('insert').split('.')[0].to_i)
|
389
|
+
end
|
390
|
+
end
|
391
|
+
}
|
392
|
+
|
393
|
+
|
394
|
+
@text.bind("Shift-KeyPress"){|e|
|
395
|
+
case e.keysym
|
396
|
+
when 'Tab'
|
397
|
+
_r = @text.tag_ranges('sel')
|
398
|
+
if _r && _r[0]
|
399
|
+
_row_begin = _r[0][0].split('.')[0].to_i
|
400
|
+
_row_end = _r[_r.length - 1][1].split('.')[0].to_i
|
401
|
+
|
402
|
+
n_space = $arcadia['conf']['editor.tab-replace-width-space'].to_i
|
403
|
+
if n_space > 0
|
404
|
+
suf = "\s"*n_space
|
405
|
+
else
|
406
|
+
suf = "\t"
|
407
|
+
n_space = 1
|
408
|
+
end
|
409
|
+
for _row in _row_begin..._row_end
|
410
|
+
if @text.get(_row.to_s+'.0',_row.to_s+'.'+n_space.to_s) == suf
|
411
|
+
@text.delete(_row.to_s+'.0',_row.to_s+'.'+n_space.to_s)
|
412
|
+
end
|
413
|
+
end
|
414
|
+
break
|
415
|
+
end
|
416
|
+
end
|
417
|
+
}
|
418
|
+
|
419
|
+
end
|
420
|
+
|
421
|
+
def initialize_line_number(_frame)
|
422
|
+
@text_line_num = TkText.new(_frame){
|
423
|
+
wrap 'none'
|
424
|
+
relief 'flat'
|
425
|
+
undo false
|
426
|
+
takefocus 0
|
427
|
+
insertofftime 0
|
428
|
+
exportselection true
|
429
|
+
autoseparators true
|
430
|
+
cursor nil
|
431
|
+
insertwidth 0
|
432
|
+
background $arcadia['conf']['editor.line_number_panel.color.background']
|
433
|
+
#background $arcadia['conf']['editor.color.background']
|
434
|
+
foreground $arcadia['conf']['editor.line_number_panel.color.foreground']
|
435
|
+
highlightcolor $arcadia['conf']['editor.line_number_panel.color.background']
|
436
|
+
highlightthickness 0
|
437
|
+
place(
|
438
|
+
'x'=>0,
|
439
|
+
'y'=>0,
|
440
|
+
'relheight'=>1,
|
441
|
+
'relwidth'=>1,
|
442
|
+
'bordermode'=>'outside'
|
443
|
+
)
|
444
|
+
}
|
445
|
+
delta = @font_metrics_bold[2][1]-@font_metrics[2][1]
|
446
|
+
@text_line_num.tag_configure('bold_case', 'spacing1'=>delta)
|
447
|
+
@text_line_num.tag_configure('breakpoint', 'background'=>'red','foreground'=>'yellow','borderwidth'=>1, 'relief'=>'raised')
|
448
|
+
@text_line_num.tag_configure('sel',
|
449
|
+
'background'=>$arcadia['conf']['editor.line_number_panel.color.background'],
|
450
|
+
'foreground'=>$arcadia['conf']['editor.line_number_panel.color.foreground'],
|
451
|
+
'relief'=>'flat'
|
452
|
+
)
|
453
|
+
@text_line_num.bind("Double-ButtonPress-1", proc{|x,y|
|
454
|
+
_index = @text_line_num.index("@#{x},#{y}")
|
455
|
+
_line = @text_line_num.get(_index+' linestart',_index+' lineend').strip
|
456
|
+
if @controller.breakpoint_lines_on_file(@file).include?(_line)
|
457
|
+
@text_line_num.tag_remove('breakpoint',_index+' linestart',_index+' lineend')
|
458
|
+
@controller.breakpoint_del(@file, _line)
|
459
|
+
else
|
460
|
+
@text_line_num.tag_add('breakpoint',_index+' linestart',_index+' lineend')
|
461
|
+
# @text_line_num.tag_add('breakpoint',_index+' linestart',_index+' linestart + 1 chars')
|
462
|
+
@controller.breakpoint_add(@file, _line)
|
463
|
+
end
|
464
|
+
},
|
465
|
+
"%x %y")
|
466
|
+
|
467
|
+
@text_line_num.configure('font', @font);
|
468
|
+
@text_line_num.tag_configure('line_num',
|
469
|
+
'foreground' => '#FFFFFF',
|
470
|
+
'background' =>'#0000a0',
|
471
|
+
'borderwidth'=>2,
|
472
|
+
'relief'=>'raised'
|
473
|
+
)
|
474
|
+
end
|
475
|
+
|
476
|
+
def initialize_highlight
|
477
|
+
if @lang_hash.nil?
|
478
|
+
@highlighting = false
|
479
|
+
return
|
480
|
+
end
|
481
|
+
@highlighting = true
|
482
|
+
@highlight_zone = Hash.new;
|
483
|
+
# @highlight_zone_length = 45;
|
484
|
+
@highlight_zone_length = 60;
|
485
|
+
@last_line_begin = 0
|
486
|
+
@last_line_end = 0
|
487
|
+
@last_zone_begin=0;
|
488
|
+
@last_zone_end=0;
|
489
|
+
@is_line_bold = Hash.new
|
490
|
+
@is_tag_bold = Hash.new
|
491
|
+
|
492
|
+
@h_classes = @lang_hash['classes'].split(',')
|
493
|
+
@h_re = Hash.new
|
494
|
+
@op_to_end_line = Array.new
|
495
|
+
@op_to_end_line.concat(@lang_hash['re_op.to_line_end'].split(',')) if @lang_hash['re_op.to_line_end']
|
496
|
+
|
497
|
+
@op_only_first = Array.new
|
498
|
+
@op_only_first.concat(@lang_hash['re_op.only_first'].split(',')) if @lang_hash['re_op.only_first']
|
499
|
+
|
500
|
+
@h_classes.each{|c|
|
501
|
+
do_tag_configure(c)
|
502
|
+
@h_re[c]=Regexp::new(@lang_hash["re.#{c}"].strip) if @lang_hash["re.#{c}"]
|
503
|
+
}
|
504
|
+
|
505
|
+
['sel','selected','tabs','spaces'].each{|_name|
|
506
|
+
if @lang_hash['hightlight.'+_name+'.foreground']
|
507
|
+
do_tag_configure(_name)
|
508
|
+
else
|
509
|
+
do_tag_configure_global(_name)
|
510
|
+
end
|
511
|
+
}
|
512
|
+
end
|
513
|
+
|
514
|
+
def do_tag_configure(_name)
|
515
|
+
h = Hash.new
|
516
|
+
if @lang_hash['hightlight.'+_name+'.color.foreground']
|
517
|
+
h['foreground']=@lang_hash['hightlight.'+_name+'.color.foreground']
|
518
|
+
end
|
519
|
+
if @lang_hash['hightlight.'+_name+'.color.background']
|
520
|
+
h['background']=@lang_hash['hightlight.'+_name+'.color.background']
|
521
|
+
end
|
522
|
+
if @lang_hash['hightlight.'+_name+'.style']== 'bold'
|
523
|
+
h['font']=@font_bold
|
524
|
+
@is_tag_bold[_name]= true
|
525
|
+
end
|
526
|
+
if @lang_hash['hightlight.'+_name+'.relief']
|
527
|
+
h['relief']=@lang_hash['hightlight.'+_name+'.relief']
|
528
|
+
end
|
529
|
+
if @lang_hash['hightlight.'+_name+'.borderwidth']
|
530
|
+
h['borderwidth']=@lang_hash['hightlight.'+_name+'.borderwidth']
|
531
|
+
end
|
532
|
+
@text.tag_configure(_name, h)
|
533
|
+
end
|
534
|
+
|
535
|
+
|
536
|
+
def do_tag_configure_global(_name)
|
537
|
+
h = Hash.new
|
538
|
+
if $arcadia['conf']['editor.hightlight.'+_name+'.color.foreground']
|
539
|
+
h['foreground']=$arcadia['conf']['editor.hightlight.'+_name+'.color.foreground']
|
540
|
+
end
|
541
|
+
if $arcadia['conf']['editor.hightlight.'+_name+'.color.background']
|
542
|
+
h['background']=$arcadia['conf']['editor.hightlight.'+_name+'.color.background']
|
543
|
+
end
|
544
|
+
if $arcadia['conf']['editor.hightlight.'+_name+'.style']== 'bold'
|
545
|
+
h['font']=@font_bold
|
546
|
+
@is_tag_bold[_name]= true
|
547
|
+
end
|
548
|
+
if $arcadia['conf']['editor.hightlight.'+_name+'.relief']
|
549
|
+
h['relief']=$arcadia['conf']['editor.hightlight.'+_name+'.relief']
|
550
|
+
end
|
551
|
+
if $arcadia['conf']['editor.hightlight.'+_name+'.borderwidth']
|
552
|
+
h['borderwidth']=$arcadia['conf']['editor.hightlight.'+_name+'.borderwidth']
|
553
|
+
end
|
554
|
+
@text.tag_configure(_name, h)
|
555
|
+
end
|
556
|
+
|
557
|
+
def pop_up_menu
|
558
|
+
@pop_up = TkMenu.new(
|
559
|
+
:parent=>@text,
|
560
|
+
:tearoff=>1,
|
561
|
+
:title => 'Menu'
|
562
|
+
)
|
563
|
+
@pop_up.insert('end',
|
564
|
+
:command,
|
565
|
+
:label=>'Save as',
|
566
|
+
:hidemargin => false,
|
567
|
+
:command=> proc{save_as}
|
568
|
+
)
|
569
|
+
@pop_up.insert('end',
|
570
|
+
:command,
|
571
|
+
:label=>'Save',
|
572
|
+
:hidemargin => false,
|
573
|
+
:command=> proc{save}
|
574
|
+
)
|
575
|
+
|
576
|
+
@pop_up.insert('end',
|
577
|
+
:command,
|
578
|
+
:label=>'Close',
|
579
|
+
:hidemargin => false,
|
580
|
+
:command=> proc{@controller.close_editor(self)}
|
581
|
+
)
|
582
|
+
|
583
|
+
@pop_up.insert('end',
|
584
|
+
:command,
|
585
|
+
:label=>'Close others',
|
586
|
+
:hidemargin => false,
|
587
|
+
:command=> proc{@controller.close_others_editor(self)}
|
588
|
+
)
|
589
|
+
|
590
|
+
@pop_up.insert('end',
|
591
|
+
:command,
|
592
|
+
:label=>'Close all',
|
593
|
+
:hidemargin => false,
|
594
|
+
:command=> proc{@controller.close_all_editor(self)}
|
595
|
+
)
|
596
|
+
|
597
|
+
|
598
|
+
@pop_up.insert('end', :separator)
|
599
|
+
|
600
|
+
@pop_up.insert('end',
|
601
|
+
:command,
|
602
|
+
:label=>'Color',
|
603
|
+
:hidemargin => false,
|
604
|
+
:command=> proc{
|
605
|
+
@text.insert('insert',Tk.chooseColor)
|
606
|
+
}
|
607
|
+
)
|
608
|
+
@pop_up.insert('end',
|
609
|
+
:command,
|
610
|
+
:label=>'Font',
|
611
|
+
:hidemargin => false,
|
612
|
+
:command=> proc{
|
613
|
+
@text.insert('insert', $arcadia['action.get.font'].call)
|
614
|
+
}
|
615
|
+
)
|
616
|
+
|
617
|
+
|
618
|
+
@pop_up.insert('end', :separator)
|
619
|
+
|
620
|
+
#---- debug menu
|
621
|
+
_sub_debug = TkMenu.new(
|
622
|
+
:parent=>@pop_up,
|
623
|
+
:tearoff=>0,
|
624
|
+
:title => 'Debug'
|
625
|
+
)
|
626
|
+
|
627
|
+
_sub_debug.insert('end',
|
628
|
+
:command,
|
629
|
+
:label=>'Eval selected',
|
630
|
+
:hidemargin => false,
|
631
|
+
:command=> proc{
|
632
|
+
_r = @text.tag_ranges('sel')
|
633
|
+
if _r.length>0
|
634
|
+
_text=@text.get(_r[0][0],_r[0][1])
|
635
|
+
if _text.length > 0
|
636
|
+
Arcadia.process_event(EvalExpressionEvent.new(self, 'expression'=>_text))
|
637
|
+
#EditorContract.instance.eval_expression(self, 'text'=>_text)
|
638
|
+
end
|
639
|
+
end
|
640
|
+
}
|
641
|
+
)
|
642
|
+
|
643
|
+
@pop_up.insert('end',
|
644
|
+
:cascade,
|
645
|
+
:label=>'Debug',
|
646
|
+
:menu=>_sub_debug,
|
647
|
+
:hidemargin => false
|
648
|
+
)
|
649
|
+
|
650
|
+
|
651
|
+
#---- code menu
|
652
|
+
_sub_code = TkMenu.new(
|
653
|
+
:parent=>@pop_up,
|
654
|
+
:tearoff=>0,
|
655
|
+
:title => 'Code'
|
656
|
+
)
|
657
|
+
|
658
|
+
_sub_code.insert('end',
|
659
|
+
:command,
|
660
|
+
:label=>'Set wrap',
|
661
|
+
:hidemargin => false,
|
662
|
+
:command=> proc{@text.configure('wrap'=>'word')}
|
663
|
+
)
|
664
|
+
|
665
|
+
_sub_code.insert('end',
|
666
|
+
:command,
|
667
|
+
:label=>'Set no wrap',
|
668
|
+
:hidemargin => false,
|
669
|
+
:command=> proc{@text.configure('wrap'=>'none')}
|
670
|
+
)
|
671
|
+
|
672
|
+
_sub_code.insert('end',
|
673
|
+
:command,
|
674
|
+
:label=>'Show tabs',
|
675
|
+
:hidemargin => false,
|
676
|
+
:command=> proc{show_tabs}
|
677
|
+
)
|
678
|
+
|
679
|
+
|
680
|
+
_sub_code.insert('end',
|
681
|
+
:command,
|
682
|
+
:label=>'Hide tabs',
|
683
|
+
:hidemargin => false,
|
684
|
+
:command=> proc{hide_tabs}
|
685
|
+
)
|
686
|
+
|
687
|
+
_sub_code.insert('end',
|
688
|
+
:command,
|
689
|
+
:label=>'Show spaces',
|
690
|
+
:hidemargin => false,
|
691
|
+
:command=> proc{show_spaces}
|
692
|
+
)
|
693
|
+
|
694
|
+
|
695
|
+
_sub_code.insert('end',
|
696
|
+
:command,
|
697
|
+
:label=>'Hide spaces',
|
698
|
+
:hidemargin => false,
|
699
|
+
:command=> proc{hide_spaces}
|
700
|
+
)
|
701
|
+
|
702
|
+
|
703
|
+
_sub_code.insert('end',
|
704
|
+
:command,
|
705
|
+
:label=>'Space to tabs indentation',
|
706
|
+
:hidemargin => false,
|
707
|
+
:command=> proc{indentation_space_2_tabs}
|
708
|
+
)
|
709
|
+
|
710
|
+
_sub_code.insert('end',
|
711
|
+
:command,
|
712
|
+
:label=>'Tabs to space indentation',
|
713
|
+
:hidemargin => false,
|
714
|
+
:command=> proc{indentation_tabs_2_space}
|
715
|
+
)
|
716
|
+
|
717
|
+
|
718
|
+
@pop_up.insert('end',
|
719
|
+
:cascade,
|
720
|
+
:label=>'Code',
|
721
|
+
:menu=>_sub_code,
|
722
|
+
:hidemargin => false
|
723
|
+
)
|
724
|
+
|
725
|
+
|
726
|
+
|
727
|
+
|
728
|
+
@text.bind("Button-3",
|
729
|
+
proc{|x,y|
|
730
|
+
_x = TkWinfo.pointerx(@text)
|
731
|
+
_y = TkWinfo.pointery(@text)
|
732
|
+
@pop_up.popup(_x,_y)
|
733
|
+
},
|
734
|
+
"%x %y")
|
735
|
+
end
|
736
|
+
|
737
|
+
def unmark_debug(_index)
|
738
|
+
@text.tag_remove('debug',_index +' linestart', _index +' +1 lines linestart')
|
739
|
+
#@text.tag_remove('debug',_index+' linestart', _index+' lineend')
|
740
|
+
end
|
741
|
+
|
742
|
+
def mark_debug(_index)
|
743
|
+
@text.tag_add('debug',_index +' linestart', _index +' +1 lines linestart')
|
744
|
+
#@text.tag_add('debug',_index +' linestart', _index +' lineend')
|
745
|
+
end
|
746
|
+
|
747
|
+
def mark_selected(_index)
|
748
|
+
@text.tag_remove('selected','1.0', 'end')
|
749
|
+
@text.tag_add('selected',_index +' linestart', _index +' +1 lines linestart')
|
750
|
+
end
|
751
|
+
|
752
|
+
|
753
|
+
def build_tree_from_source(_source)
|
754
|
+
_row = 1
|
755
|
+
_liv = 0
|
756
|
+
_livs = Array.new
|
757
|
+
root = TreeNode.new(nil, 'KRoot'){|_node|
|
758
|
+
_node.rif= 'root'
|
759
|
+
_node.label=''
|
760
|
+
}
|
761
|
+
_livs[_liv]=root
|
762
|
+
_source.each_line{|line|
|
763
|
+
line = "\s"+line.split("#")[0]+"\s"
|
764
|
+
m = /[\s\n\t\;]+(module|class|def|if|unless|begin|case|for|while|do)[\s\n\t\;]+/.match(line)
|
765
|
+
if m
|
766
|
+
index = m.post_match.strip.length - 1
|
767
|
+
if m.post_match.strip[index,index]=='{'
|
768
|
+
_row = _row +1
|
769
|
+
next
|
770
|
+
end
|
771
|
+
_liv>=0? _liv = _liv + 1:_liv=1
|
772
|
+
_pliv = _liv
|
773
|
+
_parent = nil
|
774
|
+
while (_parent == nil && _pliv>=0)
|
775
|
+
_pliv = _pliv -1
|
776
|
+
_parent = _livs[_pliv]
|
777
|
+
end
|
778
|
+
if _parent
|
779
|
+
_helptext = m.post_match.strip
|
780
|
+
_label = _helptext.split('<')[0]
|
781
|
+
if _label == nil || _label.strip.length==0
|
782
|
+
_label = _helptext
|
783
|
+
end
|
784
|
+
if (m[0].strip[0..4] == "class" && m.pre_match.strip.length==0)
|
785
|
+
_kind = 'KClass'
|
786
|
+
elsif (m[0].strip[0..4] == "class" && m.pre_match.strip.length>0)
|
787
|
+
_row = _row +1
|
788
|
+
_liv = _liv - 1
|
789
|
+
next
|
790
|
+
elsif (m[0].strip[0..5] == "module" && m.pre_match.strip.length==0)
|
791
|
+
_kind = 'KModule'
|
792
|
+
elsif (m[0].strip[0..5] == "module" && m.pre_match.strip.length>0)
|
793
|
+
_row = _row +1
|
794
|
+
_liv = _liv - 1
|
795
|
+
next
|
796
|
+
elsif ((m[0].strip[0..4] == "begin")||(m[0].strip[0..3] == "case") ||(m[0].strip[0..4] == "while") || (m[0].strip[0..2] == "for") || (m[0].strip[0..1] == "do") || ((m[0].strip[0..1] == "if" || m[0].strip[0..5] == "unless") && m.pre_match.strip.length==0))
|
797
|
+
_row = _row +1
|
798
|
+
next
|
799
|
+
elsif ((m[0].strip[0..1] == "if" || m[0].strip[0..5] == "unless") && m.pre_match.strip.length>0)
|
800
|
+
_row = _row +1
|
801
|
+
_liv = _liv - 1
|
802
|
+
next
|
803
|
+
elsif (m[0].strip[0..2] == "def" && m.pre_match.strip.length==0)
|
804
|
+
_kind = 'KDef'
|
805
|
+
if _label.include?(_parent.label + '.')
|
806
|
+
_kind = 'KDefClass'
|
807
|
+
end
|
808
|
+
# elsif (m[0].strip[0..10] == "attr_reader" && m.pre_match.strip.length==0)
|
809
|
+
# _kind = 'KAttr_reader'
|
810
|
+
# _liv = _liv - 1
|
811
|
+
# _row = _row +1
|
812
|
+
end
|
813
|
+
|
814
|
+
TreeNode.new(_parent, _kind){|_node|
|
815
|
+
_node.label = _label
|
816
|
+
_node.helptext = _helptext
|
817
|
+
_node.rif = _row.to_s
|
818
|
+
_livs[_pliv + 1]=_node
|
819
|
+
}
|
820
|
+
else
|
821
|
+
_row = _row +1
|
822
|
+
_liv = _liv - 1
|
823
|
+
next
|
824
|
+
end
|
825
|
+
end
|
826
|
+
m_end = /[\s\n\t\;]+end[\s\n\t\;]+/.match(line)
|
827
|
+
if m_end
|
828
|
+
_liv = _liv - 1
|
829
|
+
end
|
830
|
+
_row = _row +1
|
831
|
+
}
|
832
|
+
return root
|
833
|
+
end
|
834
|
+
|
835
|
+
def build_tree_from_node(_node, _label_match=nil)
|
836
|
+
|
837
|
+
@image_kclass = TkPhotoImage.new('dat' => TREE_NODE_CLASS_GIF)
|
838
|
+
@image_kmodule = TkPhotoImage.new('dat' => TREE_NODE_MODULE_GIF)
|
839
|
+
@image_kdef = TkPhotoImage.new('dat' => TREE_NODE_DEF_GIF)
|
840
|
+
@image_kdefclass = TkPhotoImage.new('dat' => TREE_NODE_DEFCLASS_GIF)
|
841
|
+
|
842
|
+
_sorted_sons = _node.sons.sort
|
843
|
+
for inode in 0.._sorted_sons.length - 1
|
844
|
+
_son = _sorted_sons[inode]
|
845
|
+
if _son.kind == 'KClass'
|
846
|
+
_image = @image_kclass
|
847
|
+
elsif _son.kind == 'KModule'
|
848
|
+
_image = @image_kmodule
|
849
|
+
elsif _son.kind == 'KDef'
|
850
|
+
_image = @image_kdef
|
851
|
+
elsif _son.kind == 'KDefClass'
|
852
|
+
_image = @image_kdefclass
|
853
|
+
end
|
854
|
+
@tree_exp.insert('end', _son.parent.rif ,_son.rif, {
|
855
|
+
'text' => _son.label ,
|
856
|
+
'helptext' => _son.helptext,
|
857
|
+
'font'=>$arcadia['conf']['editor.explorer_panel.tree.font'],
|
858
|
+
'image'=> _image
|
859
|
+
}
|
860
|
+
)
|
861
|
+
if (_label_match) && (_label_match.strip == _son.label.strip)
|
862
|
+
@selected = _son
|
863
|
+
end
|
864
|
+
build_tree_from_node(_son, _label_match)
|
865
|
+
end
|
866
|
+
end
|
867
|
+
|
868
|
+
def build_tree(_sel=nil)
|
869
|
+
if _sel
|
870
|
+
_label_sel = @tree_exp.itemcget(_sel,'text')
|
871
|
+
end
|
872
|
+
|
873
|
+
#clear tree
|
874
|
+
begin
|
875
|
+
@tree_exp.delete(@tree_exp.nodes('root'))
|
876
|
+
rescue Exception
|
877
|
+
# workaround on windows
|
878
|
+
@tree_exp.delete(@tree_exp.nodes('root'))
|
879
|
+
end
|
880
|
+
|
881
|
+
|
882
|
+
#(re)build tree
|
883
|
+
_txt = @text.get('1.0','end')
|
884
|
+
@root = build_tree_from_source(_txt)
|
885
|
+
@selected = nil
|
886
|
+
build_tree_from_node(@root, _label_sel)
|
887
|
+
if @selected
|
888
|
+
@tree_exp.selection_add(@selected.rif)
|
889
|
+
@tree_exp.open_tree(@selected.parent.rif)
|
890
|
+
@tree_exp.see(@selected.rif)
|
891
|
+
end
|
892
|
+
end
|
893
|
+
|
894
|
+
def insert_popup_menu_item(_where, *args)
|
895
|
+
@pop_up.insert(_where,*args)
|
896
|
+
end
|
897
|
+
|
898
|
+
def text_value
|
899
|
+
return @text.value
|
900
|
+
end
|
901
|
+
|
902
|
+
# vertical scrollbar : ON/OFF
|
903
|
+
def vscroll(mode)
|
904
|
+
st = TkGrid.info(@v_scroll)
|
905
|
+
if mode && st == [] then
|
906
|
+
@v_scroll.grid('row'=>0, 'column'=>1, 'sticky'=>'ns')
|
907
|
+
elsif !mode && st != [] then
|
908
|
+
@v_scroll.ungrid
|
909
|
+
end
|
910
|
+
self
|
911
|
+
end
|
912
|
+
|
913
|
+
# horizontal scrollbar : ON/OFF
|
914
|
+
def hscroll(mode, wrap_mode="char")
|
915
|
+
st = TkGrid.info(@h_scroll)
|
916
|
+
if mode && st == [] then
|
917
|
+
@h_scroll.grid('row'=>1, 'column'=>0, 'sticky'=>'ew')
|
918
|
+
@text.configure('wrap'=> 'none')
|
919
|
+
elsif !mode && st != [] then
|
920
|
+
@h_scroll.ungrid
|
921
|
+
@text.configure('wrap'=> wrap_mode)
|
922
|
+
end
|
923
|
+
self
|
924
|
+
end
|
925
|
+
|
926
|
+
def rowcol(_index, _gap_row = nil, _gap_col = nil)
|
927
|
+
_riga, _colonna = _index.split('.')
|
928
|
+
if _gap_row == nil
|
929
|
+
_riga = '1'
|
930
|
+
_gap_row = 0
|
931
|
+
end
|
932
|
+
if _gap_col == nil
|
933
|
+
_colonna = '0'
|
934
|
+
_gap_col = 0
|
935
|
+
end
|
936
|
+
return (_riga.to_i + _gap_row).to_s + '.'+ (_colonna.to_i + _gap_col).to_s
|
937
|
+
end
|
938
|
+
|
939
|
+
def find_and_set_tag_ml(_re, _row, _txt, _tag, _tag_rem = nil)
|
940
|
+
m = _re.match(_txt)
|
941
|
+
_offset = 0
|
942
|
+
_s_txt = _txt
|
943
|
+
#_old_txt = ''
|
944
|
+
while m && (_txt=m.post_match)
|
945
|
+
if !defined?(_old_txt) || _txt != _old_txt
|
946
|
+
|
947
|
+
apos = pos_to_index(_s_txt, _offset+m.begin(0))
|
948
|
+
_offset = _offset + m.end(0)
|
949
|
+
|
950
|
+
|
951
|
+
_old_txt = _txt
|
952
|
+
_r = _row + apos[0]
|
953
|
+
_ibegin = _r.to_s+'.'+apos[1].to_s
|
954
|
+
_iend = _r.to_s+'.'+(apos[1]+m.end(0)-m.begin(0)).to_s
|
955
|
+
if _tag_rem
|
956
|
+
_tag_rem.each {|value|
|
957
|
+
@text.tag_remove(value,_ibegin, _iend)
|
958
|
+
}
|
959
|
+
end
|
960
|
+
@text.tag_add(_tag,_ibegin, _iend)
|
961
|
+
if @is_tag_bold[_tag]
|
962
|
+
@is_line_bold[_r]=true
|
963
|
+
end
|
964
|
+
|
965
|
+
if @op_only_first.include?(_tag) && _txt
|
966
|
+
#eliminino la prima riga a partire dal risultato
|
967
|
+
_p = _txt.index("\n")+1
|
968
|
+
if _p
|
969
|
+
_txt = _txt[_p..-1]
|
970
|
+
_offset = _offset + _p
|
971
|
+
else
|
972
|
+
m = nil
|
973
|
+
end
|
974
|
+
end
|
975
|
+
m = _re.match(_txt)
|
976
|
+
|
977
|
+
else
|
978
|
+
m = nil
|
979
|
+
end
|
980
|
+
end
|
981
|
+
end
|
982
|
+
|
983
|
+
|
984
|
+
def find_and_set_tag(_re, _row, _txt, _tag, _tag_rem = nil)
|
985
|
+
m = _re.match(_txt)
|
986
|
+
_end = 0
|
987
|
+
if m && @is_tag_bold[_tag]
|
988
|
+
@is_line_bold[_row]=true
|
989
|
+
end
|
990
|
+
#_old_txt = ''
|
991
|
+
while m && (_txt=m.post_match)
|
992
|
+
if !defined?(_old_txt) || _txt != _old_txt
|
993
|
+
_old_txt = _txt
|
994
|
+
_ibegin = _row.to_s+'.'+(m.begin(0)+_end).to_s
|
995
|
+
_end = m.end(0) + _end
|
996
|
+
_iend = _row.to_s+'.'+(_end.to_s)
|
997
|
+
if _tag_rem
|
998
|
+
_tag_rem.each {|value|
|
999
|
+
@text.tag_remove(value,_ibegin, _iend)
|
1000
|
+
}
|
1001
|
+
end
|
1002
|
+
@text.tag_add(_tag,_ibegin, _iend)
|
1003
|
+
if @op_only_first.include?(_tag)
|
1004
|
+
m = nil
|
1005
|
+
else
|
1006
|
+
m = _re.match(_txt)
|
1007
|
+
end
|
1008
|
+
else
|
1009
|
+
m = nil
|
1010
|
+
end
|
1011
|
+
end
|
1012
|
+
end
|
1013
|
+
|
1014
|
+
def show_spaces
|
1015
|
+
@spaces_show = true
|
1016
|
+
_row = 1
|
1017
|
+
@text.value.each{|_line|
|
1018
|
+
show_chars_line(_row, _line, /[ ^\t]\s*/, 'spaces')
|
1019
|
+
_row = _row+1
|
1020
|
+
}
|
1021
|
+
end
|
1022
|
+
|
1023
|
+
|
1024
|
+
def show_tabs
|
1025
|
+
@tabs_show = true
|
1026
|
+
_row = 1
|
1027
|
+
@text.value.each{|_line|
|
1028
|
+
show_chars_line(_row, _line, /\t/, 'tabs')
|
1029
|
+
_row = _row+1
|
1030
|
+
}
|
1031
|
+
end
|
1032
|
+
|
1033
|
+
|
1034
|
+
def show_chars_line(_row, _line, _re, _tag)
|
1035
|
+
m = _re.match(_line)
|
1036
|
+
_end = 0
|
1037
|
+
while m
|
1038
|
+
_txt = m.post_match
|
1039
|
+
_ibegin = _row.to_s+'.'+(m.begin(0)+_end).to_s
|
1040
|
+
_end = m.end(0) + _end
|
1041
|
+
_iend = _row.to_s+'.'+(_end.to_s)
|
1042
|
+
@text.tag_add(_tag,_ibegin, _iend)
|
1043
|
+
m = _re.match(_txt)
|
1044
|
+
end
|
1045
|
+
end
|
1046
|
+
|
1047
|
+
def indentation_space_2_tabs(_n_space=2)
|
1048
|
+
_row = 1
|
1049
|
+
@text.value.each{|_line|
|
1050
|
+
m = /\s*/.match(_line)
|
1051
|
+
_end = 0
|
1052
|
+
if m && m.begin(0)==0
|
1053
|
+
_s = m[0]
|
1054
|
+
if !_s.include?("\n") && !_s.include?("\t")
|
1055
|
+
_ibegin = _row.to_s+'.0'
|
1056
|
+
_iend = _row.to_s+'.'+m.end(0).to_s
|
1057
|
+
_n_tab = (_s.length / _n_space).round
|
1058
|
+
@text.delete(_ibegin, _iend)
|
1059
|
+
@text.insert(_ibegin,"\t"*_n_tab )
|
1060
|
+
end
|
1061
|
+
end
|
1062
|
+
_row = _row+1
|
1063
|
+
}
|
1064
|
+
check_modify
|
1065
|
+
end
|
1066
|
+
|
1067
|
+
def indentation_tabs_2_space(_n_space=2)
|
1068
|
+
_row = 1
|
1069
|
+
@text.value.each{|_line|
|
1070
|
+
m = /\t*/.match(_line)
|
1071
|
+
_end = 0
|
1072
|
+
if m && m.begin(0)==0
|
1073
|
+
_s = m[0]
|
1074
|
+
if !_s.include?("\n")
|
1075
|
+
_ibegin = _row.to_s+'.0'
|
1076
|
+
_iend = _row.to_s+'.'+m.end(0).to_s
|
1077
|
+
@text.delete(_ibegin, _iend)
|
1078
|
+
@text.insert(_ibegin,"\s"*_s.length*_n_space )
|
1079
|
+
end
|
1080
|
+
end
|
1081
|
+
_row = _row+1
|
1082
|
+
}
|
1083
|
+
check_modify
|
1084
|
+
end
|
1085
|
+
|
1086
|
+
|
1087
|
+
def hide_tabs
|
1088
|
+
@text.tag_remove('tabs','1.0', 'end')
|
1089
|
+
@tabs_show = false
|
1090
|
+
end
|
1091
|
+
|
1092
|
+
def hide_spaces
|
1093
|
+
@text.tag_remove('spaces','1.0', 'end')
|
1094
|
+
@spaces_show = false
|
1095
|
+
end
|
1096
|
+
|
1097
|
+
|
1098
|
+
def modified?
|
1099
|
+
return !(@buffer === text_value)
|
1100
|
+
end
|
1101
|
+
|
1102
|
+
def set_modify
|
1103
|
+
if !@set_mod
|
1104
|
+
@set_mod = true
|
1105
|
+
@controller.change_tab_set_modify(@page_frame)
|
1106
|
+
end
|
1107
|
+
end
|
1108
|
+
|
1109
|
+
def reset_modify
|
1110
|
+
@controller.change_tab_reset_modify(@page_frame)
|
1111
|
+
@set_mod = false
|
1112
|
+
@file_last_access_time = File.mtime(@file) if @file
|
1113
|
+
end
|
1114
|
+
|
1115
|
+
def pos_to_index(_txt, _pos)
|
1116
|
+
_a= _txt[0.._pos].split("\n")
|
1117
|
+
if _a && _a.length > 0
|
1118
|
+
_row = _a.length
|
1119
|
+
if _a.length == 2
|
1120
|
+
_col = _a[-1].length - 1
|
1121
|
+
else
|
1122
|
+
_col = _pos
|
1123
|
+
end
|
1124
|
+
return [_row,_col]
|
1125
|
+
else
|
1126
|
+
return nil
|
1127
|
+
end
|
1128
|
+
end
|
1129
|
+
|
1130
|
+
def highlightlines(_row, _lines, _check_mod = false)
|
1131
|
+
if _check_mod
|
1132
|
+
check_modify
|
1133
|
+
end
|
1134
|
+
_txt = _lines
|
1135
|
+
_end = 0
|
1136
|
+
|
1137
|
+
# @op_to_end_line.each{|c|
|
1138
|
+
# if @h_re[c]
|
1139
|
+
# m_c = @h_re[c].match(_txt)
|
1140
|
+
# if m_c then
|
1141
|
+
# _ibegin = _row.to_s+'.'+(m_c.begin(0)).to_s
|
1142
|
+
# _iend = _row.to_s+'.'+(_line.length - 1).to_s
|
1143
|
+
# @text.tag_add(c,_ibegin, _iend)
|
1144
|
+
# _txt = m_c.pre_match
|
1145
|
+
# end
|
1146
|
+
# end
|
1147
|
+
# } if @lang_hash['re_op.to_line_end']
|
1148
|
+
|
1149
|
+
arem = Array.new
|
1150
|
+
|
1151
|
+
|
1152
|
+
@h_classes.each{|c|
|
1153
|
+
if !@op_to_end_line.include?(c) && @h_re[c]
|
1154
|
+
find_and_set_tag_ml(@h_re[c], _row, _txt, c, arem)
|
1155
|
+
arem << c
|
1156
|
+
end
|
1157
|
+
} if _txt.strip.length > 0
|
1158
|
+
|
1159
|
+
find_and_set_tag_ml(/\t/, _row, _txt, 'tabs', arem) if @tabs_show
|
1160
|
+
find_and_set_tag_ml(/[ ^\t]\s*/, _row, _txt, 'spaces', arem) if @spaces_show
|
1161
|
+
end
|
1162
|
+
|
1163
|
+
|
1164
|
+
def highlightline(_row, _line, _check_mod = false)
|
1165
|
+
if _check_mod
|
1166
|
+
check_modify
|
1167
|
+
end
|
1168
|
+
_txt = _line
|
1169
|
+
_end = 0
|
1170
|
+
|
1171
|
+
@op_to_end_line.each{|c|
|
1172
|
+
if @h_re[c]
|
1173
|
+
m_c = @h_re[c].match(_txt)
|
1174
|
+
if m_c then
|
1175
|
+
_ibegin = _row.to_s+'.'+(m_c.begin(0)).to_s
|
1176
|
+
_iend = _row.to_s+'.'+(_line.length - 1).to_s
|
1177
|
+
@text.tag_add(c,_ibegin, _iend)
|
1178
|
+
_txt = m_c.pre_match
|
1179
|
+
end
|
1180
|
+
end
|
1181
|
+
} if @lang_hash['re_op.to_line_end']
|
1182
|
+
|
1183
|
+
arem = Array.new
|
1184
|
+
|
1185
|
+
|
1186
|
+
@h_classes.each{|c|
|
1187
|
+
if !@op_to_end_line.include?(c) && @h_re[c]
|
1188
|
+
find_and_set_tag(@h_re[c], _row, _txt, c, arem)
|
1189
|
+
arem << c
|
1190
|
+
end
|
1191
|
+
} if _txt.strip.length > 0
|
1192
|
+
|
1193
|
+
find_and_set_tag(/\t/, _row, _txt, 'tabs', arem) if @tabs_show
|
1194
|
+
find_and_set_tag(/[ ^\t]\s*/, _row, _txt, 'spaces', arem) if @spaces_show
|
1195
|
+
end
|
1196
|
+
|
1197
|
+
def rehighlightline(_row)
|
1198
|
+
_ibegin = _row.to_s+'.0'
|
1199
|
+
_iend = (_row+1).to_s+'.0'
|
1200
|
+
@h_classes.each{|c| @text.tag_remove(c,_ibegin, _iend)}
|
1201
|
+
_line = @text.get(_ibegin, _iend)
|
1202
|
+
highlightline(_row, _line)
|
1203
|
+
end
|
1204
|
+
|
1205
|
+
def rehighlightlines(_row_begin, _row_end)
|
1206
|
+
_ibegin = _row_begin.to_s+'.0'
|
1207
|
+
_iend = (_row_end+1).to_s+'.0'
|
1208
|
+
@h_classes.each{|c| @text.tag_remove(c,_ibegin, _iend)}
|
1209
|
+
_lines = @text.get(_ibegin, _iend)
|
1210
|
+
highlightlines(_row_begin, _lines)
|
1211
|
+
end
|
1212
|
+
|
1213
|
+
|
1214
|
+
def row(_index='insert')
|
1215
|
+
_row = @text.index(_index).split('.')[0].to_i
|
1216
|
+
#print "def row(_index='insert')",_row.to_s,"\n"
|
1217
|
+
return _row
|
1218
|
+
end
|
1219
|
+
|
1220
|
+
def do_line_update
|
1221
|
+
#re num in @text_line_num the portion of visibled screen of @text
|
1222
|
+
if @text_line_num
|
1223
|
+
line_begin = @text.index('@0,0').split('.')[0].to_i
|
1224
|
+
line_end = @text.index('@0,'+TkWinfo.height(@text).to_s).split('.')[0].to_i + 1
|
1225
|
+
# breakpoint
|
1226
|
+
b = @controller.breakpoint_lines_on_file(@file)
|
1227
|
+
@text_line_num.delete('1.0','end')
|
1228
|
+
for j in line_begin...line_end
|
1229
|
+
#nline = j.to_s.rjust(6)
|
1230
|
+
nline = j.to_s.rjust(7)
|
1231
|
+
_index = @text_line_num.index('end')
|
1232
|
+
if @highlighting && @is_line_bold[j]
|
1233
|
+
@text_line_num.insert('end', "#{nline}\n",'bold_case')
|
1234
|
+
else
|
1235
|
+
@text_line_num.insert('end', "#{nline}\n")
|
1236
|
+
end
|
1237
|
+
if b.include?(j.to_s)
|
1238
|
+
@text_line_num.tag_add('breakpoint',_index+' -1 lines',_index+' -1 lines lineend')
|
1239
|
+
end
|
1240
|
+
end
|
1241
|
+
|
1242
|
+
if @highlighting
|
1243
|
+
_zone_begin = ((line_begin) / @highlight_zone_length).to_i + 1
|
1244
|
+
_zone_end = ((line_end) / @highlight_zone_length).to_i + 1
|
1245
|
+
(_zone_begin >=@last_zone_begin)?_zone_begin.upto(_zone_end+1){|_zone|
|
1246
|
+
highlight_zone(_zone)
|
1247
|
+
}:_zone_end.downto(_zone_begin-1){|_zone|
|
1248
|
+
highlight_zone(_zone)
|
1249
|
+
}
|
1250
|
+
@last_line_begin = line_begin
|
1251
|
+
@last_line_end = line_end
|
1252
|
+
@last_zone_begin = _zone_begin
|
1253
|
+
@last_zone_end = _zone_end
|
1254
|
+
end
|
1255
|
+
end
|
1256
|
+
end
|
1257
|
+
|
1258
|
+
def highlight_zone_new(_zone)
|
1259
|
+
if !@highlight_zone[_zone]
|
1260
|
+
_b = @highlight_zone_length*(_zone - 1)
|
1261
|
+
_e = @highlight_zone_length*(_zone) #+ 1
|
1262
|
+
rehighlightlines(_b,_e)
|
1263
|
+
@highlight_zone[_zone] = true
|
1264
|
+
end
|
1265
|
+
end
|
1266
|
+
|
1267
|
+
|
1268
|
+
def highlight_zone(_zone)
|
1269
|
+
if !@highlight_zone[_zone]
|
1270
|
+
_b = @highlight_zone_length*(_zone - 1)
|
1271
|
+
_e = @highlight_zone_length*(_zone) #+ 1
|
1272
|
+
for j in _b..._e
|
1273
|
+
rehighlightline(j)
|
1274
|
+
end
|
1275
|
+
@highlight_zone[_zone] = true
|
1276
|
+
end
|
1277
|
+
end
|
1278
|
+
|
1279
|
+
def text_see(_index=nil)
|
1280
|
+
if _index
|
1281
|
+
@text.see(_index)
|
1282
|
+
end
|
1283
|
+
end
|
1284
|
+
|
1285
|
+
def text_insert_index
|
1286
|
+
@text.index('insert')
|
1287
|
+
end
|
1288
|
+
|
1289
|
+
def text_insert(index, chars, *tags, &b)
|
1290
|
+
if block_given?
|
1291
|
+
instance_eval(&b)
|
1292
|
+
end
|
1293
|
+
_index = @text.index(index)
|
1294
|
+
_row, _col = _index.split('.')
|
1295
|
+
_row = (_row.to_i - 1).to_s
|
1296
|
+
chars.each_line {|line|
|
1297
|
+
@text.insert(_row+'.0', line, *tags)
|
1298
|
+
if !defined?(m_begin)||(m_begin == nil)
|
1299
|
+
m_begin = /=begin/.match(line)
|
1300
|
+
end
|
1301
|
+
if @highlighting
|
1302
|
+
if m_begin &&(m_begin.begin(0)==0)
|
1303
|
+
_ibegin = _row+'.0'
|
1304
|
+
_iend = _row+'.'+(line.length - 1).to_s
|
1305
|
+
@text.tag_add('comment',_ibegin, _iend)
|
1306
|
+
else
|
1307
|
+
highlightline(_row.to_i, line, false)
|
1308
|
+
end
|
1309
|
+
end
|
1310
|
+
_row = (_row.to_i + 1).to_s
|
1311
|
+
}
|
1312
|
+
if defined?(_edit_reset)
|
1313
|
+
if _edit_reset
|
1314
|
+
@text.edit_reset
|
1315
|
+
end
|
1316
|
+
else
|
1317
|
+
@text.edit_reset
|
1318
|
+
end
|
1319
|
+
end
|
1320
|
+
|
1321
|
+
def save
|
1322
|
+
if !@file
|
1323
|
+
save_as
|
1324
|
+
else
|
1325
|
+
f = File.new(@file, "w")
|
1326
|
+
begin
|
1327
|
+
if f
|
1328
|
+
f.syswrite(text_value)
|
1329
|
+
@buffer = text_value
|
1330
|
+
reset_modify
|
1331
|
+
end
|
1332
|
+
ensure
|
1333
|
+
f.close unless f.nil?
|
1334
|
+
end
|
1335
|
+
#EditorContract.instance.file_saved(self,'file' =>@file)
|
1336
|
+
end
|
1337
|
+
end
|
1338
|
+
|
1339
|
+
def save_as
|
1340
|
+
@file = Tk.getSaveFile("filetypes"=>[["Ruby Files", [".rb", ".rbw"]]])
|
1341
|
+
@file = nil if @file == "" # cancelled
|
1342
|
+
if @file
|
1343
|
+
save
|
1344
|
+
@controller.change_file_name(@page_frame, @file)
|
1345
|
+
#EditorContract.instance.file_created(self, 'file'=>@file)
|
1346
|
+
end
|
1347
|
+
end
|
1348
|
+
|
1349
|
+
def check_modify
|
1350
|
+
if modified?
|
1351
|
+
set_modify if !@set_mod
|
1352
|
+
else
|
1353
|
+
reset_modify
|
1354
|
+
end
|
1355
|
+
end
|
1356
|
+
|
1357
|
+
def check_file_last_access_time
|
1358
|
+
if @file && @file_last_access_time
|
1359
|
+
|
1360
|
+
ftime = File.mtime(@file)
|
1361
|
+
if @file_last_access_time != ftime
|
1362
|
+
msg = 'File "'+@file+'" is changed! Reload?'
|
1363
|
+
if Tk.messageBox('icon' => 'error', 'type' => 'yesno',
|
1364
|
+
'title' => '(Arcadia) Libs', 'parent' => @text,
|
1365
|
+
'message' => msg) == 'yes'
|
1366
|
+
@text.delete('1.0','end')
|
1367
|
+
load_file(@file)
|
1368
|
+
else
|
1369
|
+
@file_last_access_time = ftime
|
1370
|
+
end
|
1371
|
+
end
|
1372
|
+
end
|
1373
|
+
end
|
1374
|
+
|
1375
|
+
def init_editing(_ext='rb')
|
1376
|
+
# find file lang
|
1377
|
+
_ext='' if _ext.nil?
|
1378
|
+
lang_file = File.dirname(__FILE__)+'/langs/'+_ext+'.lang'
|
1379
|
+
if File.exist?(lang_file)
|
1380
|
+
@lang_hash = properties_file2hash(lang_file)
|
1381
|
+
elsif File.exist?(lang_file+'.bind')
|
1382
|
+
b= properties_file2hash(lang_file+'.bind')
|
1383
|
+
lang_file_bind = File.dirname(__FILE__)+'/langs/'+b['bind']
|
1384
|
+
if b && File.exist?(lang_file_bind)
|
1385
|
+
@lang_hash = properties_file2hash(lang_file_bind)
|
1386
|
+
end
|
1387
|
+
else
|
1388
|
+
@lang = nil
|
1389
|
+
end
|
1390
|
+
if _ext=='rb'
|
1391
|
+
@fm = AGTkVSplittedFrames.new(@page_frame,150)
|
1392
|
+
@fm1 = AGTkVSplittedFrames.new(@fm.right_frame,60)
|
1393
|
+
initialize_tree(@fm.left_frame)
|
1394
|
+
else
|
1395
|
+
@fm1 = AGTkVSplittedFrames.new(@page_frame,60)
|
1396
|
+
end
|
1397
|
+
@fm1.splitter_frame.configure('relief'=>'flat')
|
1398
|
+
initialize_text(@fm1.right_frame)
|
1399
|
+
initialize_text_binding
|
1400
|
+
initialize_highlight
|
1401
|
+
initialize_line_number(@fm1.left_frame)
|
1402
|
+
end
|
1403
|
+
|
1404
|
+
def file_extension(_filename=nil)
|
1405
|
+
if _filename
|
1406
|
+
_m = /(.*\.)(.*$)/.match(File.basename(_filename))
|
1407
|
+
end
|
1408
|
+
_ret = (_m && _m.length > 1)?_m[2]: nil
|
1409
|
+
end
|
1410
|
+
|
1411
|
+
def load_file(_filename = nil)
|
1412
|
+
#if filename is nil then open a new tab
|
1413
|
+
@file = _filename
|
1414
|
+
if _filename
|
1415
|
+
#init_editing(file_extension(_filename))
|
1416
|
+
File::open(_filename,'r'){ |file|
|
1417
|
+
@text.insert('end',file.readlines.collect!{| line | line.chomp+"\n" }.to_s)
|
1418
|
+
}
|
1419
|
+
end
|
1420
|
+
set_read_only(!File.stat(_filename).writable?)
|
1421
|
+
|
1422
|
+
reset
|
1423
|
+
refresh
|
1424
|
+
end
|
1425
|
+
|
1426
|
+
def set_read_only(_value)
|
1427
|
+
if @read_only != _value
|
1428
|
+
@read_only = _value
|
1429
|
+
if @read_only
|
1430
|
+
@text.configure('state'=>'disabled')
|
1431
|
+
@controller.change_tab_set_read_only(@page_frame)
|
1432
|
+
else
|
1433
|
+
@text.configure('state'=>'normal')
|
1434
|
+
@controller.change_tab_reset_read_only(@page_frame)
|
1435
|
+
end
|
1436
|
+
end
|
1437
|
+
end
|
1438
|
+
|
1439
|
+
def reset
|
1440
|
+
@buffer = text_value
|
1441
|
+
reset_modify
|
1442
|
+
@text.edit_reset
|
1443
|
+
end
|
1444
|
+
|
1445
|
+
def refresh
|
1446
|
+
build_tree if @classbrowsing
|
1447
|
+
end
|
1448
|
+
end
|
1449
|
+
|
1450
|
+
class AgMultiEditorView
|
1451
|
+
attr_reader :enb
|
1452
|
+
def initialize(parent=nil)
|
1453
|
+
@enb = Tk::BWidget::NoteBook.new(parent){
|
1454
|
+
tabbevelsize 0
|
1455
|
+
internalborderwidth 2
|
1456
|
+
activeforeground 'red'
|
1457
|
+
activebackground 'yellow'
|
1458
|
+
#background 'black'
|
1459
|
+
borderwidth 1
|
1460
|
+
side $arcadia['conf']['editor.tabs.side']
|
1461
|
+
font $arcadia['conf']['editor.tabs.font']
|
1462
|
+
pack('fill'=>'both', :padx=>0, :pady=>0, :expand => 'yes')
|
1463
|
+
}
|
1464
|
+
end
|
1465
|
+
|
1466
|
+
end
|
1467
|
+
|
1468
|
+
class AgMultiEditor < ArcadiaExt
|
1469
|
+
include Autils
|
1470
|
+
attr_reader :breakpoints
|
1471
|
+
attr_reader :splitted_frame
|
1472
|
+
def on_before_build(_event)
|
1473
|
+
#ArcadiaContractListener.new(self, DebugContract, :do_debug_event)
|
1474
|
+
#ArcadiaContractListener.new(self, EditorContract, :do_editor_event)
|
1475
|
+
#ArcadiaContractListener.new(self, MainContract, :do_main_event)
|
1476
|
+
Arcadia.add_listener(self, BufferEvent)
|
1477
|
+
Arcadia.add_listener(self, DebugEvent)
|
1478
|
+
Arcadia.add_listener(self, RunRubyFileEvent)
|
1479
|
+
Arcadia.add_listener(self, StartDebugEvent)
|
1480
|
+
end
|
1481
|
+
|
1482
|
+
def on_before_run_ruby_file(_event)
|
1483
|
+
_filename = _event.file
|
1484
|
+
if _filename.nil?
|
1485
|
+
current_editor = self.raised
|
1486
|
+
_event.file =current_editor.file if current_editor
|
1487
|
+
end
|
1488
|
+
end
|
1489
|
+
|
1490
|
+
def on_before_start_debug(_event)
|
1491
|
+
_filename = _event.file
|
1492
|
+
if _filename.nil?
|
1493
|
+
current_editor = self.raised
|
1494
|
+
_event.file =current_editor.file if current_editor
|
1495
|
+
end
|
1496
|
+
end
|
1497
|
+
|
1498
|
+
def on_build(_event)
|
1499
|
+
@main_frame = AgMultiEditorView.new(self.frame)
|
1500
|
+
@tabs_file =Hash.new
|
1501
|
+
@tabs_editor =Hash.new
|
1502
|
+
@breakpoints =Array.new
|
1503
|
+
create_find
|
1504
|
+
pop_up_menu
|
1505
|
+
end
|
1506
|
+
|
1507
|
+
def on_after_build(_event)
|
1508
|
+
self.open_last_files
|
1509
|
+
end
|
1510
|
+
|
1511
|
+
def pop_up_menu
|
1512
|
+
@pop_up = TkMenu.new(
|
1513
|
+
:parent=>@main_frame.enb,
|
1514
|
+
:tearoff=>0,
|
1515
|
+
:title => 'Menu'
|
1516
|
+
)
|
1517
|
+
@pop_up.insert('end',
|
1518
|
+
:command,
|
1519
|
+
:label=>'...',
|
1520
|
+
:state=>'disabled',
|
1521
|
+
:background=>'blue',
|
1522
|
+
:font => conf('font.bold'),
|
1523
|
+
:hidemargin => true
|
1524
|
+
)
|
1525
|
+
@c = @pop_up.insert('end',
|
1526
|
+
:command,
|
1527
|
+
:label=>'Close',
|
1528
|
+
:font => conf('font'),
|
1529
|
+
:hidemargin => false,
|
1530
|
+
:command=> proc{
|
1531
|
+
if @selected_tab_name_from_popup != nil
|
1532
|
+
_e = @tabs_editor[@selected_tab_name_from_popup]
|
1533
|
+
self.close_editor(_e)
|
1534
|
+
end
|
1535
|
+
}
|
1536
|
+
)
|
1537
|
+
@c = @pop_up.insert('end',
|
1538
|
+
:command,
|
1539
|
+
:label=>'Close others',
|
1540
|
+
:font => conf('font'),
|
1541
|
+
:hidemargin => false,
|
1542
|
+
:command=> proc{
|
1543
|
+
if @selected_tab_name_from_popup != nil
|
1544
|
+
_e = @tabs_editor[@selected_tab_name_from_popup]
|
1545
|
+
self.close_others_editor(_e)
|
1546
|
+
end
|
1547
|
+
}
|
1548
|
+
)
|
1549
|
+
@c = @pop_up.insert('end',
|
1550
|
+
:command,
|
1551
|
+
:label=>'Close all',
|
1552
|
+
:font => conf('font'),
|
1553
|
+
:hidemargin => false,
|
1554
|
+
:command=> proc{
|
1555
|
+
if @selected_tab_name_from_popup != nil
|
1556
|
+
_e = @tabs_editor[@selected_tab_name_from_popup]
|
1557
|
+
self.close_all_editor(_e)
|
1558
|
+
end
|
1559
|
+
}
|
1560
|
+
)
|
1561
|
+
|
1562
|
+
@main_frame.enb.tabbind("Button-3",
|
1563
|
+
proc{|*x|
|
1564
|
+
_x = TkWinfo.pointerx(@main_frame.enb)
|
1565
|
+
_y = TkWinfo.pointery(@main_frame.enb)
|
1566
|
+
@selected_tab_name_from_popup = x[0].split(':')[0]
|
1567
|
+
_index = @main_frame.enb.index(@selected_tab_name_from_popup)
|
1568
|
+
if _index == -1
|
1569
|
+
@selected_tab_name_from_popup = 'ff'+@selected_tab_name_from_popup
|
1570
|
+
_index = @main_frame.enb.index(@selected_tab_name_from_popup)
|
1571
|
+
end
|
1572
|
+
if _index != -1
|
1573
|
+
_file = @main_frame.enb.itemcget(@selected_tab_name_from_popup, 'text')
|
1574
|
+
@pop_up.entryconfigure(0, 'label'=>_file)
|
1575
|
+
@pop_up.popup(_x,_y)
|
1576
|
+
end
|
1577
|
+
})
|
1578
|
+
end
|
1579
|
+
|
1580
|
+
|
1581
|
+
# def do_debug_event(_event)
|
1582
|
+
#@arcadia.outln('_sender ----> '+_sender.to_s)
|
1583
|
+
#@arcadia.outln('_event.signature ----> '+_event.signature)
|
1584
|
+
# case _event.signature
|
1585
|
+
# when DebugContract::DEBUG_BEGIN
|
1586
|
+
# self.debug_begin
|
1587
|
+
# when DebugContract::DEBUG_END
|
1588
|
+
# self.debug_end
|
1589
|
+
# when DebugContract::DEBUG_STEP
|
1590
|
+
# if _event.context.file
|
1591
|
+
# self.open_file_in_debug(_event.context.file, _event.context.line)
|
1592
|
+
# end
|
1593
|
+
# end
|
1594
|
+
# end
|
1595
|
+
|
1596
|
+
def on_before_step_debug(_event)
|
1597
|
+
debug_reset
|
1598
|
+
end
|
1599
|
+
|
1600
|
+
def on_after_debug(_event)
|
1601
|
+
case _event
|
1602
|
+
when StartDebugEvent
|
1603
|
+
self.debug_begin
|
1604
|
+
when StepDebugEvent
|
1605
|
+
if _event.command == :quit
|
1606
|
+
self.debug_end
|
1607
|
+
end
|
1608
|
+
when SetBreakpointEvent
|
1609
|
+
@breakpoints << {:file=>_event.file,:line=>_event.row}
|
1610
|
+
when UnsetBreakpointEvent
|
1611
|
+
@breakpoints.delete_if{|b| (b[:file]==_event.file && b[:line]==_event.row)}
|
1612
|
+
end
|
1613
|
+
end
|
1614
|
+
|
1615
|
+
def on_debug_step_info(_event)
|
1616
|
+
if _event.file
|
1617
|
+
self.open_file_in_debug(_event.file, _event.row)
|
1618
|
+
end
|
1619
|
+
end
|
1620
|
+
|
1621
|
+
def on_buffer(_event)
|
1622
|
+
case _event
|
1623
|
+
when NewBufferEvent
|
1624
|
+
self.open_buffer
|
1625
|
+
when OpenBufferEvent
|
1626
|
+
if _event.file
|
1627
|
+
if _event.row
|
1628
|
+
_index = _event.row.to_s+'.0'
|
1629
|
+
end
|
1630
|
+
self.open_file(_event.file, _index)
|
1631
|
+
elsif _event.text
|
1632
|
+
if _event.title
|
1633
|
+
_tab_name = self.tab_name(_event.title)
|
1634
|
+
self.open_buffer(_tab_name, _event.title)
|
1635
|
+
_e = @tabs_editor[_tab_name]
|
1636
|
+
_e.text_insert('end',_event.text)
|
1637
|
+
_e.reset
|
1638
|
+
_e.refresh
|
1639
|
+
#add_reverse_item(_e)
|
1640
|
+
end
|
1641
|
+
else
|
1642
|
+
self.open_file(Tk.getOpenFile)
|
1643
|
+
end
|
1644
|
+
when CloseBufferEvent
|
1645
|
+
if _event.file
|
1646
|
+
self.close_file(_event.file)
|
1647
|
+
end
|
1648
|
+
when SaveAsBufferEvent
|
1649
|
+
if _event.file == nil
|
1650
|
+
self.raised.save_as
|
1651
|
+
else
|
1652
|
+
self.save_as_file(_event.file)
|
1653
|
+
end
|
1654
|
+
when SaveBufferEvent
|
1655
|
+
if _event.file == nil && _event.title == nil
|
1656
|
+
self.raised.save
|
1657
|
+
elsif _event.file != nil
|
1658
|
+
self.save_file(_event.file)
|
1659
|
+
elsif _event.title != nil
|
1660
|
+
self.save_file(_event.title)
|
1661
|
+
end
|
1662
|
+
when SearchBufferEvent
|
1663
|
+
if _event.what == nil
|
1664
|
+
@find.show
|
1665
|
+
end
|
1666
|
+
when GoToLineBufferEvent
|
1667
|
+
if _event.line == nil
|
1668
|
+
@find.show_go_to_line_dialog
|
1669
|
+
end
|
1670
|
+
end
|
1671
|
+
end
|
1672
|
+
|
1673
|
+
def xy_insert
|
1674
|
+
_text = self.raised.text
|
1675
|
+
_index_now = _text.index('insert')
|
1676
|
+
_rx, _ry, _widht, _heigth = _text.bbox(_index_now);
|
1677
|
+
_x = _rx + TkWinfo.rootx(_text)
|
1678
|
+
_y = _ry + TkWinfo.rooty(_text) + TkFont.new(conf('font')).metrics[2][1]
|
1679
|
+
_xroot = _x - TkWinfo.rootx(@arcadia.layout.root)
|
1680
|
+
_yroot = _y - TkWinfo.rooty(@arcadia.layout.root)
|
1681
|
+
return _xroot, _yroot
|
1682
|
+
end
|
1683
|
+
|
1684
|
+
def raise_complete_code(_context)
|
1685
|
+
# delete the file used for completion
|
1686
|
+
@raised_listbox.destroy if @raised_listbox != nil
|
1687
|
+
|
1688
|
+
candidates = _context.results[0].candidates
|
1689
|
+
_text = self.raised.text
|
1690
|
+
_index_call = _context.row+'.'+_context.col
|
1691
|
+
_index_now = _text.index('insert')
|
1692
|
+
if _index_call == _index_now
|
1693
|
+
_target = _text.get('insert - 1 chars wordstart','insert')
|
1694
|
+
if _target.length > 0 && _target != '.'
|
1695
|
+
extra_len = _target.length.+@
|
1696
|
+
_begin_index = _index_now<<' - '<<extra_len.to_s<<' chars'
|
1697
|
+
_text.tag_add('sel', _begin_index, _index_now)
|
1698
|
+
else
|
1699
|
+
_begin_index = _index_now
|
1700
|
+
extra_len = 0
|
1701
|
+
end
|
1702
|
+
if candidates.length > 1
|
1703
|
+
_rx, _ry, _widht, heigth = _text.bbox(_begin_index);
|
1704
|
+
_x = _rx + TkWinfo.rootx(_text)
|
1705
|
+
_y = _ry + TkWinfo.rooty(_text) + TkFont.new(conf('font')).metrics[2][1]
|
1706
|
+
|
1707
|
+
_xroot = _x - TkWinfo.rootx(@arcadia.layout.root)
|
1708
|
+
_yroot = _y - TkWinfo.rooty(@arcadia.layout.root)
|
1709
|
+
|
1710
|
+
_max_height = TkWinfo.screenheight(@arcadia.layout.root) - _y - 5
|
1711
|
+
|
1712
|
+
@raised_listbox = TkListbox.new(@arcadia.layout.root,
|
1713
|
+
'takefocus'=>true,
|
1714
|
+
:background=>conf('color.background'),
|
1715
|
+
:foreground=>conf('color.foreground'),
|
1716
|
+
:selectbackground=>'yellow',
|
1717
|
+
:selectforeground=>'red',
|
1718
|
+
:activestyle=>'none',
|
1719
|
+
:font => conf('font'),
|
1720
|
+
:borderwidth=>1
|
1721
|
+
)
|
1722
|
+
_font = TkFont.new(conf('font'))
|
1723
|
+
_char_height = _font.metrics[2][1]
|
1724
|
+
_width = 0
|
1725
|
+
_docs_entries = Hash.new
|
1726
|
+
candidates.each{|value|
|
1727
|
+
_key, _doc = value.split
|
1728
|
+
_docs_entries[_key]= _doc
|
1729
|
+
@raised_listbox.insert('end', _key)
|
1730
|
+
_temp_width = _font.measure(_key) + _font.measure('X')
|
1731
|
+
_width = _temp_width if _temp_width > _width
|
1732
|
+
}
|
1733
|
+
_height = (candidates.length+1)*_char_height
|
1734
|
+
_height = _max_height if _height > _max_height
|
1735
|
+
@raised_listbox.place('x'=>_xroot,'y'=>_yroot, 'width'=>_width, 'height'=>_height)
|
1736
|
+
|
1737
|
+
@raised_listbox.focus
|
1738
|
+
@raised_listbox.bind_append('KeyPress'){|e|
|
1739
|
+
case e.keysym
|
1740
|
+
when 'Escape'
|
1741
|
+
@raised_listbox.destroy
|
1742
|
+
#_menu.destroy
|
1743
|
+
Tk.callback_break
|
1744
|
+
when 'Return'
|
1745
|
+
_value = @raised_listbox.get('active')
|
1746
|
+
_text.delete(_begin_index,'insert')
|
1747
|
+
_text.insert('insert',_value)
|
1748
|
+
@raised_listbox.destroy
|
1749
|
+
#_menu.destroy
|
1750
|
+
Tk.callback_break
|
1751
|
+
when 'F1'
|
1752
|
+
_key = @raised_listbox.get('active')
|
1753
|
+
_x, _y = xy_insert
|
1754
|
+
Arcadia.process_event(DocCodeEvent.new(self, 'doc_entry'=>_docs_entries[_key], 'xdoc'=>_x, 'ydoc'=>_y))
|
1755
|
+
#EditorContract.instance.doc_code(self, 'doc_entry'=>_docs_entries[_key], 'xdoc'=>_x, 'ydoc'=>_y)
|
1756
|
+
end
|
1757
|
+
}
|
1758
|
+
elsif candidates.length == 1 && candidates[0].length>0
|
1759
|
+
_text.delete(_begin_index,'insert');
|
1760
|
+
_text.insert('insert',candidates[0].split[0])
|
1761
|
+
end
|
1762
|
+
end
|
1763
|
+
end
|
1764
|
+
|
1765
|
+
def get_find
|
1766
|
+
@find
|
1767
|
+
end
|
1768
|
+
|
1769
|
+
def create_find
|
1770
|
+
@find = Find.new(@arcadia.layout.root, self)
|
1771
|
+
@find.on_close=proc{@find.hide}
|
1772
|
+
@find.hide
|
1773
|
+
end
|
1774
|
+
|
1775
|
+
def finalize
|
1776
|
+
_files =''
|
1777
|
+
@tabs_editor.each_value{|editor|
|
1778
|
+
_files=_files+'|'+ editor.file if editor.file != nil
|
1779
|
+
close_editor(editor)
|
1780
|
+
}
|
1781
|
+
@arcadia['pers']['editor.files.open']=_files
|
1782
|
+
end
|
1783
|
+
|
1784
|
+
def raised
|
1785
|
+
_page = @main_frame.enb.raise
|
1786
|
+
return @tabs_editor[_page]
|
1787
|
+
end
|
1788
|
+
|
1789
|
+
def close_raised
|
1790
|
+
close_editor(@tabs_editor[@main_frame.enb.raise])
|
1791
|
+
|
1792
|
+
#_page = @main_frame.enb.raise
|
1793
|
+
#_editor = @tabs_editor[_page]
|
1794
|
+
#_row = _editor.text_insert_index.split('.')[0].strip.to_i
|
1795
|
+
#close_editor(_editor)
|
1796
|
+
end
|
1797
|
+
|
1798
|
+
def breakpoint_add(_file,_line)
|
1799
|
+
Arcadia.process_event(SetBreakpointEvent.new(self, 'file'=>_file, 'row'=>_line))
|
1800
|
+
#EditorContract.instance.breakpoint_created(self, 'file'=>_file, 'line'=>_line)
|
1801
|
+
#@breakpoints << {:file=>_file,:line=>_line}
|
1802
|
+
end
|
1803
|
+
|
1804
|
+
def breakpoint_del(_file,_line)
|
1805
|
+
Arcadia.process_event(UnsetBreakpointEvent.new(self, 'file'=>_file, 'row'=>_line))
|
1806
|
+
#EditorContract.instance.breakpoint_deleted(self, 'file'=>_file, 'line'=>_line)
|
1807
|
+
#@breakpoints.delete_if{|b| (b[:file]==_file && b[:line]==_line)}
|
1808
|
+
end
|
1809
|
+
|
1810
|
+
def breakpoint_lines_on_file(_file)
|
1811
|
+
result = Array.new
|
1812
|
+
@breakpoints.each{|value|
|
1813
|
+
if value[:file]==_file
|
1814
|
+
result << value[:line]
|
1815
|
+
end
|
1816
|
+
}
|
1817
|
+
return result
|
1818
|
+
end
|
1819
|
+
|
1820
|
+
def open_last_files
|
1821
|
+
if $arcadia['pers']['editor.files.open']
|
1822
|
+
_files_index =$arcadia['pers']['editor.files.open'].split("|")
|
1823
|
+
_files_index.each do |value|
|
1824
|
+
_file,_index = value.split(';')
|
1825
|
+
if _file
|
1826
|
+
open_file(_file,_index)
|
1827
|
+
end
|
1828
|
+
end
|
1829
|
+
end
|
1830
|
+
_first_page = @main_frame.enb.pages(0) if @main_frame.enb.pages.length > 0
|
1831
|
+
if _first_page
|
1832
|
+
@main_frame.enb.raise(_first_page)
|
1833
|
+
@main_frame.enb.see(_first_page)
|
1834
|
+
end
|
1835
|
+
self
|
1836
|
+
end
|
1837
|
+
|
1838
|
+
def bookmark_add(_file, _index)
|
1839
|
+
if @bookmarks == nil
|
1840
|
+
@bookmarks = Array.new
|
1841
|
+
@bookmarks_index = - 1
|
1842
|
+
else
|
1843
|
+
_cur_file, _cur_index = @bookmarks[@bookmarks_index]
|
1844
|
+
if _cur_file == _file && _cur_index == _index
|
1845
|
+
#@arcadia.outln('uguale ----> '+_file+':'+_index)
|
1846
|
+
return
|
1847
|
+
end
|
1848
|
+
@bookmarks = @bookmarks[0..@bookmarks_index]
|
1849
|
+
end
|
1850
|
+
@bookmarks << [_file, _index]
|
1851
|
+
@bookmarks_index = @bookmarks.length - 1
|
1852
|
+
#@arcadia.outln('add ----> '+_file+':'+_index)
|
1853
|
+
end
|
1854
|
+
|
1855
|
+
def bookmark_clear
|
1856
|
+
@bookmarks.clear
|
1857
|
+
@bookmarks_index = - 1
|
1858
|
+
end
|
1859
|
+
|
1860
|
+
def bookmark_next
|
1861
|
+
return if @bookmarks == nil || @bookmarks_index >= @bookmarks.length - 1
|
1862
|
+
bookmark_move(+1)
|
1863
|
+
end
|
1864
|
+
|
1865
|
+
def bookmark_move(_n=0)
|
1866
|
+
@bookmarks_index = @bookmarks_index + _n
|
1867
|
+
#Tk.messageBox('message'=>@bookmarks_index.to_s)
|
1868
|
+
_file, _index = @bookmarks[@bookmarks_index]
|
1869
|
+
_line, _col = _index.split('.') if _index
|
1870
|
+
open_file(_file, _index)
|
1871
|
+
#openfile(@bookmarks[@bookmarks_index])
|
1872
|
+
end
|
1873
|
+
|
1874
|
+
|
1875
|
+
def bookmark_prev
|
1876
|
+
return if @bookmarks == nil || @bookmarks_index <= 0
|
1877
|
+
bookmark_move(-1)
|
1878
|
+
end
|
1879
|
+
|
1880
|
+
|
1881
|
+
def get_tab_from_name(_name=nil)
|
1882
|
+
return @main_frame.enb.get_frame(_name)
|
1883
|
+
# if _name
|
1884
|
+
# @tabs_name.each{
|
1885
|
+
# |key,value|
|
1886
|
+
# if value.to_s==_name.to_s
|
1887
|
+
# return key
|
1888
|
+
# end
|
1889
|
+
# }
|
1890
|
+
# return nil
|
1891
|
+
# end
|
1892
|
+
end
|
1893
|
+
|
1894
|
+
def change_tab_set_read_only(_tab)
|
1895
|
+
_new_name = '[READ-ONLY] '+@main_frame.enb.itemcget(page_name(_tab), 'text')
|
1896
|
+
change_tab_title(_tab, _new_name)
|
1897
|
+
end
|
1898
|
+
|
1899
|
+
def change_tab_reset_read_only(_tab)
|
1900
|
+
_new_name = @main_frame.enb.itemcget(page_name(_tab), 'text').gsub!("[READ-ONLY] ",'')
|
1901
|
+
if _new_name
|
1902
|
+
change_tab_title(_tab, _new_name)
|
1903
|
+
end
|
1904
|
+
end
|
1905
|
+
|
1906
|
+
|
1907
|
+
def change_tab_set_modify(_tab)
|
1908
|
+
_new_name = '(...)'+@main_frame.enb.itemcget(page_name(_tab), 'text')
|
1909
|
+
change_tab_title(_tab, _new_name)
|
1910
|
+
end
|
1911
|
+
|
1912
|
+
def page_name(_page_frame)
|
1913
|
+
TkWinfo.appname(_page_frame).sub('f','')
|
1914
|
+
end
|
1915
|
+
|
1916
|
+
def change_tab_reset_modify(_tab)
|
1917
|
+
#_new_name = @main_frame.enb.itemcget(@tabs_name[_tab], 'text').gsub!("(...)",'')
|
1918
|
+
_new_name = @main_frame.enb.itemcget(page_name(_tab), 'text').gsub!("(...)",'')
|
1919
|
+
if _new_name
|
1920
|
+
change_tab_title(_tab, _new_name)
|
1921
|
+
end
|
1922
|
+
end
|
1923
|
+
|
1924
|
+
def change_tab_title(_tab, _new_text)
|
1925
|
+
@main_frame.enb.itemconfigure(page_name(_tab), 'text'=> _new_text)
|
1926
|
+
end
|
1927
|
+
|
1928
|
+
def change_file_name(_tab, _new_file)
|
1929
|
+
_new_label = File.basename(_new_file)
|
1930
|
+
change_tab_title(_tab, _new_label)
|
1931
|
+
@tabs_file[page_name(_tab)] = _new_file
|
1932
|
+
end
|
1933
|
+
|
1934
|
+
def debug_begin
|
1935
|
+
if @editors_in_debug != nil
|
1936
|
+
@editors_in_debug.clear
|
1937
|
+
else
|
1938
|
+
@editors_in_debug = Array.new
|
1939
|
+
end
|
1940
|
+
end
|
1941
|
+
|
1942
|
+
def debug_end
|
1943
|
+
#debug_reset
|
1944
|
+
@editors_in_debug.each{|e|
|
1945
|
+
close_editor(e)
|
1946
|
+
}
|
1947
|
+
end
|
1948
|
+
|
1949
|
+
def debug_reset
|
1950
|
+
if @last_index && @last_e
|
1951
|
+
@last_e.unmark_debug(@last_index)
|
1952
|
+
end
|
1953
|
+
end
|
1954
|
+
|
1955
|
+
def open_file_in_debug(_filename=nil, _line=nil)
|
1956
|
+
#debug_reset
|
1957
|
+
if _filename && _line
|
1958
|
+
@last_index = _line.to_s+'.0'
|
1959
|
+
_editor_exist = editor_exist?(_filename)
|
1960
|
+
@last_e = open_file(_filename, @last_index, false)
|
1961
|
+
if !_editor_exist
|
1962
|
+
@editors_in_debug << @last_e
|
1963
|
+
end
|
1964
|
+
@last_e.mark_debug(@last_index) if @last_e
|
1965
|
+
end
|
1966
|
+
end
|
1967
|
+
|
1968
|
+
def do_buffer_raise(_name, _title='...')
|
1969
|
+
_index = @main_frame.enb.index(_name)
|
1970
|
+
_new_caption = '...'
|
1971
|
+
if _index != -1
|
1972
|
+
#_name = @main_frame.enb.pages(_index)
|
1973
|
+
#_tab = get_tab_from_name(_name)
|
1974
|
+
#@main_frame.enb.raise(_name)
|
1975
|
+
_e = @tabs_editor[_name]
|
1976
|
+
if _e && _e.file != nil
|
1977
|
+
_new_caption = _e.file
|
1978
|
+
@find.use(_e)
|
1979
|
+
_e.check_file_last_access_time
|
1980
|
+
else
|
1981
|
+
_new_caption = _title
|
1982
|
+
end
|
1983
|
+
end
|
1984
|
+
if @arcadia.layout.headed?
|
1985
|
+
frame_title(_new_caption)
|
1986
|
+
#@arcadia.layout.domain(@arcadia['conf'][@name+'.frame'])['root'].top_text(_new_caption)
|
1987
|
+
end
|
1988
|
+
_title = @tabs_file[_name] != nil ? File.basename(@tabs_file[_name]) :_name
|
1989
|
+
Arcadia.broadcast_event(BufferRaisedEvent.new(self,'title'=>_title, 'file'=>@tabs_file[_name]))
|
1990
|
+
#EditorContract.instance.buffer_raised(self, 'title'=>_title, 'file'=>@tabs_file[_name])
|
1991
|
+
end
|
1992
|
+
|
1993
|
+
def editor_exist?(_filename)
|
1994
|
+
_basefilename = File.basename(_filename)
|
1995
|
+
#_basename = _basefilename.split('.')[0]+'_'+_basefilename.split('.')[1]
|
1996
|
+
|
1997
|
+
|
1998
|
+
_index = @main_frame.enb.index(self.tab_name(_filename))
|
1999
|
+
return _index != -1
|
2000
|
+
end
|
2001
|
+
|
2002
|
+
def tab_name(_str="")
|
2003
|
+
#_str = _str.downcase if is_windows?
|
2004
|
+
'ff'+_str.downcase.gsub("/","_").gsub(".","_").gsub(":","_").gsub("\\","_")
|
2005
|
+
end
|
2006
|
+
|
2007
|
+
def tab_file_name(_filename="")
|
2008
|
+
_fstr = File.expand_path(_filename)
|
2009
|
+
_fstr = _filename if _fstr == nil
|
2010
|
+
tab_name(_fstr)
|
2011
|
+
end
|
2012
|
+
|
2013
|
+
def open_file(_filename = nil, _text_index='1.0', _mark_selected=true)
|
2014
|
+
return if _filename == nil || !File.exist?(_filename) || File.ftype(_filename) != 'file'
|
2015
|
+
_basefilename = File.basename(_filename)
|
2016
|
+
_tab_name = self.tab_file_name(_filename)
|
2017
|
+
_index = @main_frame.enb.index(_tab_name)
|
2018
|
+
_exist_buffer = _index != -1
|
2019
|
+
|
2020
|
+
if _exist_buffer
|
2021
|
+
open_buffer(_tab_name)
|
2022
|
+
else
|
2023
|
+
open_buffer(_tab_name, _basefilename)
|
2024
|
+
@tabs_file[_tab_name]= _filename
|
2025
|
+
@tabs_editor[_tab_name].load_file(_filename)
|
2026
|
+
end
|
2027
|
+
|
2028
|
+
if _text_index != nil && _text_index != '1.0'
|
2029
|
+
@tabs_editor[_tab_name].text_see(_text_index)
|
2030
|
+
@tabs_editor[_tab_name].mark_selected(_text_index) if _mark_selected
|
2031
|
+
end
|
2032
|
+
|
2033
|
+
return @tabs_editor[_tab_name]
|
2034
|
+
end
|
2035
|
+
|
2036
|
+
|
2037
|
+
def open_buffer(_buffer_name = nil, _title = nil)
|
2038
|
+
_index = @main_frame.enb.index(_buffer_name)
|
2039
|
+
if _buffer_name == nil
|
2040
|
+
_buffer_name = tab_name('new')
|
2041
|
+
_title_new = '*new'
|
2042
|
+
end
|
2043
|
+
|
2044
|
+
if _index != -1
|
2045
|
+
_tab = @main_frame.enb.get_frame(_buffer_name)
|
2046
|
+
@main_frame.enb.raise(_buffer_name)
|
2047
|
+
else
|
2048
|
+
_n = 1
|
2049
|
+
while @main_frame.enb.index(_buffer_name) != -1
|
2050
|
+
_title_new = '*new'+_n.to_s
|
2051
|
+
_buffer_name = tab_name('new')+_n.to_s
|
2052
|
+
_n =_n+1
|
2053
|
+
end
|
2054
|
+
if _title == nil
|
2055
|
+
_title = _title_new
|
2056
|
+
end
|
2057
|
+
_tab = @main_frame.enb.insert('end', _buffer_name ,
|
2058
|
+
'text'=> _title,
|
2059
|
+
'raisecmd'=>proc{do_buffer_raise(_buffer_name, _title)}
|
2060
|
+
)
|
2061
|
+
_e = AgEditor.new(self, _tab)
|
2062
|
+
_e.init_editing(_e.file_extension(_title))
|
2063
|
+
@tabs_file[_buffer_name]= nil
|
2064
|
+
@tabs_editor[_buffer_name]=_e
|
2065
|
+
end
|
2066
|
+
@main_frame.enb.move(_buffer_name, 1)
|
2067
|
+
@main_frame.enb.raise(_buffer_name)
|
2068
|
+
@main_frame.enb.see(_buffer_name)
|
2069
|
+
return _tab
|
2070
|
+
end
|
2071
|
+
|
2072
|
+
def close_others_editor(_editor, _mod=true)
|
2073
|
+
@tabs_editor.values.each do |_e|
|
2074
|
+
close_editor(_e) if _e != _editor
|
2075
|
+
end
|
2076
|
+
end
|
2077
|
+
|
2078
|
+
def close_all_editor(_editor, _mod=true)
|
2079
|
+
@tabs_editor.values.each do |_e|
|
2080
|
+
close_editor(_e)
|
2081
|
+
end
|
2082
|
+
end
|
2083
|
+
|
2084
|
+
def close_editor(_editor, _mod=true)
|
2085
|
+
if ((_mod)&&(_editor.modified?))
|
2086
|
+
_message = @main_frame.enb.itemcget(page_name(_editor.page_frame), 'text')+"\n modified. Save?"
|
2087
|
+
_r = TkDialog2.new('message'=>_message, 'buttons'=>['Ok','No','Cancel']).show()
|
2088
|
+
if _r == 0
|
2089
|
+
_editor.save
|
2090
|
+
elsif _r == 1
|
2091
|
+
close_tab(_editor.page_frame)
|
2092
|
+
elsif _r == 2
|
2093
|
+
return
|
2094
|
+
end
|
2095
|
+
else
|
2096
|
+
close_tab(_editor.page_frame)
|
2097
|
+
end
|
2098
|
+
#EditorContract.instance.file_closed(self, 'file'=>_editor.file)
|
2099
|
+
end
|
2100
|
+
|
2101
|
+
def close_tab(_page_frame)
|
2102
|
+
_name = page_name(_page_frame)
|
2103
|
+
@tabs_editor.delete(_name)
|
2104
|
+
_index = @main_frame.enb.index(_name)
|
2105
|
+
@main_frame.enb.delete(_name)
|
2106
|
+
if !@main_frame.enb.pages.empty?
|
2107
|
+
@main_frame.enb.raise(@main_frame.enb.pages[_index-1])
|
2108
|
+
else
|
2109
|
+
frame_title('')
|
2110
|
+
end
|
2111
|
+
end
|
2112
|
+
|
2113
|
+
def close_file(_filename)
|
2114
|
+
close_editor(@tabs_editor[tab_name(_filename)])
|
2115
|
+
end
|
2116
|
+
|
2117
|
+
def save_file(_filename)
|
2118
|
+
@tabs_editor[tab_name(_filename)].save
|
2119
|
+
end
|
2120
|
+
|
2121
|
+
def save_as_file(_filename)
|
2122
|
+
@tabs_editor[tab_name(_filename)].save_as
|
2123
|
+
end
|
2124
|
+
|
2125
|
+
end
|
2126
|
+
|
2127
|
+
class Findview < TkFloatTitledFrame
|
2128
|
+
def initialize(_parent)
|
2129
|
+
super(_parent)
|
2130
|
+
#stop_resizing
|
2131
|
+
y0 = 10
|
2132
|
+
d = 23
|
2133
|
+
TkLabel.new(self.frame){
|
2134
|
+
text 'Find what:'
|
2135
|
+
place('x' => 8,'y' => y0,'height' => 19)
|
2136
|
+
}
|
2137
|
+
y0 = y0 + d
|
2138
|
+
@e_what = Tk::BWidget::ComboBox.new(self.frame){
|
2139
|
+
editable true
|
2140
|
+
justify 'left'
|
2141
|
+
relief 'ridge'
|
2142
|
+
autocomplete 'true'
|
2143
|
+
#insertbackground '#FFFFFF'
|
2144
|
+
entrybg '#FFFFFF'
|
2145
|
+
expand 'tab'
|
2146
|
+
takefocus 'true'
|
2147
|
+
#pack('padx'=>10, 'fill'=>'x')
|
2148
|
+
place('relwidth' => 1, 'width'=>-16,'x' => 8,'y' => y0,'height' => 19)
|
2149
|
+
}
|
2150
|
+
@e_what_entry = TkWinfo.children(@e_what)[0]
|
2151
|
+
|
2152
|
+
y0 = y0 + d
|
2153
|
+
TkLabel.new(self.frame){
|
2154
|
+
text 'Replace with:'
|
2155
|
+
place('x' => 8,'y' => y0,'height' => 19)
|
2156
|
+
}
|
2157
|
+
y0 = y0 + d
|
2158
|
+
|
2159
|
+
@e_with = Tk::BWidget::ComboBox.new(self.frame){
|
2160
|
+
editable true
|
2161
|
+
justify 'left'
|
2162
|
+
relief 'ridge'
|
2163
|
+
autocomplete 'true'
|
2164
|
+
#insertbackground '#FFFFFF'
|
2165
|
+
entrybg '#FFFFFF'
|
2166
|
+
expand 'tab'
|
2167
|
+
takefocus 'true'
|
2168
|
+
#pack('padx'=>10, 'fill'=>'x')
|
2169
|
+
place('relwidth' => 1, 'width'=>-16,'x' => 8,'y' => y0,'height' => 19)
|
2170
|
+
}
|
2171
|
+
|
2172
|
+
y0 = y0 + d
|
2173
|
+
@cb_reg = TkCheckButton.new(self.frame){|_cb_reg|
|
2174
|
+
text 'Use Regular Expression'
|
2175
|
+
justify 'left'
|
2176
|
+
relief 'flat'
|
2177
|
+
#pack('side'=>'left', 'anchor'=>'e')
|
2178
|
+
place('x' => 8,'y' => y0,'height' => 22)
|
2179
|
+
}
|
2180
|
+
y0 = y0 + d
|
2181
|
+
@cb_back = TkCheckButton.new(self.frame){|_cb_reg|
|
2182
|
+
text 'Search backwards'
|
2183
|
+
justify 'left'
|
2184
|
+
relief 'flat'
|
2185
|
+
#pack('side'=>'left', 'anchor'=>'e')
|
2186
|
+
place('x' => 8,'y' => y0,'height' => 22)
|
2187
|
+
}
|
2188
|
+
|
2189
|
+
y0 = y0 + d
|
2190
|
+
y0 = y0 + d
|
2191
|
+
@buttons_frame = TkFrame.new(self.frame).pack('fill'=>'x', 'side'=>'bottom')
|
2192
|
+
|
2193
|
+
@b_replace_all = TkButton.new(@buttons_frame){|_b_go|
|
2194
|
+
state 'disabled'
|
2195
|
+
default 'disabled'
|
2196
|
+
text 'Replace All'
|
2197
|
+
overrelief 'raised'
|
2198
|
+
justify 'center'
|
2199
|
+
#width 15
|
2200
|
+
pack('side'=>'right','ipadx'=>5, 'padx'=>5)
|
2201
|
+
#place('width' => 50,'x' => 0,'y' => y0,'height' => 23,'bordermode' => 'inside')
|
2202
|
+
}
|
2203
|
+
|
2204
|
+
|
2205
|
+
@b_replace = TkButton.new(@buttons_frame){|_b_go|
|
2206
|
+
state 'disabled'
|
2207
|
+
default 'disabled'
|
2208
|
+
text 'Replace'
|
2209
|
+
overrelief 'raised'
|
2210
|
+
justify 'center'
|
2211
|
+
#width 15
|
2212
|
+
pack('side'=>'right','ipadx'=>5, 'padx'=>5)
|
2213
|
+
#place('width' => 50,'x' => 0,'y' => y0,'height' => 23,'bordermode' => 'inside')
|
2214
|
+
}
|
2215
|
+
|
2216
|
+
|
2217
|
+
@b_go = TkButton.new(@buttons_frame){|_b_go|
|
2218
|
+
compound 'none'
|
2219
|
+
default 'disabled'
|
2220
|
+
text 'Find Next'
|
2221
|
+
#background '#ffffff'
|
2222
|
+
#image TkPhotoImage.new('dat' => FIND_GIF)
|
2223
|
+
overrelief 'raised'
|
2224
|
+
justify 'center'
|
2225
|
+
#relief 'ridge'
|
2226
|
+
#width 15
|
2227
|
+
pack('side'=>'right','ipadx'=>5, 'padx'=>5)
|
2228
|
+
#place('width' => 50,'x' => 0,'y' => y0,'height' => 23,'bordermode' => 'inside')
|
2229
|
+
}
|
2230
|
+
#place('x'=>0,'y'=>0,'relheight'=> 1,'relwidth'=> 1)
|
2231
|
+
place('x'=>100,'y'=>100,'height'=> 220,'width'=> 300)
|
2232
|
+
|
2233
|
+
end
|
2234
|
+
|
2235
|
+
def show
|
2236
|
+
super
|
2237
|
+
self.focus
|
2238
|
+
@e_what.focus
|
2239
|
+
@e_what_entry.selection_range(0,'end')
|
2240
|
+
end
|
2241
|
+
|
2242
|
+
|
2243
|
+
end
|
2244
|
+
|
2245
|
+
class Find < Findview
|
2246
|
+
attr_reader :e_what
|
2247
|
+
def initialize(_frame, _controller)
|
2248
|
+
super(_frame)
|
2249
|
+
#@l_file.configure('text'=>_title)
|
2250
|
+
#Tk.tk_call('wm', 'title', self, _title )
|
2251
|
+
@controller = _controller
|
2252
|
+
@forwards = true
|
2253
|
+
@find_action = proc{
|
2254
|
+
do_find_next
|
2255
|
+
hide
|
2256
|
+
}
|
2257
|
+
@b_go.bind('1', @find_action)
|
2258
|
+
|
2259
|
+
@b_replace.bind('1', proc{do_replace})
|
2260
|
+
|
2261
|
+
@b_replace_all.bind('1', proc{do_replace_all})
|
2262
|
+
|
2263
|
+
@e_what_entry.bind_append('KeyRelease'){|e|
|
2264
|
+
case e.keysym
|
2265
|
+
when 'Return'
|
2266
|
+
@find_action.call
|
2267
|
+
Tk.callback_break
|
2268
|
+
else
|
2269
|
+
widget_state
|
2270
|
+
end
|
2271
|
+
}
|
2272
|
+
e2 = TkWinfo.children(@e_with)[0]
|
2273
|
+
e2.bind_append('KeyPress'){|e|
|
2274
|
+
widget_state
|
2275
|
+
}
|
2276
|
+
@last_index='insert'
|
2277
|
+
|
2278
|
+
@goto_line_dialog = GoToLine.new(_frame).hide
|
2279
|
+
@goto_line_dialog.on_close=proc{@goto_line_dialog.hide}
|
2280
|
+
|
2281
|
+
@goto_line_dialog.b_go.bind('1',proc{go_line})
|
2282
|
+
@goto_line_dialog.e_line.bind_append('KeyRelease'){|e|
|
2283
|
+
case e.keysym
|
2284
|
+
when 'Return'
|
2285
|
+
go_line
|
2286
|
+
Tk.callback_break
|
2287
|
+
end
|
2288
|
+
}
|
2289
|
+
|
2290
|
+
end
|
2291
|
+
|
2292
|
+
def do_replace
|
2293
|
+
if do_find_next
|
2294
|
+
_message = 'Replace "'+@e_what.value+'" with "'+@e_with.value+'" ?'
|
2295
|
+
if TkDialog2.new('message'=>_message, 'buttons'=>['Yes','No']).show() == 0
|
2296
|
+
self.editor.text.delete(@idx1,@idx2)
|
2297
|
+
self.editor.text.insert(@idx1,@e_with.value)
|
2298
|
+
self.editor.check_modify
|
2299
|
+
end
|
2300
|
+
end
|
2301
|
+
end
|
2302
|
+
|
2303
|
+
def do_replace_all
|
2304
|
+
while do_find_next
|
2305
|
+
_message = 'Replace "'+@e_what.value+'" with "'+@e_with.value+'" ?'
|
2306
|
+
_rc = TkDialog2.new('message'=>_message, 'buttons'=>['Yes','No','Annulla']).show()
|
2307
|
+
if _rc == 0
|
2308
|
+
self.editor.text.delete(@idx1,@idx2)
|
2309
|
+
self.editor.text.insert(@idx1,@e_with.value)
|
2310
|
+
self.editor.check_modify
|
2311
|
+
elsif _rc == 2
|
2312
|
+
break
|
2313
|
+
end
|
2314
|
+
end
|
2315
|
+
end
|
2316
|
+
|
2317
|
+
def widget_state
|
2318
|
+
if (@e_what.value.length > 0) && (@e_with.value.length > 0)
|
2319
|
+
@b_replace.configure('state'=>'active')
|
2320
|
+
@b_replace_all.configure('state'=>'active')
|
2321
|
+
else
|
2322
|
+
@b_replace.configure('state'=>'disabled')
|
2323
|
+
@b_replace_all.configure('state'=>'disabled')
|
2324
|
+
end
|
2325
|
+
end
|
2326
|
+
|
2327
|
+
|
2328
|
+
def editor
|
2329
|
+
if @editor_caller == nil
|
2330
|
+
@editor_caller = @controller.raised
|
2331
|
+
end
|
2332
|
+
return @editor_caller
|
2333
|
+
end
|
2334
|
+
|
2335
|
+
def show_go_to_line_dialog
|
2336
|
+
@goto_line_dialog.show
|
2337
|
+
end
|
2338
|
+
|
2339
|
+
def go_line
|
2340
|
+
if @goto_line_dialog.e_line.value.length > 0
|
2341
|
+
_row = @goto_line_dialog.e_line.value
|
2342
|
+
_index = _row+'.1'
|
2343
|
+
self.editor.text.see(_index)
|
2344
|
+
self.editor.text.tag_add('sel', _index,_index+' lineend')
|
2345
|
+
self.editor.text.set_insert(_index)
|
2346
|
+
@controller.bookmark_add(self.editor.file, _index)
|
2347
|
+
@goto_line_dialog.hide
|
2348
|
+
end
|
2349
|
+
#self.hide()
|
2350
|
+
end
|
2351
|
+
|
2352
|
+
def use(_editor)
|
2353
|
+
if (_editor != @editor_caller)
|
2354
|
+
@last_index='insert'
|
2355
|
+
@editor_caller = _editor
|
2356
|
+
title(_editor.file)
|
2357
|
+
end
|
2358
|
+
end
|
2359
|
+
|
2360
|
+
def update_combo(_txt)
|
2361
|
+
values = @e_what.cget('values')
|
2362
|
+
if (values != nil && !values.include?(_txt))
|
2363
|
+
@e_what.insert('end', @e_what.value)
|
2364
|
+
end
|
2365
|
+
end
|
2366
|
+
|
2367
|
+
def do_find(_istart=nil)
|
2368
|
+
@forwards = @cb_back.cget('onvalue') != @cb_back.cget('variable').value.to_i
|
2369
|
+
_found = false
|
2370
|
+
@idx1 = nil
|
2371
|
+
@idx2 = nil
|
2372
|
+
if @e_what.text.length > 0
|
2373
|
+
update_combo(@e_what.text)
|
2374
|
+
if !_istart && self.editor.text.index('insert')!=nil
|
2375
|
+
_istart ='insert'
|
2376
|
+
elsif defined?(@last_index)
|
2377
|
+
_istart = @last_index
|
2378
|
+
else
|
2379
|
+
_istart = '1.0'
|
2380
|
+
end
|
2381
|
+
if @forwards
|
2382
|
+
if @cb_reg.cget('onvalue')==@cb_reg.cget('variable').value.to_i
|
2383
|
+
_index = self.editor.text.tksearch(['regexp'],@e_what.text,_istart)
|
2384
|
+
else
|
2385
|
+
_index = self.editor.text.search(@e_what.text,_istart)
|
2386
|
+
end
|
2387
|
+
else
|
2388
|
+
|
2389
|
+
if @cb_reg.cget('onvalue')==@cb_reg.cget('variable').value.to_i
|
2390
|
+
_index = self.editor.text.tksearch(['regexp','backwards'],@e_what.text,_istart)
|
2391
|
+
else
|
2392
|
+
_index = self.editor.text.tksearch(['backwards'],@e_what.text,_istart)
|
2393
|
+
end
|
2394
|
+
end
|
2395
|
+
if _index && _index.length>0
|
2396
|
+
self.editor.text.see(_index)
|
2397
|
+
_row, _col = _index.split('.')
|
2398
|
+
_index_sel_end = _row.to_i.to_s+'.'+(_col.to_i+@e_what.text.length).to_i.to_s
|
2399
|
+
if @forwards
|
2400
|
+
@last_index= _index_sel_end
|
2401
|
+
else
|
2402
|
+
@last_index= _row.to_i.to_s+'.'+(_col.to_i-1).to_i.to_s
|
2403
|
+
end
|
2404
|
+
self.editor.text.tag_add('sel', _index,_index_sel_end)
|
2405
|
+
self.editor.text.set_insert(_index)
|
2406
|
+
@idx1 =_index
|
2407
|
+
@idx2 =_index_sel_end
|
2408
|
+
_found = true
|
2409
|
+
@controller.bookmark_add(self.editor.file, _index)
|
2410
|
+
else
|
2411
|
+
_message = '"'+@e_what.value+'" not found'
|
2412
|
+
TkDialog2.new('message'=>_message, 'buttons'=>['Ok']).show()
|
2413
|
+
end
|
2414
|
+
|
2415
|
+
else
|
2416
|
+
self.show()
|
2417
|
+
end
|
2418
|
+
self.editor.text.focus
|
2419
|
+
return _found
|
2420
|
+
end
|
2421
|
+
|
2422
|
+
def do_find_next
|
2423
|
+
if @idx1 != nil
|
2424
|
+
self.editor.text.tag_remove('sel',@idx1,@idx2)
|
2425
|
+
end
|
2426
|
+
do_find(@last_index)
|
2427
|
+
end
|
2428
|
+
end
|
2429
|
+
|
2430
|
+
|
2431
|
+
class KeyTestView < TkToplevel
|
2432
|
+
attr_reader :ttest
|
2433
|
+
def initialize
|
2434
|
+
super
|
2435
|
+
|
2436
|
+
Tk.tk_call('wm', 'title', self, '...hello' )
|
2437
|
+
Tk.tk_call('wm', 'geometry', self, '638x117+200+257' )
|
2438
|
+
|
2439
|
+
@ttest = TkText.new(self){
|
2440
|
+
background '#FFF454'
|
2441
|
+
place('relwidth' => '1','relx' => 0,'x' => '0','y' => '0','relheight' => '1','rely' => 0,'height' => '0','bordermode' => 'inside','width' => '0')
|
2442
|
+
}
|
2443
|
+
|
2444
|
+
end
|
2445
|
+
end
|
2446
|
+
|
2447
|
+
class KetTest
|
2448
|
+
def initialize
|
2449
|
+
kt = KeyTestView.new
|
2450
|
+
kt.ttest.bind("KeyPress"){|e|
|
2451
|
+
kt.ttest.insert('end'," [ "+e.keysym+" ] ")
|
2452
|
+
break
|
2453
|
+
}
|
2454
|
+
end
|
2455
|
+
end
|
2456
|
+
|
2457
|
+
class CodeInsight
|
2458
|
+
end
|
2459
|
+
|
2460
|
+
class GoToLine < TkFloatTitledFrame
|
2461
|
+
attr_reader :e_line
|
2462
|
+
attr_reader :b_go
|
2463
|
+
def initialize(_parent)
|
2464
|
+
super(_parent)
|
2465
|
+
#stop_resizing
|
2466
|
+
y0 = 10
|
2467
|
+
d = 23
|
2468
|
+
TkLabel.new(self.frame){
|
2469
|
+
text 'Go to line:'
|
2470
|
+
place('x' => 8,'y' => y0,'height' => 19)
|
2471
|
+
}
|
2472
|
+
y0 = y0 + d
|
2473
|
+
@e_line = TkEntry.new(self.frame){
|
2474
|
+
justify 'left'
|
2475
|
+
relief 'ridge'
|
2476
|
+
place('relwidth' => 1, 'width'=>-16,'x' => 8,'y' => y0,'height' => 19)
|
2477
|
+
}
|
2478
|
+
|
2479
|
+
y0 = y0 + d
|
2480
|
+
y0 = y0 + d
|
2481
|
+
@buttons_frame = TkFrame.new(self.frame).pack('fill'=>'x', 'side'=>'bottom')
|
2482
|
+
|
2483
|
+
@b_go = TkButton.new(@buttons_frame){|_b_go|
|
2484
|
+
compound 'none'
|
2485
|
+
default 'disabled'
|
2486
|
+
text 'Go'
|
2487
|
+
overrelief 'raised'
|
2488
|
+
justify 'center'
|
2489
|
+
pack('side'=>'right','ipadx'=>5, 'padx'=>5)
|
2490
|
+
}
|
2491
|
+
place('x'=>150,'y'=>150,'height'=> 120,'width'=> 100)
|
2492
|
+
|
2493
|
+
end
|
2494
|
+
|
2495
|
+
def show
|
2496
|
+
super
|
2497
|
+
self.focus
|
2498
|
+
@e_line.focus
|
2499
|
+
@e_line.selection_range(0,'end')
|
2500
|
+
end
|
2501
|
+
end
|