Skip to content

bpo-4630: Add cursor no-blink option for IDLE #16960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Lib/idlelib/config-main.def
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ font-size= 10
font-bold= 0
encoding= none
line-numbers-default= 0
cursor-blink= 1

[PyShell]
auto-squeeze-min-lines= 50
Expand Down
19 changes: 19 additions & 0 deletions Lib/idlelib/configdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ def activate_config_changes(self):
instance.set_notabs_indentwidth()
instance.ApplyKeybindings()
instance.reset_help_menu_entries()
instance.UpdateCursorBlink()
for klass in reloadables:
klass.reload()

Expand Down Expand Up @@ -1844,6 +1845,9 @@ def create_page_general(self):
frame_context: Frame
context_title: Label
(*)context_int: Entry - context_lines
frame_cursor_blink_default: Frame
cursor_blink_default_title: Label
(*)cursor_blink_default_bool: Checkbutton - cursor_blink_default
frame_shell: LabelFrame
frame_auto_squeeze_min_lines: Frame
auto_squeeze_min_lines_title: Label
Expand Down Expand Up @@ -1885,6 +1889,8 @@ def create_page_general(self):
('main', 'EditorWindow', 'line-numbers-default'))
self.context_lines = tracers.add(
StringVar(self), ('extensions', 'CodeContext', 'maxlines'))
self.cursor_blink_default = tracers.add(
BooleanVar(self), ('main', 'EditorWindow', 'cursor-blink'))

# Create widgets:
# Section frames.
Expand Down Expand Up @@ -1976,6 +1982,13 @@ def create_page_general(self):
validatecommand=self.digits_only, validate='key',
)

frame_cursor_blink_default = Frame(frame_editor, borderwidth=0)
cursor_blink_default_title = Label(
frame_cursor_blink_default, text='Cursor Blink')
self.cursor_blink_default_bool = Checkbutton(
frame_cursor_blink_default,
variable=self.cursor_blink_default, width=1)

# Frame_shell.
frame_auto_squeeze_min_lines = Frame(frame_shell, borderwidth=0)
auto_squeeze_min_lines_title = Label(frame_auto_squeeze_min_lines,
Expand Down Expand Up @@ -2054,6 +2067,10 @@ def create_page_general(self):
frame_context.pack(side=TOP, padx=5, pady=0, fill=X)
context_title.pack(side=LEFT, anchor=W, padx=5, pady=5)
self.context_int.pack(side=TOP, padx=5, pady=5)
# frame_cursor_blink_default.
frame_cursor_blink_default.pack(side=TOP, padx=5, pady=0, fill=X)
cursor_blink_default_title.pack(side=LEFT, anchor=W, padx=5, pady=5)
self.cursor_blink_default_bool.pack(side=LEFT, padx=5, pady=5)

# frame_auto_squeeze_min_lines
frame_auto_squeeze_min_lines.pack(side=TOP, padx=5, pady=0, fill=X)
Expand Down Expand Up @@ -2096,6 +2113,8 @@ def load_general_cfg(self):
'main', 'EditorWindow', 'line-numbers-default', type='bool'))
self.context_lines.set(idleConf.GetOption(
'extensions', 'CodeContext', 'maxlines', type='int'))
self.cursor_blink_default.set(idleConf.GetOption(
'main', 'EditorWindow', 'cursor-blink', type='bool'))

# Set variables for shell windows.
self.auto_squeeze_min_lines.set(idleConf.GetOption(
Expand Down
14 changes: 14 additions & 0 deletions Lib/idlelib/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
'main', 'EditorWindow', 'height', type='int'),
}
self.text = text = MultiCallCreator(Text)(text_frame, **text_options)
# Store the current value of the insertofftime now so we can restore
# it if needed.
self.text._insertofftime = self.text['insertofftime']
self.UpdateCursorBlink()
self.top.focused_widget = self.text

self.createmenubar()
Expand Down Expand Up @@ -803,6 +807,16 @@ def colorize_syntax_error(self, text, pos):
text.mark_set("insert", pos + "+1c")
text.see(pos)

def UpdateCursorBlink(self):
"Update the cursor blink configuration."
cursorblink = idleConf.GetOption(
'main', 'EditorWindow', 'cursor-blink', type='bool')
if not cursorblink:
self.text.config(insertofftime=0)
else:
# Restore the original value
self.text.config(insertofftime=self.text._insertofftime)

def ResetFont(self):
"Update the text widgets' font if it is changed"
# Called from configdialog.py
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add an option to toggle IDLE's cursor blink.