34 |
ALIGN_CENTER=2 |
ALIGN_CENTER=2 |
35 |
|
|
36 |
# very simple lineWrap |
# very simple lineWrap |
37 |
def lineWrap(message,maxWidth, preserveNewlines=1, alignment=ALIGN_LEFT): |
def lineWrap(message,maxWidth, preserveNewlines=1, alignment=ALIGN_LEFT, eol=1): |
38 |
|
|
39 |
text = "" |
text = "" |
40 |
|
|
63 |
text += "%s\n" % line |
text += "%s\n" % line |
64 |
strings = strings[index:] |
strings = strings[index:] |
65 |
|
|
66 |
line = strings[:index] |
line = strings |
67 |
if alignment == ALIGN_CENTER: |
if alignment == ALIGN_CENTER: |
68 |
line = ' ' * ( (maxWidth - len(line)) /2 ) + line |
line = ' ' * ( (maxWidth - len(line)) /2 ) + line |
69 |
elif alignment == ALIGN_RIGHT: |
elif alignment == ALIGN_RIGHT: |
70 |
line = ' ' * ( (maxWidth - len(line)) ) + line |
line = ' ' * ( (maxWidth - len(line)) ) + line |
71 |
text += "%s\n" % line |
text += "%s\n" % line |
72 |
|
|
73 |
return text |
if not eol: |
74 |
|
return text[:-1] |
75 |
|
else: |
76 |
|
return text |
77 |
|
|
78 |
|
|
79 |
def textToMeasurement(text, multiplier=1): |
def textToMeasurement(text, multiplier=1): |