Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 10 additions & 0 deletions Lib/idlelib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from configparser import ConfigParser
import os
import sys
import re

from tkinter.font import Font
import idlelib
Expand Down Expand Up @@ -587,6 +588,15 @@ def GetCurrentKeySet(self):
v2 = [ x.replace('<Alt-', '<Option-') for x in v ]
if v != v2:
result[k] = v2
else:
def replace(m):
return m.group('prefix') + m.group('alpha').swapcase()+'>'

pat = '(?P<prefix><[A-Za-z-]+Key-)(?P<alpha>[a-zA-Z])>'
for k, v in result.items():
v2 = [re.sub(pat, replace, x) for x in v]
if v != v2:
v.extend(v2)

return result

Expand Down
17 changes: 0 additions & 17 deletions Lib/idlelib/idle_test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,23 +488,6 @@ def test_get_keybinding(self):
eq(conf.GetKeyBinding('NOT EXISTS', '<<copy>>'), [])
eq(conf.GetKeyBinding('IDLE Modern Unix', 'NOT EXISTS'), [])

def test_get_current_keyset(self):
current_platform = sys.platform
conf = self.mock_config()

# Ensure that platform isn't darwin
sys.platform = 'some-linux'
self.assertEqual(conf.GetCurrentKeySet(), conf.GetKeySet(conf.CurrentKeys()))

# This should not be the same, since replace <Alt- to <Option-.
# Above depended on config-extensions.def having Alt keys,
# which is no longer true.
# sys.platform = 'darwin'
# self.assertNotEqual(conf.GetCurrentKeySet(), conf.GetKeySet(conf.CurrentKeys()))

# Restore platform
sys.platform = current_platform

def test_get_keyset(self):
conf = self.mock_config()

Expand Down
Loading