Class: AgEditorOutline
- Inherits:
-
Object
- Object
- AgEditorOutline
- Defined in:
- ext/ae-editor/ae-editor.rb
Instance Attribute Summary collapse
-
#last_opened ⇒ Object
readonly
Returns the value of attribute last_opened.
-
#last_row ⇒ Object
readonly
Returns the value of attribute last_row.
-
#ss ⇒ Object
readonly
Returns the value of attribute ss.
-
#tree_exp ⇒ Object
readonly
Returns the value of attribute tree_exp.
Instance Method Summary collapse
- #build_tree(_sel = nil) ⇒ Object
- #build_tree_from_node(_node, _label_match = nil) ⇒ Object
- #destroy ⇒ Object
- #hide ⇒ Object
-
#initialize(_editor, _frame, _bar, _lang = nil) ⇒ AgEditorOutline
constructor
A new instance of AgEditorOutline.
- #initialize_tree(_frame) ⇒ Object
- #pop_up_menu_tree ⇒ Object
- #select_without_event(_line) ⇒ Object
- #show ⇒ Object
- #shure_select_line(_line, _close_if_opened = true) ⇒ Object
-
#shure_select_node(_node, _close_if_opened = true) ⇒ Object
I think this is “if synced expand out the outline for the current selection”.
- #update_row(_row = 0) ⇒ Object
Constructor Details
#initialize(_editor, _frame, _bar, _lang = nil) ⇒ AgEditorOutline
Returns a new instance of AgEditorOutline.
1083 1084 1085 1086 1087 1088 1089 |
# File 'ext/ae-editor/ae-editor.rb', line 1083 def initialize(_editor, _frame, , _lang=nil) @editor = _editor @frame = _frame @bar = @lang = _lang initialize_tree(_frame) end |
Instance Attribute Details
#last_opened ⇒ Object (readonly)
Returns the value of attribute last_opened.
1082 1083 1084 |
# File 'ext/ae-editor/ae-editor.rb', line 1082 def last_opened @last_opened end |
#last_row ⇒ Object (readonly)
Returns the value of attribute last_row.
1079 1080 1081 |
# File 'ext/ae-editor/ae-editor.rb', line 1079 def last_row @last_row end |
#ss ⇒ Object (readonly)
Returns the value of attribute ss.
1081 1082 1083 |
# File 'ext/ae-editor/ae-editor.rb', line 1081 def ss @ss end |
#tree_exp ⇒ Object (readonly)
Returns the value of attribute tree_exp.
1080 1081 1082 |
# File 'ext/ae-editor/ae-editor.rb', line 1080 def tree_exp @tree_exp end |
Instance Method Details
#build_tree(_sel = nil) ⇒ Object
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 |
# File 'ext/ae-editor/ae-editor.rb', line 1247 def build_tree(_sel=nil) #Arcadia.console(self,"msg"=>"build for #{@file}") if _sel _label_sel = @tree_exp.itemcget(_sel,'text') end #clear tree begin @tree_exp.delete(@tree_exp.nodes('root')) rescue Exception # workaround on windows @tree_exp.delete(@tree_exp.nodes('root')) end _txt = @editor.text.get('1.0','end') if @editor. || (OS.unix? && @lang == 'ruby') if @editor.file && !@editor.modified? if @editor. @ss = CtagsFileSourceStructure.new(@editor.file, @editor.) elsif OS.unix? @ss = RubyGrepFileSourceStructure.new(@editor.file) end else tmp_file = @editor.create_temp_file begin if @editor. @ss = CtagsFileSourceStructure.new(tmp_file, @editor., @lang) elsif OS.unix? @ss = RubyGrepFileSourceStructure.new(tmp_file) end ensure File.delete(tmp_file) end end else @ss = RubySourceStructureParser.new(_txt) end @selected = nil build_tree_from_node(@ss.root, _label_sel) if @selected @tree_exp.selection_add(@selected.rif) @tree_exp.open_tree(@selected.parent.rif) if @selected.parent.rif != 'root' @tree_exp.see(@selected.rif) end end |
#build_tree_from_node(_node, _label_match = nil) ⇒ Object
1213 1214 1215 1216 1217 1218 1219 1220 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 |
# File 'ext/ae-editor/ae-editor.rb', line 1213 def build_tree_from_node(_node, _label_match=nil) @image_class = Arcadia.image_res(TREE_NODE_CLASS_GIF) @image_module = Arcadia.image_res(TREE_NODE_MODULE_GIF) @image_method = Arcadia.image_res(TREE_NODE_METHOD_GIF) @image_singleton_method = Arcadia.image_res(TREE_NODE_SINGLETON_METHOD_GIF) _sorted_sons = _node.sons.sort for inode in 0.._sorted_sons.length - 1 _son = _sorted_sons[inode] if _son.kind == 'class' _image = @image_class elsif _son.kind == 'module' _image = @image_module elsif _son.kind == 'method' || _son.kind == 'procedure' _image = @image_method elsif _son.kind == 'singleton method' _image = @image_singleton_method end if !@tree_exp.exist?(_son.rif) @tree_exp.insert('end', _son.parent.rif ,_son.rif, { 'text' => _son.label , 'helptext' => _son.helptext, #'font'=>$arcadia['conf']['editor.explorer_panel.tree.font'], 'image'=> _image }.update(Arcadia.style('treeitem')) ) end if (_label_match) && (_label_match.strip == _son.label.strip) @selected = _son end build_tree_from_node(_son, _label_match) # recursion -- if there are no sons it will do nothing end end |
#destroy ⇒ Object
1195 1196 1197 1198 1199 1200 |
# File 'ext/ae-editor/ae-editor.rb', line 1195 def destroy #@tree_scroll_wrapper.destroy @tree_exp.hide @tree_exp.destroy Tk.update end |
#hide ⇒ Object
1208 1209 1210 1211 |
# File 'ext/ae-editor/ae-editor.rb', line 1208 def hide @tree_exp.hide #@tree_scroll_wrapper.hide end |
#initialize_tree(_frame) ⇒ Object
1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 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 |
# File 'ext/ae-editor/ae-editor.rb', line 1146 def initialize_tree(_frame) _tree_goto = proc{|_self| sync_val = @bar.sync @bar.sync=false begin #_line = _self.selection_get[0] _line = _self.selected _index =_line.to_s+'.0' _hinner_text = @tree_exp.itemcget(_line,'text').strip _editor_line = @editor.text.get(_index, _index+ ' lineend') if !_editor_line.include?(_hinner_text) Arcadia.console(self, 'msg'=>"#{Arcadia.text('ext.editor.outline.rebuild_tree')} \n") if @tree_thread && @tree_thread.alive? @tree_thread.exit # kill the old tree end @tree_thread = Thread.new{ build_tree(_line) Tk.update } _line = _self.selected _index =_line.to_s+'.0' end @editor.text.set_focus @editor.text.see(_index) @editor.text.tag_remove('selected','1.0','end') @editor.text.tag_add('selected',_line.to_s+'.0',(_line+1).to_s+'.0') ensure @bar.sync = sync_val end } do_open_command = proc{|no| @last_opened = no } @tree_exp = BWidgetTreePatched.new(_frame, Arcadia.style('treepanel')){ showlines false deltay 18 dragenabled true selectcommand proc{ _tree_goto.call(self) } opencmd do_open_command crosscloseimage Arcadia.image_res(ARROWRIGHT_GIF) crossopenimage Arcadia.image_res(ARROWDOWN_GIF) } @tree_exp.extend(TkScrollableWidget) @tree_exp.bind_append("Enter", proc{@tree_exp.focus}) self.show end |
#pop_up_menu_tree ⇒ Object
1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 |
# File 'ext/ae-editor/ae-editor.rb', line 1292 def #@pop_up_tree = TkMenu.new( @pop_up_tree = Arcadia.wf.( :parent=>@tree_exp, :tearoff=>0, :title => 'Menu tree' ) # @pop_up_tree.extend(TkAutoPostMenu) # @pop_up_tree.configure(Arcadia.style('menu')) @pop_up_tree.insert('end', :command, :label=> Arcadia.text('ext.editor.outline.menu.rebuild'), :hidemargin => false, :command=> proc{build_tree} ) @tree_exp.areabind_append("Button-3", proc{|x,y| _x = TkWinfo.pointerx(@tree_exp) _y = TkWinfo.pointery(@tree_exp) @pop_up_tree.popup(_x,_y) }, "%x %y") end |
#select_without_event(_line) ⇒ Object
1137 1138 1139 1140 1141 1142 1143 1144 |
# File 'ext/ae-editor/ae-editor.rb', line 1137 def select_without_event(_line) if @ss _node=@ss.deep_node_by_line(@ss.root, _line) if _node && @tree_exp.exist?(_node.rif) && _node.rif!='root' shure_select_node(_node) end end end |
#show ⇒ Object
1202 1203 1204 1205 1206 |
# File 'ext/ae-editor/ae-editor.rb', line 1202 def show #@tree_scroll_wrapper.show(0,26) @tree_exp.show(0,0) Tk.update end |
#shure_select_line(_line, _close_if_opened = true) ⇒ Object
1128 1129 1130 1131 1132 1133 1134 1135 |
# File 'ext/ae-editor/ae-editor.rb', line 1128 def shure_select_line(_line, _close_if_opened = true) if @ss && _line node = @ss.node_by_line(@ss.root, _line) else node = SourceStructure.root end shure_select_node(node, _close_if_opened) end |
#shure_select_node(_node, _close_if_opened = true) ⇒ Object
I think this is “if synced expand out the outline for the current selection”
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 |
# File 'ext/ae-editor/ae-editor.rb', line 1099 def shure_select_node(_node, _close_if_opened = true) return if @selecting_node #return if @tree_exp.exist?(_node.rif) @selecting_node = true _proc = @tree_exp.selectcommand @tree_exp.selectcommand(nil) begin @tree_exp.selection_clear @tree_exp.selection_add(_node.rif) @opened = false to_open = @last_open_node parent = _node.parent while !parent.nil? && parent.rif != 'root' @tree_exp.open_tree(parent.rif, false) @opened = to_open==parent.rif || @opened @last_open_node=parent.rif parent = parent.parent end @tree_exp.close_tree(to_open) if _close_if_opened && to_open && !@opened @tree_exp.see(_node.rif) rescue RuntimeError => e Arcadia.runtime_error(e) ensure @tree_exp.selectcommand(_proc) @selecting_node = false end @tree_exp.call_after_next_show_h_scroll(proc{Tk.update;@tree_exp.see(_node.rif)}) end |
#update_row(_row = 0) ⇒ Object
1091 1092 1093 1094 1095 1096 |
# File 'ext/ae-editor/ae-editor.rb', line 1091 def update_row(_row=0) @last_row=_row if @bar.is_sync_on? select_without_event(_row) end end |