Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
49745756
Commit
49745756
authored
Feb 18, 2002
by
Steven M. Gava
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handle user theme and key set deletion
parent
6354386d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
11 deletions
+87
-11
Lib/idlelib/config-keys.def
Lib/idlelib/config-keys.def
+1
-1
Lib/idlelib/configDialog.py
Lib/idlelib/configDialog.py
+78
-8
Lib/idlelib/configHandler.py
Lib/idlelib/configHandler.py
+8
-2
No files found.
Lib/idlelib/config-keys.def
View file @
49745756
...
...
@@ -10,7 +10,7 @@
[IDLE Classic Windows]
copy=<Control-Key-c>
cut=<Control-Key-x>
paste=<Control-Key-
v
>
paste=<Control-Key-
m
>
beginning-of-line= <Key-Home>
center-insert=<Control-Key-l>
close-all-windows=<Control-Key-q>
...
...
Lib/idlelib/configDialog.py
View file @
49745756
...
...
@@ -226,7 +226,8 @@ class ConfigDialog(Toplevel):
self
.
builtinTheme
,
None
,
command
=
None
)
self
.
optMenuThemeCustom
=
DynOptionMenu
(
frameTheme
,
self
.
customTheme
,
None
,
command
=
None
)
self
.
buttonDeleteCustomTheme
=
Button
(
frameTheme
,
text
=
'Delete Custom Theme'
)
self
.
buttonDeleteCustomTheme
=
Button
(
frameTheme
,
text
=
'Delete Custom Theme'
,
command
=
self
.
DeleteCustomTheme
)
##widget packing
#body
frameCustom
.
pack
(
side
=
LEFT
,
padx
=
5
,
pady
=
10
,
expand
=
TRUE
,
fill
=
BOTH
)
...
...
@@ -293,7 +294,8 @@ class ConfigDialog(Toplevel):
self
.
builtinKeys
,
None
,
command
=
None
)
self
.
optMenuKeysCustom
=
DynOptionMenu
(
frameKeySets
,
self
.
customKeys
,
None
,
command
=
None
)
self
.
buttonDeleteCustomKeys
=
Button
(
frameKeySets
,
text
=
'Delete Custom Key Set'
)
self
.
buttonDeleteCustomKeys
=
Button
(
frameKeySets
,
text
=
'Delete Custom Key Set'
,
command
=
self
.
DeleteCustomKeys
)
##widget packing
#body
frameCustom
.
pack
(
side
=
LEFT
,
padx
=
5
,
pady
=
5
,
expand
=
TRUE
,
fill
=
BOTH
)
...
...
@@ -456,6 +458,7 @@ class ConfigDialog(Toplevel):
def
VarChanged_customTheme
(
self
,
*
params
):
value
=
self
.
customTheme
.
get
()
if
value
!=
'- no custom themes -'
:
self
.
AddChangedItem
(
'main'
,
'Theme'
,
'name'
,
value
)
self
.
PaintThemeSample
()
...
...
@@ -486,6 +489,7 @@ class ConfigDialog(Toplevel):
def
VarChanged_customKeys
(
self
,
*
params
):
value
=
self
.
customKeys
.
get
()
if
value
!=
'- no custom keys -'
:
self
.
AddChangedItem
(
'main'
,
'Keys'
,
'name'
,
value
)
self
.
LoadKeysList
(
value
)
...
...
@@ -594,7 +598,8 @@ class ConfigDialog(Toplevel):
self
.
listBindings
.
select_anchor
(
listIndex
)
def
GetNewKeysName
(
self
,
message
):
usedNames
=
idleConf
.
GetSectionList
(
'user'
,
'keys'
)
usedNames
=
(
idleConf
.
GetSectionList
(
'user'
,
'keys'
)
+
idleConf
.
GetSectionList
(
'default'
,
'keys'
))
newKeySet
=
GetCfgSectionNameDialog
(
self
,
'New Custom Key Set'
,
message
,
usedNames
).
result
return
newKeySet
...
...
@@ -657,6 +662,58 @@ class ConfigDialog(Toplevel):
self
.
listBindings
.
select_set
(
listIndex
)
self
.
listBindings
.
select_anchor
(
listIndex
)
def
DeleteCustomKeys
(
self
):
keySetName
=
self
.
customKeys
.
get
()
if
not
tkMessageBox
.
askyesno
(
'Delete Key Set'
,
'Are you sure you wish '
+
'to delete the key set '
+
`keySetName`
+
' ?'
):
return
#remove key set from config
idleConf
.
userCfg
[
'keys'
].
remove_section
(
keySetName
)
if
self
.
changedItems
[
'keys'
].
has_key
(
keySetName
):
del
(
self
.
changedItems
[
'keys'
][
keySetName
])
#write changes
idleConf
.
userCfg
[
'keys'
].
Save
()
#reload user key set list
itemList
=
idleConf
.
GetSectionList
(
'user'
,
'keys'
)
itemList
.
sort
()
if
not
itemList
:
self
.
radioKeysCustom
.
config
(
state
=
DISABLED
)
self
.
optMenuKeysCustom
.
SetMenu
(
itemList
,
'- no custom keys -'
)
else
:
self
.
optMenuKeysCustom
.
SetMenu
(
itemList
,
itemList
[
0
])
#revert to default key set
self
.
keysAreBuiltin
.
set
(
idleConf
.
defaultCfg
[
'main'
].
Get
(
'Keys'
,
'default'
))
self
.
builtinKeys
.
set
(
idleConf
.
defaultCfg
[
'main'
].
Get
(
'Keys'
,
'name'
))
#user can't back out of these changes, they must be applied now
self
.
Apply
()
self
.
SetKeysType
()
def
DeleteCustomTheme
(
self
):
themeName
=
self
.
customTheme
.
get
()
if
not
tkMessageBox
.
askyesno
(
'Delete Theme'
,
'Are you sure you wish '
+
'to delete the theme '
+
`themeName`
+
' ?'
):
return
#remove theme from config
idleConf
.
userCfg
[
'highlight'
].
remove_section
(
themeName
)
if
self
.
changedItems
[
'highlight'
].
has_key
(
themeName
):
del
(
self
.
changedItems
[
'highlight'
][
themeName
])
#write changes
idleConf
.
userCfg
[
'highlight'
].
Save
()
#reload user theme list
itemList
=
idleConf
.
GetSectionList
(
'user'
,
'highlight'
)
itemList
.
sort
()
if
not
itemList
:
self
.
radioThemeCustom
.
config
(
state
=
DISABLED
)
self
.
optMenuThemeCustom
.
SetMenu
(
itemList
,
'- no custom themes -'
)
else
:
self
.
optMenuThemeCustom
.
SetMenu
(
itemList
,
itemList
[
0
])
#revert to default theme
self
.
themeIsBuiltin
.
set
(
idleConf
.
defaultCfg
[
'main'
].
Get
(
'Theme'
,
'default'
))
self
.
builtinTheme
.
set
(
idleConf
.
defaultCfg
[
'main'
].
Get
(
'Theme'
,
'name'
))
#user can't back out of these changes, they must be applied now
self
.
Apply
()
self
.
SetThemeType
()
def
GetColour
(
self
):
target
=
self
.
highlightTarget
.
get
()
prevColour
=
self
.
frameColourSet
.
cget
(
'bg'
)
...
...
@@ -689,7 +746,8 @@ class ConfigDialog(Toplevel):
self
.
AddChangedItem
(
'highlight'
,
theme
,
themeElement
,
newColour
)
def
GetNewThemeName
(
self
,
message
):
usedNames
=
idleConf
.
GetSectionList
(
'user'
,
'highlight'
)
usedNames
=
(
idleConf
.
GetSectionList
(
'user'
,
'highlight'
)
+
idleConf
.
GetSectionList
(
'default'
,
'highlight'
))
newTheme
=
GetCfgSectionNameDialog
(
self
,
'New Custom Theme'
,
message
,
usedNames
).
result
return
newTheme
...
...
@@ -1025,6 +1083,17 @@ class ConfigDialog(Toplevel):
idleConf
.
userCfg
[
configType
].
Save
()
self
.
ResetChangedItems
()
#clear the changed items dict
def
ActivateConfigChanges
(
self
):
#things that need to be done to make
#applied config changes dynamic:
#
#update editor/shell font and repaint
#dynamically update indentation setttings
#update theme and repaint
#update keybindings and re-bind
#update user help sources menu
pass
def
Cancel
(
self
):
self
.
destroy
()
...
...
@@ -1034,6 +1103,7 @@ class ConfigDialog(Toplevel):
def
Apply
(
self
):
self
.
SaveAllChangedConfigs
()
self
.
ActivateConfigChanges
()
def
Help
(
self
):
pass
...
...
Lib/idlelib/configHandler.py
View file @
49745756
...
...
@@ -518,8 +518,14 @@ class IdleConf:
if
keySetName
:
for
event
in
keyBindings
.
keys
():
binding
=
self
.
GetKeyBinding
(
keySetName
,
event
)
if
binding
:
#otherwise will keep default
if
binding
:
keyBindings
[
event
]
=
binding
else
:
#we are going to return a default, print warning
warning
=
(
'
\
n
Warning: configHandler.py - IdleConf.GetCoreKeys'
+
' -
\
n
problem retrieving key binding for event '
+
`event`
+
'
\
n
from key set '
+
`keySetName`
+
'.
\
n
'
+
' returning default value: '
+
`keyBindings[event]`
+
'
\
n
'
)
sys
.
stderr
.
write
(
warning
)
return
keyBindings
def
GetExtraHelpSourceList
(
self
,
configSet
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment