Class: AgMultiEditor
- Inherits:
-
ArcadiaExt
- Object
- ArcadiaExt
- AgMultiEditor
- Defined in:
- ext/ae-editor/ae-editor.rb
Instance Attribute Summary collapse
-
#breakpoints ⇒ Object
readonly
Returns the value of attribute breakpoints.
-
#splitted_frame ⇒ Object
readonly
Returns the value of attribute splitted_frame.
Instance Method Summary collapse
- #add_reverse_item(_editor) ⇒ Object
- #after_build ⇒ Object
- #before_build ⇒ Object
- #bookmark_add(_file, _index) ⇒ Object
- #bookmark_clear ⇒ Object
- #bookmark_move(_n = 0) ⇒ Object
- #bookmark_next ⇒ Object
- #bookmark_prev ⇒ Object
- #breakpoint_add(_file, _line) ⇒ Object
- #breakpoint_del(_file, _line) ⇒ Object
- #breakpoint_lines_on_file(_file) ⇒ Object
- #build ⇒ Object
- #change_file_name(_tab, _new_file) ⇒ Object
- #change_tab_reset_modify(_tab) ⇒ Object
- #change_tab_set_modify(_tab) ⇒ Object
- #change_tab_title(_tab, _new_text) ⇒ Object
- #close_all_editor(_editor, _mod = true) ⇒ Object
- #close_editor(_editor, _mod = true) ⇒ Object
- #close_file(_filename) ⇒ Object
- #close_others_editor(_editor, _mod = true) ⇒ Object
- #close_raised ⇒ Object
- #close_tab(_page_frame) ⇒ Object
- #create_find ⇒ Object
- #debug_begin ⇒ Object
- #debug_end ⇒ Object
- #debug_reset ⇒ Object
- #do_buffer_raise(_name, _title = '...') ⇒ Object
- #do_debug_event(_event) ⇒ Object
- #do_editor_event(_event) ⇒ Object
- #do_main_event(_event) ⇒ Object
- #editor_exist?(_filename) ⇒ Boolean
- #finalize ⇒ Object
-
#get_find ⇒ Object
def editor_state r = EditorContract::SObj.new r.raised_file = self.raised.file r.breakpoints = @breakpoints return r end.
- #get_tab_from_name(_name = nil) ⇒ Object
- #open_buffer(_buffer_name = nil, _title = nil) ⇒ Object
- #open_file(_filename = nil, _text_index = '1.0') ⇒ Object
- #open_file_in_debug(_filename = nil, _line = nil) ⇒ Object
- #open_last_files ⇒ Object
- #page_name(_page_frame) ⇒ Object
- #pop_up_menu ⇒ Object
- #raise_complete_code(_context) ⇒ Object
- #raised ⇒ Object
- #save_as_file(_filename) ⇒ Object
- #save_file(_filename) ⇒ Object
- #tab_file_name(_filename = "") ⇒ Object
- #tab_name(_str = "") ⇒ Object
- #xy_insert ⇒ Object
Instance Attribute Details
#breakpoints ⇒ Object (readonly)
Returns the value of attribute breakpoints.
1231 1232 1233 |
# File 'ext/ae-editor/ae-editor.rb', line 1231 def breakpoints @breakpoints end |
#splitted_frame ⇒ Object (readonly)
Returns the value of attribute splitted_frame.
1232 1233 1234 |
# File 'ext/ae-editor/ae-editor.rb', line 1232 def splitted_frame @splitted_frame end |
Instance Method Details
#add_reverse_item(_editor) ⇒ Object
1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 |
# File 'ext/ae-editor/ae-editor.rb', line 1505 def add_reverse_item(_editor) code2form = proc{ Revparsel.new(_editor.text_value) self.close_editor(_editor, false) InspectorContract.instance.(self) } _editor.('end', :command, :label=>'View as form', :hidemargin => false, :command=> code2form ) end |
#after_build ⇒ Object
1256 1257 1258 |
# File 'ext/ae-editor/ae-editor.rb', line 1256 def after_build self.open_last_files end |
#before_build ⇒ Object
1233 1234 1235 1236 1237 |
# File 'ext/ae-editor/ae-editor.rb', line 1233 def before_build ArcadiaContractListener.new(self, DebugContract, :do_debug_event) ArcadiaContractListener.new(self, EditorContract, :do_editor_event) ArcadiaContractListener.new(self, MainContract, :do_main_event) end |
#bookmark_add(_file, _index) ⇒ Object
1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 |
# File 'ext/ae-editor/ae-editor.rb', line 1595 def bookmark_add(_file, _index) if @bookmarks == nil @bookmarks = Array.new @bookmarks_index = - 1 else _cur_file, _cur_index = @bookmarks[@bookmarks_index] if _cur_file == _file && _cur_index == _index #@arcadia.outln('uguale ----> '+_file+':'+_index) return end @bookmarks = @bookmarks[0..@bookmarks_index] end @bookmarks << [_file, _index] @bookmarks_index = @bookmarks.length - 1 #@arcadia.outln('add ----> '+_file+':'+_index) end |
#bookmark_clear ⇒ Object
1612 1613 1614 1615 |
# File 'ext/ae-editor/ae-editor.rb', line 1612 def bookmark_clear @bookmarks.clear @bookmarks_index = - 1 end |
#bookmark_move(_n = 0) ⇒ Object
1622 1623 1624 1625 1626 1627 1628 1629 |
# File 'ext/ae-editor/ae-editor.rb', line 1622 def bookmark_move(_n=0) @bookmarks_index = @bookmarks_index + _n #Tk.messageBox('message'=>@bookmarks_index.to_s) _file, _index = @bookmarks[@bookmarks_index] _line, _col = _index.split('.') if _index open_file(_file, _index) #openfile(@bookmarks[@bookmarks_index]) end |
#bookmark_next ⇒ Object
1617 1618 1619 1620 |
# File 'ext/ae-editor/ae-editor.rb', line 1617 def bookmark_next return if @bookmarks == nil || @bookmarks_index >= @bookmarks.length - 1 bookmark_move(+1) end |
#bookmark_prev ⇒ Object
1632 1633 1634 1635 |
# File 'ext/ae-editor/ae-editor.rb', line 1632 def bookmark_prev return if @bookmarks == nil || @bookmarks_index <= 0 bookmark_move(-1) end |
#breakpoint_add(_file, _line) ⇒ Object
1562 1563 1564 1565 |
# File 'ext/ae-editor/ae-editor.rb', line 1562 def breakpoint_add(_file,_line) EditorContract.instance.breakpoint_created(self, 'file'=>_file, 'line'=>_line) @breakpoints << {:file=>_file,:line=>_line} end |
#breakpoint_del(_file, _line) ⇒ Object
1567 1568 1569 1570 |
# File 'ext/ae-editor/ae-editor.rb', line 1567 def breakpoint_del(_file,_line) EditorContract.instance.breakpoint_deleted(self, 'file'=>_file, 'line'=>_line) @breakpoints.delete_if{|b| (b[:file]==_file && b[:line]==_line)} end |
#breakpoint_lines_on_file(_file) ⇒ Object
1572 1573 1574 1575 1576 1577 1578 1579 1580 |
# File 'ext/ae-editor/ae-editor.rb', line 1572 def breakpoint_lines_on_file(_file) result = Array.new @breakpoints.each{|value| if value[:file]==_file result << value[:line] end } return result end |
#build ⇒ Object
1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 |
# File 'ext/ae-editor/ae-editor.rb', line 1239 def build if @arcadia.layout.headed? title_frame = @arcadia.layout.domain(conf('frame'))['root'] #@close_button = title_frame.add_button(nil,nil,TAB_CLOSE_GIF,'left') end #@splitted_frame = AGTkOSplittedFrames.new(self.frame,20) #@main_frame = AgMultiEditorView.new(@splitted_frame.bottom_frame) @main_frame = AgMultiEditorView.new(self.frame) #@close_button.bind('1',proc{close_raised}) @tabs_file =Hash.new @tabs_editor =Hash.new @breakpoints =Array.new create_find end |
#change_file_name(_tab, _new_file) ⇒ Object
1672 1673 1674 1675 1676 |
# File 'ext/ae-editor/ae-editor.rb', line 1672 def change_file_name(_tab, _new_file) _new_label = File.basename(_new_file) change_tab_title(_tab, _new_label) @tabs_file[page_name(_tab)] = _new_file end |
#change_tab_reset_modify(_tab) ⇒ Object
1660 1661 1662 1663 1664 1665 1666 |
# File 'ext/ae-editor/ae-editor.rb', line 1660 def change_tab_reset_modify(_tab) #_new_name = @main_frame.enb.itemcget(@tabs_name[_tab], 'text').gsub!("(...)",'') _new_name = @main_frame.enb.itemcget(page_name(_tab), 'text').gsub!("(...)",'') if _new_name change_tab_title(_tab, _new_name) end end |
#change_tab_set_modify(_tab) ⇒ Object
1651 1652 1653 1654 |
# File 'ext/ae-editor/ae-editor.rb', line 1651 def change_tab_set_modify(_tab) _new_name = '(...)'+@main_frame.enb.itemcget(page_name(_tab), 'text') change_tab_title(_tab, _new_name) end |
#change_tab_title(_tab, _new_text) ⇒ Object
1668 1669 1670 |
# File 'ext/ae-editor/ae-editor.rb', line 1668 def change_tab_title(_tab, _new_text) @main_frame.enb.itemconfigure(page_name(_tab), 'text'=> _new_text) end |
#close_all_editor(_editor, _mod = true) ⇒ Object
1827 1828 1829 1830 1831 |
# File 'ext/ae-editor/ae-editor.rb', line 1827 def close_all_editor(_editor, _mod=true) @tabs_editor.values.each do |_e| close_editor(_e) end end |
#close_editor(_editor, _mod = true) ⇒ Object
1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 |
# File 'ext/ae-editor/ae-editor.rb', line 1833 def close_editor(_editor, _mod=true) if ((_mod)&&(_editor.modified?)) = @main_frame.enb.itemcget(page_name(_editor.page_frame), 'text')+"\n modified. Save?" _r = TkDialog2.new('message'=>, 'buttons'=>['Ok','No','Cancel']).show() if _r == 0 _editor.save elsif _r == 1 close_tab(_editor.page_frame) elsif _r == 2 return end else close_tab(_editor.page_frame) end EditorContract.instance.file_closed(self, 'file'=>_editor.file) end |
#close_file(_filename) ⇒ Object
1860 1861 1862 |
# File 'ext/ae-editor/ae-editor.rb', line 1860 def close_file(_filename) close_editor(@tabs_editor[tab_name(_filename)]) end |
#close_others_editor(_editor, _mod = true) ⇒ Object
1821 1822 1823 1824 1825 |
# File 'ext/ae-editor/ae-editor.rb', line 1821 def close_others_editor(_editor, _mod=true) @tabs_editor.values.each do |_e| close_editor(_e) if _e != _editor end end |
#close_raised ⇒ Object
1553 1554 1555 1556 1557 1558 1559 1560 |
# File 'ext/ae-editor/ae-editor.rb', line 1553 def close_raised close_editor(@tabs_editor[@main_frame.enb.raise]) #_page = @main_frame.enb.raise #_editor = @tabs_editor[_page] #_row = _editor.text_insert_index.split('.')[0].strip.to_i #close_editor(_editor) end |
#close_tab(_page_frame) ⇒ Object
1850 1851 1852 1853 1854 1855 1856 1857 1858 |
# File 'ext/ae-editor/ae-editor.rb', line 1850 def close_tab(_page_frame) _name = page_name(_page_frame) @tabs_editor.delete(_name) _index = @main_frame.enb.index(_name) @main_frame.enb.delete(_name) if !@main_frame.enb.pages.empty? @main_frame.enb.raise(@main_frame.enb.pages[_index-1]) end end |
#create_find ⇒ Object
1531 1532 1533 1534 1535 1536 1537 |
# File 'ext/ae-editor/ae-editor.rb', line 1531 def create_find #find_frame = @arcadia.layout.register_panel(conf('find.frame'),'Find', 'Find') # @find = Find.new(@splitted_frame.top_frame, self) @find = Find.new(@arcadia.layout.root, self) @find.on_close=proc{@find.hide} @find.hide end |
#debug_begin ⇒ Object
1678 1679 1680 1681 1682 1683 1684 |
# File 'ext/ae-editor/ae-editor.rb', line 1678 def debug_begin if @editors_in_debug != nil @editors_in_debug.clear else @editors_in_debug = Array.new end end |
#debug_end ⇒ Object
1686 1687 1688 1689 1690 1691 |
# File 'ext/ae-editor/ae-editor.rb', line 1686 def debug_end debug_reset @editors_in_debug.each{|e| close_editor(e) } end |
#debug_reset ⇒ Object
1693 1694 1695 1696 1697 |
# File 'ext/ae-editor/ae-editor.rb', line 1693 def debug_reset if @last_index && @last_e @last_e.unmark_debug(@last_index) end end |
#do_buffer_raise(_name, _title = '...') ⇒ Object
1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 |
# File 'ext/ae-editor/ae-editor.rb', line 1714 def do_buffer_raise(_name, _title='...') _index = @main_frame.enb.index(_name) = '...' if _index != -1 #_name = @main_frame.enb.pages(_index) #_tab = get_tab_from_name(_name) #@main_frame.enb.raise(_name) _e = @tabs_editor[_name] if _e && _e.file != nil = _e.file @find.use(_e) _e.check_file_last_access_time else = _title end end if @arcadia.layout.headed? @arcadia.layout.domain(@arcadia['conf'][@name+'.frame'])['root'].top_text() end _title = @tabs_file[_name] != nil ? File.basename(@tabs_file[_name]) :_name EditorContract.instance.buffer_raised(self, 'title'=>_title, 'file'=>@tabs_file[_name]) end |
#do_debug_event(_event) ⇒ Object
1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 |
# File 'ext/ae-editor/ae-editor.rb', line 1330 def do_debug_event(_event) #@arcadia.outln('_sender ----> '+_sender.to_s) #@arcadia.outln('_event.signature ----> '+_event.signature) case _event.signature when DebugContract::DEBUG_BEGIN self.debug_begin when DebugContract::DEBUG_END self.debug_end when DebugContract::DEBUG_STEP if _event.context.file self.open_file_in_debug(_event.context.file, _event.context.line) end end end |
#do_editor_event(_event) ⇒ Object
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 |
# File 'ext/ae-editor/ae-editor.rb', line 1345 def do_editor_event(_event) case _event.signature when EditorContract::OPEN_FILE if _event.context.file if _event.context.line _index = _event.context.line.to_s+'.0' end self.open_file(_event.context.file, _index) _event.handled(self) end when EditorContract::CLOSE_FILE if _event.context.file self.close_file(_event.context.file) _event.handled(self) end when EditorContract::SAVE_FILE_RAISED self.raised.save _event.handled(self) when EditorContract::SAVE_FILE if _event.context.file self.save_file(_event.context.file) _event.handled(self) end when EditorContract::SAVE_AS_FILE_RAISED self.raised.save_as _event.handled(self) when EditorContract::SAVE_AS_FILE if _event.context.file self.save_as_file(_event.context.file) _event.handled(self) end when EditorContract::OPEN_TEXT if _event.context.title _tab_name = self.tab_name(_event.context.title) self.open_buffer(_tab_name, _event.context.title) _e = @tabs_editor[_tab_name] _e.text_insert('end',_event.context.text) if _event.context.text _e.reset _e.refresh add_reverse_item(_e) _event.handled(self) end when EditorContract::SHOW_SEARCH_DIALOG @find.show when EditorContract::SHOW_GOTO_LINE_DIALOG @find.show_go_to_line_dialog end end |
#do_main_event(_event) ⇒ Object
1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 |
# File 'ext/ae-editor/ae-editor.rb', line 1489 def do_main_event(_event) case _event.signature when MainContract::EVENT_HANDLED _cause = _event.context.caused_by if _cause.signature == EditorContract::COMPLETE_CODE && _cause.context.sender == self.raised raise_complete_code(_cause.context) elsif _cause.signature == EditorContract::DOC_CODE && _cause.context.file != nil # delete the file used for completion if File.exist?(_cause.context.file) && _cause.context.file.include?('~~') File.delete(_cause.context.file) end end end end |
#editor_exist?(_filename) ⇒ Boolean
1737 1738 1739 1740 1741 1742 1743 1744 |
# File 'ext/ae-editor/ae-editor.rb', line 1737 def editor_exist?(_filename) _basefilename = File.basename(_filename) #_basename = _basefilename.split('.')[0]+'_'+_basefilename.split('.')[1] _index = @main_frame.enb.index(self.tab_name(_filename)) return _index != -1 end |
#finalize ⇒ Object
1539 1540 1541 1542 1543 1544 1545 1546 |
# File 'ext/ae-editor/ae-editor.rb', line 1539 def finalize _files ='' @tabs_editor.each_value{|editor| _files=_files+'|'+ editor.file if editor.file != nil close_editor(editor) } @arcadia['pers']['editor.files.open']=_files end |
#get_find ⇒ Object
def editor_state
r = EditorContract::SObj.new
r.raised_file = self.raised.file
r.breakpoints = @breakpoints
return r
end
1527 1528 1529 |
# File 'ext/ae-editor/ae-editor.rb', line 1527 def get_find @find end |
#get_tab_from_name(_name = nil) ⇒ Object
1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 |
# File 'ext/ae-editor/ae-editor.rb', line 1638 def get_tab_from_name(_name=nil) return @main_frame.enb.get_frame(_name) # if _name # @tabs_name.each{ # |key,value| # if value.to_s==_name.to_s # return key # end # } # return nil # end end |
#open_buffer(_buffer_name = nil, _title = nil) ⇒ Object
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 |
# File 'ext/ae-editor/ae-editor.rb', line 1786 def open_buffer(_buffer_name = nil, _title = nil) _index = @main_frame.enb.index(_buffer_name) if _buffer_name == nil _buffer_name = tab_name('new') _title_new = '*new' end if _index != -1 _tab = @main_frame.enb.get_frame(_buffer_name) @main_frame.enb.raise(_buffer_name) else _n = 1 while @main_frame.enb.index(_buffer_name) != -1 _title_new = '*new'+_n.to_s _buffer_name = tab_name('new')+_n.to_s _n =_n+1 end if _title == nil _title = _title_new end _tab = @main_frame.enb.insert('end', _buffer_name , 'text'=> _title, 'raisecmd'=>proc{do_buffer_raise(_buffer_name, _title)} ) _e = AgEditor.new(self, _tab) _e.init_editing(_e.file_extension(_title)) @tabs_file[_buffer_name]= nil @tabs_editor[_buffer_name]=_e end @main_frame.enb.move(_buffer_name, 1) @main_frame.enb.raise(_buffer_name) @main_frame.enb.see(_buffer_name) return _tab end |
#open_file(_filename = nil, _text_index = '1.0') ⇒ Object
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 |
# File 'ext/ae-editor/ae-editor.rb', line 1756 def open_file(_filename = nil, _text_index='1.0') return if _filename == nil || !File.exist?(_filename) _basefilename = File.basename(_filename) _tab_name = self.tab_file_name(_filename) _index = @main_frame.enb.index(_tab_name) _exist_buffer = _index != -1 if _exist_buffer open_buffer(_tab_name) else open_buffer(_tab_name, _basefilename) # _basefilename.include?('.rb')?_image = RUBY_DOCUMENT_GIF: _image = DOCUMENT_OPEN_GIF # @main_frame.enb.itemconfigure(_tab_name, # 'image'=> TkPhotoImage.new('data' =>_image ) # ) @tabs_file[_tab_name]= _filename @tabs_editor[_tab_name].load_file(_filename) #do_buffer_raise(_tab_name) EditorContract.instance.file_opened(self, 'file'=>_filename) end if _text_index != nil && _text_index != '1.0' @tabs_editor[_tab_name].text_see(_text_index) @tabs_editor[_tab_name].mark_selected(_text_index) end return @tabs_editor[_tab_name] end |
#open_file_in_debug(_filename = nil, _line = nil) ⇒ Object
1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 |
# File 'ext/ae-editor/ae-editor.rb', line 1699 def open_file_in_debug(_filename=nil, _line=nil) debug_reset if _filename && _line @last_index = _line.to_s+'.0' _editor_exist = editor_exist?(_filename) @last_e = open_file(_filename, @last_index) if !_editor_exist @editors_in_debug << @last_e end @last_e.mark_debug(@last_index) if @last_e end end |
#open_last_files ⇒ Object
1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 |
# File 'ext/ae-editor/ae-editor.rb', line 1582 def open_last_files if $arcadia['pers']['editor.files.open'] _files_index =$arcadia['pers']['editor.files.open'].split("|") _files_index.each{|value| _file,_index = value.split(';') if _file open_file(_file,_index) end } end self end |
#page_name(_page_frame) ⇒ Object
1656 1657 1658 |
# File 'ext/ae-editor/ae-editor.rb', line 1656 def page_name(_page_frame) TkWinfo.appname(_page_frame).sub('f','') end |
#pop_up_menu ⇒ Object
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 |
# File 'ext/ae-editor/ae-editor.rb', line 1260 def @pop_up = TkMenu.new( :parent=>@main_frame.enb, :tearoff=>0, :title => 'Menu' ) @pop_up.insert('end', :command, :label=>'...', :state=>'disabled', :background=>'blue', :font => conf('font.bold'), :hidemargin => true ) @c = @pop_up.insert('end', :command, :label=>'Close', :font => conf('font'), :hidemargin => false, :command=> proc{ if @selected_tab_name_from_popup != nil _e = @tabs_editor[@selected_tab_name_from_popup] self.close_editor(_e) end } ) @c = @pop_up.insert('end', :command, :label=>'Close others', :font => conf('font'), :hidemargin => false, :command=> proc{ if @selected_tab_name_from_popup != nil _e = @tabs_editor[@selected_tab_name_from_popup] self.close_others_editor(_e) end } ) @c = @pop_up.insert('end', :command, :label=>'Close all', :font => conf('font'), :hidemargin => false, :command=> proc{ if @selected_tab_name_from_popup != nil _e = @tabs_editor[@selected_tab_name_from_popup] self.close_all_editor(_e) end } ) @main_frame.enb.tabbind("Button-3", proc{|*x| _x = TkWinfo.pointerx(@main_frame.enb) _y = TkWinfo.pointery(@main_frame.enb) @selected_tab_name_from_popup = x[0].split(':')[0] _index = @main_frame.enb.index(@selected_tab_name_from_popup) if _index == -1 @selected_tab_name_from_popup = 'ff'+@selected_tab_name_from_popup _index = @main_frame.enb.index(@selected_tab_name_from_popup) end if _index != -1 _file = @main_frame.enb.itemcget(@selected_tab_name_from_popup, 'text') @pop_up.entryconfigure(0, 'label'=>_file) @pop_up.popup(_x,_y) end }) end |
#raise_complete_code(_context) ⇒ Object
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 |
# File 'ext/ae-editor/ae-editor.rb', line 1407 def raise_complete_code(_context) # delete the file used for completion if File.exist?(_context.file) && _context.file.include?('~~') File.delete(_context.file) end @raised_listbox.destroy if @raised_listbox != nil _text = self.raised.text _index_call = _context.line+'.'+_context.col _index_now = _text.index('insert') if _index_call == _index_now _target = _text.get('insert - 1 chars wordstart','insert') if _target.length > 0 && _target != '.' extra_len = _target.length.+@ _begin_index = _index_now<<' - '<<extra_len.to_s<<' chars' _text.tag_add('sel', _begin_index, _index_now) else _begin_index = _index_now extra_len = 0 end if _context.candidates.length > 1 _rx, _ry, _widht, heigth = _text.bbox(_begin_index); _x = _rx + TkWinfo.rootx(_text) _y = _ry + TkWinfo.rooty(_text) + TkFont.new(conf('font')).metrics[2][1] _xroot = _x - TkWinfo.rootx(@arcadia.layout.root) _yroot = _y - TkWinfo.rooty(@arcadia.layout.root) _max_height = TkWinfo.screenheight(@arcadia.layout.root) - _y - 5 @raised_listbox = TkListbox.new(@arcadia.layout.root, 'takefocus'=>true, :background=>conf('color.background'), :foreground=>conf('color.foreground'), :selectbackground=>'yellow', :selectforeground=>'red', :activestyle=>'none', :font => conf('font'), :borderwidth=>1 ) _font = TkFont.new(conf('font')) _char_height = _font.metrics[2][1] _width = 0 _docs_entries = Hash.new _context.candidates.each{|value| _key, _doc = value.split _docs_entries[_key]= _doc @raised_listbox.insert('end', _key) _temp_width = _font.measure(_key) + _font.measure('X') _width = _temp_width if _temp_width > _width } _height = (_context.candidates.length+1)*_char_height _height = _max_height if _height > _max_height @raised_listbox.place('x'=>_xroot,'y'=>_yroot, 'width'=>_width, 'height'=>_height) @raised_listbox.focus @raised_listbox.bind_append('KeyPress'){|e| case e.keysym when 'Escape' @raised_listbox.destroy #_menu.destroy Tk.callback_break when 'Return' _value = @raised_listbox.get('active') _text.delete(_begin_index,'insert') _text.insert('insert',_value) @raised_listbox.destroy #_menu.destroy Tk.callback_break when 'F1' _key = @raised_listbox.get('active') _x, _y = xy_insert EditorContract.instance.doc_code(self, 'doc_entry'=>_docs_entries[_key], 'xdoc'=>_x, 'ydoc'=>_y) end } elsif _context.candidates.length == 1 && _context.candidates[0].length>0 _text.delete(_begin_index,'insert'); _text.insert('insert',_context.candidates[0].split[0]) end end end |
#raised ⇒ Object
1548 1549 1550 1551 |
# File 'ext/ae-editor/ae-editor.rb', line 1548 def raised _page = @main_frame.enb.raise return @tabs_editor[_page] end |
#save_as_file(_filename) ⇒ Object
1868 1869 1870 |
# File 'ext/ae-editor/ae-editor.rb', line 1868 def save_as_file(_filename) @tabs_editor[tab_name(_filename)].save_as end |
#save_file(_filename) ⇒ Object
1864 1865 1866 |
# File 'ext/ae-editor/ae-editor.rb', line 1864 def save_file(_filename) @tabs_editor[tab_name(_filename)].save end |
#tab_file_name(_filename = "") ⇒ Object
1750 1751 1752 1753 1754 |
# File 'ext/ae-editor/ae-editor.rb', line 1750 def tab_file_name(_filename="") _fstr = File.(_filename) _fstr = _filename if _fstr == nil tab_name(_fstr) end |
#tab_name(_str = "") ⇒ Object
1746 1747 1748 |
# File 'ext/ae-editor/ae-editor.rb', line 1746 def tab_name(_str="") 'ff'+_str.gsub("/","_").gsub(".","_").gsub(":","_").gsub("\\","_") end |
#xy_insert ⇒ Object
1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 |
# File 'ext/ae-editor/ae-editor.rb', line 1394 def xy_insert _text = self.raised.text _index_now = _text.index('insert') _rx, _ry, _widht, _heigth = _text.bbox(_index_now); _x = _rx + TkWinfo.rootx(_text) _y = _ry + TkWinfo.rooty(_text) + TkFont.new(conf('font')).metrics[2][1] _xroot = _x - TkWinfo.rootx(@arcadia.layout.root) _yroot = _y - TkWinfo.rooty(@arcadia.layout.root) return _xroot, _yroot end |