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
8a495a48
Commit
8a495a48
authored
Dec 24, 2012
by
Andrew Svetlov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #16511: Use default IDLE width and height if config param is not valid.
Patch Serhiy Storchaka.
parent
159bb537
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
35 deletions
+65
-35
Lib/idlelib/EditorWindow.py
Lib/idlelib/EditorWindow.py
+14
-7
Lib/idlelib/FormatParagraph.py
Lib/idlelib/FormatParagraph.py
+4
-2
Lib/idlelib/configDialog.py
Lib/idlelib/configDialog.py
+11
-8
Lib/idlelib/configHandler.py
Lib/idlelib/configHandler.py
+33
-18
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/idlelib/EditorWindow.py
View file @
8a495a48
...
@@ -170,13 +170,15 @@ class EditorWindow(object):
...
@@ -170,13 +170,15 @@ class EditorWindow(object):
'recent-files.lst'
)
'recent-files.lst'
)
self
.
text_frame
=
text_frame
=
Frame
(
top
)
self
.
text_frame
=
text_frame
=
Frame
(
top
)
self
.
vbar
=
vbar
=
Scrollbar
(
text_frame
,
name
=
'vbar'
)
self
.
vbar
=
vbar
=
Scrollbar
(
text_frame
,
name
=
'vbar'
)
self
.
width
=
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'width'
)
self
.
width
=
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'width'
,
type
=
'int'
)
text_options
=
{
text_options
=
{
'name'
:
'text'
,
'name'
:
'text'
,
'padx'
:
5
,
'padx'
:
5
,
'wrap'
:
'none'
,
'wrap'
:
'none'
,
'width'
:
self
.
width
,
'width'
:
self
.
width
,
'height'
:
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'height'
)}
'height'
:
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'height'
,
type
=
'int'
)}
if
TkVersion
>=
8.5
:
if
TkVersion
>=
8.5
:
# Starting with tk 8.5 we have to set the new tabstyle option
# Starting with tk 8.5 we have to set the new tabstyle option
# to 'wordprocessor' to achieve the same display of tabs as in
# to 'wordprocessor' to achieve the same display of tabs as in
...
@@ -253,7 +255,8 @@ class EditorWindow(object):
...
@@ -253,7 +255,8 @@ class EditorWindow(object):
if
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font-bold'
,
type
=
'bool'
):
if
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font-bold'
,
type
=
'bool'
):
fontWeight
=
'bold'
fontWeight
=
'bold'
text
.
config
(
font
=
(
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font'
),
text
.
config
(
font
=
(
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font'
),
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font-size'
),
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font-size'
,
type
=
'int'
),
fontWeight
))
fontWeight
))
text_frame
.
pack
(
side
=
LEFT
,
fill
=
BOTH
,
expand
=
1
)
text_frame
.
pack
(
side
=
LEFT
,
fill
=
BOTH
,
expand
=
1
)
text
.
pack
(
side
=
TOP
,
fill
=
BOTH
,
expand
=
1
)
text
.
pack
(
side
=
TOP
,
fill
=
BOTH
,
expand
=
1
)
...
@@ -268,7 +271,8 @@ class EditorWindow(object):
...
@@ -268,7 +271,8 @@ class EditorWindow(object):
# Although use-spaces=0 can be configured manually in config-main.def,
# Although use-spaces=0 can be configured manually in config-main.def,
# configuration of tabs v. spaces is not supported in the configuration
# configuration of tabs v. spaces is not supported in the configuration
# dialog. IDLE promotes the preferred Python indentation: use spaces!
# dialog. IDLE promotes the preferred Python indentation: use spaces!
usespaces
=
idleConf
.
GetOption
(
'main'
,
'Indent'
,
'use-spaces'
,
type
=
'bool'
)
usespaces
=
idleConf
.
GetOption
(
'main'
,
'Indent'
,
'use-spaces'
,
type
=
'bool'
)
self
.
usetabs
=
not
usespaces
self
.
usetabs
=
not
usespaces
# tabwidth is the display width of a literal tab character.
# tabwidth is the display width of a literal tab character.
...
@@ -382,9 +386,11 @@ class EditorWindow(object):
...
@@ -382,9 +386,11 @@ class EditorWindow(object):
self
.
text
.
tag_remove
(
"sel"
,
"1.0"
,
"end"
)
self
.
text
.
tag_remove
(
"sel"
,
"1.0"
,
"end"
)
else
:
else
:
if
not
self
.
text
.
index
(
"sel.first"
):
if
not
self
.
text
.
index
(
"sel.first"
):
self
.
text
.
mark_set
(
"my_anchor"
,
"insert"
)
# there was no previous selection
# there was no previous selection
self
.
text
.
mark_set
(
"my_anchor"
,
"insert"
)
else
:
else
:
if
self
.
text
.
compare
(
self
.
text
.
index
(
"sel.first"
),
"<"
,
self
.
text
.
index
(
"insert"
)):
if
self
.
text
.
compare
(
self
.
text
.
index
(
"sel.first"
),
"<"
,
self
.
text
.
index
(
"insert"
)):
self
.
text
.
mark_set
(
"my_anchor"
,
"sel.first"
)
# extend back
self
.
text
.
mark_set
(
"my_anchor"
,
"sel.first"
)
# extend back
else
:
else
:
self
.
text
.
mark_set
(
"my_anchor"
,
"sel.last"
)
# extend forward
self
.
text
.
mark_set
(
"my_anchor"
,
"sel.last"
)
# extend forward
...
@@ -766,7 +772,8 @@ class EditorWindow(object):
...
@@ -766,7 +772,8 @@ class EditorWindow(object):
if
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font-bold'
,
type
=
'bool'
):
if
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font-bold'
,
type
=
'bool'
):
fontWeight
=
'bold'
fontWeight
=
'bold'
self
.
text
.
config
(
font
=
(
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font'
),
self
.
text
.
config
(
font
=
(
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font'
),
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font-size'
),
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font-size'
,
type
=
'int'
),
fontWeight
))
fontWeight
))
def
RemoveKeybindings
(
self
):
def
RemoveKeybindings
(
self
):
...
...
Lib/idlelib/FormatParagraph.py
View file @
8a495a48
...
@@ -32,7 +32,8 @@ class FormatParagraph:
...
@@ -32,7 +32,8 @@ class FormatParagraph:
self
.
editwin
=
None
self
.
editwin
=
None
def
format_paragraph_event
(
self
,
event
):
def
format_paragraph_event
(
self
,
event
):
maxformatwidth
=
int
(
idleConf
.
GetOption
(
'main'
,
'FormatParagraph'
,
'paragraph'
))
maxformatwidth
=
int
(
idleConf
.
GetOption
(
'main'
,
'FormatParagraph'
,
'paragraph'
,
type
=
'int'
))
text
=
self
.
editwin
.
text
text
=
self
.
editwin
.
text
first
,
last
=
self
.
editwin
.
get_selection_indices
()
first
,
last
=
self
.
editwin
.
get_selection_indices
()
if
first
and
last
:
if
first
and
last
:
...
@@ -46,7 +47,8 @@ class FormatParagraph:
...
@@ -46,7 +47,8 @@ class FormatParagraph:
lines
=
data
.
split
(
"
\
n
"
)
lines
=
data
.
split
(
"
\
n
"
)
lines
=
map
(
lambda
st
,
l
=
len
(
comment_header
):
st
[
l
:],
lines
)
lines
=
map
(
lambda
st
,
l
=
len
(
comment_header
):
st
[
l
:],
lines
)
data
=
"
\
n
"
.
join
(
lines
)
data
=
"
\
n
"
.
join
(
lines
)
# Reformat to maxformatwidth chars or a 20 char width, whichever is greater.
# Reformat to maxformatwidth chars or a 20 char width,
# whichever is greater.
format_width
=
max
(
maxformatwidth
-
len
(
comment_header
),
20
)
format_width
=
max
(
maxformatwidth
-
len
(
comment_header
),
20
)
newdata
=
reformat_paragraph
(
data
,
format_width
)
newdata
=
reformat_paragraph
(
data
,
format_width
)
# re-split and re-insert the comment header.
# re-split and re-insert the comment header.
...
...
Lib/idlelib/configDialog.py
View file @
8a495a48
...
@@ -925,7 +925,7 @@ class ConfigDialog(Toplevel):
...
@@ -925,7 +925,7 @@ class ConfigDialog(Toplevel):
for
font
in
fonts
:
for
font
in
fonts
:
self
.
listFontName
.
insert
(
END
,
font
)
self
.
listFontName
.
insert
(
END
,
font
)
configuredFont
=
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font'
,
configuredFont
=
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font'
,
default
=
'courier'
)
default
=
'courier'
)
lc_configuredFont
=
configuredFont
.
lower
()
lc_configuredFont
=
configuredFont
.
lower
()
self
.
fontName
.
set
(
lc_configuredFont
)
self
.
fontName
.
set
(
lc_configuredFont
)
lc_fonts
=
[
s
.
lower
()
for
s
in
fonts
]
lc_fonts
=
[
s
.
lower
()
for
s
in
fonts
]
...
@@ -935,13 +935,13 @@ class ConfigDialog(Toplevel):
...
@@ -935,13 +935,13 @@ class ConfigDialog(Toplevel):
self
.
listFontName
.
select_set
(
currentFontIndex
)
self
.
listFontName
.
select_set
(
currentFontIndex
)
self
.
listFontName
.
select_anchor
(
currentFontIndex
)
self
.
listFontName
.
select_anchor
(
currentFontIndex
)
##font size dropdown
##font size dropdown
fontSize
=
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font-size'
,
fontSize
=
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font-size'
,
default
=
'10'
)
type
=
'int'
,
default
=
'10'
)
self
.
optMenuFontSize
.
SetMenu
((
'7'
,
'8'
,
'9'
,
'10'
,
'11'
,
'12'
,
'13'
,
'14'
,
self
.
optMenuFontSize
.
SetMenu
((
'7'
,
'8'
,
'9'
,
'10'
,
'11'
,
'12'
,
'13'
,
'14'
,
'16'
,
'18'
,
'20'
,
'22'
),
fontSize
)
'16'
,
'18'
,
'20'
,
'22'
),
fontSize
)
##fontWeight
##fontWeight
self
.
fontBold
.
set
(
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
self
.
fontBold
.
set
(
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'font-bold'
,
default
=
0
,
type
=
'bool'
))
'font-bold'
,
default
=
0
,
type
=
'bool'
))
##font sample
##font sample
self
.
SetFontSample
()
self
.
SetFontSample
()
...
@@ -1022,10 +1022,13 @@ class ConfigDialog(Toplevel):
...
@@ -1022,10 +1022,13 @@ class ConfigDialog(Toplevel):
self
.
autoSave
.
set
(
idleConf
.
GetOption
(
'main'
,
'General'
,
'autosave'
,
self
.
autoSave
.
set
(
idleConf
.
GetOption
(
'main'
,
'General'
,
'autosave'
,
default
=
0
,
type
=
'bool'
))
default
=
0
,
type
=
'bool'
))
#initial window size
#initial window size
self
.
winWidth
.
set
(
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'width'
))
self
.
winWidth
.
set
(
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'width'
,
self
.
winHeight
.
set
(
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'height'
))
type
=
'int'
))
self
.
winHeight
.
set
(
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'height'
,
type
=
'int'
))
#initial paragraph reformat size
#initial paragraph reformat size
self
.
paraWidth
.
set
(
idleConf
.
GetOption
(
'main'
,
'FormatParagraph'
,
'paragraph'
))
self
.
paraWidth
.
set
(
idleConf
.
GetOption
(
'main'
,
'FormatParagraph'
,
'paragraph'
,
type
=
'int'
))
# default source encoding
# default source encoding
self
.
encoding
.
set
(
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
self
.
encoding
.
set
(
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'encoding'
,
default
=
'none'
))
'encoding'
,
default
=
'none'
))
...
...
Lib/idlelib/configHandler.py
View file @
8a495a48
...
@@ -237,24 +237,39 @@ class IdleConf:
...
@@ -237,24 +237,39 @@ class IdleConf:
printed to stderr.
printed to stderr.
"""
"""
if
self
.
userCfg
[
configType
].
has_option
(
section
,
option
):
try
:
return
self
.
userCfg
[
configType
].
Get
(
section
,
option
,
if
self
.
userCfg
[
configType
].
has_option
(
section
,
option
):
type
=
type
,
raw
=
raw
)
return
self
.
userCfg
[
configType
].
Get
(
section
,
option
,
elif
self
.
defaultCfg
[
configType
].
has_option
(
section
,
option
):
type
=
type
,
raw
=
raw
)
return
self
.
defaultCfg
[
configType
].
Get
(
section
,
option
,
except
ValueError
:
type
=
type
,
raw
=
raw
)
warning
=
(
'
\
n
Warning: configHandler.py - IdleConf.GetOption -
\
n
'
else
:
#returning default, print warning
' invalid %r value for configuration option %r
\
n
'
if
warn_on_default
:
' from section %r: %r
\
n
'
%
warning
=
(
'
\
n
Warning: configHandler.py - IdleConf.GetOption -
\
n
'
(
type
,
option
,
section
,
' problem retrieving configuration option %r
\
n
'
self
.
userCfg
[
configType
].
Get
(
section
,
option
,
' from section %r.
\
n
'
raw
=
raw
)))
' returning default value: %r
\
n
'
%
try
:
(
option
,
section
,
default
))
sys
.
stderr
.
write
(
warning
)
try
:
except
IOError
:
sys
.
stderr
.
write
(
warning
)
pass
except
IOError
:
try
:
pass
if
self
.
defaultCfg
[
configType
].
has_option
(
section
,
option
):
return
default
return
self
.
defaultCfg
[
configType
].
Get
(
section
,
option
,
type
=
type
,
raw
=
raw
)
except
ValueError
:
pass
#returning default, print warning
if
warn_on_default
:
warning
=
(
'
\
n
Warning: configHandler.py - IdleConf.GetOption -
\
n
'
' problem retrieving configuration option %r
\
n
'
' from section %r.
\
n
'
' returning default value: %r
\
n
'
%
(
option
,
section
,
default
))
try
:
sys
.
stderr
.
write
(
warning
)
except
IOError
:
pass
return
default
def
SetOption
(
self
,
configType
,
section
,
option
,
value
):
def
SetOption
(
self
,
configType
,
section
,
option
,
value
):
"""In user's config file, set section's option to value.
"""In user's config file, set section's option to value.
...
...
Misc/NEWS
View file @
8a495a48
...
@@ -179,6 +179,9 @@ Core and Builtins
...
@@ -179,6 +179,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #16511: Use default IDLE width and height if config param is not valid.
Patch Serhiy Storchaka.
- Issue #16443: Add docstrings to regular expression match objects.
- Issue #16443: Add docstrings to regular expression match objects.
Patch by Anton Kasyanov.
Patch by Anton Kasyanov.
...
...
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