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
4e49b836
Commit
4e49b836
authored
Jun 04, 2004
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SF patch #961387: Make IDLE's paragraph reformatting width configurable
parent
3c145449
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
4 deletions
+27
-4
Lib/idlelib/FormatParagraph.py
Lib/idlelib/FormatParagraph.py
+6
-4
Lib/idlelib/config-main.def
Lib/idlelib/config-main.def
+3
-0
Lib/idlelib/configDialog.py
Lib/idlelib/configDialog.py
+18
-0
No files found.
Lib/idlelib/FormatParagraph.py
View file @
4e49b836
...
...
@@ -15,6 +15,7 @@
# * Fancy comments, like this bulleted list, arent handled :-)
import
re
from
configHandler
import
idleConf
class
FormatParagraph
:
...
...
@@ -31,6 +32,7 @@ class FormatParagraph:
self
.
editwin
=
None
def
format_paragraph_event
(
self
,
event
):
maxformatwidth
=
int
(
idleConf
.
GetOption
(
'main'
,
'FormatParagraph'
,
'paragraph'
))
text
=
self
.
editwin
.
text
first
,
last
=
self
.
editwin
.
get_selection_indices
()
if
first
and
last
:
...
...
@@ -44,8 +46,8 @@ class FormatParagraph:
lines
=
data
.
split
(
"
\
n
"
)
lines
=
map
(
lambda
st
,
l
=
len
(
comment_header
):
st
[
l
:],
lines
)
data
=
"
\
n
"
.
join
(
lines
)
# Reformat to
70
chars or a 20 char width, whichever is greater.
format_width
=
max
(
70
-
len
(
comment_header
),
20
)
# Reformat to
maxformatwidth
chars or a 20 char width, whichever is greater.
format_width
=
max
(
maxformatwidth
,
len
(
comment_header
),
20
)
newdata
=
reformat_paragraph
(
data
,
format_width
)
# re-split and re-insert the comment header.
newdata
=
newdata
.
split
(
"
\
n
"
)
...
...
@@ -62,7 +64,7 @@ class FormatParagraph:
newdata
=
'
\
n
'
.
join
(
map
(
builder
,
newdata
))
+
block_suffix
else
:
# Just a normal text format
newdata
=
reformat_paragraph
(
data
)
newdata
=
reformat_paragraph
(
data
,
maxformatwidth
)
text
.
tag_remove
(
"sel"
,
"1.0"
,
"end"
)
if
newdata
!=
data
:
text
.
mark_set
(
"insert"
,
first
)
...
...
@@ -99,7 +101,7 @@ def find_paragraph(text, mark):
first
=
"%d.0"
%
(
lineno
+
1
)
return
first
,
last
,
comment_header
,
text
.
get
(
first
,
last
)
def
reformat_paragraph
(
data
,
limit
=
70
):
def
reformat_paragraph
(
data
,
limit
):
lines
=
data
.
split
(
"
\
n
"
)
i
=
0
n
=
len
(
lines
)
...
...
Lib/idlelib/config-main.def
View file @
4e49b836
...
...
@@ -58,6 +58,9 @@ font-size= 10
font-bold= 0
encoding= none
[FormatParagraph]
paragraph=70
[Indent]
use-spaces= 1
num-spaces= 4
...
...
Lib/idlelib/configDialog.py
View file @
4e49b836
...
...
@@ -337,6 +337,7 @@ class ConfigDialog(Toplevel):
#tkVars
self
.
winWidth
=
StringVar
(
self
)
self
.
winHeight
=
StringVar
(
self
)
self
.
paraWidth
=
StringVar
(
self
)
self
.
startupEdit
=
IntVar
(
self
)
self
.
autoSave
=
IntVar
(
self
)
self
.
encoding
=
StringVar
(
self
)
...
...
@@ -349,6 +350,7 @@ class ConfigDialog(Toplevel):
frameRun
=
Frame
(
frame
,
borderwidth
=
2
,
relief
=
GROOVE
)
frameSave
=
Frame
(
frame
,
borderwidth
=
2
,
relief
=
GROOVE
)
frameWinSize
=
Frame
(
frame
,
borderwidth
=
2
,
relief
=
GROOVE
)
frameParaSize
=
Frame
(
frame
,
borderwidth
=
2
,
relief
=
GROOVE
)
frameEncoding
=
Frame
(
frame
,
borderwidth
=
2
,
relief
=
GROOVE
)
frameHelp
=
Frame
(
frame
,
borderwidth
=
2
,
relief
=
GROOVE
)
#frameRun
...
...
@@ -374,6 +376,11 @@ class ConfigDialog(Toplevel):
labelWinHeightTitle
=
Label
(
frameWinSize
,
text
=
'Height'
)
entryWinHeight
=
Entry
(
frameWinSize
,
textvariable
=
self
.
winHeight
,
width
=
3
)
#paragraphFormatWidth
labelParaWidthTitle
=
Label
(
frameParaSize
,
text
=
'Paragraph reformat'
+
' width (in characters)'
)
entryParaWidth
=
Entry
(
frameParaSize
,
textvariable
=
self
.
paraWidth
,
width
=
3
)
#frameEncoding
labelEncodingTitle
=
Label
(
frameEncoding
,
text
=
"Default Source Encoding"
)
radioEncLocale
=
Radiobutton
(
frameEncoding
,
variable
=
self
.
encoding
,
...
...
@@ -411,6 +418,7 @@ class ConfigDialog(Toplevel):
frameRun
.
pack
(
side
=
TOP
,
padx
=
5
,
pady
=
5
,
fill
=
X
)
frameSave
.
pack
(
side
=
TOP
,
padx
=
5
,
pady
=
5
,
fill
=
X
)
frameWinSize
.
pack
(
side
=
TOP
,
padx
=
5
,
pady
=
5
,
fill
=
X
)
frameParaSize
.
pack
(
side
=
TOP
,
padx
=
5
,
pady
=
5
,
fill
=
X
)
frameEncoding
.
pack
(
side
=
TOP
,
padx
=
5
,
pady
=
5
,
fill
=
X
)
frameHelp
.
pack
(
side
=
TOP
,
padx
=
5
,
pady
=
5
,
expand
=
TRUE
,
fill
=
BOTH
)
#frameRun
...
...
@@ -429,6 +437,9 @@ class ConfigDialog(Toplevel):
labelWinHeightTitle
.
pack
(
side
=
RIGHT
,
anchor
=
E
,
pady
=
5
)
entryWinWidth
.
pack
(
side
=
RIGHT
,
anchor
=
E
,
padx
=
10
,
pady
=
5
)
labelWinWidthTitle
.
pack
(
side
=
RIGHT
,
anchor
=
E
,
pady
=
5
)
#paragraphFormatWidth
labelParaWidthTitle
.
pack
(
side
=
LEFT
,
anchor
=
W
,
padx
=
5
,
pady
=
5
)
entryParaWidth
.
pack
(
side
=
RIGHT
,
anchor
=
E
,
padx
=
10
,
pady
=
5
)
#frameEncoding
labelEncodingTitle
.
pack
(
side
=
LEFT
,
anchor
=
W
,
padx
=
5
,
pady
=
5
)
radioEncNone
.
pack
(
side
=
RIGHT
,
anchor
=
E
,
pady
=
5
)
...
...
@@ -466,6 +477,7 @@ class ConfigDialog(Toplevel):
self
.
keysAreBuiltin
.
trace_variable
(
'w'
,
self
.
VarChanged_keysAreBuiltin
)
self
.
winWidth
.
trace_variable
(
'w'
,
self
.
VarChanged_winWidth
)
self
.
winHeight
.
trace_variable
(
'w'
,
self
.
VarChanged_winHeight
)
self
.
paraWidth
.
trace_variable
(
'w'
,
self
.
VarChanged_paraWidth
)
self
.
startupEdit
.
trace_variable
(
'w'
,
self
.
VarChanged_startupEdit
)
self
.
autoSave
.
trace_variable
(
'w'
,
self
.
VarChanged_autoSave
)
self
.
encoding
.
trace_variable
(
'w'
,
self
.
VarChanged_encoding
)
...
...
@@ -558,6 +570,10 @@ class ConfigDialog(Toplevel):
value
=
self
.
winHeight
.
get
()
self
.
AddChangedItem
(
'main'
,
'EditorWindow'
,
'height'
,
value
)
def
VarChanged_paraWidth
(
self
,
*
params
):
value
=
self
.
paraWidth
.
get
()
self
.
AddChangedItem
(
'main'
,
'FormatParagraph'
,
'paragraph'
,
value
)
def
VarChanged_startupEdit
(
self
,
*
params
):
value
=
self
.
startupEdit
.
get
()
self
.
AddChangedItem
(
'main'
,
'General'
,
'editor-on-startup'
,
value
)
...
...
@@ -1070,6 +1086,8 @@ class ConfigDialog(Toplevel):
#initial window size
self
.
winWidth
.
set
(
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'width'
))
self
.
winHeight
.
set
(
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'height'
))
#initial paragraph reformat size
self
.
paraWidth
.
set
(
idleConf
.
GetOption
(
'main'
,
'FormatParagraph'
,
'paragraph'
))
# default source encoding
self
.
encoding
.
set
(
idleConf
.
GetOption
(
'main'
,
'EditorWindow'
,
'encoding'
,
default
=
'none'
))
...
...
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