Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e28ee75

Browse files
author
Steven M. Gava
committed
improvement to keybinding re-use check
1 parent 9f25e67 commit e28ee75

4 files changed

Lines changed: 80 additions & 86 deletions

File tree

Lib/idlelib/config-extensions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# extension that are not sensibly re-configurable. If present,
1111
# ExtensionName_cfgBindings defines virtual event bindings for the extension
1212
# that may be sensibly re-configured.
13+
# See config-keys.def for notes on specifying keys.
1314

1415
[FormatParagraph]
1516
enable=1

Lib/idlelib/config-keys.def

Lines changed: 69 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2,74 +2,76 @@
22
# file is the default config file for idle key binding settings.
33
# Where multiple keys are specified for an action: if they are separated
44
# by a space (eg. action=<key1> <key2>) then the keys are altenatives, if
5-
# there is no space (eg. action=<key1>key2>) then the keys comprise a
6-
# single 'emacs style' multi-keystoke binding.
5+
# there is no space (eg. action=<key1><key2>) then the keys comprise a
6+
# single 'emacs style' multi-keystoke binding. The tk event specifier 'Key'
7+
# is used in all cases, for consistency in auto key conflict checking in the
8+
# configuration gui.
79

810
[IDLE Classic Windows]
9-
copy=<Control-c> <Control-C>
10-
cut=<Control-x> <Control-X>
11-
paste=<Control-v> <Control-V>
12-
beginning-of-line= <Home>
13-
center-insert=<Control-l>
14-
close-all-windows=<Control-q>
15-
close-window=<Alt-F4>
16-
end-of-file=<Control-d>
17-
python-docs=<F1>
18-
python-context-help=<Shift-F1>
19-
history-next=<Alt-n>
20-
history-previous=<Alt-p>
21-
interrupt-execution=<Control-c>
22-
open-class-browser=<Alt-c>
23-
open-module=<Alt-m>
24-
open-new-window=<Control-n>
25-
open-window-from-file=<Control-o>
26-
plain-newline-and-indent=<Control-j>
27-
redo=<Control-Shift-z>
28-
remove-selection=<Escape>
29-
save-copy-of-window-as-file=<Alt-Shift-s>
30-
save-window-as-file=<Alt-s>
31-
save-window=<Control-s>
32-
select-all=<Alt-a>
33-
toggle-auto-coloring=<Control-slash>
34-
undo=<Control-z>
35-
find=<Control-f>
36-
find-again=<Control-g> <F3>
37-
find-in-files=<Alt-F3>
38-
find-selection=<Control-F3>
39-
replace=<Control-h>
40-
goto-line=<Alt-g>
11+
copy=<Control-Key-c>
12+
cut=<Control-Key-x>
13+
paste=<Control-Key-v>
14+
beginning-of-line= <Key-Home>
15+
center-insert=<Control-Key-l>
16+
close-all-windows=<Control-Key-q>
17+
close-window=<Alt-Key-F4>
18+
end-of-file=<Control-Key-d>
19+
python-docs=<Key-F1>
20+
python-context-help=<Shift-Key-F1>
21+
history-next=<Alt-Key-n>
22+
history-previous=<Alt-Key-p>
23+
interrupt-execution=<Control-Key-c>
24+
open-class-browser=<Alt-Key-c>
25+
open-module=<Alt-Key-m>
26+
open-new-window=<Control-Key-n>
27+
open-window-from-file=<Control-Key-o>
28+
plain-newline-and-indent=<Control-Key-j>
29+
redo=<Control-Shift-Key-z>
30+
remove-selection=<Key-Escape>
31+
save-copy-of-window-as-file=<Alt-Shift-Key-s>
32+
save-window-as-file=<Alt-Key-s>
33+
save-window=<Control-Key-s>
34+
select-all=<Alt-Key-a>
35+
toggle-auto-coloring=<Control-Key-slash>
36+
undo=<Control-Key-z>
37+
find=<Control-Key-f>
38+
find-again=<Control-Key-g> <Key-F3>
39+
find-in-files=<Alt-Key-F3>
40+
find-selection=<Control-Key-F3>
41+
replace=<Control-Key-h>
42+
goto-line=<Alt-Key-g>
4143

4244
[IDLE Classic Unix]
43-
copy=<Alt-w> <Meta-w>
44-
cut=<Control-w>
45-
paste=<Control-y>
46-
beginning-of-line=<Control-a> <Home>
47-
center-insert=<Control-l>
48-
close-all-windows=<Control-x><Control-c>
49-
close-window=<Control-x><Control-0> <Control-x><Key-0>
50-
do-nothing=<Control-x>
51-
end-of-file=<Control-d>
52-
history-next=<Alt-n> <Meta-n>
53-
history-previous=<Alt-p> <Meta-p>
54-
interrupt-execution=<Control-c>
55-
open-class-browser=<Control-x><Control-b>
56-
open-module=<Control-x><Control-m>
57-
open-new-window=<Control-x><Control-n>
58-
open-window-from-file=<Control-x><Control-f>
59-
plain-newline-and-indent=<Control-j>
60-
python-docs=<Control-h>
61-
python-context-help=<Control-Shift-h>
62-
redo=<Alt-z> <Meta-z>
63-
remove-selection=<Escape>
64-
save-copy-of-window-as-file=<Control-x><w>
65-
save-window-as-file=<Control-x><Control-w>
66-
save-window=<Control-x><Control-s>
67-
select-all=<Alt-a> <Meta-a>
68-
toggle-auto-coloring=<Control-slash>
69-
undo=<Control-z>
70-
find=<Control-u><Control-u><Control-s>
71-
find-again=<Control-u><Control-s>
72-
find-in-files=<Alt-s> <Meta-s>
73-
find-selection=<Control-s>
74-
replace=<Control-r>
75-
goto-line=<Alt-g> <Meta-g>
45+
copy=<Alt-Key-w> <Meta-Key-w>
46+
cut=<Control-Key-w>
47+
paste=<Control-Key-y>
48+
beginning-of-line=<Control-Key-a> <Key-Home>
49+
center-insert=<Control-Key-l>
50+
close-all-windows=<Control-Key-x><Control-Key-c>
51+
close-window=<Control-Key-x><Control-Key-0>
52+
do-nothing=<Control-Key-x>
53+
end-of-file=<Control-Key-d>
54+
history-next=<Alt-Key-n> <Meta-Key-n>
55+
history-previous=<Alt-Key-p> <Meta-Key-p>
56+
interrupt-execution=<Control-Key-c>
57+
open-class-browser=<Control-Key-x><Control-Key-b>
58+
open-module=<Control-Key-x><Control-Key-m>
59+
open-new-window=<Control-Key-x><Control-Key-n>
60+
open-window-from-file=<Control-Key-x><Control-Key-f>
61+
plain-newline-and-indent=<Control-Key-j>
62+
python-docs=<Control-Key-h>
63+
python-context-help=<Control-Shift-Key-h>
64+
redo=<Alt-Key-z> <Meta-Key-z>
65+
remove-selection=<Key-Escape>
66+
save-copy-of-window-as-file=<Control-Key-x><Control-Key-y>
67+
save-window-as-file=<Control-Key-x><Control-Key-w>
68+
save-window=<Control-Key-x><Control-Key-s>
69+
select-all=<Alt-Key-a> <Meta-Key-a>
70+
toggle-auto-coloring=<Control-Key-slash>
71+
undo=<Control-Key-z>
72+
find=<Control-Key-u><Control-Key-u><Control-Key-s>
73+
find-again=<Control-Key-u><Control-Key-s>
74+
find-in-files=<Alt-Key-s> <Meta-Key-s>
75+
find-selection=<Control-Key-s>
76+
replace=<Control-Key-r>
77+
goto-line=<Alt-Key-g> <Meta-Key-g>

Lib/idlelib/configDialog.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,16 @@ def GetNewKeys(self):
561561
listIndex=self.listBindings.index(ANCHOR)
562562
binding=self.listBindings.get(listIndex)
563563
bindName=binding.split()[0] #first part, up to first space
564-
currentKeySequences=idleConf.GetCurrentKeySet().values()
564+
if self.keysAreBuiltin.get():
565+
currentKeySetName=self.builtinKeys.get()
566+
else:
567+
currentKeySetName=self.customKeys.get()
568+
currentBindings=idleConf.GetCurrentKeySet()
569+
if currentKeySetName in self.changedItems['keys'].keys(): #unsaved changes
570+
keySetChanges=self.changedItems['keys'][currentKeySetName]
571+
for event in keySetChanges.keys():
572+
currentBindings[event]=keySetChanges[event].split()
573+
currentKeySequences=currentBindings.values()
565574
newKeys=GetKeysDialog(self,'Get New Keys',bindName,
566575
currentKeySequences).result
567576
if newKeys: #new keys were specified

Lib/idlelib/keybindingDialog.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,10 @@ def __init__(self,parent,title,action,currentKeySequences):
3030
self.keyCtrl.set('')
3131
self.keyAlt=StringVar(self)
3232
self.keyAlt.set('')
33-
# self.keyMeta=StringVar(self)
34-
# self.keyMeta.set('')
3533
self.keyShift=StringVar(self)
3634
self.keyShift.set('')
37-
# self.keyFinal1=StringVar(self)
38-
# self.keyFinal1.set('')
39-
# self.keyFinal2=StringVar(self)
40-
# self.keyFinal2.set('')
41-
# self.keyFn1=IntVar(self)
42-
# self.keyFn2=IntVar(self)
4335
self.CreateWidgets()
4436
self.LoadFinalKeyList()
45-
#self.buttonOk.focus_set()
4637
self.withdraw() #hide while setting geometry
4738
self.update_idletasks()
4839
self.geometry("+%d+%d" %
@@ -91,32 +82,23 @@ def CreateWidgets(self):
9182
command=self.BuildKeyString,
9283
text='Alt',variable=self.keyAlt,onvalue='Alt',offvalue='')
9384
checkAlt.grid(row=0,column=1,padx=2,sticky=W)
94-
# checkMeta=Checkbutton(self.frameControlsBasic,
95-
# command=self.BuildKeyString,
96-
# text='Meta',variable=self.keyMeta,onvalue='Meta',offvalue='')
97-
# checkMeta.grid(row=0,column=2,padx=2,sticky=W)
9885
checkShift=Checkbutton(self.frameControlsBasic,
9986
command=self.BuildKeyString,
10087
text='Shift',variable=self.keyShift,onvalue='Shift',offvalue='')
10188
checkShift.grid(row=0,column=3,padx=2,sticky=W)
10289
labelFnAdvice=Label(self.frameControlsBasic,justify=LEFT,
10390
text="Select the desired modifier\n"+
10491
"keys above, and final key\n"+
105-
# "keys above, and final key(s)\n"+
10692
"from the list on the right.")
10793
labelFnAdvice.grid(row=1,column=0,columnspan=4,padx=2,sticky=W)
10894
self.listKeysFinal=Listbox(self.frameControlsBasic,width=15,height=10,
10995
selectmode=SINGLE)
110-
# selectmode=MULTIPLE)
11196
self.listKeysFinal.bind('<ButtonRelease-1>',self.FinalKeySelected)
11297
self.listKeysFinal.grid(row=0,column=4,rowspan=4,sticky=NS)
11398
scrollKeysFinal=Scrollbar(self.frameControlsBasic,orient=VERTICAL,
11499
command=self.listKeysFinal.yview)
115100
self.listKeysFinal.config(yscrollcommand=scrollKeysFinal.set)
116101
scrollKeysFinal.grid(row=0,column=5,rowspan=4,sticky=NS)
117-
# self.buttonAddNew=Button(self.frameControlsBasic,
118-
# text='Accept Key Sequence',width=25,command=None)
119-
# self.buttonAddNew.grid(row=2,column=0,columnspan=4)
120102
self.buttonClear=Button(self.frameControlsBasic,
121103
text='Clear Keys',command=self.ClearKeySeq)
122104
self.buttonClear.grid(row=2,column=0,columnspan=4)

0 commit comments

Comments
 (0)