Class: Find
Instance Attribute Summary collapse
-
#e_what ⇒ Object
readonly
Returns the value of attribute e_what.
Instance Method Summary collapse
- #do_find(_istart = nil) ⇒ Object
- #do_find_next ⇒ Object
- #editor ⇒ Object
- #go_line ⇒ Object
-
#initialize(_frame, _controller) ⇒ Find
constructor
A new instance of Find.
- #update_combo(_txt) ⇒ Object
- #use(_editor) ⇒ Object
Constructor Details
#initialize(_frame, _controller) ⇒ Find
Returns a new instance of Find.
1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 |
# File 'ext/ae-editor/ae-editor.rb', line 1753 def initialize(_frame, _controller) super(_frame) #@l_file.configure('text'=>_title) #Tk.tk_call('wm', 'title', self, _title ) @controller = _controller @forwards = true @find_action = proc{ _radio = @rb.get_value if _radio == 'line' go_line else @forwards = _radio == 'forwards' do_find_next end } @b_go.bind('1', @find_action) e = TkWinfo.children(@e_what)[0] e.bind_append('KeyPress'){|e| case e.keysym when 'Return' @find_action.call Tk.callback_break end } @last_index='insert' end |
Instance Attribute Details
#e_what ⇒ Object (readonly)
Returns the value of attribute e_what.
1752 1753 1754 |
# File 'ext/ae-editor/ae-editor.rb', line 1752 def e_what @e_what end |
Instance Method Details
#do_find(_istart = nil) ⇒ Object
1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 |
# File 'ext/ae-editor/ae-editor.rb', line 1814 def do_find(_istart=nil) if @e_what.text.length > 0 update_combo(@e_what.text) if !_istart && self.editor.text.index('insert')!=nil _istart ='insert' elsif defined?(@last_index) _istart = @last_index else _istart = '1.0' end if @forwards if @cb_reg.cget('onvalue')=='1' _index = self.editor.text.rsearch(@e_what.text,_istart) else _index = self.editor.text.search(@e_what.text,_istart) end else if @cb_reg.cget('onvalue')=='1' _index = self.editor.text.tkrsearch(['backwards'],@e_what.text,_istart) else _index = self.editor.text.tksearch(['backwards'],@e_what.text,_istart) end end if _index && _index.length>0 self.editor.text.see(_index) _row, _col = _index.split('.') _index_sel_end = _row.to_i.to_s+'.'+(_col.to_i+@e_what.text.length).to_i.to_s if @forwards @last_index= _index_sel_end else @last_index= _row.to_i.to_s+'.'+(_col.to_i-1).to_i.to_s end self.editor.text.tag_add('sel', _index,_index_sel_end) self.editor.text.set_insert(_index) @controller.bookmark_add(self.editor.file, _index) else = '"'+@e_what.value+'" not found' TkDialog2.new('message'=>, 'buttons'=>['Ok']).show() end else self.show() end end |
#do_find_next ⇒ Object
1860 1861 1862 |
# File 'ext/ae-editor/ae-editor.rb', line 1860 def do_find_next do_find(@last_index) end |
#editor ⇒ Object
1780 1781 1782 1783 1784 1785 |
# File 'ext/ae-editor/ae-editor.rb', line 1780 def editor if @editor_caller == nil @editor_caller = @controller.raised end return @editor_caller end |
#go_line ⇒ Object
1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 |
# File 'ext/ae-editor/ae-editor.rb', line 1788 def go_line if @e_what.value.length > 0 _row = @e_what.value _index = _row+'.1' self.editor.text.see(_index) self.editor.text.tag_add('sel', _index,_index+' lineend') self.editor.text.set_insert(_index) @controller.bookmark_add(self.editor.file, _index) end #self.hide() end |
#update_combo(_txt) ⇒ Object
1807 1808 1809 1810 1811 1812 |
# File 'ext/ae-editor/ae-editor.rb', line 1807 def update_combo(_txt) values = @e_what.cget('values') if (values != nil && !values.include?(_txt)) @e_what.insert('end', @e_what.value) end end |
#use(_editor) ⇒ Object
1800 1801 1802 1803 1804 1805 |
# File 'ext/ae-editor/ae-editor.rb', line 1800 def use(_editor) if (_editor != @editor_caller) @last_index='insert' @editor_caller = _editor end end |