Return (lineno, matchobj) or None for forward/backward search. This function calls the right function with the right arguments. It directly return the result of that call. Text is a text widget. Prog is a precompiled pattern. The ok parameter is a bit complicated as
(self, text, prog=None, ok=0)
| 100 | msg, master=self.root) |
| 101 | |
| 102 | def search_text(self, text, prog=None, ok=0): |
| 103 | '''Return (lineno, matchobj) or None for forward/backward search. |
| 104 | |
| 105 | This function calls the right function with the right arguments. |
| 106 | It directly return the result of that call. |
| 107 | |
| 108 | Text is a text widget. Prog is a precompiled pattern. |
| 109 | The ok parameter is a bit complicated as it has two effects. |
| 110 | |
| 111 | If there is a selection, the search begin at either end, |
| 112 | depending on the direction setting and ok, with ok meaning that |
| 113 | the search starts with the selection. Otherwise, search begins |
| 114 | at the insert mark. |
| 115 | |
| 116 | To aid progress, the search functions do not return an empty |
| 117 | match at the starting position unless ok is True. |
| 118 | ''' |
| 119 | |
| 120 | if not prog: |
| 121 | prog = self.getprog() |
| 122 | if not prog: |
| 123 | return None # Compilation failed -- stop |
| 124 | wrap = self.wrapvar.get() |
| 125 | first, last = get_selection(text) |
| 126 | if self.isback(): |
| 127 | if ok: |
| 128 | start = last |
| 129 | else: |
| 130 | start = first |
| 131 | line, col = get_line_col(start) |
| 132 | res = self.search_backward(text, prog, line, col, wrap, ok) |
| 133 | else: |
| 134 | if ok: |
| 135 | start = first |
| 136 | else: |
| 137 | start = last |
| 138 | line, col = get_line_col(start) |
| 139 | res = self.search_forward(text, prog, line, col, wrap, ok) |
| 140 | return res |
| 141 | |
| 142 | def search_forward(self, text, prog, line, col, wrap, ok=0): |
| 143 | wrapped = 0 |
no test coverage detected