Class: AgMultiEditor
- Inherits:
-
ArcadiaExt
- Object
- ArcadiaExt
- AgMultiEditor
- Includes:
- Autils
- 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
- #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
- #change_file_name(_tab, _new_file) ⇒ Object
- #change_tab_reset_modify(_tab) ⇒ Object
- #change_tab_reset_read_only(_tab) ⇒ Object
- #change_tab_set_modify(_tab) ⇒ Object
- #change_tab_set_read_only(_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
- #editor_exist?(_filename) ⇒ Boolean
- #finalize ⇒ Object
- #get_find ⇒ Object
- #get_tab_from_name(_name = nil) ⇒ Object
- #on_after_build(_event) ⇒ Object
- #on_after_debug(_event) ⇒ Object
- #on_before_build(_event) ⇒ Object
- #on_before_run_ruby_file(_event) ⇒ Object
- #on_before_start_debug(_event) ⇒ Object
-
#on_before_step_debug(_event) ⇒ Object
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.
- #on_buffer(_event) ⇒ Object
- #on_build(_event) ⇒ Object
- #on_debug_step_info(_event) ⇒ Object
- #open_buffer(_buffer_name = nil, _title = nil) ⇒ Object
- #open_file(_filename = nil, _text_index = '1.0', _mark_selected = true) ⇒ 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.
1470 1471 1472 |
# File 'ext/ae-editor/ae-editor.rb', line 1470 def breakpoints @breakpoints end |
#splitted_frame ⇒ Object (readonly)
Returns the value of attribute splitted_frame.
1471 1472 1473 |
# File 'ext/ae-editor/ae-editor.rb', line 1471 def splitted_frame @splitted_frame end |
Instance Method Details
#bookmark_add(_file, _index) ⇒ Object
1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 |
# File 'ext/ae-editor/ae-editor.rb', line 1838 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
1855 1856 1857 1858 |
# File 'ext/ae-editor/ae-editor.rb', line 1855 def bookmark_clear @bookmarks.clear @bookmarks_index = - 1 end |
#bookmark_move(_n = 0) ⇒ Object
1865 1866 1867 1868 1869 1870 1871 1872 |
# File 'ext/ae-editor/ae-editor.rb', line 1865 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
1860 1861 1862 1863 |
# File 'ext/ae-editor/ae-editor.rb', line 1860 def bookmark_next return if @bookmarks == nil || @bookmarks_index >= @bookmarks.length - 1 bookmark_move(+1) end |
#bookmark_prev ⇒ Object
1875 1876 1877 1878 |
# File 'ext/ae-editor/ae-editor.rb', line 1875 def bookmark_prev return if @bookmarks == nil || @bookmarks_index <= 0 bookmark_move(-1) end |
#breakpoint_add(_file, _line) ⇒ Object
1798 1799 1800 1801 1802 |
# File 'ext/ae-editor/ae-editor.rb', line 1798 def breakpoint_add(_file,_line) Arcadia.process_event(SetBreakpointEvent.new(self, 'file'=>_file, 'row'=>_line)) #EditorContract.instance.breakpoint_created(self, 'file'=>_file, 'line'=>_line) #@breakpoints << {:file=>_file,:line=>_line} end |
#breakpoint_del(_file, _line) ⇒ Object
1804 1805 1806 1807 1808 |
# File 'ext/ae-editor/ae-editor.rb', line 1804 def breakpoint_del(_file,_line) Arcadia.process_event(UnsetBreakpointEvent.new(self, 'file'=>_file, 'row'=>_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
1810 1811 1812 1813 1814 1815 1816 1817 1818 |
# File 'ext/ae-editor/ae-editor.rb', line 1810 def breakpoint_lines_on_file(_file) result = Array.new @breakpoints.each{|value| if value[:file]==_file result << value[:line] end } return result end |
#change_file_name(_tab, _new_file) ⇒ Object
1928 1929 1930 1931 1932 |
# File 'ext/ae-editor/ae-editor.rb', line 1928 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
1916 1917 1918 1919 1920 1921 1922 |
# File 'ext/ae-editor/ae-editor.rb', line 1916 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_reset_read_only(_tab) ⇒ Object
1899 1900 1901 1902 1903 1904 |
# File 'ext/ae-editor/ae-editor.rb', line 1899 def change_tab_reset_read_only(_tab) _new_name = @main_frame.enb.itemcget(page_name(_tab), 'text').gsub!("[READ-ONLY] ",'') if _new_name change_tab_title(_tab, _new_name) end end |
#change_tab_set_modify(_tab) ⇒ Object
1907 1908 1909 1910 |
# File 'ext/ae-editor/ae-editor.rb', line 1907 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_set_read_only(_tab) ⇒ Object
1894 1895 1896 1897 |
# File 'ext/ae-editor/ae-editor.rb', line 1894 def change_tab_set_read_only(_tab) _new_name = '[READ-ONLY] '+@main_frame.enb.itemcget(page_name(_tab), 'text') change_tab_title(_tab, _new_name) end |
#change_tab_title(_tab, _new_text) ⇒ Object
1924 1925 1926 |
# File 'ext/ae-editor/ae-editor.rb', line 1924 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
2078 2079 2080 2081 2082 |
# File 'ext/ae-editor/ae-editor.rb', line 2078 def close_all_editor(_editor, _mod=true) @tabs_editor.values.each do |_e| close_editor(_e) end end |
#close_editor(_editor, _mod = true) ⇒ Object
2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 |
# File 'ext/ae-editor/ae-editor.rb', line 2084 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
2113 2114 2115 |
# File 'ext/ae-editor/ae-editor.rb', line 2113 def close_file(_filename) close_editor(@tabs_editor[tab_name(_filename)]) end |
#close_others_editor(_editor, _mod = true) ⇒ Object
2072 2073 2074 2075 2076 |
# File 'ext/ae-editor/ae-editor.rb', line 2072 def close_others_editor(_editor, _mod=true) @tabs_editor.values.each do |_e| close_editor(_e) if _e != _editor end end |
#close_raised ⇒ Object
1789 1790 1791 1792 1793 1794 1795 1796 |
# File 'ext/ae-editor/ae-editor.rb', line 1789 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
2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 |
# File 'ext/ae-editor/ae-editor.rb', line 2101 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]) else frame_title('') end end |
#create_find ⇒ Object
1769 1770 1771 1772 1773 |
# File 'ext/ae-editor/ae-editor.rb', line 1769 def create_find @find = Find.new(@arcadia.layout.root, self) @find.on_close=proc{@find.hide} @find.hide end |
#debug_begin ⇒ Object
1934 1935 1936 1937 1938 1939 1940 |
# File 'ext/ae-editor/ae-editor.rb', line 1934 def debug_begin if @editors_in_debug != nil @editors_in_debug.clear else @editors_in_debug = Array.new end end |
#debug_end ⇒ Object
1942 1943 1944 1945 1946 1947 |
# File 'ext/ae-editor/ae-editor.rb', line 1942 def debug_end #debug_reset @editors_in_debug.each{|e| close_editor(e) } end |
#debug_reset ⇒ Object
1949 1950 1951 1952 1953 |
# File 'ext/ae-editor/ae-editor.rb', line 1949 def debug_reset if @last_index && @last_e @last_e.unmark_debug(@last_index) end end |
#do_buffer_raise(_name, _title = '...') ⇒ Object
1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 |
# File 'ext/ae-editor/ae-editor.rb', line 1968 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? frame_title() #@arcadia.layout.domain(@arcadia['conf'][@name+'.frame'])['root'].top_text(_new_caption) end _title = @tabs_file[_name] != nil ? File.basename(@tabs_file[_name]) :_name Arcadia.broadcast_event(BufferRaisedEvent.new(self,'title'=>_title, 'file'=>@tabs_file[_name])) #EditorContract.instance.buffer_raised(self, 'title'=>_title, 'file'=>@tabs_file[_name]) end |
#editor_exist?(_filename) ⇒ Boolean
1993 1994 1995 1996 1997 1998 1999 2000 |
# File 'ext/ae-editor/ae-editor.rb', line 1993 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
1775 1776 1777 1778 1779 1780 1781 1782 |
# File 'ext/ae-editor/ae-editor.rb', line 1775 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
1765 1766 1767 |
# File 'ext/ae-editor/ae-editor.rb', line 1765 def get_find @find end |
#get_tab_from_name(_name = nil) ⇒ Object
1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 |
# File 'ext/ae-editor/ae-editor.rb', line 1881 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 |
#on_after_build(_event) ⇒ Object
1507 1508 1509 |
# File 'ext/ae-editor/ae-editor.rb', line 1507 def on_after_build(_event) self.open_last_files end |
#on_after_debug(_event) ⇒ Object
1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 |
# File 'ext/ae-editor/ae-editor.rb', line 1600 def on_after_debug(_event) case _event when StartDebugEvent self.debug_begin when StepDebugEvent if _event.command == :quit self.debug_end end when SetBreakpointEvent @breakpoints << {:file=>_event.file,:line=>_event.row} when UnsetBreakpointEvent @breakpoints.delete_if{|b| (b[:file]==_event.file && b[:line]==_event.row)} end end |
#on_before_build(_event) ⇒ Object
1472 1473 1474 1475 1476 1477 1478 1479 1480 |
# File 'ext/ae-editor/ae-editor.rb', line 1472 def on_before_build(_event) #ArcadiaContractListener.new(self, DebugContract, :do_debug_event) #ArcadiaContractListener.new(self, EditorContract, :do_editor_event) #ArcadiaContractListener.new(self, MainContract, :do_main_event) Arcadia.add_listener(self, BufferEvent) Arcadia.add_listener(self, DebugEvent) Arcadia.add_listener(self, RunRubyFileEvent) Arcadia.add_listener(self, StartDebugEvent) end |
#on_before_run_ruby_file(_event) ⇒ Object
1482 1483 1484 1485 1486 1487 1488 |
# File 'ext/ae-editor/ae-editor.rb', line 1482 def on_before_run_ruby_file(_event) _filename = _event.file if _filename.nil? current_editor = self.raised _event.file =current_editor.file if current_editor end end |
#on_before_start_debug(_event) ⇒ Object
1490 1491 1492 1493 1494 1495 1496 |
# File 'ext/ae-editor/ae-editor.rb', line 1490 def on_before_start_debug(_event) _filename = _event.file if _filename.nil? current_editor = self.raised _event.file =current_editor.file if current_editor end end |
#on_before_step_debug(_event) ⇒ Object
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
1596 1597 1598 |
# File 'ext/ae-editor/ae-editor.rb', line 1596 def on_before_step_debug(_event) debug_reset end |
#on_buffer(_event) ⇒ Object
1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 |
# File 'ext/ae-editor/ae-editor.rb', line 1621 def on_buffer(_event) case _event when NewBufferEvent self.open_buffer when OpenBufferEvent if _event.file if _event.row _index = _event.row.to_s+'.0' end self.open_file(_event.file, _index) elsif _event.text if _event.title _tab_name = self.tab_name(_event.title) self.open_buffer(_tab_name, _event.title) _e = @tabs_editor[_tab_name] _e.text_insert('end',_event.text) _e.reset _e.refresh #add_reverse_item(_e) end else self.open_file(Tk.getOpenFile) end when CloseBufferEvent if _event.file self.close_file(_event.file) end when SaveAsBufferEvent if _event.file == nil self.raised.save_as else self.save_as_file(_event.file) end when SaveBufferEvent if _event.file == nil && _event.title == nil self.raised.save elsif _event.file != nil self.save_file(_event.file) elsif _event.title != nil self.save_file(_event.title) end when SearchBufferEvent if _event.what == nil @find.show end when GoToLineBufferEvent if _event.line == nil @find.show_go_to_line_dialog end end end |
#on_build(_event) ⇒ Object
1498 1499 1500 1501 1502 1503 1504 1505 |
# File 'ext/ae-editor/ae-editor.rb', line 1498 def on_build(_event) @main_frame = AgMultiEditorView.new(self.frame) @tabs_file =Hash.new @tabs_editor =Hash.new @breakpoints =Array.new create_find end |
#on_debug_step_info(_event) ⇒ Object
1615 1616 1617 1618 1619 |
# File 'ext/ae-editor/ae-editor.rb', line 1615 def on_debug_step_info(_event) if _event.file self.open_file_in_debug(_event.file, _event.row) end end |
#open_buffer(_buffer_name = nil, _title = nil) ⇒ Object
2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 |
# File 'ext/ae-editor/ae-editor.rb', line 2037 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', _mark_selected = true) ⇒ Object
2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 |
# File 'ext/ae-editor/ae-editor.rb', line 2013 def open_file(_filename = nil, _text_index='1.0', _mark_selected=true) return if _filename == nil || !File.exist?(_filename) || File.ftype(_filename) != 'file' _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) @tabs_file[_tab_name]= _filename @tabs_editor[_tab_name].load_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) if _mark_selected end return @tabs_editor[_tab_name] end |
#open_file_in_debug(_filename = nil, _line = nil) ⇒ Object
1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 |
# File 'ext/ae-editor/ae-editor.rb', line 1955 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, false) if !_editor_exist @editors_in_debug << @last_e end @last_e.mark_debug(@last_index) if @last_e end end |
#open_last_files ⇒ Object
1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 |
# File 'ext/ae-editor/ae-editor.rb', line 1820 def open_last_files if $arcadia['pers']['editor.files.open'] _files_index =$arcadia['pers']['editor.files.open'].split("|") _files_index.each do |value| _file,_index = value.split(';') if _file open_file(_file,_index) end end end _first_page = @main_frame.enb.pages(0) if @main_frame.enb.pages.length > 0 if _first_page @main_frame.enb.raise(_first_page) @main_frame.enb.see(_first_page) end self end |
#page_name(_page_frame) ⇒ Object
1912 1913 1914 |
# File 'ext/ae-editor/ae-editor.rb', line 1912 def page_name(_page_frame) TkWinfo.appname(_page_frame).sub('f','') end |
#pop_up_menu ⇒ Object
1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 |
# File 'ext/ae-editor/ae-editor.rb', line 1511 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
1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 |
# File 'ext/ae-editor/ae-editor.rb', line 1684 def raise_complete_code(_context) # delete the file used for completion @raised_listbox.destroy if @raised_listbox != nil candidates = _context.results[0].candidates _text = self.raised.text _index_call = _context.row+'.'+_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 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 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 = (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 Arcadia.process_event(DocCodeEvent.new(self, 'doc_entry'=>_docs_entries[_key], 'xdoc'=>_x, 'ydoc'=>_y)) #EditorContract.instance.doc_code(self, 'doc_entry'=>_docs_entries[_key], 'xdoc'=>_x, 'ydoc'=>_y) end } elsif candidates.length == 1 && candidates[0].length>0 _text.delete(_begin_index,'insert'); _text.insert('insert',candidates[0].split[0]) end end end |
#raised ⇒ Object
1784 1785 1786 1787 |
# File 'ext/ae-editor/ae-editor.rb', line 1784 def raised _page = @main_frame.enb.raise return @tabs_editor[_page] end |
#save_as_file(_filename) ⇒ Object
2121 2122 2123 |
# File 'ext/ae-editor/ae-editor.rb', line 2121 def save_as_file(_filename) @tabs_editor[tab_name(_filename)].save_as end |
#save_file(_filename) ⇒ Object
2117 2118 2119 |
# File 'ext/ae-editor/ae-editor.rb', line 2117 def save_file(_filename) @tabs_editor[tab_name(_filename)].save end |
#tab_file_name(_filename = "") ⇒ Object
2007 2008 2009 2010 2011 |
# File 'ext/ae-editor/ae-editor.rb', line 2007 def tab_file_name(_filename="") _fstr = File.(_filename) _fstr = _filename if _fstr == nil tab_name(_fstr) end |
#tab_name(_str = "") ⇒ Object
2002 2003 2004 2005 |
# File 'ext/ae-editor/ae-editor.rb', line 2002 def tab_name(_str="") #_str = _str.downcase if is_windows? 'ff'+_str.downcase.gsub("/","_").gsub(".","_").gsub(":","_").gsub("\\","_") end |
#xy_insert ⇒ Object
1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 |
# File 'ext/ae-editor/ae-editor.rb', line 1673 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 |