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

Method find_again

Lib/idlelib/search.py:77–119  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 5

default_commandMethod · 0.95
find_selectionMethod · 0.95
find_again_eventMethod · 0.80
find_againFunction · 0.80
test_find_againMethod · 0.80

Calls 11

getprogMethod · 0.80
search_textMethod · 0.80
tag_addMethod · 0.80
isbackMethod · 0.80
getpatMethod · 0.45
openMethod · 0.45
indexMethod · 0.45
bellMethod · 0.45
tag_removeMethod · 0.45
mark_setMethod · 0.45
seeMethod · 0.45

Tested by 1

test_find_againMethod · 0.64