Repeat the last search. If no search was previously run, open a new search dialog. In this case, no search is done. If a search was previously run, the search dialog won't be shown and the options from the previous search (including the search pattern) will
(self, text)
| 75 | self.find_again(self.text) |
| 76 | |
| 77 | def find_again(self, text): |
| 78 | """Repeat the last search. |
| 79 | |
| 80 | If no search was previously run, open a new search dialog. In |
| 81 | this case, no search is done. |
| 82 | |
| 83 | If a search was previously run, the search dialog won't be |
| 84 | shown and the options from the previous search (including the |
| 85 | search pattern) will be used to find the next occurrence |
| 86 | of the pattern. Next is relative based on direction. |
| 87 | |
| 88 | Position the window to display the located occurrence in the |
| 89 | text. |
| 90 | |
| 91 | Return True if the search was successful and False otherwise. |
| 92 | """ |
| 93 | if not self.engine.getpat(): |
| 94 | self.open(text) |
| 95 | return False |
| 96 | if not self.engine.getprog(): |
| 97 | return False |
| 98 | res = self.engine.search_text(text) |
| 99 | if res: |
| 100 | line, m = res |
| 101 | i, j = m.span() |
| 102 | first = "%d.%d" % (line, i) |
| 103 | last = "%d.%d" % (line, j) |
| 104 | try: |
| 105 | selfirst = text.index("sel.first") |
| 106 | sellast = text.index("sel.last") |
| 107 | if selfirst == first and sellast == last: |
| 108 | self.bell() |
| 109 | return False |
| 110 | except TclError: |
| 111 | pass |
| 112 | text.tag_remove("sel", "1.0", "end") |
| 113 | text.tag_add("sel", first, last) |
| 114 | text.mark_set("insert", self.engine.isback() and first or last) |
| 115 | text.see("insert") |
| 116 | return True |
| 117 | else: |
| 118 | self.bell() |
| 119 | return False |
| 120 | |
| 121 | def find_selection(self, text): |
| 122 | """Search for selected text with previous dialog preferences. |