def _next_with_error_or_destroy(self): """Analyzes one block""" try: self.mispellings.next() except StopIteration: if self.window: self.window.destroy() self.window = None return (mispelled, location, endloc, replace) = self.current suggest = "" for index, p in enumerate(replace): # Otherwise we end up with non-ASCII chars (26 letters + 10 digits) if index <= 36: if index <= 9: key = "%s" % index else: key = chr(ord('a') + index - 10) try: p.decode('utf-8') suggest += "[%s]%s " % (key, p) except UnicodeDecodeError: pass if not self.window: self.window = GPS.CommandWindow( on_key=self._on_key, on_activate=self._on_activate, on_cancel=self._on_cancel, close_on_activate=False) self.window.set_background(self.pref_bgcolor.get()) self.replace_mode = False self.window.set_prompt("(i,a,r,space)") self.window.write(text=suggest, cursor=0) self.buffer.select(self.current[1], self.current[2]) self.buffer.current_view().center()