bpo-4630: Add cursor no-blink option for IDLE (GH-16960)
This immediately toggles shell, editor, and output windows, but does not affect other input widgets.
diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py
index adeed74..dff104f 100644
--- a/Lib/idlelib/editor.py
+++ b/Lib/idlelib/editor.py
@@ -241,6 +241,12 @@
self.indentwidth = self.tabwidth
self.set_notabs_indentwidth()
+ # Store the current value of the insertofftime now so we can restore
+ # it if needed.
+ if not hasattr(idleConf, 'blink_off_time'):
+ idleConf.blink_off_time = self.text['insertofftime']
+ self.update_cursor_blink()
+
# When searching backwards for a reliable place to begin parsing,
# first start num_context_lines[0] lines back, then
# num_context_lines[1] lines back if that didn't work, and so on.
@@ -803,6 +809,16 @@
text.mark_set("insert", pos + "+1c")
text.see(pos)
+ def update_cursor_blink(self):
+ "Update the cursor blink configuration."
+ cursorblink = idleConf.GetOption(
+ 'main', 'EditorWindow', 'cursor-blink', type='bool')
+ if not cursorblink:
+ self.text['insertofftime'] = 0
+ else:
+ # Restore the original value
+ self.text['insertofftime'] = idleConf.blink_off_time
+
def ResetFont(self):
"Update the text widgets' font if it is changed"
# Called from configdialog.py