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

Method _selection_changed

Lib/idlelib/autocomplete_w.py:123–159  ·  view source on GitHub ↗

Call when the selection of the Listbox has changed. Updates the Listbox display and calls _change_start.

(self)

Source from the content-addressed store, hash-verified

121 return first_comp[:i]
122
123 def _selection_changed(self):
124 """Call when the selection of the Listbox has changed.
125
126 Updates the Listbox display and calls _change_start.
127 """
128 cursel = int(self.listbox.curselection()[0])
129
130 self.listbox.see(cursel)
131
132 lts = self.lasttypedstart
133 selstart = self.completions[cursel]
134 if self._binary_search(lts) == cursel:
135 newstart = lts
136 else:
137 min_len = min(len(lts), len(selstart))
138 i = 0
139 while i < min_len and lts[i] == selstart[i]:
140 i += 1
141 newstart = selstart[:i]
142 self._change_start(newstart)
143
144 if self.completions[cursel][:len(self.start)] == self.start:
145 # start is a prefix of the selected completion
146 self.listbox.configure(selectbackground=self.origselbackground,
147 selectforeground=self.origselforeground)
148 else:
149 self.listbox.configure(selectbackground=self.listbox.cget("bg"),
150 selectforeground=self.listbox.cget("fg"))
151 # If there are more completions, show them, and call me again.
152 if self.morecompletions:
153 self.completions = self.morecompletions
154 self.morecompletions = None
155 self.listbox.delete(0, END)
156 for item in self.completions:
157 self.listbox.insert(END, item)
158 self.listbox.select_set(self._binary_search(self.start))
159 self._selection_changed()
160
161 def show_window(self, comp_lists, index, complete, mode, userWantsWin):
162 """Show the autocomplete list, bind events.

Callers 2

show_windowMethod · 0.95
keypress_eventMethod · 0.95

Calls 8

_binary_searchMethod · 0.95
_change_startMethod · 0.95
curselectionMethod · 0.80
seeMethod · 0.45
configureMethod · 0.45
cgetMethod · 0.45
deleteMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected