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

Method toggle_colorize_event

Lib/idlelib/colorizer.py:222–244  ·  view source on GitHub ↗

Toggle colorizing on and off. When toggling off, if colorizing is scheduled or is in process, it will be cancelled and/or stopped. When toggling on, colorizing will be scheduled.

(self, event=None)

Source from the content-addressed store, hash-verified

220 self.stop_colorizing = True
221
222 def toggle_colorize_event(self, event=None):
223 """Toggle colorizing on and off.
224
225 When toggling off, if colorizing is scheduled or is in
226 process, it will be cancelled and/or stopped.
227
228 When toggling on, colorizing will be scheduled.
229 """
230 if self.after_id:
231 after_id = self.after_id
232 self.after_id = None
233 if DEBUG: print("cancel scheduled recolorizer")
234 self.after_cancel(after_id)
235 if self.allow_colorizing and self.colorizing:
236 if DEBUG: print("stop colorizing")
237 self.stop_colorizing = True
238 self.allow_colorizing = not self.allow_colorizing
239 if self.allow_colorizing and not self.colorizing:
240 self.after_id = self.after(1, self.recolorize)
241 if DEBUG:
242 print("auto colorizing turned",
243 "on" if self.allow_colorizing else "off")
244 return "break"
245
246 def recolorize(self):
247 """Timer event (every 1ms) to colorize text.

Callers 1

Calls 2

after_cancelMethod · 0.80
afterMethod · 0.80

Tested by 1