[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue-common/src/utils TextUtils.py
From: |
Jason Cater |
Subject: |
gnue-common/src/utils TextUtils.py |
Date: |
Sat, 09 Aug 2003 23:12:55 -0400 |
CVSROOT: /cvsroot/gnue
Module name: gnue-common
Branch:
Changes by: Jason Cater <address@hidden> 03/08/09 23:12:55
Modified files:
src/utils : TextUtils.py
Log message:
added support to lineWrap for justified text
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/utils/TextUtils.py.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
Patches:
Index: gnue-common/src/utils/TextUtils.py
diff -c gnue-common/src/utils/TextUtils.py:1.8
gnue-common/src/utils/TextUtils.py:1.9
*** gnue-common/src/utils/TextUtils.py:1.8 Sun Jul 27 19:55:23 2003
--- gnue-common/src/utils/TextUtils.py Sat Aug 9 23:12:55 2003
***************
*** 27,36 ****
# NOTES:
#
! import string
# very simple lineWrap
! def lineWrap(message,maxWidth, preserveNewlines=1):
text = ""
temptext = string.strip(str(message))
--- 27,41 ----
# NOTES:
#
! import string
!
! ALIGN_LEFT=0
! ALIGN_RIGHT=1
! ALIGN_CENTER=2
# very simple lineWrap
! def lineWrap(message,maxWidth, preserveNewlines=1, alignment=ALIGN_LEFT):
!
text = ""
temptext = string.strip(str(message))
***************
*** 43,59 ****
while len(strings) > maxWidth:
index = 0
! for sep in [' ',',',':']:
ind = string.rfind(strings,sep,0,maxWidth-1)+1
if ind > index: index = ind
if index > maxWidth or index==0:
index = maxWidth-1
!
! text += "%s\n" % strings[:index]
strings = strings[index:]
! text += "%s\n" % strings
return text
--- 48,74 ----
while len(strings) > maxWidth:
index = 0
! for sep in [' ',',',':','.',';']:
ind = string.rfind(strings,sep,0,maxWidth-1)+1
if ind > index: index = ind
if index > maxWidth or index==0:
index = maxWidth-1
!
! line = strings[:index]
! if alignment == ALIGN_CENTER:
! line = ' ' * ( (maxWidth - len(line)) /2 ) + line
! elif alignment == ALIGN_RIGHT:
! line = ' ' * ( (maxWidth - len(line)) ) + line
! text += "%s\n" % line
strings = strings[index:]
! line = strings[:index]
! if alignment == ALIGN_CENTER:
! line = ' ' * ( (maxWidth - len(line)) /2 ) + line
! elif alignment == ALIGN_RIGHT:
! line = ' ' * ( (maxWidth - len(line)) ) + line
! text += "%s\n" % line
return text
***************
*** 153,156 ****
elif parenthesis:
s += " "
! return s
\ No newline at end of file
--- 168,171 ----
elif parenthesis:
s += " "
! return s
- gnue-common/src/utils TextUtils.py,
Jason Cater <=