You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
880 B
30 lines
880 B
# -*- coding: utf-8 -*-
|
|
from .wrap_single_line import wrap_single_line
|
|
|
|
def make_column(text, linewidth=50, height=200, use_hyphenator=None):
|
|
|
|
lines = []
|
|
remaining = text
|
|
|
|
while remaining and len(lines) < height:
|
|
# print('remaining:', remaining)
|
|
|
|
if callable(linewidth):
|
|
width = linewidth(len(lines), height)
|
|
else:
|
|
width = linewidth
|
|
|
|
line, remaining = wrap_single_line(remaining, width, use_hyphenator=use_hyphenator, replace_whitespace=False)
|
|
lines.append(line)
|
|
|
|
return lines, remaining
|
|
|
|
# def position_column(column_count, width, text):
|
|
# def f (x, y, width, height, mark, blank):
|
|
# for i in range(column_count):
|
|
# lines, remaining = make_column(linewidth, height, text)
|
|
|
|
# return f
|
|
|
|
if __name__ == '__main__':
|
|
print(make_column('Hello world!', linewidth=25, height=10))
|