arcadia 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +8 -10
- data/bin/arcadia +13 -13
- data/bin/arcadia.bat +0 -0
- data/conf/arcadia.conf +35 -18
- data/conf/arcadia.init.rb +0 -0
- data/conf/arcadia.res.rb +10 -0
- data/ext/ae-breakpoints/ae-breakpoints.conf +0 -0
- data/ext/ae-breakpoints/ae-breakpoints.rb +368 -349
- data/ext/ae-editor/ae-editor.conf +2 -2
- data/ext/ae-editor/ae-editor.rb +1248 -445
- data/ext/ae-editor/langs/conf.lang +0 -0
- data/ext/ae-editor/langs/lang.lang.bind +0 -0
- data/ext/ae-editor/langs/rb.lang +0 -0
- data/ext/ae-editor/langs/rbw.lang.bind +0 -0
- data/ext/ae-file-history/ae-file-history.conf +1 -1
- data/ext/ae-file-history/ae-file-history.rb +23 -17
- data/ext/ae-output/ae-output.conf +0 -0
- data/ext/ae-output/ae-output.rb +262 -200
- data/ext/ae-rad/ae-rad-inspector.rb +34 -26
- data/ext/ae-rad/ae-rad-libs.rb +0 -0
- data/ext/ae-rad/ae-rad-palette.rb +0 -0
- data/ext/ae-rad/ae-rad.conf +0 -0
- data/ext/ae-rad/ae-rad.rb +0 -0
- data/ext/ae-rad/lib/tk/al-tk.rb +6 -2
- data/ext/ae-rad/lib/tk/al-tk.res.rb +0 -0
- data/ext/ae-rad/lib/tk/al-tkarcadia.rb +0 -0
- data/ext/ae-rad/lib/tk/al-tkcustom.rb +0 -0
- data/ext/ae-rad/lib/tkext/al-bwidget.rb +0 -0
- data/ext/ae-rad/lib/tkext/al-iwidgets.rb +0 -0
- data/ext/ae-rad/lib/tkext/al-tile.rb +0 -0
- data/ext/ae-rad/lib/tkext/al-tktable.rb +0 -0
- data/ext/ae-ruby-debug/ae-ruby-debug.conf +0 -0
- data/ext/ae-ruby-debug/ae-ruby-debug.rb +1 -0
- data/ext/ae-search-in-files/ae-search-in-files.conf +0 -0
- data/ext/ae-search-in-files/ae-search-in-files.rb +14 -10
- data/ext/ae-shell/ae-shell.conf +0 -0
- data/ext/ae-shell/ae-shell.rb +1 -1
- data/ext/ae-shell/sh.rb +0 -0
- data/lib/a-commons.rb +5 -1
- data/lib/a-contracts.rb +1 -0
- data/lib/a-core.rb +40 -9
- data/lib/a-tkcommons.rb +229 -1
- data/tcl/BWidget-1.8.0/BWman/ArrowButton.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/BWidget.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/Button.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/ButtonBox.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/ComboBox.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/Dialog.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/DragSite.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/DropSite.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/DynamicHelp.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/Entry.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/Label.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/LabelEntry.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/LabelFrame.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/ListBox.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/MainFrame.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/MessageDlg.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/NoteBook.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/PagesManager.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/PanedWindow.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/PanelFrame.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/PasswdDlg.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/ProgressBar.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/ProgressDlg.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/ScrollView.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/ScrollableFrame.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/ScrolledWindow.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/SelectColor.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/SelectFont.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/Separator.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/SpinBox.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/StatusBar.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/TitleFrame.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/Tree.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/Widget.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/contents.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/index.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/navtree.html +0 -0
- data/tcl/BWidget-1.8.0/BWman/options.htm +0 -0
- data/tcl/BWidget-1.8.0/CHANGES.txt +0 -0
- data/tcl/BWidget-1.8.0/ChangeLog +0 -0
- data/tcl/BWidget-1.8.0/LICENSE.txt +0 -0
- data/tcl/BWidget-1.8.0/README.txt +0 -0
- data/tcl/BWidget-1.8.0/arrow.tcl +0 -0
- data/tcl/BWidget-1.8.0/bitmap.tcl +0 -0
- data/tcl/BWidget-1.8.0/button.tcl +0 -0
- data/tcl/BWidget-1.8.0/buttonbox.tcl +0 -0
- data/tcl/BWidget-1.8.0/color.tcl +0 -0
- data/tcl/BWidget-1.8.0/combobox.tcl +0 -0
- data/tcl/BWidget-1.8.0/demo/basic.tcl +0 -0
- data/tcl/BWidget-1.8.0/demo/bwidget.xbm +0 -0
- data/tcl/BWidget-1.8.0/demo/demo.tcl +0 -0
- data/tcl/BWidget-1.8.0/demo/dnd.tcl +0 -0
- data/tcl/BWidget-1.8.0/demo/manager.tcl +0 -0
- data/tcl/BWidget-1.8.0/demo/select.tcl +0 -0
- data/tcl/BWidget-1.8.0/demo/tmpldlg.tcl +0 -0
- data/tcl/BWidget-1.8.0/demo/tree.tcl +0 -0
- data/tcl/BWidget-1.8.0/demo/x1.xbm +0 -0
- data/tcl/BWidget-1.8.0/dialog.tcl +0 -0
- data/tcl/BWidget-1.8.0/dragsite.tcl +0 -0
- data/tcl/BWidget-1.8.0/dropsite.tcl +0 -0
- data/tcl/BWidget-1.8.0/dynhelp.tcl +0 -0
- data/tcl/BWidget-1.8.0/entry.tcl +0 -0
- data/tcl/BWidget-1.8.0/font.tcl +0 -0
- data/tcl/BWidget-1.8.0/images/bold.gif +0 -0
- data/tcl/BWidget-1.8.0/images/copy.gif +0 -0
- data/tcl/BWidget-1.8.0/images/cut.gif +0 -0
- data/tcl/BWidget-1.8.0/images/dragfile.gif +0 -0
- data/tcl/BWidget-1.8.0/images/dragicon.gif +0 -0
- data/tcl/BWidget-1.8.0/images/error.gif +0 -0
- data/tcl/BWidget-1.8.0/images/file.gif +0 -0
- data/tcl/BWidget-1.8.0/images/folder.gif +0 -0
- data/tcl/BWidget-1.8.0/images/hourglass.gif +0 -0
- data/tcl/BWidget-1.8.0/images/info.gif +0 -0
- data/tcl/BWidget-1.8.0/images/italic.gif +0 -0
- data/tcl/BWidget-1.8.0/images/minus.xbm +0 -0
- data/tcl/BWidget-1.8.0/images/new.gif +0 -0
- data/tcl/BWidget-1.8.0/images/opcopy.xbm +0 -0
- data/tcl/BWidget-1.8.0/images/open.gif +0 -0
- data/tcl/BWidget-1.8.0/images/openfold.gif +0 -0
- data/tcl/BWidget-1.8.0/images/oplink.xbm +0 -0
- data/tcl/BWidget-1.8.0/images/opmove.xbm +0 -0
- data/tcl/BWidget-1.8.0/images/overstrike.gif +0 -0
- data/tcl/BWidget-1.8.0/images/palette.gif +0 -0
- data/tcl/BWidget-1.8.0/images/passwd.gif +0 -0
- data/tcl/BWidget-1.8.0/images/paste.gif +0 -0
- data/tcl/BWidget-1.8.0/images/plus.xbm +0 -0
- data/tcl/BWidget-1.8.0/images/print.gif +0 -0
- data/tcl/BWidget-1.8.0/images/question.gif +0 -0
- data/tcl/BWidget-1.8.0/images/redo.gif +0 -0
- data/tcl/BWidget-1.8.0/images/save.gif +0 -0
- data/tcl/BWidget-1.8.0/images/target.xbm +0 -0
- data/tcl/BWidget-1.8.0/images/underline.gif +0 -0
- data/tcl/BWidget-1.8.0/images/undo.gif +0 -0
- data/tcl/BWidget-1.8.0/images/warning.gif +0 -0
- data/tcl/BWidget-1.8.0/init.tcl +0 -0
- data/tcl/BWidget-1.8.0/label.tcl +0 -0
- data/tcl/BWidget-1.8.0/labelentry.tcl +0 -0
- data/tcl/BWidget-1.8.0/labelframe.tcl +0 -0
- data/tcl/BWidget-1.8.0/lang/da.rc +0 -0
- data/tcl/BWidget-1.8.0/lang/de.rc +0 -0
- data/tcl/BWidget-1.8.0/lang/en.rc +0 -0
- data/tcl/BWidget-1.8.0/lang/es.rc +0 -0
- data/tcl/BWidget-1.8.0/lang/fr.rc +0 -0
- data/tcl/BWidget-1.8.0/listbox.tcl +0 -0
- data/tcl/BWidget-1.8.0/mainframe.tcl +0 -0
- data/tcl/BWidget-1.8.0/messagedlg.tcl +0 -0
- data/tcl/BWidget-1.8.0/notebook.tcl +0 -0
- data/tcl/BWidget-1.8.0/pagesmgr.tcl +0 -0
- data/tcl/BWidget-1.8.0/panedw.tcl +0 -0
- data/tcl/BWidget-1.8.0/panelframe.tcl +0 -0
- data/tcl/BWidget-1.8.0/passwddlg.tcl +0 -0
- data/tcl/BWidget-1.8.0/pkgIndex.tcl +0 -0
- data/tcl/BWidget-1.8.0/progressbar.tcl +0 -0
- data/tcl/BWidget-1.8.0/progressdlg.tcl +0 -0
- data/tcl/BWidget-1.8.0/scrollframe.tcl +0 -0
- data/tcl/BWidget-1.8.0/scrollview.tcl +0 -0
- data/tcl/BWidget-1.8.0/scrollw.tcl +0 -0
- data/tcl/BWidget-1.8.0/separator.tcl +0 -0
- data/tcl/BWidget-1.8.0/spinbox.tcl +0 -0
- data/tcl/BWidget-1.8.0/statusbar.tcl +0 -0
- data/tcl/BWidget-1.8.0/tests/entry.test +0 -0
- data/tcl/BWidget-1.8.0/titleframe.tcl +0 -0
- data/tcl/BWidget-1.8.0/tree.tcl +0 -0
- data/tcl/BWidget-1.8.0/utils.tcl +0 -0
- data/tcl/BWidget-1.8.0/widget.tcl +0 -0
- data/tcl/BWidget-1.8.0/wizard.tcl +0 -0
- data/tcl/BWidget-1.8.0/xpm2image.tcl +0 -0
- metadata +2 -25
- data/ext/ae-complete-code/ae-complete-code.conf +0 -6
- data/ext/ae-complete-code/ae-complete-code.rb +0 -74
- data/ext/ae-doc-code/ae-doc-code.conf +0 -15
- data/ext/ae-doc-code/ae-doc-code.rb +0 -300
- data/ext/ae-event-log/ae-event-log.conf +0 -5
- data/ext/ae-event-log/ae-event-log.rb +0 -46
- data/ext/ae-flag/ae-flag.conf +0 -6
- data/ext/ae-flag/ae-flag.rb +0 -12
- data/ext/ae-output-event/ae-output-event.conf +0 -15
data/ext/ae-editor/ae-editor.rb
CHANGED
@@ -2,17 +2,21 @@
|
|
2
2
|
# ae-editor.rb - Arcadia Ruby ide
|
3
3
|
# by Antonio Galeone <antonio-galeone@rubyforge.org>
|
4
4
|
#
|
5
|
+
# §require_dir_ref=../..
|
6
|
+
# §require_omissis=conf/arcadia.init
|
5
7
|
|
6
8
|
require 'tk'
|
7
9
|
require 'tktext'
|
8
10
|
require 'lib/a-tkcommons'
|
11
|
+
#require 'lib/a-commons'
|
12
|
+
require 'lib/a-core'
|
9
13
|
|
10
14
|
class TreeNode
|
11
15
|
attr_reader :sons
|
12
16
|
attr_reader :parent
|
13
17
|
attr_reader :kind
|
14
|
-
attr_reader :rif, :label, :helptext
|
15
|
-
attr_writer :rif, :label, :helptext
|
18
|
+
attr_reader :rif, :rif_end, :label, :helptext
|
19
|
+
attr_writer :rif, :rif_end, :label, :helptext
|
16
20
|
def initialize(parent=nil, kind='KClass')
|
17
21
|
@sons = Array.new
|
18
22
|
@parent = parent
|
@@ -28,6 +32,502 @@ class TreeNode
|
|
28
32
|
end
|
29
33
|
end
|
30
34
|
|
35
|
+
class SourceStructure
|
36
|
+
attr_reader :root
|
37
|
+
attr_reader :injected_row
|
38
|
+
def initialize(_source)
|
39
|
+
_row = 1
|
40
|
+
_liv = 0
|
41
|
+
_livs = Array.new
|
42
|
+
@root = TreeNode.new(nil, 'KRoot'){|_node|
|
43
|
+
_node.rif= 'root'
|
44
|
+
_node.label=''
|
45
|
+
}
|
46
|
+
_livs[_liv]=@root
|
47
|
+
_source.each_line{|line|
|
48
|
+
line = "\s"+line.split("#")[0]+"\s"
|
49
|
+
m = /[\s\n\t\;]+(module|class|def|if|unless|begin|case|for|while|do)[\s\n\t\;]+/.match("\s#{line}")
|
50
|
+
if m
|
51
|
+
index = m.post_match.strip.length - 1
|
52
|
+
if m.post_match.strip[index,index]=='{'
|
53
|
+
_row = _row +1
|
54
|
+
next
|
55
|
+
end
|
56
|
+
_liv>=0? _liv = _liv + 1:_liv=1
|
57
|
+
_pliv = _liv
|
58
|
+
_parent = nil
|
59
|
+
while (_parent == nil && _pliv>=0)
|
60
|
+
_pliv = _pliv -1
|
61
|
+
_parent = _livs[_pliv]
|
62
|
+
end
|
63
|
+
if _parent
|
64
|
+
_helptext = m.post_match.strip
|
65
|
+
_label = _helptext.split('<')[0]
|
66
|
+
if _label == nil || _label.strip.length==0
|
67
|
+
_label = _helptext
|
68
|
+
end
|
69
|
+
if (m[0].strip[0..4] == "class" && m.pre_match.strip.length==0)
|
70
|
+
_kind = 'KClass'
|
71
|
+
elsif (m[0].strip[0..4] == "class" && m.pre_match.strip.length>0)
|
72
|
+
_row = _row +1
|
73
|
+
_liv = _liv - 1
|
74
|
+
next
|
75
|
+
elsif (m[0].strip[0..5] == "module" && m.pre_match.strip.length==0)
|
76
|
+
_kind = 'KModule'
|
77
|
+
elsif (m[0].strip[0..5] == "module" && m.pre_match.strip.length>0)
|
78
|
+
_row = _row +1
|
79
|
+
_liv = _liv - 1
|
80
|
+
next
|
81
|
+
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))
|
82
|
+
_row = _row +1
|
83
|
+
next
|
84
|
+
elsif ((m[0].strip[0..1] == "if" || m[0].strip[0..5] == "unless") && m.pre_match.strip.length>0)
|
85
|
+
_row = _row +1
|
86
|
+
_liv = _liv - 1
|
87
|
+
next
|
88
|
+
elsif (m[0].strip[0..2] == "def" && m.pre_match.strip.length==0)
|
89
|
+
_kind = 'KDef'
|
90
|
+
if _label.include?(_parent.label + '.')
|
91
|
+
_kind = 'KDefClass'
|
92
|
+
end
|
93
|
+
# elsif (m[0].strip[0..10] == "attr_reader" && m.pre_match.strip.length==0)
|
94
|
+
# _kind = 'KAttr_reader'
|
95
|
+
# _liv = _liv - 1
|
96
|
+
# _row = _row +1
|
97
|
+
end
|
98
|
+
|
99
|
+
if _livs[_liv-1] && _livs[_liv-1].kind != 'KDef'
|
100
|
+
TreeNode.new(_parent, _kind){|_node|
|
101
|
+
_node.label = _label
|
102
|
+
_node.helptext = _helptext
|
103
|
+
_node.rif = _row.to_s
|
104
|
+
_livs[_pliv + 1]=_node
|
105
|
+
}
|
106
|
+
# elsif _kind == 'KDef' && _parent == @root
|
107
|
+
# TreeNode.new(_livs[_liv+1], _kind){|_node|
|
108
|
+
# _node.label = _label
|
109
|
+
# _node.helptext = _helptext
|
110
|
+
# _node.rif = _row.to_s
|
111
|
+
# _livs[_pliv+2]=_node
|
112
|
+
# }
|
113
|
+
# _liv = _liv + 2
|
114
|
+
else
|
115
|
+
TreeNode.new(_livs[_liv-3], _kind){|_node|
|
116
|
+
_node.label = _label
|
117
|
+
_node.helptext = _helptext
|
118
|
+
_node.rif = _row.to_s
|
119
|
+
_livs[_pliv-1]=_node
|
120
|
+
}
|
121
|
+
_liv = _liv - 2
|
122
|
+
end
|
123
|
+
else
|
124
|
+
_row = _row +1
|
125
|
+
_liv = _liv - 1
|
126
|
+
next
|
127
|
+
end
|
128
|
+
end
|
129
|
+
m_end = /[\s\n\t\;]+end[\s\n\t\;]+/.match(line)
|
130
|
+
if m_end
|
131
|
+
if _livs[_liv]
|
132
|
+
_livs[_liv].rif_end = _row
|
133
|
+
#p "#{_livs[_liv].helptext} rif_end = #{_livs[_liv].rif_end}"
|
134
|
+
end
|
135
|
+
_liv = _liv - 1
|
136
|
+
end
|
137
|
+
_row = _row +1
|
138
|
+
}
|
139
|
+
end
|
140
|
+
|
141
|
+
def scheletor_from_node(_node, _source='', _injected_source='', _injected_class='')
|
142
|
+
_hinner_source = ''
|
143
|
+
#_sons = _node.sons.sort
|
144
|
+
_sons = _node.sons
|
145
|
+
for inode in 0.._sons.length - 1
|
146
|
+
_son = _sons[inode]
|
147
|
+
if _son.kind == 'KClass'
|
148
|
+
_hinner_source = "#{_hinner_source}class #{_son.helptext}\n"
|
149
|
+
elsif _son.kind == 'KModule'
|
150
|
+
_hinner_source = "#{_hinner_source}module #{_son.helptext}\n"
|
151
|
+
elsif _son.kind == 'KDef' && _son.helptext != 'initialize'
|
152
|
+
|
153
|
+
_hinner_source = "#{_hinner_source} def #{_son.helptext}\n"
|
154
|
+
_hinner_source = "#{_hinner_source} end\n"
|
155
|
+
elsif _son.kind == 'KDefClass'
|
156
|
+
_hinner_source = "#{_hinner_source} def #{_son.helptext}\n"
|
157
|
+
_hinner_source = "#{_hinner_source} end\n"
|
158
|
+
end
|
159
|
+
_hinner_source= scheletor_from_node(_son, _hinner_source, _injected_source, _injected_class)
|
160
|
+
end
|
161
|
+
_source = "#{_source}#{_hinner_source}" if _hinner_source.strip.length>0
|
162
|
+
if _node.kind == 'KClass' && _node.label == _injected_class
|
163
|
+
_source = "#{_source} def initialize\n #{_injected_source} end\n"
|
164
|
+
@injected_row = _source.split("\n").length-2
|
165
|
+
end
|
166
|
+
_source = "#{_source}end\n" if _node.kind == 'KClass' || _node.kind == 'KModule'
|
167
|
+
_source
|
168
|
+
end
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
def node_by_line(_from_node, _line)
|
173
|
+
_found_node = nil
|
174
|
+
_begin = _from_node.rif.to_i
|
175
|
+
_end = _from_node.rif_end.to_i
|
176
|
+
if _line.to_i <= _end && _line.to_i >= _begin
|
177
|
+
_found_node = _from_node
|
178
|
+
else
|
179
|
+
_sons = _from_node.sons
|
180
|
+
for inode in 0.._sons.length - 1
|
181
|
+
_son = _sons[inode]
|
182
|
+
_found_node = node_by_line(_son, _line)
|
183
|
+
break if _found_node
|
184
|
+
end
|
185
|
+
end
|
186
|
+
return _found_node
|
187
|
+
end
|
188
|
+
|
189
|
+
|
190
|
+
def class_node_by_line(_line)
|
191
|
+
line_node = node_by_line(@root, _line)
|
192
|
+
class_node = line_node
|
193
|
+
while class_node != nil && class_node.kind != "KClass"
|
194
|
+
class_node = class_node.parent
|
195
|
+
end
|
196
|
+
return class_node
|
197
|
+
end
|
198
|
+
|
199
|
+
def classies
|
200
|
+
end
|
201
|
+
def modules
|
202
|
+
end
|
203
|
+
def class_methods(_class)
|
204
|
+
end
|
205
|
+
|
206
|
+
|
207
|
+
end
|
208
|
+
|
209
|
+
class SafeCompleteCode
|
210
|
+
attr_reader :modified_row, :modified_col
|
211
|
+
attr_reader :filter
|
212
|
+
def initialize(_source, _row, _col, _file=nil)
|
213
|
+
@source = _source
|
214
|
+
@file = _file
|
215
|
+
@row = _row.to_i
|
216
|
+
@col = _col.to_i
|
217
|
+
@ss = SourceStructure.new(_source)
|
218
|
+
@filter=''
|
219
|
+
#@candidates = Array.new
|
220
|
+
process_source
|
221
|
+
end
|
222
|
+
|
223
|
+
# def dot_trip(_var_name)
|
224
|
+
# ret = "_candidates << #{_var_name}.class.to_s.sub('#{self.class.to_s}::','')\n"
|
225
|
+
# ret = ret + "#{_var_name}.class.instance_methods.each{|m|\n"
|
226
|
+
# ret = ret + "meth = #{_var_name}.method(m)\n"
|
227
|
+
# ret = ret + "_candidates << meth.owner.to_s.sub('#{self.class.to_s}::','')+'#'+m+'#'+meth.arity.to_s\n"
|
228
|
+
# ret = ret + "}\n"
|
229
|
+
# #ret = ret + "exit\n"
|
230
|
+
# ret
|
231
|
+
# end
|
232
|
+
|
233
|
+
def dot_trip(_var_name)
|
234
|
+
ret = "_class=#{_var_name}.class.name\n"
|
235
|
+
# ret = ret +"if _class=='Class'\n"
|
236
|
+
# ret = ret +" _methods=#{_var_name}.singleton_methods\n"
|
237
|
+
# ret = ret +"else\n"
|
238
|
+
# ret = ret +" _methods=#{_var_name}.class.instance_methods\n"
|
239
|
+
# ret = ret +"end\n"
|
240
|
+
ret = ret +" _methods=#{_var_name}.methods\n"
|
241
|
+
ret = ret +"owner_on = Method.instance_methods.include?('owner')\n"
|
242
|
+
ret = ret + "_methods.each{|m|\n"
|
243
|
+
ret = ret + "meth = #{_var_name}.method(m)\n"
|
244
|
+
ret = ret +"if owner_on\n"
|
245
|
+
ret = ret +"_owner=meth.owner.name\n"
|
246
|
+
ret = ret +"else\n"
|
247
|
+
ret = ret +"meth_insp = meth.inspect\n"
|
248
|
+
ret = ret +"to_sub ='#<Method:\s'+_class\n"
|
249
|
+
ret = ret +"_owner=meth_insp.sub(to_sub,'').split('#')[0].strip.sub('(','').sub(')','')\n"
|
250
|
+
ret = ret +"_owner=_class if _owner.strip.length==0\n"
|
251
|
+
ret = ret +"end\n"
|
252
|
+
ret = ret + "if _owner != _class\n"
|
253
|
+
ret = ret + "print _owner+'#'+m+'#'+meth.arity.to_s+'\n'\n"
|
254
|
+
ret = ret +"else\n"
|
255
|
+
ret = ret + "print ''+'#'+m+'#'+meth.arity.to_s+'\n'\n"
|
256
|
+
ret = ret +"end\n"
|
257
|
+
ret = ret + "}\n"
|
258
|
+
ret = ret + "exit\n"
|
259
|
+
ret
|
260
|
+
end
|
261
|
+
|
262
|
+
def scope_trip
|
263
|
+
ret = "ObjectSpace.each_object(Class){|o|\n"
|
264
|
+
ret = ret + " o_name = o.name\n"
|
265
|
+
ret = ret + " print '#'+o_name+'\n' if o_name && o_name.strip.length>0 \n"
|
266
|
+
ret = ret + "}\n"
|
267
|
+
ret = ret + dot_trip('self')
|
268
|
+
ret
|
269
|
+
end
|
270
|
+
|
271
|
+
def declaration(_dec_line='')
|
272
|
+
if _dec_line.include?('.new')
|
273
|
+
pre, post = _dec_line.split('.new')
|
274
|
+
dec_line_processed = "#{pre}.new"
|
275
|
+
post.strip!
|
276
|
+
if post && post[0..0]=='('
|
277
|
+
k=0
|
278
|
+
ch = '('
|
279
|
+
while k < post.length && ch != ')'
|
280
|
+
k = k+1
|
281
|
+
ch=post[k..k]
|
282
|
+
end
|
283
|
+
if ch == ')'
|
284
|
+
args = post[1..k-1]
|
285
|
+
args_array = args.split(',')
|
286
|
+
n_args = args_array.length
|
287
|
+
if n_args > 0
|
288
|
+
new_args = ''
|
289
|
+
1.upto( n_args ){
|
290
|
+
if new_args.length > 0
|
291
|
+
new_args = "#{new_args},"
|
292
|
+
end
|
293
|
+
new_args = "#{new_args}nil"
|
294
|
+
}
|
295
|
+
dec_line_processed = "#{dec_line_processed}(#{new_args})"
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
299
|
+
else
|
300
|
+
dec_line_processed = _dec_line
|
301
|
+
end
|
302
|
+
dec_line_processed
|
303
|
+
end
|
304
|
+
|
305
|
+
def is_dot?
|
306
|
+
@is_dot
|
307
|
+
end
|
308
|
+
|
309
|
+
def process_source
|
310
|
+
@modified_source = ""
|
311
|
+
@modified_row = @row
|
312
|
+
@modified_col = @col
|
313
|
+
source_array = @source.split("\n")
|
314
|
+
#---------------------------------
|
315
|
+
focus_line = source_array[@row-1]
|
316
|
+
focus_line = '' if focus_line.nil?
|
317
|
+
focus_world = ''
|
318
|
+
if focus_line && focus_line.strip.length > 0
|
319
|
+
if focus_line[@col-1..@col-1] == '.'
|
320
|
+
@is_dot=true
|
321
|
+
focus_segment = focus_line[0..@col-2]
|
322
|
+
elsif focus_line.include?('.')
|
323
|
+
@is_dot=true
|
324
|
+
focus_segment_array = focus_line.split('.')
|
325
|
+
focus_segment = ''
|
326
|
+
focus_segment_array[0..-2].each{|seg|
|
327
|
+
if focus_segment.strip.length > 0
|
328
|
+
focus_segment = focus_segment+'.'
|
329
|
+
end
|
330
|
+
focus_segment = focus_segment+seg
|
331
|
+
}
|
332
|
+
@filter = focus_segment_array[-1].strip
|
333
|
+
else
|
334
|
+
focus_segment = ''
|
335
|
+
@filter = focus_word(focus_line[0..@col-1].strip)
|
336
|
+
end
|
337
|
+
focus_world= focus_word(focus_segment)
|
338
|
+
end
|
339
|
+
@class_node = @ss.class_node_by_line(@row)
|
340
|
+
#---------------------------------
|
341
|
+
@modified_source = "#{@modified_source}Dir.chdir('#{File.dirname(@file)}')\n" if @file
|
342
|
+
@modified_row = @modified_row+1
|
343
|
+
source_array.each_with_index{|line,j|
|
344
|
+
# 0) se è un commento non lo prendo in considerazione
|
345
|
+
if line.strip.length > 0 && line.strip[0..0]=='#'
|
346
|
+
@modified_row = @modified_row-1
|
347
|
+
m = /§require_dir_ref=[\s]*(.)*/.match(line)
|
348
|
+
if m
|
349
|
+
require_dir_ref=line.split('§require_dir_ref=')[1].strip
|
350
|
+
@modified_source = "#{@modified_source}Dir.chdir('#{require_dir_ref}')\n"
|
351
|
+
@modified_row = @modified_row+1
|
352
|
+
end
|
353
|
+
m = /§require_omissis=[\s]*(.)*/.match(line)
|
354
|
+
if m
|
355
|
+
require_omissis=line.split('§require_omissis=')[1].strip
|
356
|
+
@modified_source = "#{@modified_source}require '#{require_omissis}'\n"
|
357
|
+
@modified_row = @modified_row+1
|
358
|
+
end
|
359
|
+
|
360
|
+
|
361
|
+
# 1) includiano i require
|
362
|
+
elsif line.strip.length>7 && (line.strip[0..7]=="require " || line.strip[0..7]=="require(")
|
363
|
+
@modified_source = "#{@modified_source}#{line}\n"
|
364
|
+
#@modified_row = @modified_row+1
|
365
|
+
#Arcadia.console(self, 'msg'=>"per require @modified_row=#{@modified_row}")
|
366
|
+
# 2) includiano la riga da evaluare con un $SAFE 3
|
367
|
+
elsif j.to_i == @row-1
|
368
|
+
focus_line = line
|
369
|
+
break
|
370
|
+
# 3) eliminiamo la riga
|
371
|
+
else
|
372
|
+
@modified_row = @modified_row-1
|
373
|
+
end
|
374
|
+
break if j.to_i >= @row - 1
|
375
|
+
}
|
376
|
+
if focus_line
|
377
|
+
# ricerchiamo una eventuale dichiarazione
|
378
|
+
if focus_world && focus_world.strip.length > 0
|
379
|
+
begin
|
380
|
+
re = Regexp::new('[\s\n\t\;]('+focus_world.strip+')[\s\t]*=(.)*')
|
381
|
+
source_array.each_with_index do |line,j|
|
382
|
+
#m = /[\s\n\t\;](#{focus_world})[\s\t]*=(.)*/.match(line)
|
383
|
+
|
384
|
+
m = re.match("\s#{line}")
|
385
|
+
if m
|
386
|
+
@dec_line = line
|
387
|
+
@class_dec_line_node = @ss.class_node_by_line(j+1)
|
388
|
+
break
|
389
|
+
end
|
390
|
+
end
|
391
|
+
rescue Exception => e
|
392
|
+
# Arcadia.console(self, 'msg'=>e.inspect, 'level'=>'error')
|
393
|
+
end
|
394
|
+
|
395
|
+
end
|
396
|
+
|
397
|
+
if @class_node
|
398
|
+
to_iniect = "$SAFE = 3\n"
|
399
|
+
if @class_dec_line_node && @class_dec_line_node.label == @class_node.label
|
400
|
+
to_iniect = "#{to_iniect}#{declaration(@dec_line)}\n"
|
401
|
+
end
|
402
|
+
if focus_world.length > 0
|
403
|
+
to_iniect = "#{to_iniect}#{dot_trip(focus_world)}\n"
|
404
|
+
else
|
405
|
+
to_iniect = "#{to_iniect}#{scope_trip}\n"
|
406
|
+
end
|
407
|
+
#to_iniect = "#{to_iniect}#{focus_line}\n"
|
408
|
+
to_iniect_class = @class_node.label
|
409
|
+
else
|
410
|
+
to_iniect = ''
|
411
|
+
to_iniect_class = ''
|
412
|
+
end
|
413
|
+
|
414
|
+
ss_source = @ss.scheletor_from_node(@ss.root,'',to_iniect, to_iniect_class)
|
415
|
+
ss_source_array = ss_source.split("\n")
|
416
|
+
ss_len = ss_source_array.length
|
417
|
+
if ss_len>0 && ss_source_array[0].strip != focus_line.strip
|
418
|
+
@modified_source = "#{@modified_source}#{ss_source}"
|
419
|
+
if @class_node
|
420
|
+
@modified_source = "#{@modified_source}#{@class_node.label.downcase} = #{@class_node.label}.new\n"
|
421
|
+
end
|
422
|
+
else
|
423
|
+
ss_len = 0
|
424
|
+
@class_node = nil
|
425
|
+
end
|
426
|
+
if @class_node
|
427
|
+
@modified_row = @modified_row + @ss.injected_row
|
428
|
+
else
|
429
|
+
@modified_source = "#{@modified_source}$SAFE = 3\n"
|
430
|
+
if @dec_line
|
431
|
+
|
432
|
+
|
433
|
+
@modified_source = "#{@modified_source}#{declaration(@dec_line)}\n"
|
434
|
+
@modified_row = @modified_row+1
|
435
|
+
end
|
436
|
+
#@modified_source = "#{@modified_source}_candidates=@candidates\n"
|
437
|
+
if focus_world.length > 0
|
438
|
+
@modified_source = "#{@modified_source}#{dot_trip(focus_world)}\n"
|
439
|
+
else
|
440
|
+
@modified_source = "#{@modified_source}#{scope_trip}\n"
|
441
|
+
end
|
442
|
+
#@modified_source = "#{@modified_source}@candidates=_candidates\n"
|
443
|
+
|
444
|
+
|
445
|
+
#@modified_source = "#{@modified_source}#{focus_line}\n"
|
446
|
+
@modified_row = @modified_row+1+ss_len
|
447
|
+
end
|
448
|
+
end
|
449
|
+
|
450
|
+
# Arcadia.console(self, 'msg'=>@modified_source)
|
451
|
+
# Arcadia.console(self, 'msg'=>"@modified_row=#{@modified_row}")
|
452
|
+
# Arcadia.console(self, 'msg'=>"focus_line=#{focus_line}") if focus_line
|
453
|
+
# Arcadia.console(self, 'msg'=>"focus_world=#{focus_world}") if focus_world
|
454
|
+
# Arcadia.console(self, 'msg'=>"@filter=#{@filter}") if @filter
|
455
|
+
# Arcadia.console(self, 'msg'=>"@dec_line=#{@dec_line}") if @dec_line
|
456
|
+
# Arcadia.console(self, 'msg'=>"declaration(@dec_line)=#{declaration(@dec_line)}") if @dec_line
|
457
|
+
end
|
458
|
+
|
459
|
+
def focus_word(focus_segment)
|
460
|
+
focus_world = ''
|
461
|
+
j = focus_segment.length - 1
|
462
|
+
char = focus_segment[j..j]
|
463
|
+
if char != ')'
|
464
|
+
while !["\s","\t",";",",","(","[","{",">"].include?(char) && j >= 0
|
465
|
+
focus_world = "#{char}#{focus_world}"
|
466
|
+
j=j-1
|
467
|
+
char = focus_segment[j..j]
|
468
|
+
end
|
469
|
+
else
|
470
|
+
while !["\s","\t",";"].include?(char) && j >= 0
|
471
|
+
focus_world = "#{char}#{focus_world}"
|
472
|
+
j=j-1
|
473
|
+
char = focus_segment[j..j]
|
474
|
+
end
|
475
|
+
end
|
476
|
+
focus_world
|
477
|
+
end
|
478
|
+
|
479
|
+
def candidates(_show_error = false)
|
480
|
+
temp_file = create_temp_file(@file)
|
481
|
+
begin
|
482
|
+
_cmp_s = "|ruby #{temp_file}"
|
483
|
+
_ret = nil
|
484
|
+
open(_cmp_s,"r") do
|
485
|
+
|f|
|
486
|
+
_ret = f.readlines.collect!{| line |
|
487
|
+
#line.chomp
|
488
|
+
line
|
489
|
+
}
|
490
|
+
end
|
491
|
+
# if _ret.length == 0 && _show_error
|
492
|
+
# _cmp_s_d = _cmp_s+" 2>&1"
|
493
|
+
# _error = nil
|
494
|
+
# open(_cmp_s_d,"r") do
|
495
|
+
# |f|
|
496
|
+
# _error = f.readlines.collect!{| line | line.chomp}
|
497
|
+
# end
|
498
|
+
# if _error != nil && _error.length > 0
|
499
|
+
# Arcadia.console(self, 'msg'=>_error.to_s, 'level'=>'error')
|
500
|
+
# end
|
501
|
+
# end
|
502
|
+
_ret.sort
|
503
|
+
rescue Exception => e
|
504
|
+
# Arcadia.console(self, 'msg'=>e.to_s, 'level'=>'error')
|
505
|
+
ensure
|
506
|
+
File.delete(temp_file) if File.exist?(temp_file)
|
507
|
+
end
|
508
|
+
end
|
509
|
+
|
510
|
+
|
511
|
+
def create_temp_file(_base_file=nil)
|
512
|
+
if _base_file
|
513
|
+
_file = _base_file+'~~'
|
514
|
+
else
|
515
|
+
_file = 'buffer~~'
|
516
|
+
end
|
517
|
+
f = File.new(_file, "w")
|
518
|
+
begin
|
519
|
+
if f
|
520
|
+
f.syswrite(@modified_source)
|
521
|
+
end
|
522
|
+
ensure
|
523
|
+
f.close unless f.nil?
|
524
|
+
end
|
525
|
+
_file
|
526
|
+
end
|
527
|
+
|
528
|
+
end
|
529
|
+
|
530
|
+
|
31
531
|
#class TkArcadiaText < TkText
|
32
532
|
#
|
33
533
|
# def insert(insert, chars,*tags)
|
@@ -37,6 +537,90 @@ end
|
|
37
537
|
# end
|
38
538
|
#end
|
39
539
|
|
540
|
+
|
541
|
+
class TkTextListBox < TkScrollText
|
542
|
+
def initialize(parent=nil, keys={})
|
543
|
+
super(parent, keys)
|
544
|
+
wrap 'none'
|
545
|
+
tag_configure('selected','background' =>'#bbd9b1','borderwidth'=>1, 'relief'=>'raised')
|
546
|
+
tag_configure('class', 'foreground' => '#3398cb')
|
547
|
+
@count = 0
|
548
|
+
@selected = -1
|
549
|
+
self.bind_append('KeyPress'){|e| key_press(e)}
|
550
|
+
self.bind_append('KeyRelease'){|e| key_release(e)}
|
551
|
+
self.bind_append("ButtonPress-1", proc{|x,y| button_press(x,y)}, "%x %y")
|
552
|
+
end
|
553
|
+
|
554
|
+
|
555
|
+
def insert(index, chars, *tags)
|
556
|
+
super(index, chars, *tags)
|
557
|
+
end
|
558
|
+
|
559
|
+
def add(chars)
|
560
|
+
meth_str, class_str = chars.split('-')
|
561
|
+
if meth_str && meth_str.strip.length>0 && class_str
|
562
|
+
insert('end', "#{meth_str}")
|
563
|
+
insert('end', "-#{class_str}\n", 'class')
|
564
|
+
elsif meth_str && meth_str.strip.length==0 && class_str
|
565
|
+
insert('end', "-#{class_str}\n")
|
566
|
+
else
|
567
|
+
insert('end', "#{chars}\n")
|
568
|
+
end
|
569
|
+
@count = @count+1
|
570
|
+
end
|
571
|
+
|
572
|
+
def clear
|
573
|
+
delete('1.0','end')
|
574
|
+
@count = 0
|
575
|
+
end
|
576
|
+
|
577
|
+
def button_press(x,y)
|
578
|
+
_index = self.index("@#{x},#{y}")
|
579
|
+
_line = _index.split('.')[0].to_i
|
580
|
+
self.select(_line)
|
581
|
+
end
|
582
|
+
|
583
|
+
def key_press(_e)
|
584
|
+
case _e.keysym
|
585
|
+
when 'Up'
|
586
|
+
if @selected > 0
|
587
|
+
select(@selected-1)
|
588
|
+
end
|
589
|
+
when 'Down'
|
590
|
+
if @selected < @count
|
591
|
+
select(@selected+1)
|
592
|
+
end
|
593
|
+
end
|
594
|
+
end
|
595
|
+
|
596
|
+
def key_release(_e)
|
597
|
+
case _e.keysym
|
598
|
+
when 'Next','Prior'
|
599
|
+
index = self.index('@0,0')
|
600
|
+
line = index.split('.')[0].to_i
|
601
|
+
select(line)
|
602
|
+
end
|
603
|
+
end
|
604
|
+
|
605
|
+
def selected_line
|
606
|
+
if @selected > 0
|
607
|
+
self.get("#{@selected}.0", "#{@selected}.0 lineend")
|
608
|
+
end
|
609
|
+
end
|
610
|
+
|
611
|
+
def select(_row)
|
612
|
+
self.tag_remove('selected', '1.0', 'end')
|
613
|
+
_start_index = "#{_row.to_s}.0"
|
614
|
+
_end_index = "#{_start_index} +1 lines linestart"
|
615
|
+
self.tag_add('selected', _start_index, _end_index)
|
616
|
+
self.set_insert(_start_index)
|
617
|
+
self.see(_start_index)
|
618
|
+
@selected = _row
|
619
|
+
end
|
620
|
+
|
621
|
+
end
|
622
|
+
|
623
|
+
|
40
624
|
class AgEditor
|
41
625
|
include Configurable
|
42
626
|
attr_reader :file
|
@@ -60,37 +644,31 @@ class AgEditor
|
|
60
644
|
@loading=false
|
61
645
|
end
|
62
646
|
|
63
|
-
def hide_exp
|
64
|
-
@fm.hide_left if @fm
|
65
|
-
end
|
647
|
+
# def hide_exp
|
648
|
+
# @fm.hide_left if @fm
|
649
|
+
# end
|
66
650
|
|
67
|
-
def is_exp_hide?
|
68
|
-
if @fm.nil?
|
69
|
-
return true
|
70
|
-
else
|
71
|
-
@fm.is_left_hide?
|
72
|
-
end
|
651
|
+
# def is_exp_hide?
|
652
|
+
# if @fm.nil?
|
653
|
+
# return true
|
654
|
+
# else
|
655
|
+
# @fm.is_left_hide?
|
656
|
+
# end
|
657
|
+
# end
|
658
|
+
|
659
|
+
def xy_insert
|
660
|
+
_index_now = @text.index('insert')
|
661
|
+
_rx, _ry, _widht, _heigth = @text.bbox(_index_now);
|
662
|
+
_x = _rx + TkWinfo.rootx(@text)
|
663
|
+
_y = _ry + TkWinfo.rooty(@text) + @font_metrics[2][1]
|
664
|
+
_xroot = _x - TkWinfo.rootx(Arcadia.instance.layout.root)
|
665
|
+
_yroot = _y - TkWinfo.rooty(Arcadia.instance.layout.root)
|
666
|
+
return _xroot, _yroot
|
73
667
|
end
|
74
668
|
|
669
|
+
|
75
670
|
def initialize_tree(_frame)
|
76
|
-
@classbrowsing =
|
77
|
-
|
78
|
-
@nb = Tk::BWidget::NoteBook.new(_frame, Arcadia.style('tabpanel')){
|
79
|
-
# activeforeground 'red'
|
80
|
-
# activebackground 'yellow'
|
81
|
-
# borderwidth 1
|
82
|
-
# font $arcadia['conf']['editor.tabs.font']
|
83
|
-
tabbevelsize 0
|
84
|
-
internalborderwidth 0
|
85
|
-
side $arcadia['conf']['editor.explorer_panel.tabs.side']
|
86
|
-
pack('fill'=>'both', :padx=>0, :pady=>0, :expand => 'yes')
|
87
|
-
}
|
88
|
-
@nb_tab_exp = @nb.insert('end','exp' ,
|
89
|
-
'text'=>'Source Tree',
|
90
|
-
'background'=> Arcadia.style("tabpanel.background"),
|
91
|
-
'foreground'=> Arcadia.style("tabpanel.foreground")
|
92
|
-
)
|
93
|
-
@nb.raise('exp')
|
671
|
+
@classbrowsing = @is_ruby
|
94
672
|
_tree_goto = proc{|_self|
|
95
673
|
_line = _self.selection_get[0]
|
96
674
|
_index =_line.to_s+'.0'
|
@@ -98,7 +676,6 @@ class AgEditor
|
|
98
676
|
_editor_line = @text.get(_index, _index+ ' lineend')
|
99
677
|
if !_editor_line.include?(_hinner_text)
|
100
678
|
Arcadia.console(self, 'msg'=>"... rebuild tree \n")
|
101
|
-
#Arcadia.new_msg(self, "... rebuild tree \n")
|
102
679
|
if @tree_thread && @tree_thread.alive?
|
103
680
|
@tree_thread.exit
|
104
681
|
end
|
@@ -113,24 +690,16 @@ class AgEditor
|
|
113
690
|
@text.tag_remove('selected','1.0','end')
|
114
691
|
@text.tag_add('selected',_line.to_s+'.0',(_line+1).to_s+'.0')
|
115
692
|
}
|
116
|
-
@tree_exp = Tk::BWidget::Tree.new(
|
117
|
-
#background Arcadia.conf('edit.background')
|
118
|
-
#relief Arcadia.conf('edit.relief')
|
119
|
-
#highlightbackground Arcadia.conf('edit.highlightbackground')
|
120
|
-
#borderwidth Arcadia.conf('edit.borderwidth')
|
693
|
+
@tree_exp = Tk::BWidget::Tree.new(_frame, Arcadia.style('treepanel')){
|
121
694
|
showlines false
|
122
695
|
deltay 18
|
123
696
|
dragenabled true
|
124
697
|
selectcommand proc{ _tree_goto.call(self) }
|
125
|
-
place('relwidth' => 1,'relx' => 0,'x' => '0','y' => '0','relheight' => '1','rely' => 0,'height' => 1,'bordermode' => 'inside','width' => '50')
|
126
698
|
}
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
command _c_explo
|
132
|
-
}.pack('side'=>'right', 'fill'=>'y')
|
133
|
-
@tree_exp.yscrollcommand proc{|first,last| _s_explo.set first,last}
|
699
|
+
@tree_scroll_wrapper = TkScrollWidget.new(@tree_exp)
|
700
|
+
@tree_scroll_wrapper.show
|
701
|
+
@tree_scroll_wrapper.show_v_scroll
|
702
|
+
@tree_scroll_wrapper.show_h_scroll
|
134
703
|
pop_up_menu_tree
|
135
704
|
end
|
136
705
|
|
@@ -158,34 +727,37 @@ class AgEditor
|
|
158
727
|
|
159
728
|
|
160
729
|
def initialize_text(_frame)
|
161
|
-
@v_scroll = TkScrollbar.new(_frame,{
|
162
|
-
'orient'=>'vertical'}.update(Arcadia.style('scrollbar'))
|
163
|
-
).pack('side' => 'right', 'fill' => 'y')
|
164
|
-
@text =
|
730
|
+
# @v_scroll = TkScrollbar.new(_frame,{
|
731
|
+
# 'orient'=>'vertical'}.update(Arcadia.style('scrollbar'))
|
732
|
+
# ).pack('side' => 'right', 'fill' => 'y')
|
733
|
+
@text = TkScrollText.new(_frame, Arcadia.style('edit')){|j|
|
165
734
|
wrap 'none'
|
166
|
-
# relief 'flat'
|
167
735
|
undo true
|
168
736
|
insertofftime 200
|
169
737
|
insertontime 200
|
170
|
-
# insertbackground $arcadia['conf']['editor.color.insertbackground']
|
171
|
-
# background $arcadia['conf']['editor.color.background']
|
172
|
-
# foreground $arcadia['conf']['editor.color.foreground']
|
173
|
-
# highlightcolor $arcadia['conf']['editor.color.background']
|
174
738
|
highlightthickness 0
|
175
739
|
insertwidth 3
|
176
740
|
exportselection true
|
177
741
|
autoseparators true
|
178
742
|
padx 0
|
179
743
|
tabs $arcadia['conf']['editor.tabs']
|
180
|
-
place(
|
181
|
-
'x'=>0,
|
182
|
-
'y'=>0,
|
183
|
-
'width' => -15,
|
184
|
-
'relheight'=>1,
|
185
|
-
'relwidth'=>1,
|
186
|
-
'bordermode'=>'outside'
|
187
|
-
)
|
744
|
+
# place(
|
745
|
+
# 'x'=>0,
|
746
|
+
# 'y'=>0,
|
747
|
+
# 'width' => -15,
|
748
|
+
# 'relheight'=>1,
|
749
|
+
# 'relwidth'=>1,
|
750
|
+
# 'bordermode'=>'outside'
|
751
|
+
# )
|
188
752
|
}
|
753
|
+
|
754
|
+
# class << @text
|
755
|
+
# def do_yscrollcommand(first,last)
|
756
|
+
# super
|
757
|
+
# do_line_update()
|
758
|
+
# end
|
759
|
+
# end
|
760
|
+
|
189
761
|
# @text.configure('font', @font);
|
190
762
|
|
191
763
|
#do_tag_configure_global('debug')
|
@@ -194,6 +766,11 @@ class AgEditor
|
|
194
766
|
#@text.tag_configure('debug', 'background' =>'#b9c6d9', 'borderwidth'=>1 ,'relief'=>'raise')
|
195
767
|
@buffer = text_value
|
196
768
|
pop_up_menu
|
769
|
+
@text.show
|
770
|
+
@text.show_v_scroll
|
771
|
+
@text.show_h_scroll
|
772
|
+
@text_cursor = @text.cget('cursor')
|
773
|
+
|
197
774
|
end
|
198
775
|
|
199
776
|
def create_temp_file
|
@@ -212,27 +789,333 @@ class AgEditor
|
|
212
789
|
end
|
213
790
|
_file
|
214
791
|
end
|
792
|
+
|
793
|
+
def create_temp_file_for_completion(_row)
|
794
|
+
_custom_text = ""
|
795
|
+
text_value_array = text_value.split("\n")
|
796
|
+
text_value_array.each_with_index{|line,j|
|
797
|
+
# 1) includiano i require e la riga da includere
|
798
|
+
if line.include?("require") || j.to_i == _row.to_i-1
|
799
|
+
_custom_text = "#{_custom_text}#{line}\n"
|
800
|
+
#p "inserisco=>#{line} alla riga=>#{j}"
|
801
|
+
elsif j.to_i == _row.to_i-2
|
802
|
+
_custom_text = "#{_custom_text}$SAFE = 3\n"
|
803
|
+
else
|
804
|
+
_custom_text = "#{_custom_text}\n"
|
805
|
+
#p "inserisco=>blank alla riga=>#{j}"
|
806
|
+
end
|
807
|
+
#p "riga:#{j}"
|
808
|
+
break if j.to_i >= _row.to_i - 1
|
809
|
+
}
|
810
|
+
Arcadia.console(self, 'msg'=>_custom_text)
|
811
|
+
|
812
|
+
if @file
|
813
|
+
_file = @file+'~~'
|
814
|
+
else
|
815
|
+
_file = 'buffer~~'
|
816
|
+
end
|
817
|
+
f = File.new(_file, "w")
|
818
|
+
begin
|
819
|
+
if f
|
820
|
+
f.syswrite(_custom_text)
|
821
|
+
end
|
822
|
+
ensure
|
823
|
+
f.close unless f.nil?
|
824
|
+
end
|
825
|
+
_file
|
826
|
+
end
|
827
|
+
|
828
|
+
def complete_code_begin
|
829
|
+
@n_complete_task = 1
|
830
|
+
@text.configure('cursor'=> 'hand2')
|
831
|
+
#disactivate_key_binding
|
832
|
+
end
|
833
|
+
|
834
|
+
def complete_code_end
|
835
|
+
@text.configure('cursor'=> @text_cursor)
|
836
|
+
#activate_key_binding
|
837
|
+
@n_complete_task = 0
|
838
|
+
end
|
839
|
+
|
840
|
+
|
841
|
+
def complete_code
|
842
|
+
@do_complete = @do_complete && @controller.accept_complete_code
|
843
|
+
if @do_complete
|
844
|
+
line, col = @text.index('insert').split('.')
|
845
|
+
mss = SafeCompleteCode.new(text_value, line.to_i, col.to_i, @file)
|
846
|
+
candidates = mss.candidates
|
847
|
+
raise_complete_code(candidates, line.to_s, col.to_s, mss.filter) if candidates && candidates.length > 0
|
848
|
+
end
|
849
|
+
end
|
215
850
|
|
216
|
-
def
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
851
|
+
def arity_to_str(_arity=0)
|
852
|
+
ret = ''
|
853
|
+
jolly_args = _arity < 0
|
854
|
+
if jolly_args
|
855
|
+
_arity = _arity.abs - 1
|
856
|
+
end
|
857
|
+
j = _arity
|
858
|
+
while j > 0
|
859
|
+
if ret.strip.length > 0
|
860
|
+
ret = "#{ret},"
|
861
|
+
end
|
862
|
+
ret = "#{ret}arg#{_arity-j+1}"
|
863
|
+
j = j-1
|
864
|
+
end
|
865
|
+
if jolly_args
|
866
|
+
if ret.strip.length > 0
|
867
|
+
ret = "#{ret},"
|
868
|
+
end
|
869
|
+
ret = "#{ret}*"
|
870
|
+
end
|
871
|
+
ret
|
872
|
+
end
|
873
|
+
|
874
|
+
|
875
|
+
def raise_complete_code(_candidates, _row, _col, _filter='')
|
876
|
+
@raised_listbox_frame.destroy if @raised_listbox_frame != nil
|
877
|
+
#@raised_listbox.destroy if @raised_listbox != nil
|
878
|
+
_index_call = _row+'.'+_col
|
879
|
+
_index_now = @text.index('insert')
|
880
|
+
if _index_call == _index_now
|
881
|
+
_target = @text.get('insert - 1 chars wordstart','insert')
|
882
|
+
if _target.strip == '('
|
883
|
+
_target = @text.get('insert - 2 chars wordstart','insert')
|
884
|
+
end
|
885
|
+
if _target.strip.length > 0 && _target != '.'
|
886
|
+
extra_len = _target.length.+@
|
887
|
+
_begin_index = _index_now<<' - '<<extra_len.to_s<<' chars'
|
888
|
+
@text.tag_add('sel', _begin_index, _index_now)
|
889
|
+
else
|
890
|
+
_begin_index = _index_now
|
891
|
+
extra_len = 0
|
227
892
|
end
|
228
|
-
|
229
|
-
|
893
|
+
if _candidates.length >= 1
|
894
|
+
_rx, _ry, _widht, heigth = @text.bbox(_begin_index);
|
895
|
+
_x = _rx + TkWinfo.rootx(@text)
|
896
|
+
_y = _ry + TkWinfo.rooty(@text) + @font_metrics[2][1]
|
897
|
+
_xroot = _x - TkWinfo.rootx(Arcadia.instance.layout.root)
|
898
|
+
_yroot = _y - TkWinfo.rooty(Arcadia.instance.layout.root)
|
899
|
+
|
900
|
+
_max_height = TkWinfo.screenheight(Arcadia.instance.layout.root) - _y - 5
|
901
|
+
self.complete_code_begin
|
902
|
+
|
903
|
+
# @raised_listbox_frame = TkResizingTitledFrame.new(Arcadia.instance.layout.root)
|
904
|
+
@raised_listbox_frame = TkFrame.new(Arcadia.instance.layout.root, {
|
905
|
+
:padx=>"1",
|
906
|
+
:pady=>"1",
|
907
|
+
:background=> Arcadia.conf("foreground")
|
908
|
+
})
|
909
|
+
|
910
|
+
@raised_listbox = TkTextListBox.new(@raised_listbox_frame, {
|
911
|
+
:takefocus=>true,
|
912
|
+
:selectbackground=>Arcadia.conf('hightlight.1.background'),
|
913
|
+
:selectforeground=>Arcadia.conf('hightlight.1.foreground')}.update(Arcadia.style('listbox'))
|
914
|
+
)
|
915
|
+
_char_height = @font_metrics[2][1]
|
916
|
+
_width = 0
|
917
|
+
_docs_entries = Hash.new
|
918
|
+
_item_num = 0
|
919
|
+
_update_list = proc{|_in|
|
920
|
+
_in.strip!
|
921
|
+
@raised_listbox.clear
|
922
|
+
_length = 0
|
923
|
+
_candidates.each{|value|
|
924
|
+
_doc = value.strip
|
925
|
+
_class, _key, _arity = _doc.split('#')
|
926
|
+
if _key && _arity
|
927
|
+
args = arity_to_str(_arity.to_i)
|
928
|
+
if args.length > 0
|
929
|
+
_key = "#{_key}(#{args})"
|
930
|
+
end
|
931
|
+
end
|
932
|
+
|
933
|
+
if _key && _class && _key.strip.length > 0 && _class.strip.length > 0
|
934
|
+
_item = "#{_key.strip} - #{_class.strip}"
|
935
|
+
elsif _key && _key.strip.length > 0
|
936
|
+
_item = "#{_key.strip}"
|
937
|
+
else
|
938
|
+
_key = "#{_doc.strip}"
|
939
|
+
_item = "#{_doc.strip}"
|
940
|
+
end
|
941
|
+
if _in.nil? || _in.strip.length == 0 || _item[0.._in.length-1] == _in
|
942
|
+
#|| _item[0.._in.length-1].downcase == _in
|
943
|
+
_docs_entries[_item]= _doc
|
944
|
+
# @raised_listbox.insert('end', _item)
|
945
|
+
@raised_listbox.add(_item)
|
946
|
+
_temp_length = _item.length
|
947
|
+
_length = _temp_length if _temp_length > _length
|
948
|
+
_item_num = _item_num+1
|
949
|
+
_last_valid_key = _key
|
950
|
+
end
|
951
|
+
}
|
952
|
+
_width = _length*8
|
953
|
+
@raised_listbox.select(1)
|
954
|
+
# p "_update_list end-->#{Time.new}"
|
230
955
|
|
956
|
+
Tk.event_generate(@raised_listbox, "1") if TkWinfo.mapped?(@raised_listbox)
|
957
|
+
}
|
958
|
+
|
959
|
+
_insert_selected_value = proc{
|
960
|
+
#_value = @raised_listbox.get('active').split('-')[0].strip
|
961
|
+
if @raised_listbox.selected_line && @raised_listbox.selected_line.strip.length>0
|
962
|
+
_value = @raised_listbox.selected_line.split('-')[0].strip
|
963
|
+
@raised_listbox_frame.grab("release")
|
964
|
+
@raised_listbox_frame.destroy
|
965
|
+
#_menu.destroy
|
966
|
+
@text.focus
|
967
|
+
@text.delete(_begin_index,'insert')
|
968
|
+
@text.insert('insert',_value.strip)
|
969
|
+
complete_code_end
|
970
|
+
|
971
|
+
_to_search = 'arg1'
|
972
|
+
_argindex = @text.search(_to_search,_begin_index)
|
973
|
+
if !(_argindex && _argindex.length>0)
|
974
|
+
_to_search = '*'
|
975
|
+
_argindex = @text.search(_to_search,_begin_index)
|
976
|
+
end
|
977
|
+
if _argindex && _argindex.length>0
|
978
|
+
_argrow, _argcol = _argindex.split('.')
|
979
|
+
if _argrow.to_i == _row.to_i
|
980
|
+
_argindex_sel_end = _argrow.to_i.to_s+'.'+(_argcol.to_i+_to_search.length).to_i.to_s
|
981
|
+
@text.tag_add('sel', _argindex,_argindex_sel_end)
|
982
|
+
@text.set_insert(_argindex)
|
983
|
+
end
|
984
|
+
end
|
985
|
+
end
|
986
|
+
|
987
|
+
Tk.callback_break
|
988
|
+
}
|
989
|
+
_update_list.call(_filter)
|
990
|
+
if _item_num == 0
|
991
|
+
@raised_listbox_frame.destroy
|
992
|
+
self.complete_code_end
|
993
|
+
return
|
994
|
+
elsif _item_num == 1
|
995
|
+
_insert_selected_value.call
|
996
|
+
return
|
997
|
+
end
|
998
|
+
_width = _width + 10
|
999
|
+
#_height = (candidates.length+1)*_char_height
|
1000
|
+
_height = 15*_char_height
|
1001
|
+
_height = _max_height if _height > _max_height
|
1002
|
+
|
1003
|
+
_buffer = @text.get(_begin_index, 'insert')
|
1004
|
+
_buffer_ini_length = _buffer.length
|
1005
|
+
@raised_listbox_frame.place('x'=>_xroot,'y'=>_yroot, 'width'=>_width, 'height'=>_height)
|
1006
|
+
@raised_listbox.show(0,0,'inside')
|
1007
|
+
@raised_listbox.show_v_scroll
|
1008
|
+
@raised_listbox.focus
|
1009
|
+
#@raised_listbox.activate(0)
|
1010
|
+
@raised_listbox.select(1)
|
1011
|
+
@raised_listbox_frame.grab("set")
|
1012
|
+
# Tk.event_generate(@raised_listbox, "1")
|
1013
|
+
|
1014
|
+
|
1015
|
+
@raised_listbox.bind_append("Double-ButtonPress-1",
|
1016
|
+
proc{|x,y|
|
1017
|
+
_index = @raised_listbox.index("@#{x},#{y}")
|
1018
|
+
_line = _index.split('.')[0].to_i
|
1019
|
+
@raised_listbox.select(_line)
|
1020
|
+
_insert_selected_value.call
|
1021
|
+
}, "%x %y")
|
1022
|
+
@raised_listbox.bind_append('Shift-KeyPress'){|e|
|
1023
|
+
# todo
|
1024
|
+
case e.keysym
|
1025
|
+
when 'parenleft'
|
1026
|
+
@text.insert('insert','(')
|
1027
|
+
_buffer = _buffer + '('
|
1028
|
+
_item_num = 0
|
1029
|
+
_update_list.call(_buffer)
|
1030
|
+
if _item_num == 1
|
1031
|
+
_insert_selected_value.call
|
1032
|
+
end
|
1033
|
+
Tk.callback_break
|
1034
|
+
when 'A'..'Z','equal','greater'
|
1035
|
+
if e.keysym == 'equal'
|
1036
|
+
ch = '='
|
1037
|
+
elsif e.keysym == 'greater'
|
1038
|
+
ch = '>'
|
1039
|
+
else
|
1040
|
+
ch = e.keysym
|
1041
|
+
end
|
1042
|
+
@text.insert('insert',ch)
|
1043
|
+
_buffer = _buffer + ch
|
1044
|
+
_update_list.call(_buffer)
|
1045
|
+
Tk.callback_break
|
1046
|
+
else
|
1047
|
+
if e.keysym.length > 1
|
1048
|
+
p ">#{e.keysym}<"
|
1049
|
+
Tk.callback_break
|
1050
|
+
end
|
1051
|
+
end
|
1052
|
+
}
|
1053
|
+
@raised_listbox.bind_append('KeyPress'){|e|
|
1054
|
+
case e.keysym
|
1055
|
+
when 'Escape'
|
1056
|
+
@raised_listbox.grab("release")
|
1057
|
+
@raised_listbox_frame.destroy
|
1058
|
+
complete_code_end
|
1059
|
+
@text.focus
|
1060
|
+
#_menu.destroy
|
1061
|
+
Tk.callback_break
|
1062
|
+
# when 'Return'
|
1063
|
+
# _insert_selected_value.call
|
1064
|
+
when 'F1'
|
1065
|
+
_key = @raised_listbox.selected_line.split('-')[0].strip
|
1066
|
+
_x, _y = xy_insert
|
1067
|
+
Arcadia.process_event(DocCodeEvent.new(self, 'doc_entry'=>_docs_entries[_key], 'xdoc'=>_x, 'ydoc'=>_y))
|
1068
|
+
#EditorContract.instance.doc_code(self, 'doc_entry'=>_docs_entries[_key], 'xdoc'=>_x, 'ydoc'=>_y)
|
1069
|
+
when 'a'..'z','less','space'
|
1070
|
+
if e.keysym == 'less'
|
1071
|
+
ch = '<'
|
1072
|
+
elsif e.keysym == 'space'
|
1073
|
+
ch = ''
|
1074
|
+
else
|
1075
|
+
ch = e.keysym
|
1076
|
+
end
|
1077
|
+
@text.insert('insert',ch)
|
1078
|
+
_buffer = _buffer + ch
|
1079
|
+
_update_list.call(_buffer)
|
1080
|
+
Tk.callback_break
|
1081
|
+
when 'BackSpace'
|
1082
|
+
if _buffer.length > _buffer_ini_length
|
1083
|
+
@text.delete("#{_begin_index} + #{_buffer.length-1} chars" ,'insert')
|
1084
|
+
_buffer = _buffer[0..-2]
|
1085
|
+
Tk.update
|
1086
|
+
_update_list.call(_buffer)
|
1087
|
+
Tk.callback_break
|
1088
|
+
end
|
1089
|
+
when 'Next', 'Prior'
|
1090
|
+
else
|
1091
|
+
Tk.callback_break
|
1092
|
+
end
|
1093
|
+
}
|
1094
|
+
@raised_listbox.bind_append('KeyRelease'){|e|
|
1095
|
+
case e.keysym
|
1096
|
+
when 'Return'
|
1097
|
+
_insert_selected_value.call
|
1098
|
+
end
|
1099
|
+
}
|
1100
|
+
elsif _candidates.length == 1 && _candidates[0].length>0
|
1101
|
+
@text.delete(_begin_index,'insert');
|
1102
|
+
@text.insert('insert',_candidates[0].split[0])
|
1103
|
+
complete_code_end
|
1104
|
+
end
|
1105
|
+
end
|
1106
|
+
end
|
1107
|
+
|
1108
|
+
|
1109
|
+
def activate_complete_code_key_binding
|
1110
|
+
@n_complete_task = 0
|
1111
|
+
# key binding for complete code
|
231
1112
|
@text.bind_append("Control-KeyPress"){|e|
|
232
1113
|
case e.keysym
|
233
1114
|
when 'space'
|
234
|
-
@
|
235
|
-
|
1115
|
+
if @n_complete_task == 0
|
1116
|
+
@do_complete = true
|
1117
|
+
complete_code
|
1118
|
+
end
|
236
1119
|
end
|
237
1120
|
}
|
238
1121
|
|
@@ -243,38 +1126,23 @@ class AgEditor
|
|
243
1126
|
@text.bind_append("KeyRelease"){|e|
|
244
1127
|
case e.keysym
|
245
1128
|
when 'period'
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
self.do_line_update()
|
259
|
-
})
|
260
|
-
@text.tag_bind('selected', 'Enter', proc{@text.tag_remove('selected','1.0','end')})
|
261
|
-
|
262
|
-
@text.bind("Enter", proc{check_file_last_access_time})
|
263
|
-
|
264
|
-
# complete_code = proc{
|
265
|
-
# if @do_complete
|
266
|
-
# line, col = @text.index('insert').split('.')
|
267
|
-
# _file = create_temp_file
|
268
|
-
# #EditorContract.instance.complete_code(self, 'file'=>_file, 'line'=>line.to_s, 'col'=>col.to_s)
|
269
|
-
# begin
|
270
|
-
# event = Arcadia.process_event(CompleteCodeEvent.new(self, 'file'=>_file, 'row'=>line.to_s, 'col'=>col.to_s))
|
271
|
-
# ensure
|
272
|
-
# File.delete(_file) if File.exist?(_file)
|
273
|
-
# end
|
274
|
-
# end
|
275
|
-
# @controller.raise_complete_code(event) if @do_complete
|
276
|
-
# }
|
1129
|
+
_focus_line = @text.get('insert linestart','insert')
|
1130
|
+
if _focus_line.strip[0..0] != '#'
|
1131
|
+
Thread.new do
|
1132
|
+
@do_complete = true
|
1133
|
+
sleep(1)
|
1134
|
+
if @do_complete && @n_complete_task == 0
|
1135
|
+
complete_code
|
1136
|
+
end
|
1137
|
+
end
|
1138
|
+
end
|
1139
|
+
end
|
1140
|
+
}
|
277
1141
|
|
1142
|
+
end
|
1143
|
+
|
1144
|
+
def activate_key_binding
|
1145
|
+
activate_complete_code_key_binding if @is_ruby
|
278
1146
|
@text.bind_append("Control-KeyPress"){|e|
|
279
1147
|
case e.keysym
|
280
1148
|
# when 'space'
|
@@ -311,17 +1179,7 @@ class AgEditor
|
|
311
1179
|
when 's'
|
312
1180
|
save
|
313
1181
|
when 'f'
|
314
|
-
|
315
|
-
if _r.length>0
|
316
|
-
_text=@text.get(_r[0][0],_r[0][1])
|
317
|
-
if _text.length > 0
|
318
|
-
@find.e_what.text(_text)
|
319
|
-
end
|
320
|
-
else
|
321
|
-
end
|
322
|
-
@find.use(self)
|
323
|
-
@find.e_what.focus
|
324
|
-
@find.show
|
1182
|
+
find
|
325
1183
|
when 'egrave'
|
326
1184
|
@text.insert('insert',"{")
|
327
1185
|
when 'plus'
|
@@ -329,7 +1187,7 @@ class AgEditor
|
|
329
1187
|
end
|
330
1188
|
}
|
331
1189
|
|
332
|
-
@text.
|
1190
|
+
@text.bind_append("Control-Shift-KeyPress"){|e|
|
333
1191
|
case e.keysym
|
334
1192
|
when 'I'
|
335
1193
|
_r = @text.tag_ranges('sel')
|
@@ -391,13 +1249,12 @@ class AgEditor
|
|
391
1249
|
_row, _col = _index.split('.')
|
392
1250
|
rehighlightline(_row.to_i) if @highlighting
|
393
1251
|
when 'F5'
|
394
|
-
|
395
|
-
$arcadia['shell'].run(@file.to_s)
|
1252
|
+
run_buffer
|
396
1253
|
when 'F3'
|
397
1254
|
@find.do_find_next
|
398
1255
|
when 'F1'
|
399
1256
|
line, col = @text.index('insert').split('.')
|
400
|
-
_x, _y =
|
1257
|
+
_x, _y = xy_insert
|
401
1258
|
_file = create_temp_file
|
402
1259
|
begin
|
403
1260
|
Arcadia.process_event(DocCodeEvent.new(self, 'file'=>_file, 'row'=>line.to_s, 'col'=>col.to_s, 'xdoc'=>_x, 'ydoc'=>_y))
|
@@ -426,11 +1283,6 @@ class AgEditor
|
|
426
1283
|
end
|
427
1284
|
end
|
428
1285
|
}
|
429
|
-
|
430
|
-
|
431
|
-
@text.bind("<Modified>"){|e|
|
432
|
-
check_modify
|
433
|
-
}
|
434
1286
|
|
435
1287
|
@text.bind_append("KeyRelease"){|e|
|
436
1288
|
case e.keysym
|
@@ -469,7 +1321,7 @@ class AgEditor
|
|
469
1321
|
}
|
470
1322
|
|
471
1323
|
|
472
|
-
@text.
|
1324
|
+
@text.bind_append("Shift-KeyPress"){|e|
|
473
1325
|
case e.keysym
|
474
1326
|
when 'Tab'
|
475
1327
|
_r = @text.tag_ranges('sel')
|
@@ -493,9 +1345,57 @@ class AgEditor
|
|
493
1345
|
end
|
494
1346
|
end
|
495
1347
|
}
|
1348
|
+
end
|
1349
|
+
|
1350
|
+
def find
|
1351
|
+
_r = @text.tag_ranges('sel')
|
1352
|
+
if _r.length>0
|
1353
|
+
_text=@text.get(_r[0][0],_r[0][1])
|
1354
|
+
if _text.length > 0
|
1355
|
+
@find.e_what.text(_text)
|
1356
|
+
end
|
1357
|
+
else
|
1358
|
+
end
|
1359
|
+
@find.use(self)
|
1360
|
+
@find.e_what.focus
|
1361
|
+
@find.show
|
1362
|
+
end
|
1363
|
+
|
1364
|
+
def disactivate_key_binding
|
1365
|
+
@text.bind_remove('KeyPress')
|
1366
|
+
@text.bind_remove('KeyRelease')
|
1367
|
+
@text.bind_remove('Control-KeyPress')
|
1368
|
+
@text.bind_remove('Control-Shift-KeyPress')
|
1369
|
+
@text.bind_remove('Shift-KeyPress')
|
1370
|
+
|
1371
|
+
end
|
1372
|
+
|
1373
|
+
def initialize_text_binding
|
1374
|
+
@text.add_yscrollcommand(proc{|first,last| self.do_line_update()})
|
1375
|
+
|
1376
|
+
@text.tag_bind('selected', 'Enter', proc{@text.tag_remove('selected','1.0','end')})
|
1377
|
+
|
1378
|
+
@text.bind("Enter", proc{check_file_last_access_time})
|
496
1379
|
|
1380
|
+
@text.bind("<Modified>"){|e|
|
1381
|
+
check_modify
|
1382
|
+
}
|
1383
|
+
activate_key_binding
|
497
1384
|
@text.bind_append("1",proc{Arcadia.process_event(InputEnterEvent.new(self,'receiver'=>@text))})
|
1385
|
+
end
|
498
1386
|
|
1387
|
+
def run_buffer
|
1388
|
+
if !@file
|
1389
|
+
_file = create_temp_file
|
1390
|
+
begin
|
1391
|
+
Arcadia.process_event(RunRubyFileEvent.new(self, 'file'=>_file, 'persistent'=>false))
|
1392
|
+
ensure
|
1393
|
+
File.delete(_file) if File.exist?(_file)
|
1394
|
+
end
|
1395
|
+
else
|
1396
|
+
save
|
1397
|
+
Arcadia.process_event(RunRubyFileEvent.new(self, 'file'=>@file, 'persistent'=>true))
|
1398
|
+
end
|
499
1399
|
end
|
500
1400
|
|
501
1401
|
def initialize_line_number(_frame)
|
@@ -652,6 +1552,16 @@ class AgEditor
|
|
652
1552
|
end
|
653
1553
|
end
|
654
1554
|
|
1555
|
+
def reset_highlight
|
1556
|
+
@is_line_bold.clear
|
1557
|
+
@is_tag_bold.clear
|
1558
|
+
@highlight_zone.clear
|
1559
|
+
@last_line_begin=0
|
1560
|
+
@last_line_end=0
|
1561
|
+
@last_zone_begin=0
|
1562
|
+
@last_zone_end=0
|
1563
|
+
end
|
1564
|
+
|
655
1565
|
def initialize_highlight
|
656
1566
|
@is_line_bold = Hash.new
|
657
1567
|
@is_tag_bold = Hash.new
|
@@ -940,14 +1850,14 @@ class AgEditor
|
|
940
1850
|
:command,
|
941
1851
|
:label=>'Set wrap',
|
942
1852
|
:hidemargin => false,
|
943
|
-
:command=> proc{@text.configure('wrap'=>'word')}
|
1853
|
+
:command=> proc{@text.configure('wrap'=>'word');@text.hide_h_scroll}
|
944
1854
|
)
|
945
1855
|
|
946
1856
|
_sub_code.insert('end',
|
947
1857
|
:command,
|
948
1858
|
:label=>'Set no wrap',
|
949
1859
|
:hidemargin => false,
|
950
|
-
:command=> proc{@text.configure('wrap'=>'none')}
|
1860
|
+
:command=> proc{@text.configure('wrap'=>'none');@text.show_h_scroll}
|
951
1861
|
)
|
952
1862
|
|
953
1863
|
_sub_code.insert('end',
|
@@ -1029,87 +1939,87 @@ class AgEditor
|
|
1029
1939
|
end
|
1030
1940
|
|
1031
1941
|
|
1032
|
-
def build_tree_from_source(_source)
|
1033
|
-
_row = 1
|
1034
|
-
_liv = 0
|
1035
|
-
_livs = Array.new
|
1036
|
-
root = TreeNode.new(nil, 'KRoot'){|_node|
|
1037
|
-
_node.rif= 'root'
|
1038
|
-
_node.label=''
|
1039
|
-
}
|
1040
|
-
_livs[_liv]=root
|
1041
|
-
_source.each_line{|line|
|
1042
|
-
line = "\s"+line.split("#")[0]+"\s"
|
1043
|
-
m = /[\s\n\t\;]+(module|class|def|if|unless|begin|case|for|while|do)[\s\n\t\;]+/.match(line)
|
1044
|
-
if m
|
1045
|
-
index = m.post_match.strip.length - 1
|
1046
|
-
if m.post_match.strip[index,index]=='{'
|
1047
|
-
_row = _row +1
|
1048
|
-
next
|
1049
|
-
end
|
1050
|
-
_liv>=0? _liv = _liv + 1:_liv=1
|
1051
|
-
_pliv = _liv
|
1052
|
-
_parent = nil
|
1053
|
-
while (_parent == nil && _pliv>=0)
|
1054
|
-
_pliv = _pliv -1
|
1055
|
-
_parent = _livs[_pliv]
|
1056
|
-
end
|
1057
|
-
if _parent
|
1058
|
-
_helptext = m.post_match.strip
|
1059
|
-
_label = _helptext.split('<')[0]
|
1060
|
-
if _label == nil || _label.strip.length==0
|
1061
|
-
_label = _helptext
|
1062
|
-
end
|
1063
|
-
if (m[0].strip[0..4] == "class" && m.pre_match.strip.length==0)
|
1064
|
-
_kind = 'KClass'
|
1065
|
-
elsif (m[0].strip[0..4] == "class" && m.pre_match.strip.length>0)
|
1066
|
-
_row = _row +1
|
1067
|
-
_liv = _liv - 1
|
1068
|
-
next
|
1069
|
-
elsif (m[0].strip[0..5] == "module" && m.pre_match.strip.length==0)
|
1070
|
-
_kind = 'KModule'
|
1071
|
-
elsif (m[0].strip[0..5] == "module" && m.pre_match.strip.length>0)
|
1072
|
-
_row = _row +1
|
1073
|
-
_liv = _liv - 1
|
1074
|
-
next
|
1075
|
-
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))
|
1076
|
-
_row = _row +1
|
1077
|
-
next
|
1078
|
-
elsif ((m[0].strip[0..1] == "if" || m[0].strip[0..5] == "unless") && m.pre_match.strip.length>0)
|
1079
|
-
_row = _row +1
|
1080
|
-
_liv = _liv - 1
|
1081
|
-
next
|
1082
|
-
elsif (m[0].strip[0..2] == "def" && m.pre_match.strip.length==0)
|
1083
|
-
_kind = 'KDef'
|
1084
|
-
if _label.include?(_parent.label + '.')
|
1085
|
-
_kind = 'KDefClass'
|
1086
|
-
end
|
1087
|
-
# elsif (m[0].strip[0..10] == "attr_reader" && m.pre_match.strip.length==0)
|
1088
|
-
# _kind = 'KAttr_reader'
|
1942
|
+
# def build_tree_from_source(_source)
|
1943
|
+
# _row = 1
|
1944
|
+
# _liv = 0
|
1945
|
+
# _livs = Array.new
|
1946
|
+
# root = TreeNode.new(nil, 'KRoot'){|_node|
|
1947
|
+
# _node.rif= 'root'
|
1948
|
+
# _node.label=''
|
1949
|
+
# }
|
1950
|
+
# _livs[_liv]=root
|
1951
|
+
# _source.each_line{|line|
|
1952
|
+
# line = "\s"+line.split("#")[0]+"\s"
|
1953
|
+
# m = /[\s\n\t\;]+(module|class|def|if|unless|begin|case|for|while|do)[\s\n\t\;]+/.match(line)
|
1954
|
+
# if m
|
1955
|
+
# index = m.post_match.strip.length - 1
|
1956
|
+
# if m.post_match.strip[index,index]=='{'
|
1957
|
+
# _row = _row +1
|
1958
|
+
# next
|
1959
|
+
# end
|
1960
|
+
# _liv>=0? _liv = _liv + 1:_liv=1
|
1961
|
+
# _pliv = _liv
|
1962
|
+
# _parent = nil
|
1963
|
+
# while (_parent == nil && _pliv>=0)
|
1964
|
+
# _pliv = _pliv -1
|
1965
|
+
# _parent = _livs[_pliv]
|
1966
|
+
# end
|
1967
|
+
# if _parent
|
1968
|
+
# _helptext = m.post_match.strip
|
1969
|
+
# _label = _helptext.split('<')[0]
|
1970
|
+
# if _label == nil || _label.strip.length==0
|
1971
|
+
# _label = _helptext
|
1972
|
+
# end
|
1973
|
+
# if (m[0].strip[0..4] == "class" && m.pre_match.strip.length==0)
|
1974
|
+
# _kind = 'KClass'
|
1975
|
+
# elsif (m[0].strip[0..4] == "class" && m.pre_match.strip.length>0)
|
1976
|
+
# _row = _row +1
|
1089
1977
|
# _liv = _liv - 1
|
1978
|
+
# next
|
1979
|
+
# elsif (m[0].strip[0..5] == "module" && m.pre_match.strip.length==0)
|
1980
|
+
# _kind = 'KModule'
|
1981
|
+
# elsif (m[0].strip[0..5] == "module" && m.pre_match.strip.length>0)
|
1090
1982
|
# _row = _row +1
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1983
|
+
# _liv = _liv - 1
|
1984
|
+
# next
|
1985
|
+
# 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))
|
1986
|
+
# _row = _row +1
|
1987
|
+
# next
|
1988
|
+
# elsif ((m[0].strip[0..1] == "if" || m[0].strip[0..5] == "unless") && m.pre_match.strip.length>0)
|
1989
|
+
# _row = _row +1
|
1990
|
+
# _liv = _liv - 1
|
1991
|
+
# next
|
1992
|
+
# elsif (m[0].strip[0..2] == "def" && m.pre_match.strip.length==0)
|
1993
|
+
# _kind = 'KDef'
|
1994
|
+
# if _label.include?(_parent.label + '.')
|
1995
|
+
# _kind = 'KDefClass'
|
1996
|
+
# end
|
1997
|
+
# # elsif (m[0].strip[0..10] == "attr_reader" && m.pre_match.strip.length==0)
|
1998
|
+
# # _kind = 'KAttr_reader'
|
1999
|
+
# # _liv = _liv - 1
|
2000
|
+
# # _row = _row +1
|
2001
|
+
# end
|
2002
|
+
#
|
2003
|
+
# TreeNode.new(_parent, _kind){|_node|
|
2004
|
+
# _node.label = _label
|
2005
|
+
# _node.helptext = _helptext
|
2006
|
+
# _node.rif = _row.to_s
|
2007
|
+
# _livs[_pliv + 1]=_node
|
2008
|
+
# }
|
2009
|
+
# else
|
2010
|
+
# _row = _row +1
|
2011
|
+
# _liv = _liv - 1
|
2012
|
+
# next
|
2013
|
+
# end
|
2014
|
+
# end
|
2015
|
+
# m_end = /[\s\n\t\;]+end[\s\n\t\;]+/.match(line)
|
2016
|
+
# if m_end
|
2017
|
+
# _liv = _liv - 1
|
2018
|
+
# end
|
2019
|
+
# _row = _row +1
|
2020
|
+
# }
|
2021
|
+
# return root
|
2022
|
+
# end
|
1113
2023
|
|
1114
2024
|
def build_tree_from_node(_node, _label_match=nil)
|
1115
2025
|
|
@@ -1145,6 +2055,7 @@ class AgEditor
|
|
1145
2055
|
end
|
1146
2056
|
|
1147
2057
|
def build_tree(_sel=nil)
|
2058
|
+
#Arcadia.console(self,"msg"=>"build for #{@file}")
|
1148
2059
|
if _sel
|
1149
2060
|
_label_sel = @tree_exp.itemcget(_sel,'text')
|
1150
2061
|
end
|
@@ -1160,7 +2071,9 @@ class AgEditor
|
|
1160
2071
|
|
1161
2072
|
#(re)build tree
|
1162
2073
|
_txt = @text.get('1.0','end')
|
1163
|
-
|
2074
|
+
#@root = build_tree_from_source(_txt)
|
2075
|
+
@root = SourceStructure.new(_txt).root
|
2076
|
+
|
1164
2077
|
@selected = nil
|
1165
2078
|
build_tree_from_node(@root, _label_sel)
|
1166
2079
|
if @selected
|
@@ -1549,7 +2462,7 @@ class AgEditor
|
|
1549
2462
|
# real_line_begin = line_begin
|
1550
2463
|
# end
|
1551
2464
|
|
1552
|
-
if _ry < 0
|
2465
|
+
if _ry && _ry < 0
|
1553
2466
|
real_line_end = line_end + 1
|
1554
2467
|
# x = (_heigth+_ry)/_heigth
|
1555
2468
|
# @text_line_num.yview_scroll(-(_heigth+_ry),"pixels")
|
@@ -1595,7 +2508,7 @@ class AgEditor
|
|
1595
2508
|
#add_tag_breakpoint(_index+' -1 lines')
|
1596
2509
|
end
|
1597
2510
|
end
|
1598
|
-
if _ry < 0
|
2511
|
+
if _ry && _ry < 0
|
1599
2512
|
#Arcadia.console(self, 'msg'=>"scrollo -> #{-(_heigth+_ry)}")
|
1600
2513
|
#Arcadia.console(self, 'msg'=>"_coef -> #{_coef}")
|
1601
2514
|
|
@@ -1721,6 +2634,7 @@ class AgEditor
|
|
1721
2634
|
'title' => '(Arcadia) Libs', 'parent' => @text,
|
1722
2635
|
'message' => msg) == 'yes'
|
1723
2636
|
@text.delete('1.0','end')
|
2637
|
+
reset_highlight
|
1724
2638
|
load_file(@file)
|
1725
2639
|
else
|
1726
2640
|
@file_last_access_time = ftime
|
@@ -1757,37 +2671,37 @@ class AgEditor
|
|
1757
2671
|
end
|
1758
2672
|
|
1759
2673
|
def init_editing(_ext='rb', _w1=150, _w2=60)
|
1760
|
-
|
1761
|
-
|
1762
|
-
#
|
1763
|
-
#
|
1764
|
-
# @
|
1765
|
-
#
|
1766
|
-
#
|
1767
|
-
# lang_file_bind = File.dirname(__FILE__)+'/langs/'+b['bind']
|
1768
|
-
# if b && File.exist?(lang_file_bind)
|
1769
|
-
# @lang_hash = properties_file2hash(lang_file_bind)
|
1770
|
-
# end
|
2674
|
+
@is_ruby = _ext=='rb'||_ext=='rbw'
|
2675
|
+
@lang_hash = languages_hash(_ext)
|
2676
|
+
# if !_ext.nil? && @is_ruby
|
2677
|
+
# @fm = AGTkVSplittedFrames.new(@page_frame,_w1)
|
2678
|
+
# @fm1 = AGTkVSplittedFrames.new(@fm.right_frame,_w2)
|
2679
|
+
# initialize_tree(@controller.frame(1).hinner_frame)
|
2680
|
+
# initialize_tree(@fm.left_frame)
|
1771
2681
|
# else
|
1772
|
-
# @
|
2682
|
+
# @fm1 = AGTkVSplittedFrames.new(@page_frame,_w2)
|
1773
2683
|
# end
|
1774
|
-
|
1775
|
-
@lang_hash = languages_hash(_ext)
|
1776
|
-
if !_ext.nil? && is_ruby
|
1777
|
-
@fm = AGTkVSplittedFrames.new(@page_frame,_w1)
|
1778
|
-
@fm1 = AGTkVSplittedFrames.new(@fm.right_frame,_w2)
|
1779
|
-
initialize_tree(@fm.left_frame)
|
1780
|
-
else
|
1781
|
-
@fm1 = AGTkVSplittedFrames.new(@page_frame,_w2)
|
1782
|
-
end
|
2684
|
+
@fm1 = AGTkVSplittedFrames.new(@page_frame,_w2)
|
1783
2685
|
@fm1.splitter_frame.configure('relief'=>'flat')
|
1784
2686
|
initialize_text(@fm1.right_frame)
|
1785
2687
|
initialize_highlight
|
1786
2688
|
initialize_line_number(@fm1.left_frame)
|
1787
2689
|
initialize_text_binding
|
1788
|
-
|
2690
|
+
end
|
2691
|
+
|
2692
|
+
def show_outline
|
2693
|
+
if @tree_scroll_wrapper
|
2694
|
+
@tree_scroll_wrapper.show
|
2695
|
+
else
|
2696
|
+
initialize_tree(@controller.frame(1).hinner_frame)
|
2697
|
+
build_tree
|
2698
|
+
end
|
1789
2699
|
end
|
1790
2700
|
|
2701
|
+
def hide_outline
|
2702
|
+
@tree_scroll_wrapper.hide if @tree_scroll_wrapper
|
2703
|
+
end
|
2704
|
+
|
1791
2705
|
def file_extension(_filename=nil)
|
1792
2706
|
if _filename
|
1793
2707
|
_m = /(.*\.)(.*$)/.match(File.basename(_filename))
|
@@ -1835,7 +2749,7 @@ class AgEditor
|
|
1835
2749
|
end
|
1836
2750
|
|
1837
2751
|
def refresh
|
1838
|
-
build_tree if @classbrowsing
|
2752
|
+
build_tree if @classbrowsing #&& !is_exp_hide?
|
1839
2753
|
end
|
1840
2754
|
end
|
1841
2755
|
|
@@ -1857,6 +2771,7 @@ class AgMultiEditorView
|
|
1857
2771
|
|
1858
2772
|
end
|
1859
2773
|
|
2774
|
+
|
1860
2775
|
class AgMultiEditor < ArcadiaExt
|
1861
2776
|
include Autils
|
1862
2777
|
attr_reader :breakpoints
|
@@ -1871,11 +2786,19 @@ class AgMultiEditor < ArcadiaExt
|
|
1871
2786
|
Arcadia.attach_listener(self, StartDebugEvent)
|
1872
2787
|
end
|
1873
2788
|
|
2789
|
+
|
1874
2790
|
def on_before_run_ruby_file(_event)
|
1875
2791
|
_filename = _event.file
|
1876
2792
|
if _filename.nil?
|
1877
2793
|
current_editor = self.raised
|
1878
|
-
|
2794
|
+
if current_editor
|
2795
|
+
if current_editor.file
|
2796
|
+
_event.file = current_editor.file
|
2797
|
+
_event.persistent = true
|
2798
|
+
else
|
2799
|
+
_event.file = current_editor.create_temp_file
|
2800
|
+
end
|
2801
|
+
end
|
1879
2802
|
end
|
1880
2803
|
end
|
1881
2804
|
|
@@ -2083,171 +3006,24 @@ class AgMultiEditor < ArcadiaExt
|
|
2083
3006
|
end
|
2084
3007
|
end
|
2085
3008
|
|
2086
|
-
# def load_persistent_breakpoints
|
2087
|
-
# b = Arcadia.persistent('editor.debug_breakpoints')
|
2088
|
-
# if b
|
2089
|
-
# _files_list =b.split("|")
|
2090
|
-
# _files_list.each do |value|
|
2091
|
-
# _file,_line = value.split('@@@')
|
2092
|
-
# if _file && _line
|
2093
|
-
# breakpoint_add(_file,_line)
|
2094
|
-
# end
|
2095
|
-
# end
|
2096
|
-
# end
|
2097
|
-
# end
|
2098
|
-
|
2099
|
-
def xy_insert
|
2100
|
-
_text = self.raised.text
|
2101
|
-
_index_now = _text.index('insert')
|
2102
|
-
_rx, _ry, _widht, _heigth = _text.bbox(_index_now);
|
2103
|
-
_x = _rx + TkWinfo.rootx(_text)
|
2104
|
-
_y = _ry + TkWinfo.rooty(_text) + TkFont.new(conf('font')).metrics[2][1]
|
2105
|
-
_xroot = _x - TkWinfo.rootx(@arcadia.layout.root)
|
2106
|
-
_yroot = _y - TkWinfo.rooty(@arcadia.layout.root)
|
2107
|
-
return _xroot, _yroot
|
2108
|
-
end
|
2109
|
-
|
2110
|
-
def raise_complete_code(_context)
|
2111
|
-
# delete the file used for completion
|
2112
|
-
@raised_listbox.destroy if @raised_listbox != nil
|
2113
|
-
|
2114
|
-
candidates = _context.results[0].candidates
|
2115
|
-
_text = self.raised.text
|
2116
|
-
_index_call = _context.row+'.'+_context.col
|
2117
|
-
_index_now = _text.index('insert')
|
2118
|
-
if _index_call == _index_now
|
2119
|
-
_target = _text.get('insert - 1 chars wordstart','insert')
|
2120
|
-
if _target.length > 0 && _target != '.'
|
2121
|
-
extra_len = _target.length.+@
|
2122
|
-
_begin_index = _index_now<<' - '<<extra_len.to_s<<' chars'
|
2123
|
-
_text.tag_add('sel', _begin_index, _index_now)
|
2124
|
-
else
|
2125
|
-
_begin_index = _index_now
|
2126
|
-
extra_len = 0
|
2127
|
-
end
|
2128
|
-
if candidates.length > 1
|
2129
|
-
_rx, _ry, _widht, heigth = _text.bbox(_begin_index);
|
2130
|
-
_x = _rx + TkWinfo.rootx(_text)
|
2131
|
-
_y = _ry + TkWinfo.rooty(_text) + TkFont.new(conf('edit.font')).metrics[2][1]
|
2132
|
-
|
2133
|
-
_xroot = _x - TkWinfo.rootx(@arcadia.layout.root)
|
2134
|
-
_yroot = _y - TkWinfo.rooty(@arcadia.layout.root)
|
2135
|
-
|
2136
|
-
_max_height = TkWinfo.screenheight(@arcadia.layout.root) - _y - 5
|
2137
|
-
|
2138
|
-
@raised_listbox = TkListbox.new(@arcadia.layout.root, {
|
2139
|
-
:takefocus=>true,
|
2140
|
-
:selectbackground=>Arcadia.conf('hightlight.1.background'),
|
2141
|
-
:selectforeground=>Arcadia.conf('hightlight.1.foreground'),
|
2142
|
-
:activestyle=>'none'}.update(Arcadia.style('listbox'))
|
2143
|
-
)
|
2144
|
-
v_scroll = TkScrollbar.new(@raised_listbox,{
|
2145
|
-
'orient'=>'vertical'}.update(Arcadia.style('scrollbar'))
|
2146
|
-
).pack('side' => 'right', 'fill' => 'y')
|
2147
|
-
|
2148
|
-
v_scroll.command(proc{|*args|
|
2149
|
-
@raised_listbox.yview *args
|
2150
|
-
})
|
2151
|
-
@raised_listbox.yscrollcommand(proc{|first,last| v_scroll.set(first,last) })
|
2152
|
-
|
2153
|
-
_font = TkFont.new(conf('edit.font'))
|
2154
|
-
_char_height = _font.metrics[2][1]
|
2155
|
-
_width = 0
|
2156
|
-
_docs_entries = Hash.new
|
2157
|
-
_update_list = proc{|_in|
|
2158
|
-
@raised_listbox.delete('0','end')
|
2159
|
-
candidates.each{|value|
|
2160
|
-
_key, _doc = value.split
|
2161
|
-
if _in.nil? || _in.strip.length == 0 || _key[0.._in.length-1] == _in
|
2162
|
-
_docs_entries[_key]= _doc
|
2163
|
-
@raised_listbox.insert('end', _key)
|
2164
|
-
_temp_width = _font.measure(_key) + _font.measure('X')*3
|
2165
|
-
_width = _temp_width if _temp_width > _width
|
2166
|
-
end
|
2167
|
-
}
|
2168
|
-
Tk.event_generate(@raised_listbox, "1") if TkWinfo.mapped?(@raised_listbox)
|
2169
|
-
}
|
2170
|
-
_update_list.call
|
2171
|
-
_width = _width + 15
|
2172
|
-
#_height = (candidates.length+1)*_char_height
|
2173
|
-
_height = 15*_char_height
|
2174
|
-
_height = _max_height if _height > _max_height
|
2175
|
-
|
2176
|
-
_buffer = _text.get(_begin_index, 'insert')
|
2177
|
-
_buffer_ini_length = _buffer.length
|
2178
|
-
# i2 = _begin_index
|
2179
|
-
# i1 = _text.index("#{i2} -1 chars")
|
2180
|
-
# xchar = _text.get(i1, i2)
|
2181
|
-
# while xchar != '.' && xchar != "\s" && xchar != "\n"
|
2182
|
-
# _buffer = xchar + _buffer
|
2183
|
-
# i2 = i1
|
2184
|
-
# i1 = _text.index("#{i2} -1 chars")
|
2185
|
-
# xchar = _text.get(i1, i2)
|
2186
|
-
# end
|
2187
|
-
@raised_listbox.place('x'=>_xroot,'y'=>_yroot, 'width'=>_width, 'height'=>_height)
|
2188
|
-
@raised_listbox.focus
|
2189
|
-
@raised_listbox.activate(0)
|
2190
|
-
@raised_listbox.grab("set")
|
2191
|
-
Tk.event_generate(@raised_listbox, "1")
|
2192
|
-
_insert_selected_value = proc{
|
2193
|
-
_value = @raised_listbox.get('active')
|
2194
|
-
_text.delete(_begin_index,'insert')
|
2195
|
-
_text.insert('insert',_value)
|
2196
|
-
@raised_listbox.grab("release")
|
2197
|
-
@raised_listbox.destroy
|
2198
|
-
_text.focus
|
2199
|
-
#_menu.destroy
|
2200
|
-
Tk.callback_break
|
2201
|
-
}
|
2202
|
-
@raised_listbox.bind_append("Double-ButtonPress-1"){|e|
|
2203
|
-
_insert_selected_value.call
|
2204
|
-
}
|
2205
|
-
@raised_listbox.bind_append('KeyPress'){|e|
|
2206
|
-
case e.keysym
|
2207
|
-
when 'Escape'
|
2208
|
-
@raised_listbox.grab("release")
|
2209
|
-
@raised_listbox.destroy
|
2210
|
-
_text.focus
|
2211
|
-
#_menu.destroy
|
2212
|
-
Tk.callback_break
|
2213
|
-
when 'Return'
|
2214
|
-
_insert_selected_value.call
|
2215
|
-
when 'F1'
|
2216
|
-
_key = @raised_listbox.get('active')
|
2217
|
-
_x, _y = xy_insert
|
2218
|
-
Arcadia.process_event(DocCodeEvent.new(self, 'doc_entry'=>_docs_entries[_key], 'xdoc'=>_x, 'ydoc'=>_y))
|
2219
|
-
#EditorContract.instance.doc_code(self, 'doc_entry'=>_docs_entries[_key], 'xdoc'=>_x, 'ydoc'=>_y)
|
2220
|
-
when 'a'..'z'
|
2221
|
-
_text.insert('insert',e.keysym)
|
2222
|
-
_buffer = _buffer + e.keysym
|
2223
|
-
_update_list.call(_buffer)
|
2224
|
-
when 'BackSpace'
|
2225
|
-
if _buffer.length > _buffer_ini_length
|
2226
|
-
_text.delete("#{_begin_index} + #{_buffer.length-1} chars" ,'insert')
|
2227
|
-
_buffer = _buffer[0..-2]
|
2228
|
-
Tk.update
|
2229
|
-
_update_list.call(_buffer)
|
2230
|
-
end
|
2231
|
-
end
|
2232
|
-
}
|
2233
|
-
elsif candidates.length == 1 && candidates[0].length>0
|
2234
|
-
_text.delete(_begin_index,'insert');
|
2235
|
-
_text.insert('insert',candidates[0].split[0])
|
2236
|
-
end
|
2237
|
-
end
|
2238
|
-
end
|
2239
|
-
|
2240
3009
|
def get_find
|
2241
3010
|
@find
|
2242
3011
|
end
|
2243
|
-
|
3012
|
+
|
3013
|
+
|
2244
3014
|
def create_find
|
2245
3015
|
@find = Find.new(@arcadia.layout.root, self)
|
2246
3016
|
@find.on_close=proc{@find.hide}
|
2247
3017
|
@find.hide
|
2248
3018
|
end
|
2249
3019
|
|
3020
|
+
def start_find
|
3021
|
+
_e = raised
|
3022
|
+
_e.find if _e
|
3023
|
+
end
|
3024
|
+
|
2250
3025
|
def on_finalize(_event)
|
3026
|
+
@batch_files = true
|
2251
3027
|
_files =''
|
2252
3028
|
@tabs_editor.each_value{|editor|
|
2253
3029
|
if editor.file != nil
|
@@ -2265,6 +3041,7 @@ class AgMultiEditor < ArcadiaExt
|
|
2265
3041
|
# end
|
2266
3042
|
# }
|
2267
3043
|
# Arcadia.persistent('editor.debug_breakpoints', _breakpoints)
|
3044
|
+
@batch_files = true
|
2268
3045
|
end
|
2269
3046
|
|
2270
3047
|
def raised
|
@@ -2299,7 +3076,14 @@ class AgMultiEditor < ArcadiaExt
|
|
2299
3076
|
return result
|
2300
3077
|
end
|
2301
3078
|
|
3079
|
+
def update(_kind,_name)
|
3080
|
+
if _kind == 'RAISE' && _name == 'editor'
|
3081
|
+
change_outline(raised)
|
3082
|
+
end
|
3083
|
+
end
|
3084
|
+
|
2302
3085
|
def open_last_files
|
3086
|
+
@batch_files = true
|
2303
3087
|
if $arcadia['pers']['editor.files.open']
|
2304
3088
|
_files_index =$arcadia['pers']['editor.files.open'].split("|")
|
2305
3089
|
_files_index.each do |value|
|
@@ -2309,11 +3093,14 @@ class AgMultiEditor < ArcadiaExt
|
|
2309
3093
|
end
|
2310
3094
|
end
|
2311
3095
|
end
|
3096
|
+
@batch_files = false
|
2312
3097
|
_first_page = @main_frame.enb.pages(0) if @main_frame.enb.pages.length > 0
|
2313
3098
|
if _first_page
|
2314
3099
|
@main_frame.enb.raise(_first_page)
|
2315
3100
|
@main_frame.enb.see(_first_page)
|
2316
3101
|
end
|
3102
|
+
frame(1)
|
3103
|
+
@arcadia.layout.add_observer(self)
|
2317
3104
|
self
|
2318
3105
|
end
|
2319
3106
|
|
@@ -2433,7 +3220,7 @@ class AgMultiEditor < ArcadiaExt
|
|
2433
3220
|
#debug_reset
|
2434
3221
|
@editors_in_debug.each{|e|
|
2435
3222
|
close_editor(e)
|
2436
|
-
p "close editor #{e.file}"
|
3223
|
+
#p "close editor #{e.file}"
|
2437
3224
|
}
|
2438
3225
|
end
|
2439
3226
|
|
@@ -2460,6 +3247,14 @@ class AgMultiEditor < ArcadiaExt
|
|
2460
3247
|
end
|
2461
3248
|
end
|
2462
3249
|
|
3250
|
+
def change_outline(_e)
|
3251
|
+
if !@batch_files && frame(1).raised?
|
3252
|
+
@last_outline_e.hide_outline if @last_outline_e
|
3253
|
+
_e.show_outline
|
3254
|
+
@last_outline_e = _e
|
3255
|
+
end
|
3256
|
+
end
|
3257
|
+
|
2463
3258
|
def do_buffer_raise(_name, _title='...')
|
2464
3259
|
_index = @main_frame.enb.index(_name)
|
2465
3260
|
_new_caption = '...'
|
@@ -2468,6 +3263,7 @@ class AgMultiEditor < ArcadiaExt
|
|
2468
3263
|
#_tab = get_tab_from_name(_name)
|
2469
3264
|
#@main_frame.enb.raise(_name)
|
2470
3265
|
_e = @tabs_editor[_name]
|
3266
|
+
change_outline(_e) if _e
|
2471
3267
|
if _e && _e.file != nil
|
2472
3268
|
_new_caption = _e.file
|
2473
3269
|
@find.use(_e)
|
@@ -2577,15 +3373,19 @@ class AgMultiEditor < ArcadiaExt
|
|
2577
3373
|
end
|
2578
3374
|
|
2579
3375
|
def close_others_editor(_editor, _mod=true)
|
3376
|
+
@batch_files = true
|
2580
3377
|
@tabs_editor.values.each do |_e|
|
2581
3378
|
close_editor(_e) if _e != _editor
|
2582
3379
|
end
|
3380
|
+
@batch_files = false
|
2583
3381
|
end
|
2584
3382
|
|
2585
3383
|
def close_all_editor(_editor, _mod=true)
|
3384
|
+
@batch_files = true
|
2586
3385
|
@tabs_editor.values.each do |_e|
|
2587
3386
|
close_editor(_e)
|
2588
3387
|
end
|
3388
|
+
@batch_files = false
|
2589
3389
|
end
|
2590
3390
|
|
2591
3391
|
def close_editor(_editor, _mod=true)
|
@@ -2629,6 +3429,27 @@ class AgMultiEditor < ArcadiaExt
|
|
2629
3429
|
@tabs_editor[tab_name(_filename)].save_as
|
2630
3430
|
end
|
2631
3431
|
|
3432
|
+
def accept_complete_code
|
3433
|
+
@ok_complete = true
|
3434
|
+
if !defined?(@ok_complete)
|
3435
|
+
|
3436
|
+
msg =<<EOS
|
3437
|
+
"Complete code" is actually based on rcodetools
|
3438
|
+
that exec code for retreave candidades.
|
3439
|
+
So it can be dangerous for example if you write system call.
|
3440
|
+
Do you want to activate it?
|
3441
|
+
EOS
|
3442
|
+
@ok_complete = Arcadia.dialog(self,
|
3443
|
+
'level'=>'warning',
|
3444
|
+
'type'=>'yes_no',
|
3445
|
+
'title' => '(Arcadia) Complete code',
|
3446
|
+
'msg'=>msg.upcase)=='yes'
|
3447
|
+
|
3448
|
+
end
|
3449
|
+
return @ok_complete
|
3450
|
+
end
|
3451
|
+
|
3452
|
+
|
2632
3453
|
end
|
2633
3454
|
|
2634
3455
|
class Findview < TkFloatTitledFrame
|
@@ -2637,12 +3458,12 @@ class Findview < TkFloatTitledFrame
|
|
2637
3458
|
#stop_resizing
|
2638
3459
|
y0 = 10
|
2639
3460
|
d = 23
|
2640
|
-
|
2641
|
-
|
2642
|
-
|
2643
|
-
|
2644
|
-
|
2645
|
-
|
3461
|
+
TkLabel.new(self.frame, Arcadia.style('label')){
|
3462
|
+
text 'Find what:'
|
3463
|
+
place('x' => 8,'y' => y0,'height' => 19)
|
3464
|
+
}
|
3465
|
+
y0 = y0 + d
|
3466
|
+
@e_what = Tk::BWidget::ComboBox.new(self.frame, Arcadia.style('combobox')){
|
2646
3467
|
editable true
|
2647
3468
|
justify 'left'
|
2648
3469
|
#relief 'ridge'
|
@@ -2651,19 +3472,19 @@ class Findview < TkFloatTitledFrame
|
|
2651
3472
|
takefocus 'true'
|
2652
3473
|
#pack('padx'=>10, 'fill'=>'x')
|
2653
3474
|
place('relwidth' => 1, 'width'=>-16,'x' => 8,'y' => y0,'height' => 19)
|
2654
|
-
|
2655
|
-
|
3475
|
+
}
|
3476
|
+
@e_what_entry = TkWinfo.children(@e_what)[0]
|
2656
3477
|
|
2657
|
-
|
3478
|
+
@e_what_entry.bind_append("1",proc{Arcadia.process_event(InputEnterEvent.new(self,'receiver'=>@e_what_entry))})
|
2658
3479
|
|
2659
|
-
|
2660
|
-
|
2661
|
-
|
2662
|
-
|
2663
|
-
|
2664
|
-
|
3480
|
+
y0 = y0 + d
|
3481
|
+
TkLabel.new(self.frame, Arcadia.style('label')){
|
3482
|
+
text 'Replace with:'
|
3483
|
+
place('x' => 8,'y' => y0,'height' => 19)
|
3484
|
+
}
|
3485
|
+
y0 = y0 + d
|
2665
3486
|
|
2666
|
-
|
3487
|
+
@e_with = Tk::BWidget::ComboBox.new(self.frame, Arcadia.style('combobox')){
|
2667
3488
|
editable true
|
2668
3489
|
justify 'left'
|
2669
3490
|
autocomplete 'true'
|
@@ -2672,9 +3493,9 @@ class Findview < TkFloatTitledFrame
|
|
2672
3493
|
#pack('padx'=>10, 'fill'=>'x')
|
2673
3494
|
place('relwidth' => 1, 'width'=>-16,'x' => 8,'y' => y0,'height' => 19)
|
2674
3495
|
}
|
2675
|
-
|
3496
|
+
@e_with_entry = TkWinfo.children(@e_with)[0]
|
2676
3497
|
|
2677
|
-
|
3498
|
+
@e_with_entry.bind_append("1",proc{Arcadia.process_event(InputEnterEvent.new(self,'receiver'=>@e_with_entry))})
|
2678
3499
|
|
2679
3500
|
y0 = y0 + d
|
2680
3501
|
@cb_reg = TkCheckButton.new(self.frame, Arcadia.style('checkbox')){|_cb_reg|
|
@@ -2693,9 +3514,9 @@ class Findview < TkFloatTitledFrame
|
|
2693
3514
|
place('x' => 8,'y' => y0,'height' => 22)
|
2694
3515
|
}
|
2695
3516
|
|
2696
|
-
|
2697
|
-
|
2698
|
-
|
3517
|
+
y0 = y0 + d
|
3518
|
+
y0 = y0 + d
|
3519
|
+
@buttons_frame = TkFrame.new(self.frame, Arcadia.style('panel')).pack('fill'=>'x', 'side'=>'bottom')
|
2699
3520
|
|
2700
3521
|
@b_replace_all = TkButton.new(@buttons_frame, Arcadia.style('button')){|_b_go|
|
2701
3522
|
state 'disabled'
|
@@ -2860,10 +3681,17 @@ class Find < Findview
|
|
2860
3681
|
if (_editor != @editor_caller)
|
2861
3682
|
@last_index='insert'
|
2862
3683
|
@editor_caller = _editor
|
2863
|
-
|
3684
|
+
_title = File.basename(_editor.file)
|
3685
|
+
title(_title)
|
3686
|
+
@goto_line_dialog.title(_title) if @goto_line_dialog
|
2864
3687
|
end
|
2865
3688
|
end
|
2866
3689
|
|
3690
|
+
def show
|
3691
|
+
super
|
3692
|
+
use(@controller.raised)
|
3693
|
+
end
|
3694
|
+
|
2867
3695
|
def update_combo(_txt)
|
2868
3696
|
values = @e_what.cget('values')
|
2869
3697
|
if (values != nil && !values.include?(_txt))
|
@@ -2935,31 +3763,6 @@ class Find < Findview
|
|
2935
3763
|
end
|
2936
3764
|
|
2937
3765
|
|
2938
|
-
class KeyTestView < TkToplevel
|
2939
|
-
attr_reader :ttest
|
2940
|
-
def initialize
|
2941
|
-
super
|
2942
|
-
|
2943
|
-
Tk.tk_call('wm', 'title', self, '...hello' )
|
2944
|
-
Tk.tk_call('wm', 'geometry', self, '638x117+200+257' )
|
2945
|
-
|
2946
|
-
@ttest = TkText.new(self){
|
2947
|
-
background '#FFF454'
|
2948
|
-
place('relwidth' => '1','relx' => 0,'x' => '0','y' => '0','relheight' => '1','rely' => 0,'height' => '0','bordermode' => 'inside','width' => '0')
|
2949
|
-
}
|
2950
|
-
|
2951
|
-
end
|
2952
|
-
end
|
2953
|
-
|
2954
|
-
class KetTest
|
2955
|
-
def initialize
|
2956
|
-
kt = KeyTestView.new
|
2957
|
-
kt.ttest.bind("KeyPress"){|e|
|
2958
|
-
kt.ttest.insert('end'," [ "+e.keysym+" ] ")
|
2959
|
-
break
|
2960
|
-
}
|
2961
|
-
end
|
2962
|
-
end
|
2963
3766
|
|
2964
3767
|
class CodeInsight
|
2965
3768
|
end
|
@@ -2972,11 +3775,11 @@ class GoToLine < TkFloatTitledFrame
|
|
2972
3775
|
#stop_resizing
|
2973
3776
|
y0 = 10
|
2974
3777
|
d = 23
|
2975
|
-
|
2976
|
-
|
2977
|
-
|
2978
|
-
|
2979
|
-
|
3778
|
+
TkLabel.new(self.frame, Arcadia.style('label')){
|
3779
|
+
text 'Go to line:'
|
3780
|
+
place('x' => 8,'y' => y0,'height' => 19)
|
3781
|
+
}
|
3782
|
+
y0 = y0 + d
|
2980
3783
|
@e_line = TkEntry.new(self.frame, Arcadia.style('edit')){
|
2981
3784
|
justify 'left'
|
2982
3785
|
#relief 'ridge'
|
@@ -2986,7 +3789,7 @@ class GoToLine < TkFloatTitledFrame
|
|
2986
3789
|
|
2987
3790
|
y0 = y0 + d
|
2988
3791
|
y0 = y0 + d
|
2989
|
-
|
3792
|
+
@buttons_frame = TkFrame.new(self.frame, Arcadia.style('panel')).pack('fill'=>'x', 'side'=>'bottom')
|
2990
3793
|
|
2991
3794
|
@b_go = TkButton.new(@buttons_frame, Arcadia.style('button')){|_b_go|
|
2992
3795
|
compound 'none'
|
@@ -2996,7 +3799,7 @@ class GoToLine < TkFloatTitledFrame
|
|
2996
3799
|
#justify 'center'
|
2997
3800
|
pack('side'=>'right','ipadx'=>5, 'padx'=>5)
|
2998
3801
|
}
|
2999
|
-
place('x'=>150,'y'=>150,'height'=> 120,'width'=>
|
3802
|
+
place('x'=>150,'y'=>150,'height'=> 120,'width'=> 240)
|
3000
3803
|
|
3001
3804
|
end
|
3002
3805
|
|