MCPcopy Index your code
hub / github.com/python/cpython / search_text

Method search_text

Lib/idlelib/searchengine.py:102–140  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 3

replace_allMethod · 0.80
do_findMethod · 0.80
find_againMethod · 0.80

Calls 7

getprogMethod · 0.95
isbackMethod · 0.95
search_backwardMethod · 0.95
search_forwardMethod · 0.95
get_selectionFunction · 0.85
get_line_colFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected