mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
changeover to new keybinding configuration implementation
This commit is contained in:
parent
c628a06c70
commit
72c3bf076f
11 changed files with 50 additions and 109 deletions
|
@ -7,14 +7,6 @@ import re
|
||||||
|
|
||||||
class AutoExpand:
|
class AutoExpand:
|
||||||
|
|
||||||
keydefs = {
|
|
||||||
'<<expand-word>>': ['<Alt-slash>'],
|
|
||||||
}
|
|
||||||
|
|
||||||
unix_keydefs = {
|
|
||||||
'<<expand-word>>': ['<Meta-slash>', '<Alt-slash>'],
|
|
||||||
}
|
|
||||||
|
|
||||||
menudefs = [
|
menudefs = [
|
||||||
('edit', [
|
('edit', [
|
||||||
('E_xpand word', '<<expand-word>>'),
|
('E_xpand word', '<<expand-word>>'),
|
||||||
|
|
|
@ -41,7 +41,6 @@ class AutoIndent:
|
||||||
|
|
||||||
menudefs = [
|
menudefs = [
|
||||||
('format', [ # /s/edit/format dscherer@cmu.edu
|
('format', [ # /s/edit/format dscherer@cmu.edu
|
||||||
None,
|
|
||||||
('_Indent region', '<<indent-region>>'),
|
('_Indent region', '<<indent-region>>'),
|
||||||
('_Dedent region', '<<dedent-region>>'),
|
('_Dedent region', '<<dedent-region>>'),
|
||||||
('Comment _out region', '<<comment-region>>'),
|
('Comment _out region', '<<comment-region>>'),
|
||||||
|
@ -53,39 +52,6 @@ class AutoIndent:
|
||||||
]),
|
]),
|
||||||
]
|
]
|
||||||
|
|
||||||
keydefs = {
|
|
||||||
'<<smart-backspace>>': ['<Key-BackSpace>'],
|
|
||||||
'<<newline-and-indent>>': ['<Key-Return>', '<KP_Enter>'],
|
|
||||||
'<<smart-indent>>': ['<Key-Tab>']
|
|
||||||
}
|
|
||||||
|
|
||||||
windows_keydefs = {
|
|
||||||
'<<indent-region>>': ['<Control-bracketright>'],
|
|
||||||
'<<dedent-region>>': ['<Shift-Tab>', # dscherer@cmu.edu
|
|
||||||
'<Control-bracketleft>'],
|
|
||||||
'<<comment-region>>': ['<Alt-Key-3>'],
|
|
||||||
'<<uncomment-region>>': ['<Alt-Key-4>'],
|
|
||||||
'<<tabify-region>>': ['<Alt-Key-5>'],
|
|
||||||
'<<untabify-region>>': ['<Alt-Key-6>'],
|
|
||||||
'<<toggle-tabs>>': ['<Alt-Key-t>'],
|
|
||||||
'<<change-indentwidth>>': ['<Alt-Key-u>'],
|
|
||||||
}
|
|
||||||
|
|
||||||
unix_keydefs = {
|
|
||||||
'<<indent-region>>': ['<Alt-bracketright>',
|
|
||||||
'<Meta-bracketright>',
|
|
||||||
'<Control-bracketright>'],
|
|
||||||
'<<dedent-region>>': ['<Alt-bracketleft>',
|
|
||||||
'<Meta-bracketleft>',
|
|
||||||
'<Control-bracketleft>'],
|
|
||||||
'<<comment-region>>': ['<Alt-Key-3>', '<Meta-Key-3>'],
|
|
||||||
'<<uncomment-region>>': ['<Alt-Key-4>', '<Meta-Key-4>'],
|
|
||||||
'<<tabify-region>>': ['<Alt-Key-5>', '<Meta-Key-5>'],
|
|
||||||
'<<untabify-region>>': ['<Alt-Key-6>', '<Meta-Key-6>'],
|
|
||||||
'<<toggle-tabs>>': ['<Alt-Key-t>'],
|
|
||||||
'<<change-indentwidth>>': ['<Alt-Key-u>'],
|
|
||||||
}
|
|
||||||
|
|
||||||
# usetabs true -> literal tab characters are used by indent and
|
# usetabs true -> literal tab characters are used by indent and
|
||||||
# dedent cmds, possibly mixed with spaces if
|
# dedent cmds, possibly mixed with spaces if
|
||||||
# indentwidth is not a multiple of tabwidth
|
# indentwidth is not a multiple of tabwidth
|
||||||
|
|
|
@ -73,6 +73,6 @@ menudefs = [
|
||||||
]),
|
]),
|
||||||
]
|
]
|
||||||
|
|
||||||
default_keydefs = idleConf.GetKeys(keySetName=idleConf.CurrentKeys())
|
default_keydefs = idleConf.GetCurrentKeySet()
|
||||||
|
|
||||||
del sys
|
del sys
|
||||||
|
|
|
@ -10,19 +10,6 @@ class CallTips:
|
||||||
menudefs = [
|
menudefs = [
|
||||||
]
|
]
|
||||||
|
|
||||||
keydefs = {
|
|
||||||
'<<paren-open>>': ['<Key-parenleft>'],
|
|
||||||
'<<paren-close>>': ['<Key-parenright>'],
|
|
||||||
'<<check-calltip-cancel>>': ['<KeyRelease>'],
|
|
||||||
'<<calltip-cancel>>': ['<ButtonPress>', '<Key-Escape>'],
|
|
||||||
}
|
|
||||||
|
|
||||||
windows_keydefs = {
|
|
||||||
}
|
|
||||||
|
|
||||||
unix_keydefs = {
|
|
||||||
}
|
|
||||||
|
|
||||||
def __init__(self, editwin):
|
def __init__(self, editwin):
|
||||||
self.editwin = editwin
|
self.editwin = editwin
|
||||||
self.text = editwin.text
|
self.text = editwin.text
|
||||||
|
|
|
@ -590,17 +590,7 @@ class EditorWindow:
|
||||||
cls = getattr(mod, name)
|
cls = getattr(mod, name)
|
||||||
ins = cls(self)
|
ins = cls(self)
|
||||||
self.extensions[name] = ins
|
self.extensions[name] = ins
|
||||||
kdnames = ["keydefs"]
|
keydefs=idleConf.GetExtensionBindings(name)
|
||||||
if sys.platform == 'win32':
|
|
||||||
kdnames.append("windows_keydefs")
|
|
||||||
elif sys.platform == 'mac':
|
|
||||||
kdnames.append("mac_keydefs")
|
|
||||||
else:
|
|
||||||
kdnames.append("unix_keydefs")
|
|
||||||
keydefs = {}
|
|
||||||
for kdname in kdnames:
|
|
||||||
if hasattr(ins, kdname):
|
|
||||||
keydefs.update(getattr(ins, kdname))
|
|
||||||
if keydefs:
|
if keydefs:
|
||||||
self.apply_bindings(keydefs)
|
self.apply_bindings(keydefs)
|
||||||
for vevent in keydefs.keys():
|
for vevent in keydefs.keys():
|
||||||
|
@ -612,6 +602,7 @@ class EditorWindow:
|
||||||
methodname = methodname + "_event"
|
methodname = methodname + "_event"
|
||||||
if hasattr(ins, methodname):
|
if hasattr(ins, methodname):
|
||||||
self.text.bind(vevent, getattr(ins, methodname))
|
self.text.bind(vevent, getattr(ins, methodname))
|
||||||
|
|
||||||
if hasattr(ins, "menudefs"):
|
if hasattr(ins, "menudefs"):
|
||||||
self.fill_menus(ins.menudefs, keydefs)
|
self.fill_menus(ins.menudefs, keydefs)
|
||||||
return ins
|
return ins
|
||||||
|
|
|
@ -45,11 +45,6 @@ def loader_connect(client, addr):
|
||||||
protocol.publish('ExecBinding', loader_connect)
|
protocol.publish('ExecBinding', loader_connect)
|
||||||
|
|
||||||
class ExecBinding:
|
class ExecBinding:
|
||||||
keydefs = {
|
|
||||||
'<<run-complete-script>>': ['<F5>'],
|
|
||||||
'<<stop-execution>>': ['<Cancel>'], #'<Control-c>'
|
|
||||||
}
|
|
||||||
|
|
||||||
menudefs = [
|
menudefs = [
|
||||||
('run', [None,
|
('run', [None,
|
||||||
('Run program', '<<run-complete-script>>'),
|
('Run program', '<<run-complete-script>>'),
|
||||||
|
|
|
@ -25,14 +25,6 @@ class FormatParagraph:
|
||||||
])
|
])
|
||||||
]
|
]
|
||||||
|
|
||||||
keydefs = {
|
|
||||||
'<<format-paragraph>>': ['<Alt-q>'],
|
|
||||||
}
|
|
||||||
|
|
||||||
unix_keydefs = {
|
|
||||||
'<<format-paragraph>>': ['<Meta-q>'],
|
|
||||||
}
|
|
||||||
|
|
||||||
def __init__(self, editwin):
|
def __init__(self, editwin):
|
||||||
self.editwin = editwin
|
self.editwin = editwin
|
||||||
|
|
||||||
|
|
|
@ -43,19 +43,7 @@ class ParenMatch:
|
||||||
to the right of a right paren. I don't know how to do that in Tk,
|
to the right of a right paren. I don't know how to do that in Tk,
|
||||||
so I haven't bothered.
|
so I haven't bothered.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
menudefs = []
|
menudefs = []
|
||||||
|
|
||||||
keydefs = {
|
|
||||||
'<<flash-open-paren>>' : ('<KeyRelease-parenright>',
|
|
||||||
'<KeyRelease-bracketright>',
|
|
||||||
'<KeyRelease-braceright>'),
|
|
||||||
'<<check-restore>>' : ('<KeyPress>',),
|
|
||||||
}
|
|
||||||
|
|
||||||
windows_keydefs = {}
|
|
||||||
unix_keydefs = {}
|
|
||||||
|
|
||||||
iconf = idleconf.getsection('ParenMatch')
|
iconf = idleconf.getsection('ParenMatch')
|
||||||
STYLE = iconf.getdef('style', 'default')
|
STYLE = iconf.getdef('style', 'default')
|
||||||
FLASH_DELAY = iconf.getint('flash-delay')
|
FLASH_DELAY = iconf.getint('flash-delay')
|
||||||
|
|
|
@ -35,12 +35,6 @@ by Untabify Region (both in the Edit menu)."""
|
||||||
|
|
||||||
class ScriptBinding:
|
class ScriptBinding:
|
||||||
|
|
||||||
keydefs = {
|
|
||||||
'<<check-module>>': ['<Alt-F5>', '<Meta-F5>'],
|
|
||||||
'<<import-module>>': ['<F5>'],
|
|
||||||
'<<run-script>>': ['<Control-F5>'],
|
|
||||||
}
|
|
||||||
|
|
||||||
menudefs = [
|
menudefs = [
|
||||||
('edit', [None,
|
('edit', [None,
|
||||||
('Check module', '<<check-module>>'),
|
('Check module', '<<check-module>>'),
|
||||||
|
|
|
@ -10,14 +10,7 @@ class ZoomHeight:
|
||||||
('_Zoom Height', '<<zoom-height>>'),
|
('_Zoom Height', '<<zoom-height>>'),
|
||||||
])
|
])
|
||||||
]
|
]
|
||||||
|
|
||||||
windows_keydefs = {
|
|
||||||
'<<zoom-height>>': ['<Alt-F2>'],
|
|
||||||
}
|
|
||||||
unix_keydefs = {
|
|
||||||
'<<zoom-height>>': ['<Control-x><Control-z>'],
|
|
||||||
}
|
|
||||||
|
|
||||||
def __init__(self, editwin):
|
def __init__(self, editwin):
|
||||||
self.editwin = editwin
|
self.editwin = editwin
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,66 @@
|
||||||
# IDLE reads several config files to determine user preferences. This
|
# IDLE reads several config files to determine user preferences. This
|
||||||
# file is the default config file for idle extensions settings.
|
# file is the default config file for idle extensions settings.
|
||||||
|
#
|
||||||
|
# Each extension must have at least one section, named after the extension
|
||||||
|
# module. This section must contain an 'enable' item (=1 to enable the
|
||||||
|
# extension, =0 to disable it) and also contains any other general configuration
|
||||||
|
# items for the extension. Each extension may also define up to two optional
|
||||||
|
# sections named ExtensionName_bindings and ExtensionName_cfgBindings. If
|
||||||
|
# present, ExtensionName_bindings defines virtual event bindings for the
|
||||||
|
# extension that are not sensibly re-configurable. If present,
|
||||||
|
# ExtensionName_cfgBindings defines virtual event bindings for the extension
|
||||||
|
# that may be sensibly re-configured.
|
||||||
|
|
||||||
[FormatParagraph]
|
[FormatParagraph]
|
||||||
enable=1
|
enable=1
|
||||||
|
[FormatParagraph_cfgBindings]
|
||||||
|
format-paragraph=<Alt-Key-q>
|
||||||
|
|
||||||
[AutoIndent]
|
[AutoIndent]
|
||||||
enable=1
|
enable=1
|
||||||
|
[AutoIndent_cfgBindings]
|
||||||
|
smart-backspace=<Key-BackSpace>
|
||||||
|
newline-and-indent=<Key-Return> <Key-KP_Enter>
|
||||||
|
smart-indent=<Key-Tab>
|
||||||
|
indent-region=<Control-Key-bracketright>
|
||||||
|
dedent-region=<Control-Key-bracketleft>
|
||||||
|
comment-region=<Alt-Key-3>
|
||||||
|
uncomment-region=<Alt-Key-4>
|
||||||
|
tabify-region=<Alt-Key-5>
|
||||||
|
untabify-region=<Alt-Key-6>
|
||||||
|
toggle-tabs=<Alt-Key-t>
|
||||||
|
change-indentwidth=<Alt-Key-u>
|
||||||
|
|
||||||
[AutoExpand]
|
[AutoExpand]
|
||||||
enable=1
|
enable=1
|
||||||
|
[AutoExpand_cfgBindings]
|
||||||
|
expand-word=<Alt-Key-slash>
|
||||||
|
|
||||||
[ZoomHeight]
|
[ZoomHeight]
|
||||||
enable=1
|
enable=1
|
||||||
|
[ZoomHeight_cfgBindings]
|
||||||
#[ScriptBinding] # disabled in favor of ExecBinding
|
zoom-height=<Alt-Key-F2>
|
||||||
#enable=0
|
|
||||||
|
|
||||||
[ExecBinding]
|
[ExecBinding]
|
||||||
enable=1
|
enable=1
|
||||||
|
[ExecBinding_cfgBindings]
|
||||||
|
run-complete-script=<Key-F5>
|
||||||
|
stop-execution=<Key-Cancel>
|
||||||
|
|
||||||
|
#[ScriptBinding] #currently ExecBinding has replaced ScriptBinding
|
||||||
|
#enable=0
|
||||||
|
#[ScriptBinding_cfgBindings]
|
||||||
|
#run-script=<Key-F5>
|
||||||
|
#check-module=<Alt-Key-F5> <Meta-Key-F5>
|
||||||
|
#import-module=<Control-Key-F5>
|
||||||
|
|
||||||
[CallTips]
|
[CallTips]
|
||||||
enable=1
|
enable=1
|
||||||
|
[CallTips_bindings]
|
||||||
|
paren-open=<Key-parenleft>
|
||||||
|
paren-close=<Key-parenright>
|
||||||
|
check-calltip-cancel=<KeyRelease>
|
||||||
|
calltip-cancel=<ButtonPress> <Key-Escape>
|
||||||
|
|
||||||
[ParenMatch]
|
[ParenMatch]
|
||||||
enable=0
|
enable=0
|
||||||
|
@ -29,3 +69,6 @@ flash-delay= 500
|
||||||
bell= 1
|
bell= 1
|
||||||
hilite-foreground= black
|
hilite-foreground= black
|
||||||
hilite-background= #43cd80
|
hilite-background= #43cd80
|
||||||
|
[ParenMatch_bindings]
|
||||||
|
flash-open-paren=<KeyRelease-parenright> <KeyRelease-bracketright> <KeyRelease-braceright>
|
||||||
|
check-restore=<KeyPress>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue