[Python-checkins] python/dist/src/Lib/idlelib FormatParagraph.py,
1.5, 1.6 config-main.def, 1.20, 1.21 configDialog.py, 1.58, 1.59
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Fri Jun 4 02:31:10 EDT 2004
Update of /cvsroot/python/python/dist/src/Lib/idlelib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24185
Modified Files:
FormatParagraph.py config-main.def configDialog.py
Log Message:
SF patch #961387: Make IDLE's paragraph reformatting width configurable
Index: FormatParagraph.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/FormatParagraph.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** FormatParagraph.py 16 Sep 2002 02:22:19 -0000 1.5
--- FormatParagraph.py 4 Jun 2004 06:31:08 -0000 1.6
***************
*** 16,19 ****
--- 16,20 ----
import re
+ from configHandler import idleConf
class FormatParagraph:
***************
*** 32,35 ****
--- 33,37 ----
def format_paragraph_event(self, event):
+ maxformatwidth = int(idleConf.GetOption('main','FormatParagraph','paragraph'))
text = self.editwin.text
first, last = self.editwin.get_selection_indices()
***************
*** 45,50 ****
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)
newdata = reformat_paragraph(data, format_width)
# re-split and re-insert the comment header.
--- 47,52 ----
lines = map(lambda st, l=len(comment_header): st[l:], lines)
data = "\n".join(lines)
! # 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.
***************
*** 63,67 ****
else:
# Just a normal text format
! newdata = reformat_paragraph(data)
text.tag_remove("sel", "1.0", "end")
if newdata != data:
--- 65,69 ----
else:
# Just a normal text format
! newdata = reformat_paragraph(data, maxformatwidth)
text.tag_remove("sel", "1.0", "end")
if newdata != data:
***************
*** 100,104 ****
return first, last, comment_header, text.get(first, last)
! def reformat_paragraph(data, limit=70):
lines = data.split("\n")
i = 0
--- 102,106 ----
return first, last, comment_header, text.get(first, last)
! def reformat_paragraph(data, limit):
lines = data.split("\n")
i = 0
Index: config-main.def
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/config-main.def,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** config-main.def 9 Aug 2003 01:51:28 -0000 1.20
--- config-main.def 4 Jun 2004 06:31:08 -0000 1.21
***************
*** 59,62 ****
--- 59,65 ----
encoding= none
+ [FormatParagraph]
+ paragraph=70
+
[Indent]
use-spaces= 1
Index: configDialog.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/configDialog.py,v
retrieving revision 1.58
retrieving revision 1.59
diff -C2 -d -r1.58 -r1.59
*** configDialog.py 11 Apr 2004 03:16:07 -0000 1.58
--- configDialog.py 4 Jun 2004 06:31:08 -0000 1.59
***************
*** 338,341 ****
--- 338,342 ----
self.winWidth=StringVar(self)
self.winHeight=StringVar(self)
+ self.paraWidth=StringVar(self)
self.startupEdit=IntVar(self)
self.autoSave=IntVar(self)
***************
*** 350,353 ****
--- 351,355 ----
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)
***************
*** 375,378 ****
--- 377,385 ----
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")
***************
*** 412,415 ****
--- 419,423 ----
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)
***************
*** 430,433 ****
--- 438,444 ----
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)
***************
*** 467,470 ****
--- 478,482 ----
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)
***************
*** 559,562 ****
--- 571,578 ----
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()
***************
*** 1071,1074 ****
--- 1087,1092 ----
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',
More information about the Python-checkins
mailing list