summaryrefslogtreecommitdiff
path: root/Lib/idlelib/colorizer.py
diff options
context:
space:
mode:
authorCheryl Sabella <cheryl.sabella@gmail.com>2019-02-27 08:21:16 -0500
committerGitHub <noreply@github.com>2019-02-27 08:21:16 -0500
commited1deb0719f0ac1b08a374e30ad26a701d4d51a2 (patch)
tree1556f2cca59544ff887ae182a3b8d5023feaa377 /Lib/idlelib/colorizer.py
parent32f5fdd7f4213743fe2f6eedd0fe2108f3157021 (diff)
downloadcpython-git-ed1deb0719f0ac1b08a374e30ad26a701d4d51a2.tar.gz
bpo-36096: IDLE: Refactor class variables in colorizer (GH-12002)
Diffstat (limited to 'Lib/idlelib/colorizer.py')
-rw-r--r--Lib/idlelib/colorizer.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/Lib/idlelib/colorizer.py b/Lib/idlelib/colorizer.py
index 57942e8a7c..fd13281fb2 100644
--- a/Lib/idlelib/colorizer.py
+++ b/Lib/idlelib/colorizer.py
@@ -55,26 +55,35 @@ def color_config(text):
class ColorDelegator(Delegator):
"""Delegator for syntax highlighting (text coloring).
- Class variables:
- after_id: Identifier for scheduled after event.
+ Instance variables:
+ delegate: Delegator below this one in the stack, meaning the
+ one this one delegates to.
+
+ Used to track state:
+ after_id: Identifier for scheduled after event, which is a
+ timer for colorizing the text.
allow_colorizing: Boolean toggle for applying colorizing.
colorizing: Boolean flag when colorizing is in process.
stop_colorizing: Boolean flag to end an active colorizing
process.
close_when_done: Widget to destroy after colorizing process
completes (doesn't seem to be used by IDLE).
-
- Instance variables:
- delegate: Delegator below this one in the stack, meaning the
- one this one delegates to.
"""
def __init__(self):
Delegator.__init__(self)
+ self.init_state()
self.prog = prog
self.idprog = idprog
self.LoadTagDefs()
+ def init_state(self):
+ "Initialize variables that track colorizing state."
+ self.after_id = None
+ self.allow_colorizing = True
+ self.stop_colorizing = False
+ self.colorizing = False
+
def setdelegate(self, delegate):
"""Set the delegate for this instance.
@@ -134,11 +143,6 @@ class ColorDelegator(Delegator):
self.delegate.delete(index1, index2)
self.notify_range(index1)
- after_id = None
- allow_colorizing = True
- stop_colorizing = False
- colorizing = False
-
def notify_range(self, index1, index2=None):
"Mark text changes for processing and restart colorizing, if active."
self.tag_add("TODO", index1, index2)