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
f9bb90e4
Commit
f9bb90e4
authored
Jan 24, 2002
by
Steven M. Gava
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
further work on saving configs
parent
813b56e3
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
165 additions
and
47 deletions
+165
-47
Lib/idlelib/configDialog.py
Lib/idlelib/configDialog.py
+97
-22
Lib/idlelib/configHandler.py
Lib/idlelib/configHandler.py
+68
-23
Lib/idlelib/keybindingDialog.py
Lib/idlelib/keybindingDialog.py
+0
-2
No files found.
Lib/idlelib/configDialog.py
View file @
f9bb90e4
This diff is collapsed.
Click to expand it.
Lib/idlelib/configHandler.py
View file @
f9bb90e4
...
...
@@ -23,7 +23,7 @@ class IdleConfParser(ConfigParser):
self
.
file
=
cfgFile
ConfigParser
.
__init__
(
self
,
defaults
=
cfgDefaults
)
def
Get
(
self
,
section
,
option
,
type
=
None
):
def
Get
(
self
,
section
,
option
,
type
=
None
,
default
=
None
):
"""
Get an option value for given section/option or return default.
If type is specified, return as type.
...
...
@@ -35,8 +35,10 @@ class IdleConfParser(ConfigParser):
else
:
getVal
=
self
.
get
if
self
.
has_option
(
section
,
option
):
#return getVal(section, option, raw, vars)
#return getVal(section, option, raw, vars
, default
)
return
getVal
(
section
,
option
)
else
:
return
default
def
GetOptionList
(
self
,
section
):
"""
...
...
@@ -188,21 +190,63 @@ class IdleConf:
else
:
raise
'Invalid fgBg specified'
def
GetTheme
(
self
,
name
=
None
):
"""
Gets the requested theme or returns a final fallback theme in case
one can't be obtained from either the user or default config files.
"""
pass
def
GetThemeDict
(
self
,
type
,
themeName
):
"""
type - string, 'default' or 'user' theme type
themeName - string, theme name
Returns a dictionary which holds {option:value} for each element
in the specified theme. Values are loaded over a set of ultimate last
fallback defaults to guarantee that all theme elements are present in
a newly created theme.
"""
if
type
==
'user'
:
cfgParser
=
self
.
userCfg
[
'highlight'
]
elif
type
==
'default'
:
cfgParser
=
self
.
defaultCfg
[
'highlight'
]
else
:
raise
'Invalid theme type specified'
#foreground and background values are provded for each theme element
#(apart from cursor) even though all these values are not yet used
#by idle, to allow for their use in the future. Default values are
#generally black and white.
theme
=
{
'normal-foreground'
:
'#000000'
,
'normal-background'
:
'#ffffff'
,
'keyword-foreground'
:
'#000000'
,
'keyword-background'
:
'#ffffff'
,
'comment-foreground'
:
'#000000'
,
'comment-background'
:
'#ffffff'
,
'string-foreground'
:
'#000000'
,
'string-background'
:
'#ffffff'
,
'definition-foreground'
:
'#000000'
,
'definition-background'
:
'#ffffff'
,
'hilite-foreground'
:
'#000000'
,
'hilite-background'
:
'gray'
,
'break-foreground'
:
'#ffffff'
,
'break-background'
:
'#000000'
,
'hit-foreground'
:
'#ffffff'
,
'hit-background'
:
'#000000'
,
'error-foreground'
:
'#ffffff'
,
'error-background'
:
'#000000'
,
#cursor (only foreground can be set)
'cursor-foreground'
:
'#000000'
,
#shell window
'stdout-foreground'
:
'#000000'
,
'stdout-background'
:
'#ffffff'
,
'stderr-foreground'
:
'#000000'
,
'stderr-background'
:
'#ffffff'
,
'console-foreground'
:
'#000000'
,
'console-background'
:
'#ffffff'
}
for
element
in
theme
.
keys
():
colour
=
cfgParser
.
Get
(
type
,
themeName
,
element
,
default
=
theme
[
element
])
theme
[
element
]
=
colour
return
theme
def
CurrentTheme
(
self
):
"""
Returns the name of the currently active theme
"""
return
self
.
GetOption
(
'main'
,
'Theme'
,
'name'
,
default
=
''
)
def
CurrentKeys
(
self
):
"""
Returns the name of the currently active theme
...
...
@@ -299,8 +343,6 @@ class IdleConf:
return
extBinds
def
GetKeyBinding
(
self
,
keySetName
,
eventStr
):
"""
returns the keybinding for a specific event.
...
...
@@ -313,32 +355,35 @@ class IdleConf:
return
binding
def
GetCurrentKeySet
(
self
):
return
self
.
GetKeySet
(
self
.
CurrentKeys
())
def
GetKeySet
(
self
,
keySetName
):
"""
Returns a dictionary of: all
current
core keybindings, plus the
Returns a dictionary of: all
requested
core keybindings, plus the
keybindings for all currently active extensions. If a binding defined
in an extension is already in use, that binding is disabled.
"""
currentKeySet
=
self
.
GetCoreKeys
(
keySetName
=
self
.
CurrentKeys
()
)
keySet
=
self
.
GetCoreKeys
(
keySetName
)
activeExtns
=
self
.
GetExtensions
(
activeOnly
=
1
)
for
extn
in
activeExtns
:
extKeys
=
self
.
__GetRawExtensionKeys
(
extn
)
if
extKeys
:
#the extension defines keybindings
for
event
in
extKeys
.
keys
():
if
extKeys
[
event
]
in
currentK
eySet
.
values
():
if
extKeys
[
event
]
in
k
eySet
.
values
():
#the binding is already in use
extKeys
[
event
]
=
''
#disable this binding
currentK
eySet
[
event
]
=
extKeys
[
event
]
#add binding
return
currentK
eySet
k
eySet
[
event
]
=
extKeys
[
event
]
#add binding
return
k
eySet
def
GetCoreKeys
(
self
,
keySetName
=
None
):
"""
returns the requested set of core keybindings, with fallbacks if
required.
Keybindings loaded from the config file(s) are loaded _over_ these
defaults, so if there is a problem getting any core binding there will
be an 'ultimate last resort fallback' to the CUA-ish bindings
defined here.
"""
#keybindings loaded from the config file(s) are loaded _over_ these
#defaults, so if there is a problem getting any core binding there will
#be an 'ultimate last resort fallback' to the CUA-ish bindings
#defined here.
keyBindings
=
{
'<<Copy>>'
:
[
'<Control-c>'
,
'<Control-C>'
],
'<<Cut>>'
:
[
'<Control-x>'
,
'<Control-X>'
],
...
...
Lib/idlelib/keybindingDialog.py
View file @
f9bb90e4
...
...
@@ -264,8 +264,6 @@ if __name__ == '__main__':
#test the dialog
root
=
Tk
()
def
run
():
#import aboutDialog
#aboutDialog.AboutDialog(root,'About')
keySeq
=
''
dlg
=
GetKeysDialog
(
root
,
'Get Keys'
,
'find-again'
,[])
print
dlg
.
result
...
...
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